physical 0.4.3 → 0.4.4
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 +5 -5
- data/.gitignore +1 -0
- data/CHANGELOG.md +4 -0
- data/lib/physical/cuboid.rb +2 -1
- data/lib/physical/item.rb +11 -0
- data/lib/physical/location.rb +4 -3
- data/lib/physical/spec_support/shared_examples.rb +14 -0
- data/lib/physical/types.rb +2 -0
- data/lib/physical/version.rb +1 -1
- data/physical.gemspec +1 -0
- metadata +17 -4
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: df340805fcfc8168b20b7ad8b1c6100be37fb1163b52d8d87b2f4fc7aa9f6440
|
4
|
+
data.tar.gz: 610081278560cfda0563c368baed947ddc3d932ea6786f21b21e5e21c324de98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44f4503f2905735ac04eaf80e004491f7fb4644ea97e58a5718fdda12b0e775217f8a80709759b5ec7487b3cfcd336ae59fd12e35d2c3904e71d062ec4b105bf
|
7
|
+
data.tar.gz: 21eb1efd17a46c0b993683a176646575f4340d5dc2d8015c7d65778601059a9cf3b969e0c004a6c841ec48bd0a3af2a449b359c3d619ac2a0953420883679263
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -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`
|
data/lib/physical/cuboid.rb
CHANGED
data/lib/physical/item.rb
CHANGED
@@ -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
|
data/lib/physical/location.rb
CHANGED
@@ -81,9 +81,9 @@ module Physical
|
|
81
81
|
|
82
82
|
def to_hash
|
83
83
|
{
|
84
|
-
country: country
|
84
|
+
country: country&.code,
|
85
85
|
postal_code: zip,
|
86
|
-
region: region
|
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
|
-
|
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
|
data/lib/physical/types.rb
CHANGED
@@ -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
|
data/lib/physical/version.rb
CHANGED
data/physical.gemspec
CHANGED
@@ -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.
|
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-
|
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.
|
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
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.4.4
|