From a489ecad537e513f7f4e31cb358dd8f1565915ed Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Sun, 16 Jun 2024 11:18:28 +0200 Subject: [PATCH] Frozen string literals --- Gemfile | 2 ++ Rakefile | 2 ++ lib/money.rb | 2 ++ lib/money/bank/base.rb | 2 ++ lib/money/bank/single_currency.rb | 2 ++ lib/money/bank/variable_exchange.rb | 2 ++ lib/money/currency.rb | 2 +- lib/money/currency/heuristics.rb | 2 +- lib/money/currency/loader.rb | 2 ++ lib/money/locale_backend/base.rb | 2 ++ lib/money/locale_backend/currency.rb | 2 ++ lib/money/locale_backend/errors.rb | 2 ++ lib/money/locale_backend/i18n.rb | 2 ++ lib/money/locale_backend/legacy.rb | 2 ++ lib/money/money.rb | 3 ++- lib/money/money/allocation.rb | 2 +- lib/money/money/arithmetic.rb | 2 ++ lib/money/money/constructors.rb | 2 ++ lib/money/money/formatter.rb | 3 ++- lib/money/money/formatting_rules.rb | 2 +- lib/money/money/locale_backend.rb | 2 +- lib/money/rates_store/memory.rb | 2 ++ lib/money/version.rb | 2 ++ money.gemspec | 3 ++- spec/bank/base_spec.rb | 2 ++ spec/bank/single_currency_spec.rb | 2 ++ spec/bank/variable_exchange_spec.rb | 2 ++ spec/currency/heuristics_spec.rb | 2 +- spec/currency/loader_spec.rb | 2 +- spec/currency_spec.rb | 2 +- spec/locale_backend/currency_spec.rb | 2 +- spec/locale_backend/i18n_spec.rb | 2 +- spec/locale_backend/legacy_spec.rb | 2 +- spec/money/allocation_spec.rb | 2 +- spec/money/arithmetic_spec.rb | 2 +- spec/money/constructors_spec.rb | 2 +- spec/money/formatting_rules_spec.rb | 2 +- spec/money/formatting_spec.rb | 2 +- spec/money/locale_backend_spec.rb | 2 +- spec/money_spec.rb | 2 +- spec/rates_store/memory_spec.rb | 2 ++ spec/spec_helper.rb | 2 ++ spec/support/shared_examples/money_examples.rb | 2 ++ 43 files changed, 68 insertions(+), 21 deletions(-) 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 436e54bebf..4da9a59e01 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 b4e682b55b..477f7eb230 100644 --- a/lib/money/currency.rb +++ b/lib/money/currency.rb @@ -1,4 +1,4 @@ -# encoding: utf-8 +# frozen_string_literal: true require "json" require "money/currency/loader" diff --git a/lib/money/currency/heuristics.rb b/lib/money/currency/heuristics.rb index 1cfec0d76d..4cae8d9cb5 100644 --- a/lib/money/currency/heuristics.rb +++ b/lib/money/currency/heuristics.rb @@ -1,4 +1,4 @@ -# encoding: utf-8 +# frozen_string_literal: true class Money class Currency 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 faa0d269db..90905c5cd6 100644 --- a/lib/money/money.rb +++ b/lib/money/money.rb @@ -1,4 +1,5 @@ -# encoding: utf-8 +# 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 768147f7cc..efd0a431f9 100644 --- a/lib/money/money/allocation.rb +++ b/lib/money/money/allocation.rb @@ -1,4 +1,4 @@ -# encoding: utf-8 +# frozen_string_literal: true class Money class Allocation 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 bff2b8010a..d902b9b634 100644 --- a/lib/money/money/formatter.rb +++ b/lib/money/money/formatter.rb @@ -1,4 +1,5 @@ -# encoding: UTF-8 +# frozen_string_literal: true + require 'money/money/formatting_rules' class Money diff --git a/lib/money/money/formatting_rules.rb b/lib/money/money/formatting_rules.rb index 68c917800c..45bff2d25b 100644 --- a/lib/money/money/formatting_rules.rb +++ b/lib/money/money/formatting_rules.rb @@ -1,4 +1,4 @@ -# encoding: UTF-8 +# frozen_string_literal: true class Money class FormattingRules diff --git a/lib/money/money/locale_backend.rb b/lib/money/money/locale_backend.rb index 30491301c8..78a8589685 100644 --- a/lib/money/money/locale_backend.rb +++ b/lib/money/money/locale_backend.rb @@ -1,4 +1,4 @@ -# encoding: UTF-8 +# frozen_string_literal: true require 'money/locale_backend/errors' require 'money/locale_backend/legacy' 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 0e643793b7..487f2325ff 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' end diff --git a/money.gemspec b/money.gemspec index f52d28664e..7312f2b779 100644 --- a/money.gemspec +++ b/money.gemspec @@ -1,4 +1,5 @@ -# -*- encoding: utf-8 -*- +# 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 543b32a38e..908db5f6bc 100644 --- a/spec/currency/heuristics_spec.rb +++ b/spec/currency/heuristics_spec.rb @@ -1,4 +1,4 @@ -# encoding: utf-8 +# frozen_string_literal: true describe Money::Currency::Heuristics do describe "#analyze_string" do diff --git a/spec/currency/loader_spec.rb b/spec/currency/loader_spec.rb index b350e65f34..553edbc573 100644 --- a/spec/currency/loader_spec.rb +++ b/spec/currency/loader_spec.rb @@ -1,4 +1,4 @@ -# encoding: utf-8 +# frozen_string_literal: true describe Money::Currency::Loader do it "returns a currency table hash" do diff --git a/spec/currency_spec.rb b/spec/currency_spec.rb index 2e01018bbc..96cad451f4 100644 --- a/spec/currency_spec.rb +++ b/spec/currency_spec.rb @@ -1,4 +1,4 @@ -# encoding: utf-8 +# 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 2779cbef4a..400d7b29bb 100644 --- a/spec/locale_backend/currency_spec.rb +++ b/spec/locale_backend/currency_spec.rb @@ -1,4 +1,4 @@ -# encoding: utf-8 +# frozen_string_literal: true describe Money::LocaleBackend::Currency do describe '#lookup' do diff --git a/spec/locale_backend/i18n_spec.rb b/spec/locale_backend/i18n_spec.rb index 5fe7b63607..0e54aad57b 100644 --- a/spec/locale_backend/i18n_spec.rb +++ b/spec/locale_backend/i18n_spec.rb @@ -1,4 +1,4 @@ -# encoding: utf-8 +# frozen_string_literal: true describe Money::LocaleBackend::I18n do describe '#initialize' do diff --git a/spec/locale_backend/legacy_spec.rb b/spec/locale_backend/legacy_spec.rb index 5e0c56296d..c70cd9d368 100644 --- a/spec/locale_backend/legacy_spec.rb +++ b/spec/locale_backend/legacy_spec.rb @@ -1,4 +1,4 @@ -# encoding: utf-8 +# 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 215c95c392..3dc5a2a96e 100644 --- a/spec/money/allocation_spec.rb +++ b/spec/money/allocation_spec.rb @@ -1,4 +1,4 @@ -# encoding: utf-8 +# frozen_string_literal: true describe Money::Allocation do describe 'given number as argument' do diff --git a/spec/money/arithmetic_spec.rb b/spec/money/arithmetic_spec.rb index a430caa3fc..841e269cba 100644 --- a/spec/money/arithmetic_spec.rb +++ b/spec/money/arithmetic_spec.rb @@ -1,4 +1,4 @@ -# encoding: utf-8 +# frozen_string_literal: true describe Money::Arithmetic do describe "-@" do diff --git a/spec/money/constructors_spec.rb b/spec/money/constructors_spec.rb index facead47db..2b443cf6d7 100644 --- a/spec/money/constructors_spec.rb +++ b/spec/money/constructors_spec.rb @@ -1,4 +1,4 @@ -# encoding: utf-8 +# frozen_string_literal: true describe Money::Constructors do diff --git a/spec/money/formatting_rules_spec.rb b/spec/money/formatting_rules_spec.rb index 17f4a365c5..7f739f19f4 100644 --- a/spec/money/formatting_rules_spec.rb +++ b/spec/money/formatting_rules_spec.rb @@ -1,4 +1,4 @@ -# encoding: utf-8 +# frozen_string_literal: true describe Money::FormattingRules do it 'does not modify frozen rules in place' do diff --git a/spec/money/formatting_spec.rb b/spec/money/formatting_spec.rb index bed46ca8a0..71e2b1c5f5 100644 --- a/spec/money/formatting_spec.rb +++ b/spec/money/formatting_spec.rb @@ -1,4 +1,4 @@ -# encoding: utf-8 +# frozen_string_literal: true describe Money, "formatting" do diff --git a/spec/money/locale_backend_spec.rb b/spec/money/locale_backend_spec.rb index ec2e4f0bac..8408df2348 100644 --- a/spec/money/locale_backend_spec.rb +++ b/spec/money/locale_backend_spec.rb @@ -1,4 +1,4 @@ -# encoding: utf-8 +# frozen_string_literal: true describe Money::LocaleBackend do describe '.find' do diff --git a/spec/money_spec.rb b/spec/money_spec.rb index bfba7b5255..de17e0d046 100644 --- a/spec/money_spec.rb +++ b/spec/money_spec.rb @@ -1,4 +1,4 @@ -# encoding: utf-8 +# frozen_string_literal: true describe Money do describe '.locale_backend' do 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) }