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 +4 -4
- data/.rubocop.yml +4 -1
- data/CHANGELOG.md +11 -0
- data/Gemfile.lock +41 -37
- data/Gemfile_test +12 -4
- data/README.md +11 -10
- data/lib/money_with_date/active_record/monetizable.rb +1 -1
- data/lib/money_with_date/bank/variable_exchange.rb +1 -1
- data/lib/money_with_date/class_methods.rb +1 -0
- data/lib/money_with_date/hooks.rb +0 -4
- data/lib/money_with_date/version.rb +2 -2
- data/lib/money_with_date.rb +6 -5
- data/money_with_date.gemspec +3 -1
- metadata +6 -7
- data/lib/money_with_date/active_record/class_methods.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ea5e9735d420c5bc644d12c9c27621c2c0d6a16c42108ba93460af3542a33bc
|
4
|
+
data.tar.gz: 56ca079c22121b3fcc7fcb4c0000aea97e590bcb4487403b9d474eb92a833e8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49da9ee683e362ac6fb444b92133d9a2de229536bcc65c29a74dff5e15da30c9cc490f975770f14586a9400f52c738c5548b0e41514f64432c82054c8cfd547c
|
7
|
+
data.tar.gz: 580056af02a78f82a027bad22ac8baede08e9623bb4f935637170e5d9d39af0f93731ce643f31df5dfa7798c4ffb423eae9b41510ac0b7a73f0715f5273e03e0
|
data/.rubocop.yml
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion:
|
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.
|
5
|
-
money (>= 6.14.0, <= 6.
|
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.
|
13
|
-
diff-lcs (1.5.
|
14
|
-
i18n (1.
|
12
|
+
concurrent-ruby (1.3.4)
|
13
|
+
diff-lcs (1.5.1)
|
14
|
+
i18n (1.14.5)
|
15
15
|
concurrent-ruby (~> 1.0)
|
16
|
-
|
17
|
-
|
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.
|
20
|
-
parser (3.
|
21
|
+
parallel (1.26.3)
|
22
|
+
parser (3.3.5.0)
|
21
23
|
ast (~> 2.4.1)
|
22
|
-
|
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.
|
27
|
-
regexp_parser (2.2
|
28
|
-
|
29
|
-
|
30
|
-
rspec-
|
31
|
-
rspec-
|
32
|
-
|
33
|
-
|
34
|
-
|
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.
|
38
|
-
rspec-mocks (3.
|
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.
|
41
|
-
rspec-support (3.
|
42
|
-
rubocop (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.
|
49
|
+
parser (>= 3.3.0.2)
|
45
50
|
rainbow (>= 2.2.2, < 4.0)
|
46
|
-
regexp_parser (>=
|
47
|
-
|
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 (>=
|
51
|
-
rubocop-ast (1.
|
52
|
-
parser (>= 3.
|
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 (
|
56
|
-
rubocop (~> 1.
|
57
|
-
ruby-progressbar (1.
|
58
|
-
unicode-display_width (2.
|
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.
|
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
|
-
|
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
|
49
|
+
# => Money.from_amount(4.82, "EUR")
|
50
50
|
# 2 CHF == 1,92 EUR on today's date
|
51
|
-
# 1 USD
|
52
|
-
# 1,92 + 0,9 + 2
|
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: **>=
|
336
|
-
- money: **>= 6.14.0** and **<= 6.
|
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: `
|
341
|
-
- Rails:
|
342
|
-
- money: `6.14.0`, `6.14.1`, and `6.
|
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
|
-
|
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
|
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.
|
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
|
@@ -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.
|
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.
|
9
|
+
MAXIMUM_MONEY_VERSION = "6.19.0"
|
10
10
|
MAXIMUM_MONEY_RAILS_VERSION = "1.15.0"
|
11
11
|
end
|
data/lib/money_with_date.rb
CHANGED
@@ -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
|
-
|
13
|
-
|
12
|
+
Money.prepend(MoneyWithDate::InstanceMethods)
|
13
|
+
Money.singleton_class.prepend(MoneyWithDate::ClassMethods)
|
14
14
|
|
15
15
|
# :nocov:
|
16
|
-
|
17
|
-
|
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?(
|
20
|
+
require "money_with_date/railtie" if defined?(Rails::Railtie) && defined?(MoneyRails)
|
20
21
|
# :nocov:
|
data/money_with_date.gemspec
CHANGED
@@ -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 = ">=
|
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.
|
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:
|
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.
|
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.
|
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:
|
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.
|
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
|