hash_math 1.2.0.pre.alpha → 1.2.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: ac40548aa245ecbca0e7e2cc3dd8d617db1937108aa64f60513a7819b84bf534
4
- data.tar.gz: 15b253850e012966eeb4aadbcd5873bd9571abe0fa62bd83a242ed39de8e2395
3
+ metadata.gz: a13830be433114e0438c34e2e15e136a01ab61c93b57c14e9be2b39a4dc9a7bf
4
+ data.tar.gz: 14a4d2765184d10f6149dd446be54f1cea68c505e308fbf884a982cecc0ad161
5
5
  SHA512:
6
- metadata.gz: d2289559ffbb080f16eff2655ab83860ca2779120d17ce5795d163dd762f425da9ab27ec16f7f480ffb84b824eaab60068de18548215a770abb4e24847f6e66f
7
- data.tar.gz: 5256981292c2f27c706753524f3816b04207a322b179a92028d7e5a902c2d4836fb8b353684beab691c28f0e5c3920715fbff79412a7a8a0e8fa223716e90226
6
+ metadata.gz: b5294dee4cb58c9d28cc829b2d18a51edb6036bf110c2ad94bc827e52d80e6b7417cf96e5b699af812b91d6b9ee9be75e2ba2f796a65234e333f68f3fb587033
7
+ data.tar.gz: '0706231920aa50e791e43820e9544a399d132ff9f5a1ee29cd0fc2c70414ecb181d28350a4aa3f1b5df67bdf904dc93b876246cfdb4e53507e33358e1100de71'
@@ -1,4 +1,4 @@
1
- # 1.2.0 (TBD)
1
+ # 1.2.0 (August 19th, 2020)
2
2
 
3
3
  Additions:
4
4
 
@@ -26,12 +26,18 @@ module HashMath
26
26
  end
27
27
 
28
28
  # Add an enumerable list of lookup records to this instance's lookup dataset.
29
+ # Raises ArgumentError if name is blank.
29
30
  def add_each(name, objects)
31
+ raise ArgumentError, 'name is required' if name.to_s.empty?
32
+
30
33
  tap { objects.each { |o| add(name, o) } }
31
34
  end
32
35
 
33
36
  # Add a lookup record to this instance's lookup dataset.
37
+ # Raises ArgumentError if name is blank.
34
38
  def add(name, object)
39
+ raise ArgumentError, 'name is required' if name.to_s.empty?
40
+
35
41
  tap { mappings_by_name.fetch(name.to_s).add(object) }
36
42
  end
37
43
 
@@ -33,7 +33,7 @@ module HashMath
33
33
 
34
34
  attr_reader :value, :set, :with, :lookup
35
35
 
36
- def_delegators :lookup, :name, :by, :add, :add_each
36
+ def_delegators :lookup, :name, :by
37
37
 
38
38
  # lookup: can either be a Mapper#Lookup instance or a hash with the attributes to initialize
39
39
  # for a Mapper#Lookup instance.
@@ -8,5 +8,5 @@
8
8
  #
9
9
 
10
10
  module HashMath
11
- VERSION = '1.2.0-alpha'
11
+ VERSION = '1.2.0'
12
12
  end
@@ -63,55 +63,77 @@ describe HashMath::Mapper do
63
63
  { patient_id: 2, patient_status: 'doesnt_exist', marital_status: 'no_exist' }
64
64
  end
65
65
 
66
- context 'when nil' do
67
- it 'returns base mapped hash' do
68
- expected = {
69
- patient_status_id: nil,
70
- marital_status_id: nil
71
- }
66
+ describe '#add' do
67
+ it 'raises ArgumentError when name is nil' do
68
+ expect { subject.add(nil, {}) }.to raise_error(ArgumentError)
69
+ end
70
+
71
+ it 'raises ArgumentError when name is empty string' do
72
+ expect { subject.add('', {}) }.to raise_error(ArgumentError)
73
+ end
74
+ end
72
75
 
73
- actual = subject.map(nil)
76
+ describe '#add_each' do
77
+ it 'raises ArgumentError when name is nil' do
78
+ expect { subject.add_each(nil, []) }.to raise_error(ArgumentError)
79
+ end
74
80
 
75
- expect(actual).to eq(expected)
81
+ it 'raises ArgumentError when name is empty string' do
82
+ expect { subject.add_each('', []) }.to raise_error(ArgumentError)
76
83
  end
77
84
  end
78
85
 
79
- context 'when keys are missing' do
80
- it 'returns hash with nil values' do
81
- expected = omitted.merge(
82
- patient_status_id: nil,
83
- marital_status_id: nil
84
- )
86
+ describe '#map' do
87
+ context 'with nil input' do
88
+ it 'returns base mapped hash' do
89
+ expected = {
90
+ patient_status_id: nil,
91
+ marital_status_id: nil
92
+ }
85
93
 
86
- actual = subject.map(omitted)
94
+ actual = subject.map(nil)
87
95
 
88
- expect(actual).to eq(expected)
96
+ expect(actual).to eq(expected)
97
+ end
89
98
  end
90
- end
91
99
 
92
- context 'when keys are present' do
93
- it 'returns hash with values' do
94
- expected = filled.merge(
95
- patient_status_id: 1,
96
- marital_status_id: 1
97
- )
100
+ context 'with missing keys input' do
101
+ it 'returns hash with nil values' do
102
+ expected = omitted.merge(
103
+ patient_status_id: nil,
104
+ marital_status_id: nil
105
+ )
98
106
 
99
- actual = subject.map(filled)
107
+ actual = subject.map(omitted)
100
108
 
101
- expect(actual).to eq(expected)
109
+ expect(actual).to eq(expected)
110
+ end
111
+ end
112
+
113
+ context 'with present keys input' do
114
+ it 'returns hash with values' do
115
+ expected = filled.merge(
116
+ patient_status_id: 1,
117
+ marital_status_id: 1
118
+ )
119
+
120
+ actual = subject.map(filled)
121
+
122
+ expect(actual).to eq(expected)
123
+ end
102
124
  end
103
- end
104
125
 
105
- context 'when keys are present but values are missing' do
106
- it 'returns hash with nil values' do
107
- expected = mismatched.merge(
108
- patient_status_id: nil,
109
- marital_status_id: nil
110
- )
126
+ context 'with present keys input but no values match lookups' do
127
+ it 'returns hash with nil values' do
128
+ expected = mismatched.merge(
129
+ patient_status_id: nil,
130
+ marital_status_id: nil
131
+ )
111
132
 
112
- actual = subject.map(mismatched)
133
+ actual = subject.map(mismatched)
113
134
 
114
- expect(actual).to eq(expected)
135
+ expect(actual).to eq(expected)
136
+ end
115
137
  end
116
138
  end
117
139
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash_math
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0.pre.alpha
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Ruggio
@@ -194,9 +194,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
194
194
  version: '2.5'
195
195
  required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  requirements:
197
- - - ">"
197
+ - - ">="
198
198
  - !ruby/object:Gem::Version
199
- version: 1.3.1
199
+ version: '0'
200
200
  requirements: []
201
201
  rubygems_version: 3.0.3
202
202
  signing_key: