physical 0.3.1 → 0.3.2

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
  SHA1:
3
- metadata.gz: 64c1693d32341f8f6b609ed4a0b7335241a24565
4
- data.tar.gz: 60bcc9ae5fe97bab563306adf2a73be10e1906ef
3
+ metadata.gz: de7fabfb964fcae3c3c6beaff9910aaab0c00ca3
4
+ data.tar.gz: 33c951d1c9d9dae5d3147b7a21485d127a0e843b
5
5
  SHA512:
6
- metadata.gz: b2c048261f3f6bfd8ef97e9df35ed8861c4bce8e50c4f955a173064a106691681177c893e79f733600a8e6cb6a96510da9ed51a70c328854b902bcbf9bcaa0cf
7
- data.tar.gz: d2953c50d6023619c8217bd31ac55c46bb07e4645b55709eb9005271ad37acc213b3681d25e11408d3332fbae8fa0da40d03ef16567070a07f836dd29d38f778
6
+ metadata.gz: 573c585f62bf8829a4dd12c2b8b110152a21fe0fa340f34cb567ecf82bbde2ba70dbfb5ab11c7cdd94b350904014f9b3c257257a112daa6f444d2396170493c3
7
+ data.tar.gz: 186ee3032e9582f736cf698a5dd5c0ba9a23c340f65ddb46c3895736db9b90ae1b5b039ded12f2bf4da70ca9c55c8680cc5b592d0dd0f005a7aa5acbf9f0d4a9
@@ -25,6 +25,27 @@ module Physical
25
25
 
26
26
  private
27
27
 
28
+ NORMALIZED_METHOD_REGEX = /(\w+)\??$/
29
+
30
+ def method_missing(method)
31
+ symbolized_properties = properties.symbolize_keys
32
+ method_name = normalize_method_name(method)
33
+ if symbolized_properties.key?(method_name)
34
+ symbolized_properties[method_name]
35
+ else
36
+ super
37
+ end
38
+ end
39
+
40
+ def respond_to_missing?(method, *args)
41
+ method_name = normalize_method_name(method)
42
+ properties.symbolize_keys.key?(method_name) || super
43
+ end
44
+
45
+ def normalize_method_name(method)
46
+ method.to_s.sub(NORMALIZED_METHOD_REGEX, '\1').to_sym
47
+ end
48
+
28
49
  def fill_dimensions(dimensions)
29
50
  dimensions.fill(dimensions.length..2) do |index|
30
51
  @dimensions[index] || Measured::Length(self.class::DEFAULT_LENGTH, :cm)
@@ -17,10 +17,12 @@ module Physical
17
17
  def <<(item)
18
18
  @items.add(item)
19
19
  end
20
+ alias_method :add, :<<
20
21
 
21
22
  def >>(item)
22
23
  @items.delete(item)
23
24
  end
25
+ alias_method :delete, :>>
24
26
 
25
27
  def weight
26
28
  container.weight + items.map(&:weight).reduce(Measured::Weight(0, :g), &:+) + void_fill_weight
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'factory_bot'
4
+ require_relative 'box_factory'
5
+ require_relative 'item_factory'
4
6
 
5
7
  FactoryBot.define do
6
8
  factory :physical_package, class: "Physical::Package" do
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'factory_bot'
4
+ require_relative 'location_factory'
5
+ require_relative 'package_factory'
4
6
 
5
7
  FactoryBot.define do
6
8
  factory :physical_shipment, class: "Physical::Shipment" do
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Physical
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.2"
5
5
  end
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.3.1
4
+ version: 0.3.2
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-05-24 00:00:00.000000000 Z
11
+ date: 2019-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: carmen