gecko-ruby 0.7.1 → 0.8.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: e4f3f023ad3d71372f8b6cf44073ee2e6a2a85bb1f436a17a88aefa291157d04
4
- data.tar.gz: 5e142ad7043284a42208069536ff59754ab5fed8b6ee81667b4e0e5d67c3b9ef
3
+ metadata.gz: eb9de08507d0105e06a6d879856fa389834a6854e27947f24ed4ffd9fb84a64e
4
+ data.tar.gz: f869506161aa22431c4eed00e71b326678a45d612e4d15754bfaba831b954784
5
5
  SHA512:
6
- metadata.gz: 8d4cde1de8764069e49af88c32d179cccb12cd9e7eb874e76ffc03e340cb99fe4ce8edca81c460b78c1b9e152f2e63551418d578657df7fc66410e3d97db7c0c
7
- data.tar.gz: ea2fc39f2316c403e1904a6985e22aa6586925258d752f2979e4e8380f4894c86c8ee03f9d7745fc8dea43c757d87454df8061b691b60c1b3d66180c37150f4c
6
+ metadata.gz: 2b6eef606da5df282eba8fa943a73a6460d3a5a51cbd824158a6b76bdcef7cc2d817124735839b4ca0af866df6cb1075d348016c626a700767bd7445c4b6733a
7
+ data.tar.gz: 901d13594b029897e6de3033fa0f153b7ba9d1f0654fa233f5ec5580b9499a0f33c29680a21d4e90a2af30902ba77db12c652f7b74bda58ef3629db0e19a08ad
@@ -2,7 +2,6 @@ language: ruby
2
2
  before_install:
3
3
  - gem install bundler
4
4
  rvm:
5
- - 2.3
6
5
  - 2.4
7
6
  - 2.5
8
7
  - 2.6
@@ -1,3 +1,7 @@
1
+ ## 0.8.0 (2019-07-01)
2
+ - Add `discount_amount` attribute and `discounted_price` helper to `OrderLineItem`'s
3
+ - Drop support for Ruby 2.3
4
+
1
5
  ## 0.7.1 (2019-03-19)
2
6
  - Add `Gecko::Record::Note` model.
3
7
  - Fix issue with `find_many` which manifested as a bug in `has_many` definitions with cached records being duplicated when more than 100 children existed.
@@ -17,6 +17,8 @@ module Gecko
17
17
  attribute :shippable, Boolean, readonly: true
18
18
 
19
19
  attribute :discount, BigDecimal
20
+ attribute :discount_amount, BigDecimal
21
+
20
22
  attribute :quantity, BigDecimal
21
23
  attribute :price, BigDecimal
22
24
  attribute :tax_rate_override, BigDecimal
@@ -24,6 +26,21 @@ module Gecko
24
26
  attribute :position, Integer
25
27
 
26
28
  attribute :image_url, String, readonly: true
29
+
30
+ def discounted_price
31
+ if discount_amount&.nonzero?
32
+ price - discount_amount
33
+ else
34
+ price * discount_multiplier
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def discount_multiplier
41
+ return 1 unless discount
42
+ 1 - discount / 100
43
+ end
27
44
  end
28
45
 
29
46
  class OrderLineItemAdapter < BaseAdapter
@@ -1,3 +1,3 @@
1
1
  module Gecko
2
- VERSION = '0.7.1'
2
+ VERSION = '0.8.0'
3
3
  end
@@ -15,4 +15,14 @@ class Gecko::OrderLineItemTest < Minitest::Test
15
15
  def test_initializes_record
16
16
  assert_instance_of(Gecko::Record::OrderLineItem, @record)
17
17
  end
18
+
19
+ def test_discounted_price_with_discount
20
+ record = record_class.new(client, price: 20, discount: 20)
21
+ assert_equal(16, record.discounted_price)
22
+ end
23
+
24
+ def test_discounted_price_with_discount_amount
25
+ record = record_class.new(client, price: 20, discount_amount: 5)
26
+ assert_equal(15, record.discounted_price)
27
+ end
18
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gecko-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bradley Priest
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-19 00:00:00.000000000 Z
11
+ date: 2019-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler