diff --git a/Gemfile b/Gemfile
index 04e6bd1c52..4a97316c9e 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
source 'https://rubygems.org'
gem 'pry', require: false
diff --git a/Rakefile b/Rakefile
index 006924e6e0..69b26853ff 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require "bundler/gem_tasks"
require "rake/clean"
require "rspec/core/rake_task"
diff --git a/lib/money.rb b/lib/money.rb
index 4244935d7f..85abfc704b 100644
--- a/lib/money.rb
+++ b/lib/money.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require "bigdecimal"
require "bigdecimal/util"
require "set"
diff --git a/lib/money/bank/base.rb b/lib/money/bank/base.rb
index a791f79f44..03174528a0 100644
--- a/lib/money/bank/base.rb
+++ b/lib/money/bank/base.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Money
# Provides classes that aid in the ability of exchange one currency with
# another.
diff --git a/lib/money/bank/single_currency.rb b/lib/money/bank/single_currency.rb
index ac3ffc1e8c..35182e2951 100644
--- a/lib/money/bank/single_currency.rb
+++ b/lib/money/bank/single_currency.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'money/bank/base'
class Money
diff --git a/lib/money/bank/variable_exchange.rb b/lib/money/bank/variable_exchange.rb
index 1a7dbe4b83..4d54b6f3e0 100644
--- a/lib/money/bank/variable_exchange.rb
+++ b/lib/money/bank/variable_exchange.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'money/bank/base'
require 'money/rates_store/memory'
require 'json'
diff --git a/lib/money/currency.rb b/lib/money/currency.rb
index 155a92eed2..ff6d2c9e0c 100644
--- a/lib/money/currency.rb
+++ b/lib/money/currency.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require "json"
require "money/currency/loader"
require "money/currency/heuristics"
diff --git a/lib/money/currency/heuristics.rb b/lib/money/currency/heuristics.rb
index 59fa19bdbb..4cae8d9cb5 100644
--- a/lib/money/currency/heuristics.rb
+++ b/lib/money/currency/heuristics.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Money
class Currency
module Heuristics
diff --git a/lib/money/currency/loader.rb b/lib/money/currency/loader.rb
index 9f54eec35f..633ce17dc3 100644
--- a/lib/money/currency/loader.rb
+++ b/lib/money/currency/loader.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Money
class Currency
module Loader
diff --git a/lib/money/locale_backend/base.rb b/lib/money/locale_backend/base.rb
index 047c679029..9f42fa643c 100644
--- a/lib/money/locale_backend/base.rb
+++ b/lib/money/locale_backend/base.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'money/locale_backend/errors'
class Money
diff --git a/lib/money/locale_backend/currency.rb b/lib/money/locale_backend/currency.rb
index 4fd033aa01..19858864ce 100644
--- a/lib/money/locale_backend/currency.rb
+++ b/lib/money/locale_backend/currency.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'money/locale_backend/base'
class Money
diff --git a/lib/money/locale_backend/errors.rb b/lib/money/locale_backend/errors.rb
index 10711e5229..d46e83834b 100644
--- a/lib/money/locale_backend/errors.rb
+++ b/lib/money/locale_backend/errors.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Money
module LocaleBackend
class NotSupported < StandardError; end
diff --git a/lib/money/locale_backend/i18n.rb b/lib/money/locale_backend/i18n.rb
index 213c31dcb0..ef6fe32846 100644
--- a/lib/money/locale_backend/i18n.rb
+++ b/lib/money/locale_backend/i18n.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'money/locale_backend/base'
class Money
diff --git a/lib/money/locale_backend/legacy.rb b/lib/money/locale_backend/legacy.rb
index 1e03af3574..80ab6210eb 100644
--- a/lib/money/locale_backend/legacy.rb
+++ b/lib/money/locale_backend/legacy.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'money/locale_backend/base'
require 'money/locale_backend/i18n'
diff --git a/lib/money/money.rb b/lib/money/money.rb
index e6cc582092..c647adf998 100644
--- a/lib/money/money.rb
+++ b/lib/money/money.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require "money/bank/variable_exchange"
require "money/bank/single_currency"
require "money/money/arithmetic"
diff --git a/lib/money/money/allocation.rb b/lib/money/money/allocation.rb
index e131115b2f..efd0a431f9 100644
--- a/lib/money/money/allocation.rb
+++ b/lib/money/money/allocation.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Money
class Allocation
# Splits a given amount in parts. The allocation is based on the parts' proportions
diff --git a/lib/money/money/arithmetic.rb b/lib/money/money/arithmetic.rb
index b3ba0e711b..2063714b84 100644
--- a/lib/money/money/arithmetic.rb
+++ b/lib/money/money/arithmetic.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Money
module Arithmetic
# Wrapper for coerced numeric values to distinguish
diff --git a/lib/money/money/constructors.rb b/lib/money/money/constructors.rb
index a5cd17053b..9cf9b97b7a 100644
--- a/lib/money/money/constructors.rb
+++ b/lib/money/money/constructors.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Money
module Constructors
diff --git a/lib/money/money/formatter.rb b/lib/money/money/formatter.rb
index 1b6bd78cf3..25f889f062 100644
--- a/lib/money/money/formatter.rb
+++ b/lib/money/money/formatter.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'money/money/formatting_rules'
class Money
@@ -315,17 +317,19 @@ def append_sign(formatted_number)
def append_currency_symbol(formatted_number)
if rules[:with_currency]
- formatted_number << " "
+ currency_part =
+ if rules[:html]
+ "#{currency}"
+ elsif rules[:html_wrap]
+ html_wrap(currency.to_s, "currency")
+ else
+ currency.to_s
+ end
- if rules[:html]
- formatted_number << "#{currency.to_s}"
- elsif rules[:html_wrap]
- formatted_number << html_wrap(currency.to_s, "currency")
- else
- formatted_number << currency.to_s
- end
+ "#{formatted_number} #{currency_part}"
+ else
+ formatted_number
end
- formatted_number
end
def show_free_text?
diff --git a/lib/money/money/formatting_rules.rb b/lib/money/money/formatting_rules.rb
index 78fafede7e..9cd0da39b0 100644
--- a/lib/money/money/formatting_rules.rb
+++ b/lib/money/money/formatting_rules.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Money
class FormattingRules
def initialize(currency, *raw_rules)
diff --git a/lib/money/money/locale_backend.rb b/lib/money/money/locale_backend.rb
index 72ca083a75..78a8589685 100644
--- a/lib/money/money/locale_backend.rb
+++ b/lib/money/money/locale_backend.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'money/locale_backend/errors'
require 'money/locale_backend/legacy'
require 'money/locale_backend/i18n'
diff --git a/lib/money/rates_store/memory.rb b/lib/money/rates_store/memory.rb
index d2edb8d358..aa88a0d710 100644
--- a/lib/money/rates_store/memory.rb
+++ b/lib/money/rates_store/memory.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'monitor'
class Money
diff --git a/lib/money/version.rb b/lib/money/version.rb
index 3bd9e65026..25f725d6d8 100644
--- a/lib/money/version.rb
+++ b/lib/money/version.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Money
VERSION = '6.19.0'.freeze
end
diff --git a/money.gemspec b/money.gemspec
index 29a8c4e7c1..40261cb28f 100644
--- a/money.gemspec
+++ b/money.gemspec
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "money/version"
diff --git a/spec/bank/base_spec.rb b/spec/bank/base_spec.rb
index 061efac074..6899a6400c 100644
--- a/spec/bank/base_spec.rb
+++ b/spec/bank/base_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
describe Money::Bank::Base do
describe ".instance" do
diff --git a/spec/bank/single_currency_spec.rb b/spec/bank/single_currency_spec.rb
index 93cd318340..1dd380c335 100644
--- a/spec/bank/single_currency_spec.rb
+++ b/spec/bank/single_currency_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
describe Money::Bank::SingleCurrency do
describe "#exchange_with" do
it "raises when called" do
diff --git a/spec/bank/variable_exchange_spec.rb b/spec/bank/variable_exchange_spec.rb
index 4237a58e46..41d83e8f0a 100644
--- a/spec/bank/variable_exchange_spec.rb
+++ b/spec/bank/variable_exchange_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'json'
require 'yaml'
diff --git a/spec/currency/heuristics_spec.rb b/spec/currency/heuristics_spec.rb
index 64bed8475b..908a25b14c 100644
--- a/spec/currency/heuristics_spec.rb
+++ b/spec/currency/heuristics_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
describe Money::Currency::Heuristics do
describe "#analyze_string" do
it "it raises deprecation error" do
diff --git a/spec/currency/loader_spec.rb b/spec/currency/loader_spec.rb
index f998c7f889..553edbc573 100644
--- a/spec/currency/loader_spec.rb
+++ b/spec/currency/loader_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
describe Money::Currency::Loader do
it "returns a currency table hash" do
expect(subject.load_currencies).to be_a Hash
diff --git a/spec/currency_spec.rb b/spec/currency_spec.rb
index 1e512cd418..5601ad79c9 100644
--- a/spec/currency_spec.rb
+++ b/spec/currency_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
describe Money::Currency do
FOO = '{ "priority": 1, "iso_code": "FOO", "iso_numeric": "840", "name": "United States Dollar", "symbol": "$", "subunit": "Cent", "subunit_to_unit": 1000, "symbol_first": true, "html_entity": "$", "decimal_mark": ".", "thousands_separator": ",", "smallest_denomination": 1 }'
diff --git a/spec/locale_backend/currency_spec.rb b/spec/locale_backend/currency_spec.rb
index 5a66b10e61..400d7b29bb 100644
--- a/spec/locale_backend/currency_spec.rb
+++ b/spec/locale_backend/currency_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
describe Money::LocaleBackend::Currency do
describe '#lookup' do
let(:currency) { Money::Currency.new('EUR') }
diff --git a/spec/locale_backend/i18n_spec.rb b/spec/locale_backend/i18n_spec.rb
index ea135aa72f..0e54aad57b 100644
--- a/spec/locale_backend/i18n_spec.rb
+++ b/spec/locale_backend/i18n_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
describe Money::LocaleBackend::I18n do
describe '#initialize' do
it 'raises an error when I18n is not defined' do
diff --git a/spec/locale_backend/legacy_spec.rb b/spec/locale_backend/legacy_spec.rb
index 3d917e8b28..c70cd9d368 100644
--- a/spec/locale_backend/legacy_spec.rb
+++ b/spec/locale_backend/legacy_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
describe Money::LocaleBackend::Legacy do
after { Money.use_i18n = true }
diff --git a/spec/money/allocation_spec.rb b/spec/money/allocation_spec.rb
index 872b77079c..3dc5a2a96e 100644
--- a/spec/money/allocation_spec.rb
+++ b/spec/money/allocation_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
describe Money::Allocation do
describe 'given number as argument' do
it 'raises an error when invalid argument is given' do
diff --git a/spec/money/arithmetic_spec.rb b/spec/money/arithmetic_spec.rb
index 0fe2d9e2a4..1bfceb3dbf 100644
--- a/spec/money/arithmetic_spec.rb
+++ b/spec/money/arithmetic_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
describe Money::Arithmetic do
describe "-@" do
it "changes the sign of a number" do
diff --git a/spec/money/constructors_spec.rb b/spec/money/constructors_spec.rb
index 0a877302a6..2b443cf6d7 100644
--- a/spec/money/constructors_spec.rb
+++ b/spec/money/constructors_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
describe Money::Constructors do
describe "::empty" do
diff --git a/spec/money/formatting_rules_spec.rb b/spec/money/formatting_rules_spec.rb
index 046954755b..7f739f19f4 100644
--- a/spec/money/formatting_rules_spec.rb
+++ b/spec/money/formatting_rules_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
describe Money::FormattingRules do
it 'does not modify frozen rules in place' do
expect {
diff --git a/spec/money/formatting_spec.rb b/spec/money/formatting_spec.rb
index a4a8c20d22..4df16269cf 100644
--- a/spec/money/formatting_spec.rb
+++ b/spec/money/formatting_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
describe Money, "formatting" do
BAR = '{ "priority": 1, "iso_code": "BAR", "iso_numeric": "840", "name": "Dollar with 4 decimal places", "symbol": "$", "subunit": "Cent", "subunit_to_unit": 10000, "symbol_first": true, "html_entity": "$", "decimal_mark": ".", "thousands_separator": ",", "smallest_denomination": 1 }'
diff --git a/spec/money/locale_backend_spec.rb b/spec/money/locale_backend_spec.rb
index 7661963d30..8408df2348 100644
--- a/spec/money/locale_backend_spec.rb
+++ b/spec/money/locale_backend_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
describe Money::LocaleBackend do
describe '.find' do
it 'returns an initialized backend' do
diff --git a/spec/money_spec.rb b/spec/money_spec.rb
index c7b1322127..42e55b61ac 100644
--- a/spec/money_spec.rb
+++ b/spec/money_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
describe Money do
describe '.locale_backend' do
after { Money.locale_backend = :legacy }
diff --git a/spec/rates_store/memory_spec.rb b/spec/rates_store/memory_spec.rb
index ae80253609..1f2c612af0 100644
--- a/spec/rates_store/memory_spec.rb
+++ b/spec/rates_store/memory_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
describe Money::RatesStore::Memory do
let(:subject) { described_class.new }
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 5736c8b1ce..daa828a285 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
$LOAD_PATH.unshift File.dirname(__FILE__)
require "rspec"
require "money"
diff --git a/spec/support/shared_examples/money_examples.rb b/spec/support/shared_examples/money_examples.rb
index 26bbda8188..dab9d522cc 100644
--- a/spec/support/shared_examples/money_examples.rb
+++ b/spec/support/shared_examples/money_examples.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
RSpec.shared_examples 'instance with custom bank' do |operation, value|
let(:custom_bank) { Money::Bank::VariableExchange.new }
let(:instance) { Money.new(1, :usd, custom_bank) }