stackone_migration 1.1.1 → 1.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a44d4260363aee391c5c48f3d0f0fe6500181ab834949b6b9a530ba802a50051
4
- data.tar.gz: '0653183cc3817cf604d47fc928c944861481c760bddaf1261c7b11a87017f08c'
3
+ metadata.gz: 3197edeffdaf152df83de7c93ebff0545a858e052b5b93ce71ee94a763e2965c
4
+ data.tar.gz: 3119c44bbf9229ca6251730d591dcd677be5437145e952b0fdf766b480dcb7e4
5
5
  SHA512:
6
- metadata.gz: ed07b461361433768d77c4ba9e88babaf7e5bfcd10c152208e2fe52ca010a6bad342c16f0280b17c1793f356a70f067e012a50d976efa6c3f18146567a7a3b0c
7
- data.tar.gz: 8428afb3002ba02cb8dd52090bf4b1930de55f9d0bfabdee11195b47089f3e38daffcbf19fdf882a3fa4768992ea9b6a2d2f4671b97b1a023815f0fcc14a10ac
6
+ metadata.gz: 67ef8e7855f098123b1e73d9dab35f5d221e64800cdeaceb66aac58123f7b0cd06add2502e68a27e161603be2999e6927b504366fe192b136fb2f8a172bea405
7
+ data.tar.gz: 4fdc3504c3ac5b670803985f365fb888a4922d3d4fe1a37cad0a8e3b782259cbb35a611a16070cdc7ebf77c6574c36f9c577fbb97ea9c95a72cce50d09e573ce
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stackone_migration (1.1.1)
4
+ stackone_migration (1.1.2)
5
5
  merge_hris_client (~> 3.0)
6
6
  stackone_hris_client (~> 1.2.2)
7
7
 
@@ -1,3 +1,5 @@
1
+ require 'json'
2
+
1
3
  module StackOneMigration
2
4
  class EmployeesMapper
3
5
  def self.gender_enum_hash
@@ -108,13 +110,33 @@ module StackOneMigration
108
110
  :hire_date => employee.hire_date,
109
111
  :employment_status => MergeHRISClient::EmploymentStatusEnum.build_from_hash(employment_status_enum_hash[employee.employment_status&.to_sym]),
110
112
  :termination_date => employee.termination_date,
111
- :company => employee.company,
112
- :home_location => employee.home_location,
113
- :work_location => employee.work_location,
113
+ :company => json_str_to_hash(employee.company),
114
+ :home_location => json_str_to_hash(employee.home_location),
115
+ :work_location => json_str_to_hash(employee.work_location),
114
116
  :employments => map_employments(employee.employments),
115
117
  )
116
118
  end
117
119
 
120
+ def self.json_str_to_hash(hash_string)
121
+ begin
122
+ return nil if hash_string.nil?
123
+
124
+ new_str = hash_string
125
+ .gsub(/:(\w+)/, '"\1"')
126
+ .gsub('=>', ':')
127
+ .gsub('nil', 'null')
128
+ .gsub(/'/, '"')
129
+
130
+ hash = JSON.parse(new_str)
131
+
132
+ hash.transform_keys(&:to_sym)
133
+ rescue JSON::ParserError => e
134
+ puts "Error parsing JSON string: #{e.message}"
135
+
136
+ hash_string
137
+ end
138
+ end
139
+
118
140
  def self.map_to_employment_model(employment)
119
141
  return nil if employment.nil?
120
142
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StackOneMigration
4
- VERSION = '1.1.1'
4
+ VERSION = '1.1.2'
5
5
  end
@@ -24,19 +24,19 @@ describe StackOneMigration::EmployeesMapper do
24
24
  :work_phone_number => '(456) 787-3508',
25
25
  :job_title => 'Manager',
26
26
  :department => 'Human Resources',
27
- :home_location => {
27
+ :home_location => "{
28
28
  :phone_number => '(456) 787-3508',
29
29
  :street_1 => '123 Main St',
30
30
  :street_2 => 'Apt 1',
31
31
  :city => 'San Francisco',
32
32
  :state => 'CA',
33
33
  :zip_code => '94105',
34
- :country => 'US',
35
- },
34
+ :country => 'US'
35
+ }",
36
36
  :work_location => nil,
37
- :company => {
38
- display_name: 'StackOne',
39
- },
37
+ :company => "{
38
+ \"display_name\": 'StackOne'
39
+ }",
40
40
  :employments => [
41
41
  {
42
42
  job_title: 'Manager',
@@ -105,7 +105,7 @@ describe StackOneMigration::EmployeesMapper do
105
105
  },
106
106
  :work_location => nil,
107
107
  :company => {
108
- display_name: 'StackOne',
108
+ display_name: 'StackOne',
109
109
  },
110
110
  )
111
111
  expect(target_model.gender).to have_attributes(:value => 'FEMALE')
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.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - StackOne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-05 00:00:00.000000000 Z
11
+ date: 2023-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: merge_hris_client