physical 0.4.3 → 0.4.4

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
- SHA1:
3
- metadata.gz: b5071305935c7247bcd7f1cdc6f67693d5c8cb37
4
- data.tar.gz: 6040fbc65b93b5d0aced798b9c4f4007952e954f
2
+ SHA256:
3
+ metadata.gz: df340805fcfc8168b20b7ad8b1c6100be37fb1163b52d8d87b2f4fc7aa9f6440
4
+ data.tar.gz: 610081278560cfda0563c368baed947ddc3d932ea6786f21b21e5e21c324de98
5
5
  SHA512:
6
- metadata.gz: 346db67ecfe973dfcf2553331d0d67836e62cff6de2ea688227e37f01703cb1871a4d49b7670d71d0023d5a17cb92e4005bef7e9ebc9a2317c0320a8fbc5b89f
7
- data.tar.gz: 937e4dbd4098d311d36622db26514e40b15e4f6c9690facb0fda1bc37056e68dc73f14b1c4b1ec03f406bd1e927b0c4172c06311fb0a02992e0dfe28c7b215c1
6
+ metadata.gz: 44f4503f2905735ac04eaf80e004491f7fb4644ea97e58a5718fdda12b0e775217f8a80709759b5ec7487b3cfcd336ae59fd12e35d2c3904e71d062ec4b105bf
7
+ data.tar.gz: 21eb1efd17a46c0b993683a176646575f4340d5dc2d8015c7d65778601059a9cf3b969e0c004a6c841ec48bd0a3af2a449b359c3d619ac2a0953420883679263
data/.gitignore CHANGED
@@ -9,4 +9,5 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ .ruby-version
12
13
  Gemfile.lock
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## Unreleased
8
8
 
9
+ ## [0.4.4] - 2019-10-29
10
+ ### Added
11
+ - Add `#sku`, `#cost` and `#description` to `Physical::Item`
12
+
9
13
  ## [0.4.3] - 2019-10-14
10
14
  ### Added
11
15
  - Add `#latitude` and `#longitude` to `Physical::Location`
@@ -26,7 +26,8 @@ module Physical
26
26
  end
27
27
 
28
28
  def ==(other)
29
- id == other.id
29
+ other.is_a?(self.class) &&
30
+ id == other&.id
30
31
  end
31
32
 
32
33
  private
@@ -3,5 +3,16 @@
3
3
  module Physical
4
4
  class Item < Cuboid
5
5
  DEFAULT_LENGTH = 0
6
+
7
+ attr_reader :cost,
8
+ :sku,
9
+ :description
10
+
11
+ def initialize(cost: nil, sku: nil, description: nil, **kwargs)
12
+ @cost = Types::Money.optional[cost]
13
+ @sku = sku
14
+ @description = description
15
+ super kwargs
16
+ end
6
17
  end
7
18
  end
@@ -81,9 +81,9 @@ module Physical
81
81
 
82
82
  def to_hash
83
83
  {
84
- country: country.code,
84
+ country: country&.code,
85
85
  postal_code: zip,
86
- region: region.code,
86
+ region: region&.code,
87
87
  city: city,
88
88
  name: name,
89
89
  address1: address1,
@@ -98,7 +98,8 @@ module Physical
98
98
  end
99
99
 
100
100
  def ==(other)
101
- to_hash == other.to_hash
101
+ other.is_a?(self.class) &&
102
+ to_hash == other&.to_hash
102
103
  end
103
104
  end
104
105
  end
@@ -28,4 +28,18 @@ RSpec.shared_examples 'a cuboid' do
28
28
  expect(subject.width).to eq(Measured::Length.new(3.3, :cm))
29
29
  expect(subject.height).to eq(Measured::Length.new(2.2, :cm))
30
30
  end
31
+
32
+ describe "#==" do
33
+ let(:args) { Hash[id: 123] }
34
+ let(:other_cuboid) { described_class.new(args) }
35
+ let(:non_cuboid) { double(id: 123) }
36
+
37
+ it "compares cuboids" do
38
+ aggregate_failures do
39
+ expect(subject == other_cuboid).to be(true)
40
+ expect(subject == non_cuboid).to be(false)
41
+ expect(subject == nil).to be(false)
42
+ end
43
+ end
44
+ end
31
45
  end
@@ -1,4 +1,5 @@
1
1
  require 'measured'
2
+ require 'money'
2
3
  require 'dry-types'
3
4
 
4
5
  module Physical
@@ -9,6 +10,7 @@ module Physical
9
10
  Length = Types.Instance(::Measured::Length)
10
11
  Volume = Types.Instance(::Measured::Volume)
11
12
  Density = Types.Instance(::Measured::Density)
13
+ Money = Types.Instance(::Money)
12
14
 
13
15
  Dimensions = Types::Strict::Array.of(Length)
14
16
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Physical
4
- VERSION = "0.4.3"
4
+ VERSION = "0.4.4"
5
5
  end
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_runtime_dependency "carmen", "~> 1.0"
24
24
  spec.add_runtime_dependency "measured", "~> 2.4"
25
25
  spec.add_runtime_dependency "dry-types", "~> 1.0.0"
26
+ spec.add_runtime_dependency "money", ">= 5"
26
27
 
27
28
  spec.add_development_dependency "bundler", [">= 1.16", "< 3"]
28
29
  spec.add_development_dependency "factory_bot", "~> 4.8"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: physical
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Meyerhoff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-14 00:00:00.000000000 Z
11
+ date: 2019-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: carmen
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: money
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '5'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '5'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -125,7 +139,6 @@ files:
125
139
  - ".gitignore"
126
140
  - ".rspec"
127
141
  - ".rubocop.yml"
128
- - ".ruby-version"
129
142
  - ".travis.yml"
130
143
  - CHANGELOG.md
131
144
  - CODE_OF_CONDUCT.md
@@ -173,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
186
  version: '0'
174
187
  requirements: []
175
188
  rubyforge_project:
176
- rubygems_version: 2.6.14.1
189
+ rubygems_version: 2.7.6.2
177
190
  signing_key:
178
191
  specification_version: 4
179
192
  summary: A facade to deal with physical packages
@@ -1 +0,0 @@
1
- 2.4.4