stackone_migration 1.2.2 → 1.4.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 +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +4 -4
- data/lib/stackone_migration/mappers/employees_mapper.rb +26 -9
- data/lib/stackone_migration/version.rb +1 -1
- data/spec/mappers/employees_mapper_spec.rb +103 -19
- data/stackone_migration.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67a03369917c2e312bf393a5f96d3493d5b6430647fc8f080d3b2a37be59c29a
|
4
|
+
data.tar.gz: ac3404c9425e9a1bddbf0613025bfaa84e1091e6afc5b137dc12f4eaa1cdfd18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 603295af5e304db4088764640a04a6c5d61a5cb0f569d66aec876732b49c659e6054eaa7b870c511d244a244dc7f47b194e8c20440c22cc1bd9e18792c0f59ed
|
7
|
+
data.tar.gz: 1e766c8704c8ab85cdb04607819dced4e65b6516c550c322975bb95de60cd6bc20e7419d013389158466b8353ed1f87f391f180567a87fdfe70839975196dfec
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
stackone_migration (1.
|
4
|
+
stackone_migration (1.4.0)
|
5
5
|
merge_hris_client (~> 3.0)
|
6
|
-
stackone_hris_client (~> 1.
|
6
|
+
stackone_hris_client (~> 1.5.1)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
@@ -58,7 +58,7 @@ GEM
|
|
58
58
|
rubocop-ast (1.27.0)
|
59
59
|
parser (>= 3.2.1.0)
|
60
60
|
ruby-progressbar (1.13.0)
|
61
|
-
stackone_hris_client (1.
|
61
|
+
stackone_hris_client (1.5.1)
|
62
62
|
typhoeus (~> 1.0, >= 1.0.1)
|
63
63
|
typhoeus (1.4.0)
|
64
64
|
ethon (>= 0.9.0)
|
@@ -73,7 +73,7 @@ DEPENDENCIES
|
|
73
73
|
rake (~> 13.0.1)
|
74
74
|
rspec (~> 3.6, >= 3.6.0)
|
75
75
|
rubocop (~> 1.48.0)
|
76
|
-
stackone_hris_client (~> 1.
|
76
|
+
stackone_hris_client (~> 1.5.1)
|
77
77
|
stackone_migration!
|
78
78
|
|
79
79
|
BUNDLED WITH
|
@@ -101,14 +101,14 @@ module StackOneMigration
|
|
101
101
|
:personal_email => employee.personal_email,
|
102
102
|
:work_email => employee.work_email,
|
103
103
|
:mobile_phone_number => employee.personal_phone_number,
|
104
|
-
:gender => MergeHRISClient::GenderEnum.build_from_hash(gender_enum_hash
|
104
|
+
:gender => MergeHRISClient::GenderEnum.build_from_hash(map_enum(gender_enum_hash,employee.gender)),
|
105
105
|
:date_of_birth => employee.date_of_birth,
|
106
106
|
:start_date => employee.start_date,
|
107
107
|
:manager => employee.manager_id,
|
108
|
-
:ethnicity => MergeHRISClient::EthnicityEnum.build_from_hash(ethnicity_enum_hash
|
109
|
-
:marital_status => MergeHRISClient::MaritalStatusEnum.build_from_hash(marital_status_enum_hash
|
108
|
+
:ethnicity => MergeHRISClient::EthnicityEnum.build_from_hash(map_enum(ethnicity_enum_hash, employee.ethnicity)),
|
109
|
+
:marital_status => MergeHRISClient::MaritalStatusEnum.build_from_hash(map_enum(marital_status_enum_hash, employee.marital_status)),
|
110
110
|
:hire_date => employee.hire_date,
|
111
|
-
:employment_status => MergeHRISClient::EmploymentStatusEnum.build_from_hash(employment_status_enum_hash
|
111
|
+
:employment_status => MergeHRISClient::EmploymentStatusEnum.build_from_hash(map_enum(employment_status_enum_hash, employee.employment_status)),
|
112
112
|
:termination_date => employee.termination_date,
|
113
113
|
:home_location => map_to_location_model(employee.home_location),
|
114
114
|
:work_location => map_to_location_model(employee.work_location),
|
@@ -129,8 +129,8 @@ module StackOneMigration
|
|
129
129
|
:city => location.city,
|
130
130
|
:state => location.state,
|
131
131
|
:zip_code => location.zip_code,
|
132
|
-
:country =>
|
133
|
-
:location_type => MergeHRISClient::LocationTypeEnum.build_from_hash(location_type_enum_hash
|
132
|
+
:country => map_country_enum(location.country),
|
133
|
+
:location_type => MergeHRISClient::LocationTypeEnum.build_from_hash(map_enum(location_type_enum_hash, location.location_type)),
|
134
134
|
)
|
135
135
|
end
|
136
136
|
|
@@ -140,11 +140,11 @@ module StackOneMigration
|
|
140
140
|
MergeHRISClient::Employment.new(
|
141
141
|
:job_title => employment.job_title,
|
142
142
|
:pay_rate => employment.pay_rate,
|
143
|
-
:pay_period => MergeHRISClient::PayPeriodEnum.build_from_hash(pay_period_enum_hash
|
144
|
-
:pay_frequency => MergeHRISClient::PayFrequencyEnum.build_from_hash(pay_frequency_enum_hash
|
143
|
+
:pay_period => MergeHRISClient::PayPeriodEnum.build_from_hash(map_enum(pay_period_enum_hash, employment.pay_period)),
|
144
|
+
:pay_frequency => MergeHRISClient::PayFrequencyEnum.build_from_hash(map_enum(pay_frequency_enum_hash, employment.pay_frequency)),
|
145
145
|
:pay_currency => MergeHRISClient::PayCurrencyEnum.build_from_hash(employment.pay_currency&.to_s&.upcase),
|
146
146
|
:effective_date => employment.effective_date,
|
147
|
-
:employment_type => MergeHRISClient::EmploymentTypeEnum.build_from_hash(employment_type_enum_hash
|
147
|
+
:employment_type => MergeHRISClient::EmploymentTypeEnum.build_from_hash(map_enum(employment_type_enum_hash, employment.employment_type)),
|
148
148
|
)
|
149
149
|
end
|
150
150
|
|
@@ -187,5 +187,22 @@ module StackOneMigration
|
|
187
187
|
:previous => nil
|
188
188
|
)
|
189
189
|
end
|
190
|
+
|
191
|
+
def self.map_enum(enum_hash, enum)
|
192
|
+
return nil if enum.nil? || enum.value.nil?
|
193
|
+
|
194
|
+
mapped_enum = enum_hash[enum&.value&.to_sym]
|
195
|
+
return mapped_enum unless mapped_enum.nil? || mapped_enum == 'MERGE_NONSTANDARD_VALUE'
|
196
|
+
|
197
|
+
enum.source_value
|
198
|
+
end
|
199
|
+
|
200
|
+
def self.map_country_enum(enum)
|
201
|
+
return nil if enum.nil? || enum.value.nil?
|
202
|
+
|
203
|
+
enum_value = enum.value != 'unmapped_value' ? enum.value : enum.source_value
|
204
|
+
|
205
|
+
MergeHRISClient::CountryEnum.build_from_hash(enum_value)
|
206
|
+
end
|
190
207
|
end
|
191
208
|
end
|
@@ -14,13 +14,13 @@ describe StackOneMigration::EmployeesMapper do
|
|
14
14
|
:personal_email => 'ija@egje.wf',
|
15
15
|
:work_email => 'kota@efpiphi.kw',
|
16
16
|
:personal_phone_number => '(715) 658-9486',
|
17
|
-
:gender => 'female',
|
17
|
+
:gender => StackOneHRIS::GenderEnum.new(value: 'female', source_value: 'female'),
|
18
18
|
:date_of_birth => '1990-01-01',
|
19
19
|
:start_date => '2018-01-01',
|
20
20
|
:manager_id => '417b5e62-e011-5e69-a906-0aefade9ded1',
|
21
|
-
:ethnicity => 'white',
|
22
|
-
:marital_status => 'married',
|
23
|
-
:employment_status => 'terminated',
|
21
|
+
:ethnicity => StackOneHRIS::EthnicityEnum.new(value: 'white', source_value: 'white'),
|
22
|
+
:marital_status => StackOneHRIS::MaritalStatusEnum.new(value: 'married', source_value: 'married'),
|
23
|
+
:employment_status => StackOneHRIS::EmploymentStatusEnum.new(value: 'terminated', source_value: 'terminated'),
|
24
24
|
:work_phone_number => '(456) 787-3508',
|
25
25
|
:job_title => 'Manager',
|
26
26
|
:department => 'Human Resources',
|
@@ -32,18 +32,19 @@ describe StackOneMigration::EmployeesMapper do
|
|
32
32
|
:city => "San Francisco",
|
33
33
|
:state => "CA",
|
34
34
|
:zip_code => "94105",
|
35
|
-
:country =>
|
35
|
+
:country => StackOneHRIS::CountryCodeEnum.new(value: 'US', source_value: 'United States'),
|
36
|
+
:location_type => StackOneHRIS::LocationTypeEnum.new(value: 'home', source_value: 'home'),
|
36
37
|
),
|
37
38
|
:work_location => nil,
|
38
39
|
:employments => [
|
39
40
|
StackOneHRIS::Employment.new(
|
40
41
|
:job_title => 'Manager',
|
41
42
|
:pay_rate => 100000,
|
42
|
-
:pay_period => 'year',
|
43
|
-
:pay_frequency => 'weekly',
|
43
|
+
:pay_period => StackOneHRIS::PayPeriodEnum.new(value: 'year', source_value: 'year'),
|
44
|
+
:pay_frequency => StackOneHRIS::PayFrequencyEnum.new(value: 'weekly', source_value: 'weekly'),
|
44
45
|
:pay_currency => 'USD',
|
45
46
|
:effective_date => '2018-01-01',
|
46
|
-
:employment_type => 'full_time',
|
47
|
+
:employment_type => StackOneHRIS::EmploymentTypeEnum.new(value: 'full_time', source_value: 'full_time'),
|
47
48
|
)
|
48
49
|
]
|
49
50
|
)
|
@@ -59,7 +60,7 @@ describe StackOneMigration::EmployeesMapper do
|
|
59
60
|
:personal_email => 'ija@egje.wf',
|
60
61
|
:work_email => 'kota@efpiphi.kw',
|
61
62
|
:personal_phone_number => '(715) 658-9486',
|
62
|
-
:gender => 'female',
|
63
|
+
:gender => StackOneHRIS::GenderEnum.new(value: 'female', source_value: 'female'),
|
63
64
|
:date_of_birth => '1990-01-01',
|
64
65
|
:start_date => '2018-01-01',
|
65
66
|
:manager_id => '417b5e62-e011-5e69-a906-0aefade9ded1',
|
@@ -119,7 +120,7 @@ describe StackOneMigration::EmployeesMapper do
|
|
119
120
|
:city => "San Francisco",
|
120
121
|
:state => "CA",
|
121
122
|
:zip_code => "94105",
|
122
|
-
:country =>
|
123
|
+
:country => StackOneHRIS::CountryCodeEnum.new(value: 'US', source_value: 'United States'),
|
123
124
|
)
|
124
125
|
|
125
126
|
target_model = described_class.map_to_location_model(sample_location)
|
@@ -137,8 +138,8 @@ describe StackOneMigration::EmployeesMapper do
|
|
137
138
|
:city => "San Francisco",
|
138
139
|
:state => "CA",
|
139
140
|
:zip_code => "94105",
|
140
|
-
:country =>
|
141
|
-
:location_type => 'home'
|
141
|
+
:country => StackOneHRIS::CountryCodeEnum.new(value: 'US', source_value: 'United States'),
|
142
|
+
:location_type => StackOneHRIS::LocationTypeEnum.new(value: 'home', source_value: 'home'),
|
142
143
|
)
|
143
144
|
|
144
145
|
target_model = described_class.map_to_location_model(sample_location)
|
@@ -152,21 +153,49 @@ describe StackOneMigration::EmployeesMapper do
|
|
152
153
|
expect(target_model.city).to eq("San Francisco")
|
153
154
|
expect(target_model.state).to eq("CA")
|
154
155
|
expect(target_model.zip_code).to eq("94105")
|
155
|
-
expect(target_model.country).to have_attributes(:
|
156
|
+
expect(target_model.country).to have_attributes(:value => 'US')
|
156
157
|
expect(target_model.location_type).to have_attributes(:value => 'HOME')
|
157
158
|
end
|
158
159
|
end
|
159
160
|
|
161
|
+
context '.map_country_enum' do
|
162
|
+
it 'maps a country to correct class' do
|
163
|
+
sample_country = StackOneHRIS::CountryCodeEnum.new(value: 'US', source_value: 'United States')
|
164
|
+
|
165
|
+
target_model = described_class.map_country_enum(sample_country)
|
166
|
+
|
167
|
+
expect(target_model).to be_a(MergeHRISClient::CountryEnum)
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'maps to a country with the right attributes' do
|
171
|
+
sample_country = StackOneHRIS::CountryCodeEnum.new(value: 'US', source_value: 'United States')
|
172
|
+
|
173
|
+
target_model = described_class.map_country_enum(sample_country)
|
174
|
+
|
175
|
+
expect(target_model).to have_attributes(:value => 'US', :raw_value => 'US')
|
176
|
+
end
|
177
|
+
|
178
|
+
context 'when the original enum is an unmapped value' do
|
179
|
+
it 'maps to a country with non standard value' do
|
180
|
+
sample_country = StackOneHRIS::CountryCodeEnum.new(value: 'unmapped_value', source_value: 'United States')
|
181
|
+
|
182
|
+
target_model = described_class.map_country_enum(sample_country)
|
183
|
+
|
184
|
+
expect(target_model).to have_attributes(:value => 'MERGE_NONSTANDARD_VALUE', :raw_value => 'United States')
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
160
189
|
context '.map_to_employment_model' do
|
161
190
|
it 'maps a employeement to correct class' do
|
162
191
|
sample_employment = StackOneHRIS::Employment.new(
|
163
192
|
:job_title => 'Manager',
|
164
193
|
:pay_rate => 100000,
|
165
|
-
:pay_period => 'year',
|
166
|
-
:pay_frequency => 'weekly',
|
194
|
+
:pay_period => StackOneHRIS::PayPeriodEnum.new(value: 'year', source_value: 'year'),
|
195
|
+
:pay_frequency => StackOneHRIS::PayFrequencyEnum.new(value: 'weekly', source_value: 'weekly'),
|
167
196
|
:pay_currency => 'USD',
|
168
197
|
:effective_date => '2018-01-01',
|
169
|
-
:employment_type => 'full_time',
|
198
|
+
:employment_type => StackOneHRIS::EmploymentTypeEnum.new(value: 'full_time', source_value: 'full_time'),
|
170
199
|
)
|
171
200
|
|
172
201
|
target_model = described_class.map_to_employment_model(sample_employment)
|
@@ -178,11 +207,11 @@ describe StackOneMigration::EmployeesMapper do
|
|
178
207
|
sample_employment = StackOneHRIS::Employment.new(
|
179
208
|
:job_title => 'Manager',
|
180
209
|
:pay_rate => 100000,
|
181
|
-
:pay_period => 'year',
|
182
|
-
:pay_frequency => 'weekly',
|
210
|
+
:pay_period => StackOneHRIS::PayPeriodEnum.new(value: 'year', source_value: 'year'),
|
211
|
+
:pay_frequency => StackOneHRIS::PayFrequencyEnum.new(value: 'weekly', source_value: 'weekly'),
|
183
212
|
:pay_currency => 'USD',
|
184
213
|
:effective_date => '2018-01-01',
|
185
|
-
:employment_type => 'full_time',
|
214
|
+
:employment_type => StackOneHRIS::EmploymentTypeEnum.new(value: 'full_time', source_value: 'full_time'),
|
186
215
|
)
|
187
216
|
|
188
217
|
target_model = described_class.map_to_employment_model(sample_employment)
|
@@ -266,4 +295,59 @@ describe StackOneMigration::EmployeesMapper do
|
|
266
295
|
end
|
267
296
|
end
|
268
297
|
end
|
298
|
+
|
299
|
+
context '.map_enum' do
|
300
|
+
it 'returns the mapped enum' do
|
301
|
+
target_value = described_class.map_enum(
|
302
|
+
described_class.pay_period_enum_hash,
|
303
|
+
StackOneHRIS::PayPeriodEnum.new(value: 'year', source_value: 'year')
|
304
|
+
)
|
305
|
+
|
306
|
+
expect(target_value).to eq('YEAR')
|
307
|
+
end
|
308
|
+
|
309
|
+
context 'when the enum is nil' do
|
310
|
+
it 'returns nil' do
|
311
|
+
target_value = described_class.map_enum(
|
312
|
+
described_class.pay_period_enum_hash,
|
313
|
+
nil
|
314
|
+
)
|
315
|
+
|
316
|
+
expect(target_value).to be_nil
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
context 'when the enum value is nil' do
|
321
|
+
it 'returns nil' do
|
322
|
+
target_value = described_class.map_enum(
|
323
|
+
described_class.pay_period_enum_hash,
|
324
|
+
StackOneHRIS::PayPeriodEnum.new(value: nil, source_value: 'year')
|
325
|
+
)
|
326
|
+
|
327
|
+
expect(target_value).to be_nil
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
context 'when the enum value is an unmapped value' do
|
332
|
+
it 'returns the source value' do
|
333
|
+
target_value = described_class.map_enum(
|
334
|
+
described_class.pay_period_enum_hash,
|
335
|
+
StackOneHRIS::PayPeriodEnum.new(value: 'unmapped_value', source_value: 'year_custom_value')
|
336
|
+
)
|
337
|
+
|
338
|
+
expect(target_value).to eq('year_custom_value')
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
context 'when the enum value maps to a MERGE_NONSTANDARD_VALUE' do
|
343
|
+
it 'returns the mapped enum' do
|
344
|
+
target_value = described_class.map_enum(
|
345
|
+
described_class.marital_status_enum_hash,
|
346
|
+
StackOneHRIS::MaritalStatusEnum.new(value: 'other', source_value: 'other_status')
|
347
|
+
)
|
348
|
+
|
349
|
+
expect(target_value).to eq('other_status')
|
350
|
+
end
|
351
|
+
end
|
352
|
+
end
|
269
353
|
end
|
data/stackone_migration.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.required_ruby_version = '>= 2.7'
|
17
17
|
|
18
18
|
s.add_runtime_dependency 'merge_hris_client', '~> 3.0'
|
19
|
-
s.add_runtime_dependency 'stackone_hris_client', '~> 1.
|
19
|
+
s.add_runtime_dependency 'stackone_hris_client', '~> 1.5.1'
|
20
20
|
|
21
21
|
s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
|
22
22
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stackone_migration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- StackOne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: merge_hris_client
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.5.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
40
|
+
version: 1.5.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|