amountable 0.3.2 → 0.4.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 +4 -4
- data/.github/workflows/CI.yml +11 -3
- data/.github/workflows/{gem-push.yml → gem-publish-public.yml} +1 -1
- data/.gitignore +2 -0
- data/.rspec +1 -1
- data/LICENSE +1 -1
- data/amountable.gemspec +2 -3
- data/db/migrate/0_create_amounts.rb +1 -1
- data/gemfiles/activerecord_5.2.gemfile +5 -0
- data/gemfiles/activerecord_6.0.gemfile +5 -0
- data/gemfiles/activerecord_6.1.gemfile +5 -0
- data/lib/amountable/amount.rb +2 -17
- data/lib/amountable/jsonb_methods.rb +1 -1
- data/lib/amountable/nil_amount.rb +1 -1
- data/lib/amountable/operations.rb +1 -1
- data/lib/amountable/table_methods.rb +1 -1
- data/lib/amountable/version.rb +2 -2
- data/lib/amountable/virtual_amount.rb +1 -1
- data/lib/amountable.rb +1 -1
- data/spec/amountable/amount_spec.rb +1 -1
- data/spec/amountable/amountable_spec.rb +3 -3
- data/spec/amountable/nil_amount_spec.rb +1 -1
- data/spec/internal/app/models/order.rb +1 -1
- data/spec/internal/app/models/subscription.rb +1 -1
- data/spec/internal/db/schema.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/support/database.rb +2 -2
- metadata +12 -24
- data/.travis.yml +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7f15a987389dd56fc45dcddf6145adddbfe47bfc8b3b7666180c1bd51d7638a1
|
|
4
|
+
data.tar.gz: 1a23700ce3d891c26c35e53fe2d2e3c2d07dea910b0e6057a71aa17740933b6b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3642a8c7ad8a7eb8ff0e039cb77abadb6ee11b4d53521e53028d2b4c74ad71e8a3ed1ab3762e36e55067d8e31813dfde1c0a2fdf1ae15fdf7583bac6f4ba65b4
|
|
7
|
+
data.tar.gz: 68285488fe760b730d09fd54640e2529bd579dbb3227cd313842ae8c7f5d4aa6db6d46d0e7bc7dc7a03541c0cf8de78a6aadb731fb654252df217f2ffa4a7a38
|
data/.github/workflows/CI.yml
CHANGED
|
@@ -2,6 +2,8 @@ name: CI
|
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
5
7
|
pull_request:
|
|
6
8
|
|
|
7
9
|
jobs:
|
|
@@ -10,8 +12,12 @@ jobs:
|
|
|
10
12
|
strategy:
|
|
11
13
|
matrix:
|
|
12
14
|
ruby:
|
|
13
|
-
- 2.6
|
|
14
|
-
- 2.7
|
|
15
|
+
- '2.6'
|
|
16
|
+
- '2.7'
|
|
17
|
+
activerecord:
|
|
18
|
+
- '6.1'
|
|
19
|
+
- '6.0'
|
|
20
|
+
- '5.2'
|
|
15
21
|
services:
|
|
16
22
|
postgres:
|
|
17
23
|
image: postgres:12
|
|
@@ -26,7 +32,9 @@ jobs:
|
|
|
26
32
|
--health-timeout 5s
|
|
27
33
|
--health-retries 5
|
|
28
34
|
|
|
29
|
-
name: Ruby ${{ matrix.ruby }}
|
|
35
|
+
name: Ruby ${{ matrix.ruby }} / ActiveRecord ${{ matrix.activerecord }}
|
|
36
|
+
env:
|
|
37
|
+
BUNDLE_GEMFILE: gemfiles/activerecord_${{ matrix.activerecord }}.gemfile
|
|
30
38
|
steps:
|
|
31
39
|
- uses: actions/checkout@v2
|
|
32
40
|
- run: |
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
--
|
|
1
|
+
--force-color
|
data/LICENSE
CHANGED
data/amountable.gemspec
CHANGED
|
@@ -15,10 +15,9 @@ Gem::Specification.new do |gem|
|
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
|
16
16
|
gem.test_files = gem.files.grep(%r{^spec/})
|
|
17
17
|
gem.require_paths = ['lib']
|
|
18
|
-
gem.required_ruby_version = '>= 2.
|
|
18
|
+
gem.required_ruby_version = '>= 2.6'
|
|
19
19
|
|
|
20
|
-
gem.add_dependency 'activerecord', '>=
|
|
21
|
-
gem.add_dependency 'activesupport', '>= 4.1'
|
|
20
|
+
gem.add_dependency 'activerecord', '>= 5.2', '< 7'
|
|
22
21
|
gem.add_dependency 'activerecord-import', '>= 0.19.1'
|
|
23
22
|
gem.add_dependency 'money-rails', '>=1.7.0'
|
|
24
23
|
gem.add_dependency 'monetize'
|
data/lib/amountable/amount.rb
CHANGED
|
@@ -1,21 +1,7 @@
|
|
|
1
|
-
# Copyright 2015-
|
|
1
|
+
# Copyright 2015-2021, Instacart
|
|
2
2
|
|
|
3
3
|
module Amountable
|
|
4
4
|
class Amount < ActiveRecord::Base
|
|
5
|
-
class_attribute :columns
|
|
6
|
-
self.columns = []
|
|
7
|
-
|
|
8
|
-
def self.column(name, sql_type = nil, default = nil, null = true)
|
|
9
|
-
type = "ActiveRecord::Type::#{sql_type.to_s.camelize}".constantize.new
|
|
10
|
-
columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, type, null)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
column :amountable_type, :string, nil, false
|
|
14
|
-
column :amountable_id, :integer, nil, false
|
|
15
|
-
column :value_currency, :string, nil, true
|
|
16
|
-
column :value_cents, :integer, 0, false
|
|
17
|
-
column :name, :string, nil, false
|
|
18
|
-
|
|
19
5
|
include Amountable::Operations
|
|
20
6
|
|
|
21
7
|
belongs_to :amountable, polymorphic: true
|
|
@@ -31,6 +17,5 @@ module Amountable
|
|
|
31
17
|
raise StandardError.new("Can't persist amount to database") if persistable == false
|
|
32
18
|
super
|
|
33
19
|
end
|
|
34
|
-
|
|
35
20
|
end
|
|
36
|
-
end
|
|
21
|
+
end
|
data/lib/amountable/version.rb
CHANGED
data/lib/amountable.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright 2015-
|
|
1
|
+
# Copyright 2015-2021, Instacart
|
|
2
2
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
@@ -23,7 +23,7 @@ describe Amountable do
|
|
|
23
23
|
expect(amount.persisted?).to be true
|
|
24
24
|
end
|
|
25
25
|
expect do
|
|
26
|
-
expect(order.
|
|
26
|
+
expect(order.update(sub_total: Money.new(200)))
|
|
27
27
|
end.not_to change { Amountable::Amount.count }
|
|
28
28
|
end
|
|
29
29
|
|
|
@@ -80,7 +80,7 @@ describe Amountable do
|
|
|
80
80
|
expect { subscription.save }.not_to change { Amountable::Amount.count }
|
|
81
81
|
expect(amount.persisted?).to be false
|
|
82
82
|
end
|
|
83
|
-
subscription.
|
|
83
|
+
subscription.update(sub_total: Money.new(200))
|
|
84
84
|
expect(subscription.sub_total).to eq(Money.new(200))
|
|
85
85
|
expect(subscription.total).to eq(Money.new(200))
|
|
86
86
|
subscription.sub_total = Money.zero
|
data/spec/internal/db/schema.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/support/database.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright 2015-
|
|
1
|
+
# Copyright 2015-2021, Instacart
|
|
2
2
|
|
|
3
3
|
db_name = ENV['DB'] || 'postgresql'
|
|
4
4
|
spec_dir = Pathname.new(File.dirname(__FILE__)) / '..'
|
|
@@ -10,7 +10,7 @@ ActiveRecord::Migration.verbose = false
|
|
|
10
10
|
ActiveRecord::Base.default_timezone = :utc
|
|
11
11
|
ActiveRecord::Base.configurations = YAML.load_file(database_yml)
|
|
12
12
|
ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), '../debug.log'))
|
|
13
|
-
ActiveRecord::Base.logger.level = ENV['
|
|
13
|
+
ActiveRecord::Base.logger.level = ENV['CI'] ? ::Logger::ERROR : ::Logger::DEBUG
|
|
14
14
|
config = ActiveRecord::Base.configurations[db_name]
|
|
15
15
|
|
|
16
16
|
begin
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: amountable
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Emmanuel Turlay
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-01
|
|
11
|
+
date: 2021-10-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|
|
@@ -16,34 +16,20 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '5.2'
|
|
20
20
|
- - "<"
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: '
|
|
22
|
+
version: '7'
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
26
|
requirements:
|
|
27
27
|
- - ">="
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
|
-
version: '
|
|
29
|
+
version: '5.2'
|
|
30
30
|
- - "<"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
33
|
-
- !ruby/object:Gem::Dependency
|
|
34
|
-
name: activesupport
|
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
|
36
|
-
requirements:
|
|
37
|
-
- - ">="
|
|
38
|
-
- !ruby/object:Gem::Version
|
|
39
|
-
version: '4.1'
|
|
40
|
-
type: :runtime
|
|
41
|
-
prerelease: false
|
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
43
|
-
requirements:
|
|
44
|
-
- - ">="
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: '4.1'
|
|
32
|
+
version: '7'
|
|
47
33
|
- !ruby/object:Gem::Dependency
|
|
48
34
|
name: activerecord-import
|
|
49
35
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -194,16 +180,18 @@ extra_rdoc_files: []
|
|
|
194
180
|
files:
|
|
195
181
|
- ".github/dependabot.yml"
|
|
196
182
|
- ".github/workflows/CI.yml"
|
|
197
|
-
- ".github/workflows/gem-
|
|
183
|
+
- ".github/workflows/gem-publish-public.yml"
|
|
198
184
|
- ".gitignore"
|
|
199
185
|
- ".rspec"
|
|
200
|
-
- ".travis.yml"
|
|
201
186
|
- Gemfile
|
|
202
187
|
- LICENSE
|
|
203
188
|
- README.md
|
|
204
189
|
- Rakefile
|
|
205
190
|
- amountable.gemspec
|
|
206
191
|
- db/migrate/0_create_amounts.rb
|
|
192
|
+
- gemfiles/activerecord_5.2.gemfile
|
|
193
|
+
- gemfiles/activerecord_6.0.gemfile
|
|
194
|
+
- gemfiles/activerecord_6.1.gemfile
|
|
207
195
|
- lib/amountable.rb
|
|
208
196
|
- lib/amountable/amount.rb
|
|
209
197
|
- lib/amountable/jsonb_methods.rb
|
|
@@ -234,14 +222,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
234
222
|
requirements:
|
|
235
223
|
- - ">="
|
|
236
224
|
- !ruby/object:Gem::Version
|
|
237
|
-
version: 2.
|
|
225
|
+
version: '2.6'
|
|
238
226
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
239
227
|
requirements:
|
|
240
228
|
- - ">="
|
|
241
229
|
- !ruby/object:Gem::Version
|
|
242
230
|
version: '0'
|
|
243
231
|
requirements: []
|
|
244
|
-
rubygems_version: 3.
|
|
232
|
+
rubygems_version: 3.2.22
|
|
245
233
|
signing_key:
|
|
246
234
|
specification_version: 4
|
|
247
235
|
summary: Easy Money fields for your Rails models.
|