money_with_date 0.2.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19a3520f2cff5cb626afdfdc78e11fb523ad404dfe43ebe95dcb62f42d4e4a39
4
- data.tar.gz: dcc7d487825b89ae67974aadff50047ae93054a3dfc5f3bfc555eb44b80e60c1
3
+ metadata.gz: 5ea5e9735d420c5bc644d12c9c27621c2c0d6a16c42108ba93460af3542a33bc
4
+ data.tar.gz: 56ca079c22121b3fcc7fcb4c0000aea97e590bcb4487403b9d474eb92a833e8f
5
5
  SHA512:
6
- metadata.gz: 45923e5ffc8d54de1296fd6e07d42ff34785509c13a08b223d7d45d8b7f483c35076dfb5a98fdbde054a0c80632a709fc715eb8663c3cc28d20bf2b43161df6b
7
- data.tar.gz: 25660ea4172f74c68ce085708171ae817b6c3fb6715d0cac616c378d1e4f2286d7bbbe3ec1b01f35c1d974903fb69990a465c44007000265f14521e4c81f0084
6
+ metadata.gz: 49da9ee683e362ac6fb444b92133d9a2de229536bcc65c29a74dff5e15da30c9cc490f975770f14586a9400f52c738c5548b0e41514f64432c82054c8cfd547c
7
+ data.tar.gz: 580056af02a78f82a027bad22ac8baede08e9623bb4f935637170e5d9d39af0f93731ce643f31df5dfa7798c4ffb423eae9b41510ac0b7a73f0715f5273e03e0
data/.rubocop.yml CHANGED
@@ -1,11 +1,14 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.6
2
+ TargetRubyVersion: 3.0
3
3
  NewCops: enable
4
4
  Exclude:
5
5
  - 'spec_money/**/*'
6
6
  - 'spec_money_rails/**/*'
7
7
  - 'vendor/**/*'
8
8
 
9
+ Style/AccessorGrouping:
10
+ Enabled: false
11
+
9
12
  Style/StringLiterals:
10
13
  Enabled: true
11
14
  EnforcedStyle: double_quotes
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.4.0] - 2024-09-06
4
+
5
+ - Update supported versions ([#7](https://github.com/infinum/money_with_date/pull/7))
6
+
7
+ **Breaking**: drops support for Ruby 2.6 and 2.7, and Rails 5.2 and 6.0.
8
+
9
+ ## [0.3.0] - 2022-09-18
10
+
11
+ - Fix monetizable module specs ([#4](https://github.com/infinum/money_with_date/pull/4))
12
+ - Globalize default_date_column configuration option ([#5](https://github.com/infinum/money_with_date/pull/5))
13
+
3
14
  ## [0.2.0] - 2022-09-16
4
15
 
5
16
  - Make the gem work without money-rails ([#2](https://github.com/infinum/money_with_date/pull/2))
data/Gemfile.lock CHANGED
@@ -1,61 +1,65 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- money_with_date (0.1.0)
5
- money (>= 6.14.0, <= 6.16.0)
4
+ money_with_date (0.4.0)
5
+ money (>= 6.14.0, <= 6.19.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  ast (2.4.2)
11
11
  coderay (1.1.3)
12
- concurrent-ruby (1.1.9)
13
- diff-lcs (1.5.0)
14
- i18n (1.10.0)
12
+ concurrent-ruby (1.3.4)
13
+ diff-lcs (1.5.1)
14
+ i18n (1.14.5)
15
15
  concurrent-ruby (~> 1.0)
16
- method_source (1.0.0)
17
- money (6.16.0)
16
+ json (2.7.2)
17
+ language_server-protocol (3.17.0.3)
18
+ method_source (1.1.0)
19
+ money (6.19.0)
18
20
  i18n (>= 0.6.4, <= 2)
19
- parallel (1.21.0)
20
- parser (3.1.0.0)
21
+ parallel (1.26.3)
22
+ parser (3.3.5.0)
21
23
  ast (~> 2.4.1)
22
- pry (0.14.1)
24
+ racc
25
+ pry (0.14.2)
23
26
  coderay (~> 1.1)
24
27
  method_source (~> 1.0)
28
+ racc (1.8.1)
25
29
  rainbow (3.1.1)
26
- rake (13.0.6)
27
- regexp_parser (2.2.1)
28
- rexml (3.2.5)
29
- rspec (3.11.0)
30
- rspec-core (~> 3.11.0)
31
- rspec-expectations (~> 3.11.0)
32
- rspec-mocks (~> 3.11.0)
33
- rspec-core (3.11.0)
34
- rspec-support (~> 3.11.0)
35
- rspec-expectations (3.11.0)
30
+ rake (13.2.1)
31
+ regexp_parser (2.9.2)
32
+ rspec (3.13.0)
33
+ rspec-core (~> 3.13.0)
34
+ rspec-expectations (~> 3.13.0)
35
+ rspec-mocks (~> 3.13.0)
36
+ rspec-core (3.13.1)
37
+ rspec-support (~> 3.13.0)
38
+ rspec-expectations (3.13.2)
36
39
  diff-lcs (>= 1.2.0, < 2.0)
37
- rspec-support (~> 3.11.0)
38
- rspec-mocks (3.11.0)
40
+ rspec-support (~> 3.13.0)
41
+ rspec-mocks (3.13.1)
39
42
  diff-lcs (>= 1.2.0, < 2.0)
40
- rspec-support (~> 3.11.0)
41
- rspec-support (3.11.0)
42
- rubocop (1.25.1)
43
+ rspec-support (~> 3.13.0)
44
+ rspec-support (3.13.1)
45
+ rubocop (1.66.1)
46
+ json (~> 2.3)
47
+ language_server-protocol (>= 3.17.0)
43
48
  parallel (~> 1.10)
44
- parser (>= 3.1.0.0)
49
+ parser (>= 3.3.0.2)
45
50
  rainbow (>= 2.2.2, < 4.0)
46
- regexp_parser (>= 1.8, < 3.0)
47
- rexml
48
- rubocop-ast (>= 1.15.1, < 2.0)
51
+ regexp_parser (>= 2.4, < 3.0)
52
+ rubocop-ast (>= 1.32.2, < 2.0)
49
53
  ruby-progressbar (~> 1.7)
50
- unicode-display_width (>= 1.4.0, < 3.0)
51
- rubocop-ast (1.15.2)
52
- parser (>= 3.0.1.1)
54
+ unicode-display_width (>= 2.4.0, < 3.0)
55
+ rubocop-ast (1.32.3)
56
+ parser (>= 3.3.1.0)
53
57
  rubocop-rake (0.6.0)
54
58
  rubocop (~> 1.0)
55
- rubocop-rspec (2.8.0)
56
- rubocop (~> 1.19)
57
- ruby-progressbar (1.11.0)
58
- unicode-display_width (2.1.0)
59
+ rubocop-rspec (3.0.4)
60
+ rubocop (~> 1.61)
61
+ ruby-progressbar (1.13.0)
62
+ unicode-display_width (2.5.0)
59
63
 
60
64
  PLATFORMS
61
65
  ruby
@@ -70,4 +74,4 @@ DEPENDENCIES
70
74
  rubocop-rspec
71
75
 
72
76
  BUNDLED WITH
73
- 2.3.7
77
+ 2.5.18
data/Gemfile_test CHANGED
@@ -4,9 +4,17 @@ source "https://rubygems.org"
4
4
 
5
5
  gemspec
6
6
 
7
- gem "money", ENV["MONEY_VERSION"]
8
- gem "money-rails", ENV["MONEY_RAILS_VERSION"]
9
- gem "activerecord", ENV["RAILS_VERSION"]
10
- gem "sqlite3"
7
+ gem "money", ENV["MONEY_VERSION"] if ENV["MONEY_VERSION"]
8
+ gem "money-rails", ENV["MONEY_RAILS_VERSION"] if ENV["MONEY_RAILS_VERSION"]
9
+ gem "activerecord", ENV["RAILS_VERSION"] if ENV["RAILS_VERSION"]
10
+
11
+ if ENV["RAILS_VERSION"]
12
+ if Gem::Version.new(ENV.fetch("RAILS_VERSION").delete_prefix("~> ")) >= Gem::Version.new("7.1.0")
13
+ gem "sqlite3"
14
+ else
15
+ gem "sqlite3", "~> 1.4"
16
+ end
17
+ end
18
+
11
19
  gem "rubyzip"
12
20
  gem "simplecov", require: false
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A Ruby library which extends the popular [money](https://github.com/RubyMoney/money) and [money-rails](https://github.com/RubyMoney/money-rails) gems with support for dated Money objects.
4
4
 
5
- Dated Money objects are useful in situations where you have to exchange money between currencies based on historical exchange rates, and you'd like to keep date information on the Money object itself.
5
+ Dated Money objects are useful in situations where you have to exchange money between currencies based on historical exchange rates, and you'd like to keep date information on the Money object itself.
6
6
 
7
7
  ## Installation
8
8
 
@@ -46,10 +46,10 @@ transactions = [
46
46
  ]
47
47
 
48
48
  transactions.map { |money| money.exchange_to(:eur) }.sum
49
- # => Money.from_amount(4,82, "EUR")
49
+ # => Money.from_amount(4.82, "EUR")
50
50
  # 2 CHF == 1,92 EUR on today's date
51
- # 1 USD = 0,9 EUR on 1/1/2020
52
- # 1,92 + 0,9 + 2 = 4,82
51
+ # 1 USD == 0,9 EUR on 1/1/2020
52
+ # 1,92 + 0,9 + 2 == 4,82
53
53
 
54
54
  # In Rails, a date column can be used to control the date of the Money object:
55
55
  class Product < ActiveRecord::Base
@@ -332,17 +332,18 @@ Money.default_date_column = nil
332
332
  ## Supported Versions
333
333
 
334
334
  `money_with_date` has the following version requirements:
335
- - Ruby: **>= 2.6.0**
336
- - money: **>= 6.14.0** and **<= 6.16.0**
335
+ - Ruby: **>= 3.0.0**
336
+ - money: **>= 6.14.0** and **<= 6.19.0**
337
337
  - money-rails: **1.15.0**
338
338
 
339
339
  The gem has been tested against all possible combinations of supported Ruby, Rails, money, and money-rails versions:
340
- - Ruby: `2.6`, `2.7`, `3.0`, and `3.1`
341
- - Rails: `5.2.8.1`, `6.0.6`, `6.1.7`, `7.0.4`
342
- - money: `6.14.0`, `6.14.1`, and `6.16.0`
340
+ - Ruby: `3.0`, `3.1`, `3.2` and `3.3`
341
+ - Rails: `~> 6.1.0`, `~> 7.0.0`, `~> 7.1.0` and `~> 7.2.0`
342
+ - money: `6.14.0`, `6.14.1`, `6.16.0`, `6.17.0`, `6.18.0` and `6.19.0`
343
343
  - money-rails: `1.15.0`
344
344
 
345
- Note: the gem hasn't been tested on Rails `5.2.8.1` with Rubies `3.0` and `3.1`, and on Rails `7.0.4` with Ruby `2.6` as those combinations of versions aren't compatible.
345
+ The following combinations have been excluded from the test matrix because of incompatibility:
346
+ - Ruby `3.0` with Rails `~> 7.2.0`
346
347
 
347
348
  In addition to running its own test suite, the CI for this gem also runs [money's](https://github.com/RubyMoney/money/tree/main/spec) and [money-rails's](https://github.com/RubyMoney/money-rails/tree/main/spec) test suites with this gem loaded, to prevent regressions. This has been achieved by cloning their test suites from GitHub and requiring this gem in their spec files. For technical information, check the CI [workflow](.github/workflows/ci.yml).
348
349
 
@@ -4,7 +4,7 @@ module MoneyWithDate
4
4
  module ActiveRecord
5
5
  module Monetizable
6
6
  def read_monetized(name, subunit_name, options = {}, *args)
7
- money = super(name, subunit_name, options, *args)
7
+ money = super
8
8
  date = find_date_for(options[:with_model_date], options[:with_date])
9
9
 
10
10
  if money&.date == date
@@ -54,7 +54,7 @@ module MoneyWithDate
54
54
  def rates
55
55
  return super if store.method(:get_rate).parameters.size == 2
56
56
 
57
- store.each_rate.each_with_object({}) do |(from, to, rate, date), hash|
57
+ store.each_rate.with_object({}) do |(from, to, rate, date), hash|
58
58
  hash[date.to_s] ||= {}
59
59
  hash[date.to_s][[from, to].join(SERIALIZER_SEPARATOR)] = rate
60
60
  end
@@ -3,6 +3,7 @@
3
3
  module MoneyWithDate
4
4
  module ClassMethods
5
5
  attr_accessor :date_determines_equality
6
+ attr_accessor :default_date_column
6
7
 
7
8
  attr_writer :default_date
8
9
 
@@ -5,12 +5,8 @@ module MoneyWithDate
5
5
  def self.init
6
6
  ::ActiveSupport.on_load(:active_record) do
7
7
  require "money_with_date/active_record/monetizable"
8
- require "money_with_date/active_record/class_methods"
9
8
 
10
9
  ::ActiveRecord::Base.prepend(::MoneyWithDate::ActiveRecord::Monetizable)
11
- ::Money.singleton_class.prepend(::MoneyWithDate::ActiveRecord::ClassMethods)
12
-
13
- ::Money.default_date_column = :created_at
14
10
  end
15
11
  end
16
12
 
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MoneyWithDate
4
- VERSION = "0.2.0"
4
+ VERSION = "0.4.0"
5
5
 
6
6
  MINIMUM_MONEY_VERSION = "6.14.0"
7
7
  MINIMUM_MONEY_RAILS_VERSION = "1.15.0"
8
8
 
9
- MAXIMUM_MONEY_VERSION = "6.16.0"
9
+ MAXIMUM_MONEY_VERSION = "6.19.0"
10
10
  MAXIMUM_MONEY_RAILS_VERSION = "1.15.0"
11
11
  end
@@ -9,12 +9,13 @@ require_relative "money_with_date/instance_methods"
9
9
  require_relative "money_with_date/bank/variable_exchange"
10
10
  require_relative "money_with_date/rates_store/memory"
11
11
 
12
- ::Money.prepend(::MoneyWithDate::InstanceMethods)
13
- ::Money.singleton_class.prepend(::MoneyWithDate::ClassMethods)
12
+ Money.prepend(MoneyWithDate::InstanceMethods)
13
+ Money.singleton_class.prepend(MoneyWithDate::ClassMethods)
14
14
 
15
15
  # :nocov:
16
- ::Money.date_determines_equality = false
17
- ::Money.default_date = ::Date.respond_to?(:current) ? -> { ::Date.current } : -> { ::Date.today }
16
+ Money.date_determines_equality = false
17
+ Money.default_date = Date.respond_to?(:current) ? -> { Date.current } : -> { Date.today }
18
+ Money.default_date_column = :created_at
18
19
 
19
- require "money_with_date/railtie" if defined?(::Rails::Railtie) && defined?(::MoneyRails)
20
+ require "money_with_date/railtie" if defined?(Rails::Railtie) && defined?(MoneyRails)
20
21
  # :nocov:
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.summary = "Extension for the money gem which adds dates to Money objects"
12
12
  spec.homepage = "https://github.com/infinum/money_with_date"
13
13
  spec.license = "MIT"
14
- spec.required_ruby_version = ">= 2.6.0"
14
+ spec.required_ruby_version = ">= 3.0.0"
15
15
 
16
16
  spec.metadata["homepage_uri"] = spec.homepage
17
17
  spec.metadata["source_code_uri"] = spec.homepage
@@ -30,10 +30,12 @@ Gem::Specification.new do |spec|
30
30
 
31
31
  spec.add_dependency "money", ">= #{MoneyWithDate::MINIMUM_MONEY_VERSION}", "<= #{MoneyWithDate::MAXIMUM_MONEY_VERSION}" # rubocop:disable Layout/LineLength
32
32
 
33
+ # rubocop:disable Gemspec/DevelopmentDependencies
33
34
  spec.add_development_dependency "pry"
34
35
  spec.add_development_dependency "rake"
35
36
  spec.add_development_dependency "rspec"
36
37
  spec.add_development_dependency "rubocop"
37
38
  spec.add_development_dependency "rubocop-rake"
38
39
  spec.add_development_dependency "rubocop-rspec"
40
+ # rubocop:enable all
39
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: money_with_date
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lovro Bikić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-16 00:00:00.000000000 Z
11
+ date: 2024-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: money
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 6.14.0
20
20
  - - "<="
21
21
  - !ruby/object:Gem::Version
22
- version: 6.16.0
22
+ version: 6.19.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 6.14.0
30
30
  - - "<="
31
31
  - !ruby/object:Gem::Version
32
- version: 6.16.0
32
+ version: 6.19.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: pry
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -132,7 +132,6 @@ files:
132
132
  - README.md
133
133
  - Rakefile
134
134
  - lib/money_with_date.rb
135
- - lib/money_with_date/active_record/class_methods.rb
136
135
  - lib/money_with_date/active_record/monetizable.rb
137
136
  - lib/money_with_date/bank/variable_exchange.rb
138
137
  - lib/money_with_date/class_methods.rb
@@ -158,14 +157,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
158
157
  requirements:
159
158
  - - ">="
160
159
  - !ruby/object:Gem::Version
161
- version: 2.6.0
160
+ version: 3.0.0
162
161
  required_rubygems_version: !ruby/object:Gem::Requirement
163
162
  requirements:
164
163
  - - ">="
165
164
  - !ruby/object:Gem::Version
166
165
  version: '0'
167
166
  requirements: []
168
- rubygems_version: 3.3.7
167
+ rubygems_version: 3.5.11
169
168
  signing_key:
170
169
  specification_version: 4
171
170
  summary: Extension for the money gem which adds dates to Money objects
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module MoneyWithDate
4
- module ActiveRecord
5
- module ClassMethods
6
- attr_accessor :default_date_column
7
- end
8
- end
9
- end