stackone_migration 1.1.0 → 1.1.1
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 +115 -5
- data/lib/stackone_migration/version.rb +1 -1
- data/spec/mappers/employees_mapper_spec.rb +48 -108
- 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: a44d4260363aee391c5c48f3d0f0fe6500181ab834949b6b9a530ba802a50051
|
4
|
+
data.tar.gz: '0653183cc3817cf604d47fc928c944861481c760bddaf1261c7b11a87017f08c'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed07b461361433768d77c4ba9e88babaf7e5bfcd10c152208e2fe52ca010a6bad342c16f0280b17c1793f356a70f067e012a50d976efa6c3f18146567a7a3b0c
|
7
|
+
data.tar.gz: 8428afb3002ba02cb8dd52090bf4b1930de55f9d0bfabdee11195b47089f3e38daffcbf19fdf882a3fa4768992ea9b6a2d2f4671b97b1a023815f0fcc14a10ac
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
stackone_migration (1.1.
|
4
|
+
stackone_migration (1.1.1)
|
5
5
|
merge_hris_client (~> 3.0)
|
6
|
-
stackone_hris_client (~> 1.2.
|
6
|
+
stackone_hris_client (~> 1.2.2)
|
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.2.
|
61
|
+
stackone_hris_client (1.2.2)
|
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.2.
|
76
|
+
stackone_hris_client (~> 1.2.2)
|
77
77
|
stackone_migration!
|
78
78
|
|
79
79
|
BUNDLED WITH
|
@@ -1,5 +1,91 @@
|
|
1
1
|
module StackOneMigration
|
2
2
|
class EmployeesMapper
|
3
|
+
def self.gender_enum_hash
|
4
|
+
{
|
5
|
+
:male => 'MALE',
|
6
|
+
:female => 'FEMALE',
|
7
|
+
:non_binary => 'NON-BINARY',
|
8
|
+
:other => 'OTHER',
|
9
|
+
:not_disclosed => 'PREFER_NOT_TO_DISCLOSE',
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.marital_status_enum_hash
|
14
|
+
{
|
15
|
+
:single => 'SINGLE',
|
16
|
+
:married => 'MARRIED_FILING_JOINTLY',
|
17
|
+
:divorced => 'MERGE_NONSTANDARD_VALUE',
|
18
|
+
:widowed => 'QUALIFYING_WIDOW_OR_WIDOWER_WITH_DEPENDENT_CHILD',
|
19
|
+
:domestic_partnership => 'MERGE_NONSTANDARD_VALUE',
|
20
|
+
:other => 'MERGE_NONSTANDARD_VALUE',
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.ethnicity_enum_hash
|
25
|
+
{
|
26
|
+
:white => 'WHITE',
|
27
|
+
:black_or_african_american => 'BLACK_OR_AFRICAN_AMERICAN',
|
28
|
+
:asian => 'ASIAN_OR_INDIAN_SUBCONTINENT',
|
29
|
+
:hispanic_or_latino => 'HISPANIC_OR_LATINO',
|
30
|
+
:american_indian_or_alaska_native => 'AMERICAN_INDIAN_OR_ALASKA_NATIVE',
|
31
|
+
:native_hawaiian_or_pacific_islander => 'NATIVE_HAWAIIAN_OR_OTHER_PACIFIC_ISLANDER',
|
32
|
+
:two_or_more_races => 'TWO_OR_MORE_RACES',
|
33
|
+
:not_disclosed => 'PREFER_NOT_TO_DISCLOSE',
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.employment_status_enum_hash
|
38
|
+
{
|
39
|
+
:active => 'ACTIVE',
|
40
|
+
:pending => 'PENDING',
|
41
|
+
:terminated => 'INACTIVE',
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.employment_type_enum_hash
|
46
|
+
{
|
47
|
+
:full_time => 'FULL_TIME',
|
48
|
+
:part_time => 'PART_TIME',
|
49
|
+
:contractor => 'CONTRACTOR',
|
50
|
+
:intern => 'INTERN',
|
51
|
+
:freelance => 'FREELANCE',
|
52
|
+
:terminated => 'MERGE_NONSTANDARD_VALUE',
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.pay_period_enum_hash
|
57
|
+
{
|
58
|
+
:hour => 'HOUR',
|
59
|
+
:day => 'DAY',
|
60
|
+
:week => 'WEEK',
|
61
|
+
:every_two_weeks => 'EVERY_TWO_WEEKS',
|
62
|
+
:month => 'MONTH',
|
63
|
+
:quarter => 'QUARTER',
|
64
|
+
:every_six_months => 'EVERY_SIX_MONTHS',
|
65
|
+
:year => 'YEAR',
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.pay_frequency_enum_hash
|
70
|
+
{
|
71
|
+
:weekly => 'WEEKLY',
|
72
|
+
:bi_weekly => 'BIWEEKLY',
|
73
|
+
:monthly => 'MONTHLY',
|
74
|
+
:quarterly => 'QUARTERLY',
|
75
|
+
:semi_annually => 'SEMIANNUALLY',
|
76
|
+
:yearly => 'ANNUALLY',
|
77
|
+
:thirteen_monthly => 'THIRTEEN-MONTHLY',
|
78
|
+
:pro_rata => 'PRO_RATA',
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.location_type_enum_hash
|
83
|
+
{
|
84
|
+
:home => 'HOME',
|
85
|
+
:work => 'WORK',
|
86
|
+
}
|
87
|
+
end
|
88
|
+
|
3
89
|
def self.map_to_employee_model(employee)
|
4
90
|
return nil if employee.nil?
|
5
91
|
|
@@ -13,22 +99,46 @@ module StackOneMigration
|
|
13
99
|
:personal_email => employee.personal_email,
|
14
100
|
:work_email => employee.work_email,
|
15
101
|
:mobile_phone_number => employee.personal_phone_number,
|
16
|
-
:gender => employee.gender,
|
102
|
+
:gender => MergeHRISClient::GenderEnum.build_from_hash(gender_enum_hash[employee.gender&.to_sym]),
|
17
103
|
:date_of_birth => employee.date_of_birth,
|
18
104
|
:start_date => employee.start_date,
|
19
105
|
:manager => employee.manager_id,
|
20
|
-
:ethnicity => employee.ethnicity,
|
21
|
-
:marital_status => employee.marital_status,
|
106
|
+
:ethnicity => MergeHRISClient::EthnicityEnum.build_from_hash(ethnicity_enum_hash[employee.ethnicity&.to_sym]),
|
107
|
+
:marital_status => MergeHRISClient::MaritalStatusEnum.build_from_hash(marital_status_enum_hash[employee.marital_status&.to_sym]),
|
22
108
|
:hire_date => employee.hire_date,
|
23
|
-
:employment_status => employee.employment_status,
|
109
|
+
:employment_status => MergeHRISClient::EmploymentStatusEnum.build_from_hash(employment_status_enum_hash[employee.employment_status&.to_sym]),
|
24
110
|
:termination_date => employee.termination_date,
|
25
111
|
:company => employee.company,
|
26
112
|
:home_location => employee.home_location,
|
27
113
|
:work_location => employee.work_location,
|
28
|
-
:employments => employee.employments,
|
114
|
+
:employments => map_employments(employee.employments),
|
115
|
+
)
|
116
|
+
end
|
117
|
+
|
118
|
+
def self.map_to_employment_model(employment)
|
119
|
+
return nil if employment.nil?
|
120
|
+
|
121
|
+
MergeHRISClient::Employment.new(
|
122
|
+
:job_title => employment[:job_title],
|
123
|
+
:pay_rate => employment[:pay_rate],
|
124
|
+
:pay_period => MergeHRISClient::PayPeriodEnum.build_from_hash(pay_period_enum_hash[employment[:pay_period]&.to_sym]),
|
125
|
+
:pay_frequency => MergeHRISClient::PayFrequencyEnum.build_from_hash(pay_frequency_enum_hash[employment[:pay_frequency]&.to_sym]),
|
126
|
+
:pay_currency => MergeHRISClient::PayCurrencyEnum.build_from_hash(employment[:pay_currency]&.to_s.upcase),
|
127
|
+
:effective_date => employment[:effective_date],
|
128
|
+
:employment_type => MergeHRISClient::EmploymentTypeEnum.build_from_hash(employment_type_enum_hash[employment[:employment_type]&.to_sym]),
|
29
129
|
)
|
30
130
|
end
|
31
131
|
|
132
|
+
def self.map_employments(employments)
|
133
|
+
if employments.nil?
|
134
|
+
mapped_results = []
|
135
|
+
else
|
136
|
+
mapped_results = employments.map do |employment|
|
137
|
+
map_to_employment_model(employment)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
32
142
|
def self.map_single_employee_to_list_model(employee)
|
33
143
|
mapped_employee = map_to_employee_model(employee)
|
34
144
|
|
@@ -18,6 +18,9 @@ describe StackOneMigration::EmployeesMapper do
|
|
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
24
|
:work_phone_number => '(456) 787-3508',
|
22
25
|
:job_title => 'Manager',
|
23
26
|
:department => 'Human Resources',
|
@@ -88,7 +91,6 @@ describe StackOneMigration::EmployeesMapper do
|
|
88
91
|
:personal_email => 'ija@egje.wf',
|
89
92
|
:work_email => 'kota@efpiphi.kw',
|
90
93
|
:mobile_phone_number => '(715) 658-9486',
|
91
|
-
:gender => 'female',
|
92
94
|
:date_of_birth => '1990-01-01',
|
93
95
|
:start_date => '2018-01-01',
|
94
96
|
:manager => '417b5e62-e011-5e69-a906-0aefade9ded1',
|
@@ -105,26 +107,59 @@ describe StackOneMigration::EmployeesMapper do
|
|
105
107
|
:company => {
|
106
108
|
display_name: 'StackOne',
|
107
109
|
},
|
108
|
-
|
109
|
-
|
110
|
+
)
|
111
|
+
expect(target_model.gender).to have_attributes(:value => 'FEMALE')
|
112
|
+
expect(target_model.ethnicity).to have_attributes(:value => 'WHITE')
|
113
|
+
expect(target_model.marital_status).to have_attributes(:value => 'MARRIED_FILING_JOINTLY')
|
114
|
+
expect(target_model.employment_status).to have_attributes(:value => 'INACTIVE')
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'when the employee record to map is nil' do
|
118
|
+
it 'returns nil' do
|
119
|
+
target_model = described_class.map_to_employee_model(nil)
|
120
|
+
|
121
|
+
expect(target_model).to be_nil
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
context '.map_to_employment_model' do
|
127
|
+
it 'maps a employeement hash to correct class' do
|
128
|
+
sample_employment = {
|
110
129
|
job_title: 'Manager',
|
111
130
|
pay_rate: 100000,
|
112
131
|
pay_period: 'yearly',
|
113
132
|
pay_frequency: 'weekly',
|
114
133
|
pay_currency: 'USD',
|
115
134
|
effective_date: '2018-01-01',
|
116
|
-
|
135
|
+
employment_type: 'full_time',
|
117
136
|
}
|
118
|
-
|
119
|
-
)
|
137
|
+
|
138
|
+
target_model = described_class.map_to_employment_model(sample_employment)
|
139
|
+
|
140
|
+
expect(target_model).to be_a(MergeHRISClient::Employment)
|
120
141
|
end
|
121
142
|
|
122
|
-
|
123
|
-
|
124
|
-
|
143
|
+
it 'maps a employeement hash with the right attributes' do
|
144
|
+
sample_employment = {
|
145
|
+
job_title: 'Manager',
|
146
|
+
pay_rate: 100000,
|
147
|
+
pay_period: 'year',
|
148
|
+
pay_frequency: 'weekly',
|
149
|
+
pay_currency: 'usd',
|
150
|
+
effective_date: '2018-01-01',
|
151
|
+
employment_type: 'full_time',
|
152
|
+
}
|
125
153
|
|
126
|
-
|
127
|
-
|
154
|
+
target_model = described_class.map_to_employment_model(sample_employment)
|
155
|
+
|
156
|
+
expect(target_model.job_title).to eq('Manager')
|
157
|
+
expect(target_model.pay_rate).to eq(100000)
|
158
|
+
expect(target_model.pay_period).to have_attributes(:value => 'YEAR')
|
159
|
+
expect(target_model.pay_frequency).to have_attributes(:value => 'WEEKLY')
|
160
|
+
expect(target_model.pay_currency).to have_attributes(:value => 'USD')
|
161
|
+
expect(target_model.effective_date).to eq('2018-01-01')
|
162
|
+
expect(target_model.employment_type).to have_attributes(:value => 'FULL_TIME')
|
128
163
|
end
|
129
164
|
end
|
130
165
|
|
@@ -140,48 +175,8 @@ describe StackOneMigration::EmployeesMapper do
|
|
140
175
|
|
141
176
|
expect(target_model).to have_attributes(
|
142
177
|
:_next => nil,
|
143
|
-
:results => [
|
144
|
-
MergeHRISClient::Employee.new(
|
145
|
-
:id => '123',
|
146
|
-
:remote_id => '123',
|
147
|
-
:first_name => 'Jean',
|
148
|
-
:last_name => 'Harrington',
|
149
|
-
:display_full_name => 'Jean Harrington',
|
150
|
-
:avatar => 'https://www.gravatar.com/avatar/0c1c0c1c0c1c0c1c0c1c0c1c0c1c0c1c?d=mm&s=200',
|
151
|
-
:personal_email => 'ija@egje.wf',
|
152
|
-
:work_email => 'kota@efpiphi.kw',
|
153
|
-
:mobile_phone_number => '(715) 658-9486',
|
154
|
-
:gender => 'female',
|
155
|
-
:date_of_birth => '1990-01-01',
|
156
|
-
:start_date => '2018-01-01',
|
157
|
-
:manager => '417b5e62-e011-5e69-a906-0aefade9ded1',
|
158
|
-
:home_location => {
|
159
|
-
phone_number: '(456) 787-3508',
|
160
|
-
street_1: '123 Main St',
|
161
|
-
street_2: 'Apt 1',
|
162
|
-
city: 'San Francisco',
|
163
|
-
state: 'CA',
|
164
|
-
zip_code: '94105',
|
165
|
-
country: 'US',
|
166
|
-
},
|
167
|
-
:work_location => nil,
|
168
|
-
:company => {
|
169
|
-
display_name: 'StackOne',
|
170
|
-
},
|
171
|
-
:employments => [
|
172
|
-
{
|
173
|
-
job_title: 'Manager',
|
174
|
-
pay_rate: 100000,
|
175
|
-
pay_period: 'yearly',
|
176
|
-
pay_frequency: 'weekly',
|
177
|
-
pay_currency: 'USD',
|
178
|
-
effective_date: '2018-01-01',
|
179
|
-
employee_type: 'full_time',
|
180
|
-
}
|
181
|
-
]
|
182
|
-
)
|
183
|
-
],
|
184
178
|
:previous => nil)
|
179
|
+
expect(target_model).to include(:results)
|
185
180
|
end
|
186
181
|
|
187
182
|
context 'when the single employee record to map is nil' do
|
@@ -221,64 +216,9 @@ describe StackOneMigration::EmployeesMapper do
|
|
221
216
|
|
222
217
|
expect(target_model).to have_attributes(
|
223
218
|
:_next => 'next_page_token',
|
224
|
-
:results => [
|
225
|
-
MergeHRISClient::Employee.new(
|
226
|
-
:id => '123',
|
227
|
-
:remote_id => '123',
|
228
|
-
:first_name => 'Jean',
|
229
|
-
:last_name => 'Harrington',
|
230
|
-
:display_full_name => 'Jean Harrington',
|
231
|
-
:avatar => 'https://www.gravatar.com/avatar/0c1c0c1c0c1c0c1c0c1c0c1c0c1c0c1c?d=mm&s=200',
|
232
|
-
:personal_email => 'ija@egje.wf',
|
233
|
-
:work_email => 'kota@efpiphi.kw',
|
234
|
-
:mobile_phone_number => '(715) 658-9486',
|
235
|
-
:gender => 'female',
|
236
|
-
:date_of_birth => '1990-01-01',
|
237
|
-
:start_date => '2018-01-01',
|
238
|
-
:manager => '417b5e62-e011-5e69-a906-0aefade9ded1',
|
239
|
-
:home_location => {
|
240
|
-
phone_number: '(456) 787-3508',
|
241
|
-
street_1: '123 Main St',
|
242
|
-
street_2: 'Apt 1',
|
243
|
-
city: 'San Francisco',
|
244
|
-
state: 'CA',
|
245
|
-
zip_code: '94105',
|
246
|
-
country: 'US',
|
247
|
-
},
|
248
|
-
:work_location => nil,
|
249
|
-
:company => {
|
250
|
-
display_name: 'StackOne',
|
251
|
-
},
|
252
|
-
:employments => [
|
253
|
-
{
|
254
|
-
job_title: 'Manager',
|
255
|
-
pay_rate: 100000,
|
256
|
-
pay_period: 'yearly',
|
257
|
-
pay_frequency: 'weekly',
|
258
|
-
pay_currency: 'USD',
|
259
|
-
effective_date: '2018-01-01',
|
260
|
-
employee_type: 'full_time',
|
261
|
-
}
|
262
|
-
]
|
263
|
-
),
|
264
|
-
MergeHRISClient::Employee.new(
|
265
|
-
:id => '456',
|
266
|
-
:remote_id => '456',
|
267
|
-
:first_name => 'Allie',
|
268
|
-
:last_name => 'Shaw',
|
269
|
-
:display_full_name => 'Allie Shaw',
|
270
|
-
:avatar => 'https://www.gravatar.com/avatar/0c1c0c1c0c1c0c1c0c1c0c1c0c1c0c1c?d=mm&s=200',
|
271
|
-
:personal_email => 'ija@egje.wf',
|
272
|
-
:work_email => 'kota@efpiphi.kw',
|
273
|
-
:mobile_phone_number => '(715) 658-9486',
|
274
|
-
:gender => 'female',
|
275
|
-
:date_of_birth => '1990-01-01',
|
276
|
-
:start_date => '2018-01-01',
|
277
|
-
:manager => '417b5e62-e011-5e69-a906-0aefade9ded1',
|
278
|
-
)
|
279
|
-
],
|
280
219
|
:previous => nil
|
281
220
|
)
|
221
|
+
expect(target_model.results.length).to eq(2)
|
282
222
|
end
|
283
223
|
|
284
224
|
context 'when the employee list to map is nil' do
|
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.2.
|
19
|
+
s.add_runtime_dependency 'stackone_hris_client', '~> 1.2.2'
|
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.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- StackOne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-05 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.2.
|
33
|
+
version: 1.2.2
|
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.2.
|
40
|
+
version: 1.2.2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|