money_with_date 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7821b105830f8b5149853c813849e0682f8d11d0399ee0e4dac4319641dff0d5
4
- data.tar.gz: c97ae3c5c36d4d699cd9739bb0235c9c15c7265dc57fd53c1822c677eb09511f
3
+ metadata.gz: 9c882466426f32c18819782c6de254ec34194c4a8714e7c9c49713c8248d16cd
4
+ data.tar.gz: ca6a54db86d677feade11354c29420785e4cbf70841f7e6c7db580364faafbb8
5
5
  SHA512:
6
- metadata.gz: 19e7424b1284b3f13ffb4a8f257f72b0a1ca8bfefd06561ffe4165a2d85732c48e39e54305e1f0b04a430cccf3432d827197fa2268ed5b260c9cc888085c4971
7
- data.tar.gz: eb2d53e6939725cc3e6fa20f2734803395da997fab1fffd52d9f23c88eda73eecc282337465acdb6ad3773af96fc213c5d78f3747c5dddfcdf80210bcb50f7e8
6
+ metadata.gz: 7d1601dbe8066ae5284e3747c3ed35eb0db6544f97fe3199ecd9e2654d8d06d4ae91d9eb9b78b9b958f7bdd669ca2a7e0362615a858786d41bda480f16363353
7
+ data.tar.gz: 90e451547eeda86cfc97fe67f86777b2ffa84a3b1f2f4b017a5ff0f95f9b3f1c441e23e0181ca5d8e822c5606bd5c0fdfbf14fd03b9fcf2369191892a2e3f770
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.6
2
+ TargetRubyVersion: 3.1
3
3
  NewCops: enable
4
4
  Exclude:
5
5
  - 'spec_money/**/*'
@@ -29,3 +29,6 @@ Metrics/BlockLength:
29
29
 
30
30
  Layout/LineLength:
31
31
  Max: 120
32
+
33
+ Naming/BlockForwarding:
34
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.5.0] - 2026-07-06
4
+
5
+ - Update supported versions ([#8](https://github.com/infinum/money_with_date/pull/8))
6
+
7
+ **Breaking**: drops support for Ruby 3.0
8
+
9
+ ## [0.4.0] - 2024-09-06
10
+
11
+ - Update supported versions ([#7](https://github.com/infinum/money_with_date/pull/7))
12
+
13
+ **Breaking**: drops support for Ruby 2.6 and 2.7, and Rails 5.2 and 6.0.
14
+
3
15
  ## [0.3.0] - 2022-09-18
4
16
 
5
17
  - Fix monetizable module specs ([#4](https://github.com/infinum/money_with_date/pull/4))
data/Gemfile.lock CHANGED
@@ -1,61 +1,65 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- money_with_date (0.2.0)
5
- money (>= 6.14.0, <= 6.16.0)
4
+ money_with_date (0.5.0)
5
+ money (>= 6.14.0, <= 7.0.2)
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.10)
13
- diff-lcs (1.5.0)
14
- i18n (1.12.0)
12
+ concurrent-ruby (1.3.7)
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
+ 4.0.3
data/Gemfile_test CHANGED
@@ -4,9 +4,23 @@ 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
+
10
+ if ENV["RAILS_VERSION"]
11
+ gem "logger"
12
+ gem "activerecord", ENV["RAILS_VERSION"]
13
+
14
+ if Gem::Version.new(ENV.fetch("RAILS_VERSION").delete_prefix("~> ")) >= Gem::Version.new("7.1.0")
15
+ gem "sqlite3"
16
+ else
17
+ gem "sqlite3", "~> 1.4"
18
+ end
19
+ end
20
+
21
+ gem "base64"
22
+ gem "benchmark"
23
+ gem "bigdecimal"
24
+ gem "mutex_m"
11
25
  gem "rubyzip"
12
26
  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
 
@@ -332,17 +332,15 @@ 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**
337
- - money-rails: **1.15.0**
335
+ - Ruby: **>= 3.1.0**
336
+ - money: **>= 6.14.0** and **<= 7.0.2**
337
+ - money-rails: **>= 1.15.0** and **<= 3.0.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`
343
- - money-rails: `1.15.0`
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.
340
+ - Ruby: `3.1`, `3.2`, `3.3`, `3.4` and `4.0`
341
+ - Rails: `~> 6.1.0`, `~> 7.0.0`, `~> 7.1.0`, `~> 7.2.0`, `~> 8.0.0` and `~> 8.1.0`
342
+ - money: `6.14.0`, `6.14.1`, `6.16.0`, `6.17.0`, `6.18.0`, `6.19.0`, `7.0.0`, `7.0.1` and `7.0.2`
343
+ - money-rails: `1.15.0`, `2.0.0` and `3.0.0`
346
344
 
347
345
  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
346
 
@@ -3,16 +3,32 @@
3
3
  module MoneyWithDate
4
4
  module ActiveRecord
5
5
  module Monetizable
6
- def read_monetized(name, subunit_name, options = {}, *args)
7
- money = super(name, subunit_name, options, *args)
8
- date = find_date_for(options[:with_model_date], options[:with_date])
6
+ # :nocov:
7
+ # see https://github.com/RubyMoney/money-rails/pull/670/changes
8
+ if ::Gem::Version.new(::MoneyRails::VERSION) >= ::Gem::Version.new("2.0.0")
9
+ def read_monetized(name, subunit_name, options = {}, *args, **kwargs)
10
+ money = super
11
+ date = find_date_for(options[:with_model_date], options[:with_date])
9
12
 
10
- if money&.date == date
11
- money
12
- else
13
- instance_variable_set("@#{name}", money&.with_date(date))
13
+ if money&.date == date
14
+ money
15
+ else
16
+ instance_variable_set("@#{name}", money&.with_date(date))
17
+ end
18
+ end
19
+ else
20
+ def read_monetized(name, subunit_name, options = {}, *args)
21
+ money = super
22
+ date = find_date_for(options[:with_model_date], options[:with_date])
23
+
24
+ if money&.date == date
25
+ money
26
+ else
27
+ instance_variable_set("@#{name}", money&.with_date(date))
28
+ end
14
29
  end
15
30
  end
31
+ # :nocov:
16
32
 
17
33
  private
18
34
 
@@ -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
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MoneyWithDate
4
- VERSION = "0.3.0"
4
+ VERSION = "0.5.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"
10
- MAXIMUM_MONEY_RAILS_VERSION = "1.15.0"
9
+ MAXIMUM_MONEY_VERSION = "7.0.2"
10
+ MAXIMUM_MONEY_RAILS_VERSION = "3.0.0"
11
11
  end
@@ -9,13 +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 }
18
- ::Money.default_date_column = :created_at
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
19
19
 
20
- require "money_with_date/railtie" if defined?(::Rails::Railtie) && defined?(::MoneyRails)
20
+ require "money_with_date/railtie" if defined?(Rails::Railtie) && defined?(MoneyRails)
21
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.1.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,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: money_with_date
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lovro Bikić
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-09-18 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: money
@@ -19,7 +18,7 @@ dependencies:
19
18
  version: 6.14.0
20
19
  - - "<="
21
20
  - !ruby/object:Gem::Version
22
- version: 6.16.0
21
+ version: 7.0.2
23
22
  type: :runtime
24
23
  prerelease: false
25
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +28,7 @@ dependencies:
29
28
  version: 6.14.0
30
29
  - - "<="
31
30
  - !ruby/object:Gem::Version
32
- version: 6.16.0
31
+ version: 7.0.2
33
32
  - !ruby/object:Gem::Dependency
34
33
  name: pry
35
34
  requirement: !ruby/object:Gem::Requirement
@@ -114,7 +113,6 @@ dependencies:
114
113
  - - ">="
115
114
  - !ruby/object:Gem::Version
116
115
  version: '0'
117
- description:
118
116
  email:
119
117
  - lovro.bikic@gmail.com
120
118
  executables: []
@@ -149,7 +147,6 @@ metadata:
149
147
  source_code_uri: https://github.com/infinum/money_with_date
150
148
  changelog_uri: https://github.com/infinum/money_with_date/blob/master/CHANGELOG.md
151
149
  rubygems_mfa_required: 'true'
152
- post_install_message:
153
150
  rdoc_options: []
154
151
  require_paths:
155
152
  - lib
@@ -157,15 +154,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
157
154
  requirements:
158
155
  - - ">="
159
156
  - !ruby/object:Gem::Version
160
- version: 2.6.0
157
+ version: 3.1.0
161
158
  required_rubygems_version: !ruby/object:Gem::Requirement
162
159
  requirements:
163
160
  - - ">="
164
161
  - !ruby/object:Gem::Version
165
162
  version: '0'
166
163
  requirements: []
167
- rubygems_version: 3.3.7
168
- signing_key:
164
+ rubygems_version: 4.0.3
169
165
  specification_version: 4
170
166
  summary: Extension for the money gem which adds dates to Money objects
171
167
  test_files: []