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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aee387d2d2d88c2fc8086dd0cc4b09293e775bd3c9a4f5e6bc507d18ca06976b
4
- data.tar.gz: 93b2fef942db13a396dae78c9fe533d74290f7ffd47b0df6d581fe8e5fdcbf72
3
+ metadata.gz: 7f15a987389dd56fc45dcddf6145adddbfe47bfc8b3b7666180c1bd51d7638a1
4
+ data.tar.gz: 1a23700ce3d891c26c35e53fe2d2e3c2d07dea910b0e6057a71aa17740933b6b
5
5
  SHA512:
6
- metadata.gz: 2c090c0efc1c00740a594f805fa49c967adce57369b19d5d509be9c1d708e454a9ce778d7d262aee3ae387d050e6f5b70692fc9a4b4f06ad520732388e78bf5e
7
- data.tar.gz: 4119055f5f5e0631abf38758e638e2fa5619b5136c09a740a799bbe1b9743d36a662b37f7a091a0129090b397cf800b91c15e5fd7d3429d1b56d91a9ec451666
6
+ metadata.gz: 3642a8c7ad8a7eb8ff0e039cb77abadb6ee11b4d53521e53028d2b4c74ad71e8a3ed1ab3762e36e55067d8e31813dfde1c0a2fdf1ae15fdf7583bac6f4ba65b4
7
+ data.tar.gz: 68285488fe760b730d09fd54640e2529bd579dbb3227cd313842ae8c7f5d4aa6db6d46d0e7bc7dc7a03541c0cf8de78a6aadb731fb654252df217f2ffa4a7a38
@@ -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: |
@@ -1,4 +1,4 @@
1
- name: Ruby Gem
1
+ name: Publish Public Gem
2
2
 
3
3
  on:
4
4
  release:
data/.gitignore CHANGED
@@ -7,3 +7,5 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ gemfiles/*.lock
11
+ *.log
data/.rspec CHANGED
@@ -1 +1 @@
1
- --colour
1
+ --force-color
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright © 2015-2016, Instacart
1
+ Copyright © 2015-2021, Instacart
2
2
 
3
3
  Permission to use, copy, modify, and/or distribute this software for any
4
4
  purpose with or without fee is hereby granted, provided that the above
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.1.1'
18
+ gem.required_ruby_version = '>= 2.6'
19
19
 
20
- gem.add_dependency 'activerecord', '>= 4.1', '< 6.1'
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'
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2017, Instacart
1
+ # Copyright 2015-2021, Instacart
2
2
 
3
3
  class CreateAmounts < ActiveRecord::Migration
4
4
  def change
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: "../"
4
+
5
+ gem "activerecord", "~> 5.2.0"
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: "../"
4
+
5
+ gem "activerecord", "~> 6.0.0"
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: "../"
4
+
5
+ gem "activerecord", "~> 6.1.0"
@@ -1,21 +1,7 @@
1
- # Copyright 2015-2017, Instacart
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
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2017, Instacart
1
+ # Copyright 2015-2021, Instacart
2
2
 
3
3
  module Amountable
4
4
  module JsonbMethods
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2017, Instacart
1
+ # Copyright 2015-2021, Instacart
2
2
 
3
3
  module Amountable
4
4
  class NilAmount
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2017, Instacart
1
+ # Copyright 2015-2021, Instacart
2
2
 
3
3
  module Amountable
4
4
  module Operations
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2017, Instacart
1
+ # Copyright 2015-2021, Instacart
2
2
 
3
3
  module Amountable
4
4
  module TableMethods
@@ -1,5 +1,5 @@
1
- # Copyright 2015-2017, Instacart
1
+ # Copyright 2015-2021, Instacart
2
2
 
3
3
  module Amountable
4
- VERSION = '0.3.2'
4
+ VERSION = '0.4.0'
5
5
  end
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2017, Instacart
1
+ # Copyright 2015-2021, Instacart
2
2
 
3
3
  module Amountable
4
4
  class VirtualAmount
data/lib/amountable.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2017, Instacart
1
+ # Copyright 2015-2021, Instacart
2
2
 
3
3
  module Amountable
4
4
  extend ActiveSupport::Autoload
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2016, Instacart
1
+ # Copyright 2015-2021, Instacart
2
2
 
3
3
  require 'spec_helper'
4
4
 
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2016, Instacart
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.update_attributes(sub_total: Money.new(200)))
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.update_attributes(sub_total: Money.new(200))
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
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2016, Instacart
1
+ # Copyright 2015-2021, Instacart
2
2
 
3
3
  require 'spec_helper'
4
4
 
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2016, Instacart
1
+ # Copyright 2015-2021, Instacart
2
2
 
3
3
  class Order < ActiveRecord::Base
4
4
 
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2016, Instacart
1
+ # Copyright 2015-2021, Instacart
2
2
 
3
3
  if jsonb_available?
4
4
  class Subscription < ActiveRecord::Base
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2016, Instacart
1
+ # Copyright 2015-2021, Instacart
2
2
 
3
3
  ActiveRecord::Schema.define do
4
4
 
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2016, Instacart
1
+ # Copyright 2015-2021, Instacart
2
2
 
3
3
  ENV['RAILS_ENV'] = 'test'
4
4
  require 'rails'
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2016, Instacart
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['TRAVIS'] ? ::Logger::ERROR : ::Logger::DEBUG
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.3.2
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-07 00:00:00.000000000 Z
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: '4.1'
19
+ version: '5.2'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '6.1'
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: '4.1'
29
+ version: '5.2'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '6.1'
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-push.yml"
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.1.1
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.1.4
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.
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.2
4
- addons:
5
- postgresql: "9.4"