shopify-money 0.15.0 → 0.16.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: 56953634d128da5cb62dfb11b5c60868a162c4ff7edb9bb810110d17c02469f9
4
- data.tar.gz: c8e6f0e99b480cfcf9be4183adfc633baf14f0f9ee0d777bea01b225c01cfc09
3
+ metadata.gz: f9919cf2d14833f204c05a9642efb7a48bb23822c70c48cf523ccbc68c3e7491
4
+ data.tar.gz: d73bd65e6cb49ee8f5be7add57683274bb006fbfd0ec61aec566385fd92d50f6
5
5
  SHA512:
6
- metadata.gz: 4888a59e2f50348092b73c2b7255b215f994f9b47efbd379ad88d6f4624f4eca403840f584f4d5760a17c02d20f38f0fc49f286c0e19e3557e4976037d1f8049
7
- data.tar.gz: ce77e720fae3724a0cc8303336ac12aee09a7a61862f0ba01f0dc7dce3c4e86f2fd7073ee7828d5cc313b77d9b285dfce07bd84e1d8e289e597e1cf25a349c7d
6
+ metadata.gz: b3dc0c02cee6598d2369ce472a5df01dfb3528cfb45f517394ab7c29b059338b8d65d10c03ae397a4ecdff98a7987a61e0312b894947b728e1ed32078b726086
7
+ data.tar.gz: 1e7cec90da29c1327fdf64984f34e7b6fa01282eb7a0c2e3eda6482d688b06d148b7b7bff760555e3a7d7302ec8b20079ad468cd7c02dabb83c7e9a0aeb0a1f2
@@ -29,7 +29,7 @@ eek:
29
29
  smallest_denomination: 5
30
30
  ghc:
31
31
  priority: 100
32
- iso_code: GHS
32
+ iso_code: GHC
33
33
  name: Ghanaian Cedi
34
34
  symbol: "₵"
35
35
  disambiguate_symbol: GH₵
data/lib/money.rb CHANGED
@@ -9,7 +9,6 @@ require_relative 'money/errors'
9
9
  require_relative 'money/deprecations'
10
10
  require_relative 'money/accounting_money_parser'
11
11
  require_relative 'money/core_extensions'
12
- require_relative 'money_accessor'
13
12
  require_relative 'money_column' if defined?(ActiveRecord)
14
13
 
15
14
  require_relative 'rubocop/cop/money' if defined?(RuboCop)
data/lib/money/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  class Money
3
- VERSION = "0.15.0"
3
+ VERSION = "0.16.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify-money
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-12 00:00:00.000000000 Z
11
+ date: 2021-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -128,7 +128,6 @@ files:
128
128
  - lib/money/money_parser.rb
129
129
  - lib/money/null_currency.rb
130
130
  - lib/money/version.rb
131
- - lib/money_accessor.rb
132
131
  - lib/money_column.rb
133
132
  - lib/money_column/active_record_hooks.rb
134
133
  - lib/money_column/active_record_type.rb
@@ -144,7 +143,6 @@ files:
144
143
  - spec/currency/loader_spec.rb
145
144
  - spec/currency_spec.rb
146
145
  - spec/helpers_spec.rb
147
- - spec/money_accessor_spec.rb
148
146
  - spec/money_column_spec.rb
149
147
  - spec/money_parser_spec.rb
150
148
  - spec/money_spec.rb
@@ -185,7 +183,6 @@ test_files:
185
183
  - spec/currency/loader_spec.rb
186
184
  - spec/currency_spec.rb
187
185
  - spec/helpers_spec.rb
188
- - spec/money_accessor_spec.rb
189
186
  - spec/money_column_spec.rb
190
187
  - spec/money_parser_spec.rb
191
188
  - spec/money_spec.rb
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
- module MoneyAccessor
3
- def self.included(base)
4
- base.extend(ClassMethods)
5
- end
6
-
7
- module ClassMethods
8
- def money_accessor(*columns)
9
- variable_get = self <= Struct ? :[] : :instance_variable_get
10
- variable_set = self <= Struct ? :[]= : :instance_variable_set
11
-
12
- Array(columns).flatten.each do |name|
13
- variable_name = self <= Struct ? name : "@#{name}"
14
-
15
- define_method(name) do
16
- value = public_send(variable_get, variable_name)
17
- value.blank? ? nil : Money.new(value)
18
- end
19
-
20
- define_method("#{name}=") do |value|
21
- if value.blank? || !value.respond_to?(:to_money)
22
- public_send(variable_set, variable_name, nil)
23
- nil
24
- else
25
- money = value.to_money
26
- public_send(variable_set, variable_name, money.value)
27
- money
28
- end
29
- end
30
- end
31
- end
32
- end
33
- end
@@ -1,87 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'spec_helper'
3
-
4
- class NormalObject
5
- include MoneyAccessor
6
-
7
- money_accessor :price
8
-
9
- def initialize(price)
10
- @price = price
11
- end
12
- end
13
-
14
- class StructObject < Struct.new(:price)
15
- include MoneyAccessor
16
-
17
- money_accessor :price
18
- end
19
-
20
- RSpec.shared_examples_for "an object with a money accessor" do
21
- it "generates an attribute reader that returns a money object" do
22
- object = described_class.new(100)
23
-
24
- expect(object.price).to eq(Money.new(100))
25
- end
26
-
27
- it "generates an attribute reader that returns a nil object if the value was nil" do
28
- object = described_class.new(nil)
29
-
30
- expect(object.price).to eq(nil)
31
- end
32
-
33
- it "generates an attribute reader that returns a nil object if the value was blank" do
34
- object = described_class.new('')
35
-
36
- expect(object.price).to eq(nil)
37
- end
38
-
39
- it "generates an attribute writer that allow setting a money object" do
40
- object = described_class.new(0)
41
- object.price = Money.new(10)
42
-
43
- expect(object.price).to eq(Money.new(10))
44
- end
45
-
46
- it "generates an attribute writer that allow setting a integer value" do
47
- object = described_class.new(0)
48
- object.price = 10
49
-
50
- expect(object.price).to eq(Money.new(10))
51
- end
52
-
53
- it "generates an attribute writer that allow setting a float value" do
54
- object = described_class.new(0)
55
- object.price = 10.12
56
-
57
- expect(object.price).to eq(Money.new(10.12))
58
- end
59
-
60
- it "generates an attribute writer that allow setting a nil value" do
61
- object = described_class.new(0)
62
- object.price = nil
63
-
64
- expect(object.price).to eq(nil)
65
- end
66
-
67
- it "generates an attribute writer that allow setting a blank value" do
68
- object = described_class.new(0)
69
- object.price = ''
70
-
71
- expect(object.price).to eq(nil)
72
- end
73
- end
74
-
75
- RSpec.describe NormalObject do
76
- it_behaves_like "an object with a money accessor"
77
- end
78
-
79
- RSpec.describe StructObject do
80
- it_behaves_like "an object with a money accessor"
81
-
82
- it 'does not generate an ivar to store the price value' do
83
- object = described_class.new(10.00)
84
-
85
- expect(object.instance_variable_get(:@price)).to eq(nil)
86
- end
87
- end