go_import 3.0.28 → 3.0.29
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 +8 -8
- data/lib/go_import/errors.rb +3 -0
- data/lib/go_import/model/rootmodel.rb +87 -123
- data/lib/go_import/serialize_helper.rb +4 -0
- data/sources/excel/.go_import/runner.rb +6 -5
- data/sources/excel/Gemfile +2 -1
- data/sources/excel-basic/Gemfile +1 -1
- data/sources/lime-easy/converter.rb +2 -2
- data/sources/lime-pro-basic/.go_import/runner.rb +1 -1
- data/sources/salesforce/Gemfile.lock +48 -48
- data/spec/helpers/serialize_helper_spec.rb +1 -0
- data/spec/helpers/xsd_validate_spec.rb +8 -6
- data/spec/rootmodel_spec.rb +165 -141
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Njc2YjFkNDUzNDc3NWY1YWI1MDY1MmJmMzQ4NTY5M2YzNjRiYmY2ZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTVlNjU2N2U5MjA5YWJhNDhjMTM0MGVkMzljYzU5YzZhYjZmMjc0ZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NTcxZDE0OTFhYjA2MzI4MzkyMzYxMWU2NWUzOTg1OTIwYTQxMWEzOWM0MDdh
|
10
|
+
MDRkMWQyMzVmNmE1ZjFlZWFkYjMyMGE1OGYxNTQ4ZjM1NjZlNzliMWRmMGE1
|
11
|
+
MzAzYzE3ODJlOTdmODFiMGQxZWIwNGE5ZGQzZWUyN2M4NTRhMjU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzBkMTEyZjMyMjA1M2Q4YzBiODZmZWY4NDc1OWJkYzYyMTAzODBjYmRhNzNj
|
14
|
+
YzYwZjc2NTA0MDFhOWM0MzA2NmQwNDA1NjRiZDdkODBhYTRlNTc0Zjg5ZWJk
|
15
|
+
NWMwNzQwN2JhMzkzZGI2MmU5NDFjMTNjNmU2ZTA0MjYyYzU3NDY=
|
data/lib/go_import/errors.rb
CHANGED
@@ -34,26 +34,19 @@ module GoImport
|
|
34
34
|
|
35
35
|
def initialize()
|
36
36
|
@settings = Settings.new
|
37
|
-
@organizations =
|
38
|
-
@coworkers =
|
37
|
+
@organizations = {}
|
38
|
+
@coworkers = {}
|
39
39
|
@import_coworker = Coworker.new
|
40
40
|
@import_coworker.integration_id = "import"
|
41
41
|
@import_coworker.first_name = "Import"
|
42
|
-
@coworkers.
|
43
|
-
@deals =
|
44
|
-
@notes =
|
42
|
+
@coworkers[@import_coworker.integration_id] = @import_coworker
|
43
|
+
@deals = {}
|
44
|
+
@notes = {}
|
45
45
|
@documents = Documents.new
|
46
46
|
end
|
47
47
|
|
48
48
|
# Adds the specifed coworker object to the model.
|
49
|
-
|
50
|
-
# rootmodel.add_coworker({
|
51
|
-
# :integration_id=>"123",
|
52
|
-
# :first_name=>"Kalle",
|
53
|
-
# :last_name=>"Anka",
|
54
|
-
# :email=>"kalle.anka@vonanka.com"
|
55
|
-
# })
|
56
|
-
#
|
49
|
+
|
57
50
|
# @example Add a coworker from a new coworker
|
58
51
|
# coworker = GoImport::Coworker.new
|
59
52
|
# coworker.integration_id = "123"
|
@@ -61,106 +54,76 @@ module GoImport
|
|
61
54
|
# coworker.last_name="Anka"
|
62
55
|
# coworker.email = "kalle.anka@vonanka.com"
|
63
56
|
# rootmodel.add_coworker(coworker)
|
64
|
-
#
|
65
|
-
# @example If you want to keep adding coworkers and dont care about duplicates not being added
|
66
|
-
# begin
|
67
|
-
# rootmodel.add_coworker(coworker)
|
68
|
-
# rescue GoImport::AlreadyAddedError
|
69
|
-
# puts "Warning: already added coworker"
|
70
|
-
# end
|
71
|
-
# @see Coworker
|
72
57
|
def add_coworker(coworker)
|
73
|
-
@coworkers = [] if @coworkers == nil
|
74
|
-
|
75
58
|
if coworker.nil?
|
76
59
|
return nil
|
77
60
|
end
|
78
61
|
|
79
|
-
|
62
|
+
if !coworker.is_a?(Coworker)
|
63
|
+
raise ArgumentError.new("Expected a coworker")
|
64
|
+
end
|
65
|
+
|
66
|
+
if coworker.integration_id.nil? || coworker.integration_id.length == 0
|
67
|
+
raise IntegrationIdIsRequiredError, "An integration id is required for a coworker."
|
68
|
+
end
|
80
69
|
|
81
70
|
if find_coworker_by_integration_id(coworker.integration_id) != nil
|
82
71
|
raise AlreadyAddedError, "Already added a coworker with integration_id #{coworker.integration_id}"
|
83
72
|
end
|
84
73
|
|
85
|
-
@coworkers.
|
74
|
+
@coworkers[coworker.integration_id] = coworker
|
86
75
|
|
87
76
|
return coworker
|
88
77
|
end
|
89
78
|
|
90
79
|
# Adds the specifed organization object to the model.
|
91
|
-
# @example Add an organization from a hash
|
92
|
-
# rootmodel.add_organization({
|
93
|
-
# :integration_id => "123",
|
94
|
-
# :name => "Beagle Boys",
|
95
|
-
# })
|
96
|
-
#
|
97
80
|
# @example Add an organization from a new organization
|
98
81
|
# organization = GoImport::Organization.new
|
99
82
|
# organization.integration_id = "123"
|
100
83
|
# organization.name = "Beagle Boys"
|
101
84
|
# rootmodel.add_organization(organization)
|
102
|
-
#
|
103
|
-
# @example If you want to keep adding organizations and dont
|
104
|
-
# care about duplicates not being added. Your model might not
|
105
|
-
# be saved due to duplicate integration_ids.
|
106
|
-
# begin
|
107
|
-
# rootmodel.add_organization(organization)
|
108
|
-
# rescue GoImport::AlreadyAddedError
|
109
|
-
# puts "Warning: already added organization"
|
110
|
-
# end
|
111
|
-
# @see Coworker
|
112
85
|
def add_organization(organization)
|
113
|
-
@organizations = [] if @organizations.nil?
|
114
|
-
|
115
86
|
if organization.nil?
|
116
87
|
return nil
|
117
88
|
end
|
118
89
|
|
119
|
-
|
90
|
+
if !organization.is_a?(Organization)
|
91
|
+
raise ArgumentError.new("Expected an organization")
|
92
|
+
end
|
93
|
+
|
94
|
+
if organization.integration_id.nil? || organization.integration_id.length == 0
|
95
|
+
raise IntegrationIdIsRequiredError, "An integration id is required for an organization."
|
96
|
+
end
|
120
97
|
|
121
|
-
if (
|
122
|
-
find_organization_by_integration_id(organization.integration_id) != nil
|
98
|
+
if find_organization_by_integration_id(organization.integration_id) != nil
|
123
99
|
raise AlreadyAddedError, "Already added an organization with integration_id #{organization.integration_id}"
|
124
100
|
end
|
125
101
|
|
126
|
-
@organizations.
|
102
|
+
@organizations[organization.integration_id] = organization
|
127
103
|
|
128
104
|
return organization
|
129
105
|
end
|
130
106
|
|
131
107
|
# Adds the specifed deal object to the model.
|
132
|
-
# @example Add an deal from a hash
|
133
|
-
# rootmodel.add_deal({
|
134
|
-
# :integration_id => "123",
|
135
|
-
# :name => "Big deal",
|
136
|
-
# })
|
137
|
-
#
|
138
108
|
# @example Add a deal from a new deal
|
139
109
|
# deal = GoImport::Deal.new
|
140
110
|
# deal.integration_id = "123"
|
141
111
|
# deal.name = "Big deal"
|
142
112
|
# rootmodel.add_deal(deal)
|
143
|
-
#
|
144
|
-
# @example If you want to keep adding deals and dont
|
145
|
-
# care about duplicates not being added. Your model might not
|
146
|
-
# be saved due to duplicate integration_ids.
|
147
|
-
# begin
|
148
|
-
# rootmodel.add_deal(deal)
|
149
|
-
# rescue GoImport::AlreadyAddedError
|
150
|
-
# puts "Warning: already added deal"
|
151
|
-
# end
|
152
|
-
# @see Coworker
|
153
113
|
def add_deal(deal)
|
154
|
-
@deals = [] if @deals.nil?
|
155
|
-
|
156
114
|
if deal.nil?
|
157
115
|
return nil
|
158
116
|
end
|
159
117
|
|
160
|
-
|
118
|
+
if !deal.is_a?(Deal)
|
119
|
+
raise ArgumentError.new("Expected a deal")
|
120
|
+
end
|
121
|
+
|
122
|
+
if deal.integration_id.nil? || deal.integration_id.length == 0
|
123
|
+
raise IntegrationIdIsRequiredError, "An integration id is required for a deal."
|
124
|
+
end
|
161
125
|
|
162
|
-
if (
|
163
|
-
find_deal_by_integration_id(deal.integration_id) != nil
|
126
|
+
if find_deal_by_integration_id(deal.integration_id) != nil
|
164
127
|
raise AlreadyAddedError, "Already added a deal with integration_id #{deal.integration_id}"
|
165
128
|
end
|
166
129
|
|
@@ -168,44 +131,35 @@ module GoImport
|
|
168
131
|
deal.responsible_coworker = @import_coworker
|
169
132
|
end
|
170
133
|
|
171
|
-
@deals.
|
134
|
+
@deals[deal.integration_id] = deal
|
172
135
|
|
173
136
|
return deal
|
174
137
|
end
|
175
138
|
|
176
139
|
# Adds the specifed note object to the model.
|
177
|
-
#
|
178
|
-
#
|
179
|
-
#
|
180
|
-
# :text => "This is a note",
|
181
|
-
# })
|
140
|
+
#
|
141
|
+
# If no integration_id has been specifed go-import will use a
|
142
|
+
# GUID as integration_id.
|
182
143
|
#
|
183
144
|
# @example Add a note from a new note
|
184
145
|
# note = GoImport::Note.new
|
185
146
|
# note.integration_id = "123"
|
186
|
-
# note.text = "
|
147
|
+
# note.text = "This is a note"
|
187
148
|
# rootmodel.add_note(note)
|
188
|
-
#
|
189
|
-
# @example If you want to keep adding deals and dont
|
190
|
-
# care about duplicates not being added. Your model might not
|
191
|
-
# be saved due to duplicate integration_ids.
|
192
|
-
# begin
|
193
|
-
# rootmodel.add_deal(deal)
|
194
|
-
# rescue GoImport::AlreadyAddedError
|
195
|
-
# puts "Warning: already added deal"
|
196
|
-
# end
|
197
|
-
# @see Coworker
|
198
149
|
def add_note(note)
|
199
|
-
@notes = [] if @notes == nil
|
200
|
-
|
201
150
|
if note.nil?
|
202
151
|
return nil
|
203
|
-
|
152
|
+
end
|
204
153
|
|
205
|
-
|
154
|
+
if !note.is_a?(Note)
|
155
|
+
raise ArgumentError.new("Expected a note")
|
156
|
+
end
|
206
157
|
|
207
|
-
if
|
208
|
-
|
158
|
+
if note.integration_id.nil? || note.integration_id.length == 0
|
159
|
+
note.integration_id = SecureRandom.uuid
|
160
|
+
end
|
161
|
+
|
162
|
+
if find_note_by_integration_id(note.integration_id) != nil
|
209
163
|
raise AlreadyAddedError, "Already added a note with integration_id #{note.integration_id}"
|
210
164
|
end
|
211
165
|
|
@@ -213,7 +167,7 @@ module GoImport
|
|
213
167
|
note.created_by = @import_coworker
|
214
168
|
end
|
215
169
|
|
216
|
-
@notes.
|
170
|
+
@notes[note.integration_id] = note
|
217
171
|
|
218
172
|
return note
|
219
173
|
end
|
@@ -231,28 +185,35 @@ module GoImport
|
|
231
185
|
end
|
232
186
|
|
233
187
|
def find_coworker_by_integration_id(integration_id)
|
234
|
-
|
235
|
-
|
188
|
+
if @coworkers.has_key?(integration_id)
|
189
|
+
return @coworkers[integration_id]
|
190
|
+
else
|
191
|
+
return nil
|
236
192
|
end
|
237
193
|
end
|
238
194
|
|
239
195
|
def find_organization_by_integration_id(integration_id)
|
240
|
-
|
241
|
-
|
196
|
+
if @organizations.has_key?(integration_id)
|
197
|
+
return @organizations[integration_id]
|
198
|
+
else
|
199
|
+
return nil
|
242
200
|
end
|
201
|
+
|
243
202
|
end
|
244
203
|
|
245
204
|
def find_person_by_integration_id(integration_id)
|
246
205
|
return nil if @organizations.nil?
|
247
|
-
@organizations.each do |organization|
|
206
|
+
@organizations.each do |key, organization|
|
248
207
|
person = organization.find_employee_by_integration_id(integration_id)
|
249
208
|
return person if person
|
250
209
|
end
|
251
210
|
end
|
252
211
|
|
253
212
|
def find_note_by_integration_id(integration_id)
|
254
|
-
|
255
|
-
|
213
|
+
if @notes.has_key?(integration_id)
|
214
|
+
return @notes[integration_id]
|
215
|
+
else
|
216
|
+
return nil
|
256
217
|
end
|
257
218
|
end
|
258
219
|
|
@@ -260,7 +221,7 @@ module GoImport
|
|
260
221
|
def find_deals_for_organization(organization)
|
261
222
|
deals = []
|
262
223
|
|
263
|
-
deals = @deals.select do |deal|
|
224
|
+
deals = @deals.values.select do |deal|
|
264
225
|
!deal.customer.nil? && deal.customer.integration_id == organization.integration_id
|
265
226
|
end
|
266
227
|
|
@@ -268,34 +229,37 @@ module GoImport
|
|
268
229
|
end
|
269
230
|
|
270
231
|
def find_deal_by_integration_id(integration_id)
|
271
|
-
|
272
|
-
|
232
|
+
if @deals.has_key?(integration_id)
|
233
|
+
return @deals[integration_id]
|
234
|
+
else
|
235
|
+
return nil
|
273
236
|
end
|
274
237
|
end
|
275
238
|
|
276
|
-
# Returns a string describing problems with the data. For
|
239
|
+
# Returns a string describing problems with the data. For
|
240
|
+
# instance if integration_id for any entity is not unique.
|
277
241
|
def sanity_check
|
278
242
|
error = String.new
|
279
243
|
|
280
|
-
dups = get_integration_id_duplicates(with_non_empty_integration_id(@coworkers))
|
281
|
-
dups_error_items = (dups.collect{|coworker| coworker.integration_id}).compact
|
282
|
-
if dups.length > 0
|
283
|
-
|
284
|
-
end
|
285
|
-
|
286
|
-
dups = get_integration_id_duplicates(with_non_empty_integration_id(@organizations))
|
287
|
-
dups_error_items = (dups.collect{|org| org.integration_id}).compact
|
288
|
-
if dups.length > 0
|
289
|
-
|
290
|
-
end
|
291
|
-
|
292
|
-
dups = get_integration_id_duplicates(with_non_empty_integration_id(@deals))
|
293
|
-
dups_error_items = (dups.collect{|deal| deal.integration_id}).compact
|
294
|
-
if dups_error_items.length > 0
|
295
|
-
|
296
|
-
end
|
297
|
-
|
298
|
-
persons = @organizations.collect{|o| o.employees}.flatten.compact
|
244
|
+
# dups = get_integration_id_duplicates(with_non_empty_integration_id(@coworkers))
|
245
|
+
# dups_error_items = (dups.collect{|coworker| coworker.integration_id}).compact
|
246
|
+
# if dups.length > 0
|
247
|
+
# error = "#{error}\nDuplicate coworker integration_id: #{dups_error_items.join(", ")}."
|
248
|
+
# end
|
249
|
+
|
250
|
+
# dups = get_integration_id_duplicates(with_non_empty_integration_id(@organizations))
|
251
|
+
# dups_error_items = (dups.collect{|org| org.integration_id}).compact
|
252
|
+
# if dups.length > 0
|
253
|
+
# error = "#{error}\nDuplicate organization integration_id: #{dups_error_items.join(", ")}."
|
254
|
+
# end
|
255
|
+
|
256
|
+
# dups = get_integration_id_duplicates(with_non_empty_integration_id(@deals))
|
257
|
+
# dups_error_items = (dups.collect{|deal| deal.integration_id}).compact
|
258
|
+
# if dups_error_items.length > 0
|
259
|
+
# error = "#{error}\nDuplicate deal integration_id: #{dups_error_items.join(", ")}."
|
260
|
+
# end
|
261
|
+
|
262
|
+
persons = @organizations.collect{|k, o| o.employees}.flatten.compact
|
299
263
|
dups = get_integration_id_duplicates(with_non_empty_integration_id(persons))
|
300
264
|
dups_error_items = (dups.collect{|person| person.integration_id}).compact
|
301
265
|
if dups_error_items.length > 0
|
@@ -315,7 +279,7 @@ module GoImport
|
|
315
279
|
errors = String.new
|
316
280
|
warnings = String.new
|
317
281
|
|
318
|
-
@organizations.each do |o|
|
282
|
+
@organizations.each do |k, o|
|
319
283
|
validation_message = o.validate()
|
320
284
|
|
321
285
|
if !validation_message.empty?
|
@@ -37,6 +37,10 @@ module GoImport
|
|
37
37
|
raw_var.each do |raw_var_elem|
|
38
38
|
SerializeHelper::serialize_rexml(element, raw_var_elem)
|
39
39
|
end
|
40
|
+
elsif (raw_var.is_a?(Hash))
|
41
|
+
raw_var.each do |key, raw_var_elem|
|
42
|
+
SerializeHelper::serialize_rexml(element, raw_var_elem)
|
43
|
+
end
|
40
44
|
else
|
41
45
|
element.text = raw_var.to_s.encode('UTF-8')
|
42
46
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'go_import'
|
4
4
|
require 'roo'
|
5
|
+
require 'progress'
|
5
6
|
require_relative("../converter")
|
6
7
|
|
7
8
|
def convert_source
|
@@ -93,7 +94,7 @@ def convert_source
|
|
93
94
|
# coworkers.
|
94
95
|
if defined?(organization_rows) && !organization_rows.nil?
|
95
96
|
puts "Trying to convert organizations..."
|
96
|
-
organization_rows.each do |row|
|
97
|
+
organization_rows.with_progress().each do |row|
|
97
98
|
organization = converter.to_organization(row, rootmodel)
|
98
99
|
rootmodel.add_organization(organization)
|
99
100
|
end
|
@@ -102,7 +103,7 @@ def convert_source
|
|
102
103
|
# Add people and link them to their organizations
|
103
104
|
if defined?(person_rows) && !person_rows.nil?
|
104
105
|
puts "Trying to convert persons..."
|
105
|
-
person_rows.each do |row|
|
106
|
+
person_rows.with_progress().each do |row|
|
106
107
|
# People are special since they are not added directly to
|
107
108
|
# the root model
|
108
109
|
converter.import_person_to_organization(row, rootmodel)
|
@@ -112,7 +113,7 @@ def convert_source
|
|
112
113
|
# Deals can connected to coworkers, organizations and people.
|
113
114
|
if defined?(deal_rows) && !deal_rows.nil?
|
114
115
|
puts "Trying to convert deals..."
|
115
|
-
deal_rows.each do |row|
|
116
|
+
deal_rows.with_progress().each do |row|
|
116
117
|
rootmodel.add_deal(converter.to_deal(row, rootmodel))
|
117
118
|
end
|
118
119
|
end
|
@@ -121,14 +122,14 @@ def convert_source
|
|
121
122
|
# organizations and notes and might refernce a person
|
122
123
|
if defined?(note_rows) && !note_rows.nil?
|
123
124
|
puts "Trying to convert notes..."
|
124
|
-
note_rows.each do |row|
|
125
|
+
note_rows.with_progress().each do |row|
|
125
126
|
rootmodel.add_note(converter.to_note(row, rootmodel))
|
126
127
|
end
|
127
128
|
end
|
128
129
|
|
129
130
|
if defined?(file_rows) && !file_rows.nil?
|
130
131
|
puts "Trying to convert files..."
|
131
|
-
file_rows.each do |row|
|
132
|
+
file_rows.with_progress().each do |row|
|
132
133
|
rootmodel.add_file(converter.to_file(row, rootmodel))
|
133
134
|
end
|
134
135
|
end
|
data/sources/excel/Gemfile
CHANGED
data/sources/excel-basic/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# encoding:
|
1
|
+
# encoding: UTF-8
|
2
2
|
require 'go_import'
|
3
3
|
|
4
4
|
# Customize this file to suit your input files.
|
@@ -21,7 +21,7 @@ require 'go_import'
|
|
21
21
|
# 1) Export all data from KONTAKT.mdb to a folder named Export located
|
22
22
|
# in the folder created by go_import new. Export data using the
|
23
23
|
# magical tool called PowerSellMigrationExport.exe that can be found
|
24
|
-
# in K:\Lundalogik\LIME Easy\
|
24
|
+
# in K:\Lundalogik\LIME Easy\Tillbehör\Migrationsexport.
|
25
25
|
#
|
26
26
|
# 2) Modify this file (the to_* methods) according to your customer's
|
27
27
|
# KONTAKT.mdb and wishes.
|
@@ -1,48 +1,48 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
diff-lcs (1.2.5)
|
5
|
-
global_phone (1.0.1)
|
6
|
-
go_import (3.0.18)
|
7
|
-
bundler
|
8
|
-
global_phone
|
9
|
-
iso_country_codes
|
10
|
-
nokogiri
|
11
|
-
roo
|
12
|
-
sixarm_ruby_email_address_validation
|
13
|
-
thor
|
14
|
-
iso_country_codes (0.6.1)
|
15
|
-
mini_portile (0.6.1)
|
16
|
-
nokogiri (1.6.4.1-x86-mingw32)
|
17
|
-
mini_portile (~> 0.6.0)
|
18
|
-
roo (1.13.2)
|
19
|
-
nokogiri
|
20
|
-
rubyzip
|
21
|
-
spreadsheet (> 0.6.4)
|
22
|
-
rspec (3.1.0)
|
23
|
-
rspec-core (~> 3.1.0)
|
24
|
-
rspec-expectations (~> 3.1.0)
|
25
|
-
rspec-mocks (~> 3.1.0)
|
26
|
-
rspec-core (3.1.7)
|
27
|
-
rspec-support (~> 3.1.0)
|
28
|
-
rspec-expectations (3.1.2)
|
29
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
-
rspec-support (~> 3.1.0)
|
31
|
-
rspec-mocks (3.1.3)
|
32
|
-
rspec-support (~> 3.1.0)
|
33
|
-
rspec-support (3.1.2)
|
34
|
-
ruby-ole (1.2.11.7)
|
35
|
-
rubyzip (1.1.6)
|
36
|
-
sixarm_ruby_email_address_validation (2.0.0)
|
37
|
-
spreadsheet (1.0.0)
|
38
|
-
ruby-ole (>= 1.0)
|
39
|
-
thor (0.19.1)
|
40
|
-
|
41
|
-
PLATFORMS
|
42
|
-
x86-mingw32
|
43
|
-
|
44
|
-
DEPENDENCIES
|
45
|
-
go_import
|
46
|
-
rspec
|
47
|
-
rubyzip
|
48
|
-
thor
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.2.5)
|
5
|
+
global_phone (1.0.1)
|
6
|
+
go_import (3.0.18)
|
7
|
+
bundler
|
8
|
+
global_phone
|
9
|
+
iso_country_codes
|
10
|
+
nokogiri
|
11
|
+
roo
|
12
|
+
sixarm_ruby_email_address_validation
|
13
|
+
thor
|
14
|
+
iso_country_codes (0.6.1)
|
15
|
+
mini_portile (0.6.1)
|
16
|
+
nokogiri (1.6.4.1-x86-mingw32)
|
17
|
+
mini_portile (~> 0.6.0)
|
18
|
+
roo (1.13.2)
|
19
|
+
nokogiri
|
20
|
+
rubyzip
|
21
|
+
spreadsheet (> 0.6.4)
|
22
|
+
rspec (3.1.0)
|
23
|
+
rspec-core (~> 3.1.0)
|
24
|
+
rspec-expectations (~> 3.1.0)
|
25
|
+
rspec-mocks (~> 3.1.0)
|
26
|
+
rspec-core (3.1.7)
|
27
|
+
rspec-support (~> 3.1.0)
|
28
|
+
rspec-expectations (3.1.2)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.1.0)
|
31
|
+
rspec-mocks (3.1.3)
|
32
|
+
rspec-support (~> 3.1.0)
|
33
|
+
rspec-support (3.1.2)
|
34
|
+
ruby-ole (1.2.11.7)
|
35
|
+
rubyzip (1.1.6)
|
36
|
+
sixarm_ruby_email_address_validation (2.0.0)
|
37
|
+
spreadsheet (1.0.0)
|
38
|
+
ruby-ole (>= 1.0)
|
39
|
+
thor (0.19.1)
|
40
|
+
|
41
|
+
PLATFORMS
|
42
|
+
x86-mingw32
|
43
|
+
|
44
|
+
DEPENDENCIES
|
45
|
+
go_import
|
46
|
+
rspec
|
47
|
+
rubyzip
|
48
|
+
thor
|
@@ -184,6 +184,7 @@ describe GoImport::SerializeHelper do
|
|
184
184
|
rootmodel = GoImport::RootModel.new
|
185
185
|
organization = GoImport::Organization.new
|
186
186
|
organization.name = "Ankeborgs bibliotek"
|
187
|
+
organization.integration_id = "123"
|
187
188
|
rootmodel.add_organization organization
|
188
189
|
GoImport::SerializeHelper::serialize(rootmodel, -1)
|
189
190
|
}
|
@@ -9,12 +9,13 @@ describe GoImport::SerializeHelper do
|
|
9
9
|
s.set_custom_field({:integration_id => "2", :title => "cf title"})
|
10
10
|
s.set_custom_field({:integration_id => "3", :title => "cf title2"})
|
11
11
|
end
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
coworker = GoImport::Coworker.new({
|
13
|
+
:integration_id => "123",
|
14
|
+
:first_name => "Kalle",
|
15
|
+
:last_name => "Anka",
|
16
|
+
:email => "kalle.anka@vonanka.com"
|
17
|
+
})
|
18
|
+
rootmodel.add_coworker(coworker)
|
18
19
|
organization = GoImport::Organization.new
|
19
20
|
organization.name = "Ankeborgs bibliotek"
|
20
21
|
organization.with_source do |source|
|
@@ -25,6 +26,7 @@ describe GoImport::SerializeHelper do
|
|
25
26
|
organization.set_tag("tag:Bj\u{00F6}rk")
|
26
27
|
organization.set_custom_value("2", "cf value")
|
27
28
|
organization.set_custom_value("3", "cf Bj\u{00F6}rk")
|
29
|
+
organization.integration_id = "313"
|
28
30
|
organization.with_postal_address do |addr|
|
29
31
|
addr.city = "Ankeborg"
|
30
32
|
end
|
data/spec/rootmodel_spec.rb
CHANGED
@@ -6,62 +6,64 @@ describe "RootModel" do
|
|
6
6
|
GoImport::RootModel.new
|
7
7
|
}
|
8
8
|
|
9
|
-
it "will contain
|
9
|
+
it "will contain import coworker by default" do
|
10
10
|
rootmodel.find_coworker_by_integration_id("import").first_name.should eq "Import"
|
11
11
|
rootmodel.coworkers.length.should eq 1
|
12
12
|
end
|
13
|
-
|
14
|
-
it "can add a coworker from a hash" do
|
15
|
-
rootmodel.add_coworker({
|
16
|
-
:integration_id => "123key",
|
17
|
-
:first_name => "Kalle",
|
18
|
-
:last_name => "Anka",
|
19
|
-
:email => "kalle.anka@vonanka.com"
|
20
|
-
})
|
21
|
-
rootmodel.find_coworker_by_integration_id("123key").first_name.should eq "Kalle"
|
22
|
-
rootmodel.coworkers.length.should eq 2
|
23
|
-
end
|
24
|
-
|
13
|
+
|
25
14
|
it "can add a coworker from a new coworker" do
|
15
|
+
# given
|
26
16
|
coworker = GoImport::Coworker.new
|
27
17
|
coworker.integration_id = "123key"
|
28
18
|
coworker.first_name="Kalle"
|
29
19
|
coworker.last_name="Anka"
|
30
20
|
coworker.email = "kalle.anka@vonanka.com"
|
21
|
+
|
22
|
+
# when
|
31
23
|
rootmodel.add_coworker(coworker)
|
24
|
+
|
25
|
+
# end
|
32
26
|
rootmodel.find_coworker_by_integration_id("123key").first_name.should eq "Kalle"
|
33
27
|
rootmodel.coworkers.length.should eq 2
|
34
28
|
end
|
35
29
|
|
30
|
+
it "will only add coworkers" do
|
31
|
+
# given
|
32
|
+
not_a_coworker = { :integration_id => "123", :first_name => "Vincent" }
|
33
|
+
|
34
|
+
# when, then
|
35
|
+
expect {
|
36
|
+
rootmodel.add_coworker(not_a_coworker)
|
37
|
+
}.to raise_error(ArgumentError)
|
38
|
+
rootmodel.coworkers.length.should eq 1
|
39
|
+
end
|
40
|
+
|
36
41
|
it "will not add a new coworker when the coworker is already added (same integration id)" do
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
42
|
+
# when
|
43
|
+
coworker1 = GoImport::Coworker.new({
|
44
|
+
:integration_id => "123key",
|
45
|
+
:first_name => "Kalle",
|
46
|
+
:last_name => "Anka",
|
47
|
+
:email => "kalle.anka@vonanka.com"
|
48
|
+
})
|
49
|
+
rootmodel.add_coworker(coworker1)
|
43
50
|
rootmodel.coworkers.length.should eq 2
|
51
|
+
|
52
|
+
# when
|
53
|
+
coworker2 = GoImport::Coworker.new({
|
54
|
+
|
55
|
+
:integration_id => "123key",
|
56
|
+
:first_name => "Knatte",
|
57
|
+
:last_name => "Anka",
|
58
|
+
:email => "knatte.anka@vonanka.com"
|
59
|
+
})
|
44
60
|
expect {
|
45
|
-
rootmodel.add_coworker(
|
46
|
-
:integration_id=>"123key",
|
47
|
-
:first_name=>"Knatte",
|
48
|
-
:last_name=>"Anka",
|
49
|
-
:email=>"knatte.anka@vonanka.com"
|
50
|
-
})
|
61
|
+
rootmodel.add_coworker(coworker2)
|
51
62
|
}.to raise_error(GoImport::AlreadyAddedError)
|
52
63
|
rootmodel.find_coworker_by_integration_id("123key").first_name.should eq "Kalle"
|
53
64
|
rootmodel.coworkers.length.should eq 2
|
54
65
|
end
|
55
66
|
|
56
|
-
it "can add an organization from hash" do
|
57
|
-
rootmodel.add_organization({
|
58
|
-
:integration_id => "123key",
|
59
|
-
:name => "Beagle Boys"
|
60
|
-
})
|
61
|
-
rootmodel.find_organization_by_integration_id("123key").name.should eq "Beagle Boys"
|
62
|
-
rootmodel.organizations.length.should eq 1
|
63
|
-
end
|
64
|
-
|
65
67
|
it "can add an organization from a new organization" do
|
66
68
|
# given
|
67
69
|
organization = GoImport::Organization.new
|
@@ -76,48 +78,61 @@ describe "RootModel" do
|
|
76
78
|
rootmodel.organizations.length.should eq 1
|
77
79
|
end
|
78
80
|
|
79
|
-
it "will
|
81
|
+
it "will only add organizations" do
|
80
82
|
# given
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
83
|
+
not_an_organization = { :integration_id => "123", :name => "This is not a note"}
|
84
|
+
|
85
|
+
# when, then
|
86
|
+
expect {
|
87
|
+
rootmodel.add_organization(not_an_organization)
|
88
|
+
}.to raise_error(ArgumentError)
|
89
|
+
rootmodel.organizations.length.should eq 0
|
90
|
+
end
|
91
|
+
|
92
|
+
it "will not add a new organization when the organization is already added (same integration id)" do
|
93
|
+
# given
|
94
|
+
org = GoImport::Organization.new({
|
95
|
+
:integration_id => "123key",
|
96
|
+
:name => "Beagle Boys"
|
97
|
+
})
|
98
|
+
rootmodel.add_organization(org)
|
85
99
|
rootmodel.organizations.length.should eq 1
|
86
100
|
rootmodel.find_organization_by_integration_id("123key").name.should eq "Beagle Boys"
|
87
101
|
|
88
102
|
# when, then
|
103
|
+
org2 = GoImport::Organization.new({
|
104
|
+
:integration_id => "123key",
|
105
|
+
:name => "Beagle Boys 2"
|
106
|
+
})
|
89
107
|
expect {
|
90
|
-
rootmodel.add_organization(
|
91
|
-
:integration_id => "123key",
|
92
|
-
:name => "Beagle Boys 2"
|
93
|
-
})
|
108
|
+
rootmodel.add_organization(org2)
|
94
109
|
}.to raise_error(GoImport::AlreadyAddedError)
|
95
110
|
rootmodel.find_organization_by_integration_id("123key").name.should eq "Beagle Boys"
|
96
111
|
rootmodel.organizations.length.should eq 1
|
97
112
|
end
|
98
113
|
|
99
|
-
it "will add
|
114
|
+
it "will not add a organization when integration_id is nil" do
|
100
115
|
# given
|
101
116
|
org1 = GoImport::Organization.new
|
102
117
|
org1.name = "Beagle Boys"
|
103
|
-
|
104
|
-
org2.name = "The Corporation"
|
105
|
-
|
106
|
-
# when
|
107
|
-
rootmodel.add_organization(org1)
|
108
|
-
rootmodel.add_organization(org2)
|
118
|
+
org1.integration_id = nil
|
109
119
|
|
110
|
-
# then
|
111
|
-
|
120
|
+
# when, then
|
121
|
+
expect {
|
122
|
+
rootmodel.add_organization(org1)
|
123
|
+
}.to raise_error(GoImport::IntegrationIdIsRequiredError)
|
112
124
|
end
|
113
125
|
|
114
|
-
it "
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
126
|
+
it "will not add a organization when integration_id is empty" do
|
127
|
+
# given
|
128
|
+
org1 = GoImport::Organization.new
|
129
|
+
org1.name = "Beagle Boys"
|
130
|
+
org1.integration_id = ""
|
131
|
+
|
132
|
+
# when, then
|
133
|
+
expect {
|
134
|
+
rootmodel.add_organization(org1)
|
135
|
+
}.to raise_error(GoImport::IntegrationIdIsRequiredError)
|
121
136
|
end
|
122
137
|
|
123
138
|
it "can add a deal from a new deal" do
|
@@ -134,6 +149,17 @@ describe "RootModel" do
|
|
134
149
|
rootmodel.deals.length.should eq 1
|
135
150
|
end
|
136
151
|
|
152
|
+
it "will only add deals" do
|
153
|
+
# given
|
154
|
+
not_a_deal = { :integration_id => "123", :name => "This is not a deal" }
|
155
|
+
|
156
|
+
# when, then
|
157
|
+
expect {
|
158
|
+
rootmodel.add_deal(not_a_deal)
|
159
|
+
}.to raise_error(ArgumentError)
|
160
|
+
rootmodel.deals.length.should eq 0
|
161
|
+
end
|
162
|
+
|
137
163
|
it "will set reponsible coworker to import_coworker if none specifed" do
|
138
164
|
# given
|
139
165
|
deal = GoImport::Deal.new
|
@@ -165,48 +191,61 @@ describe "RootModel" do
|
|
165
191
|
|
166
192
|
it "will not add a new deal when the deal is already added (same integration id)" do
|
167
193
|
# given
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
194
|
+
deal1 = GoImport::Deal.new({
|
195
|
+
:integration_id => "123key",
|
196
|
+
:name => "Big deal"
|
197
|
+
})
|
198
|
+
rootmodel.add_deal(deal1)
|
172
199
|
rootmodel.deals.length.should eq 1
|
173
200
|
rootmodel.find_deal_by_integration_id("123key").name.should eq "Big deal"
|
174
201
|
|
175
202
|
# when, then
|
203
|
+
deal2 = GoImport::Deal.new({
|
204
|
+
:integration_id => "123key",
|
205
|
+
:name => "Bigger deal"
|
206
|
+
})
|
176
207
|
expect {
|
177
|
-
rootmodel.add_deal(
|
178
|
-
:integration_id => "123key",
|
179
|
-
:name => "Bigger deal"
|
180
|
-
})
|
208
|
+
rootmodel.add_deal(deal2)
|
181
209
|
}.to raise_error(GoImport::AlreadyAddedError)
|
182
210
|
rootmodel.find_deal_by_integration_id("123key").name.should eq "Big deal"
|
183
211
|
rootmodel.deals.length.should eq 1
|
184
212
|
end
|
185
213
|
|
186
|
-
it "will add
|
214
|
+
it "will not add a deal when integration_id is nil" do
|
187
215
|
# given
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
deal2.name = "The even bigger deal"
|
216
|
+
deal = GoImport::Deal.new
|
217
|
+
deal.name = "The new deal"
|
218
|
+
deal.integration_id = nil
|
192
219
|
|
193
|
-
# when
|
194
|
-
|
195
|
-
|
220
|
+
# when, then
|
221
|
+
expect {
|
222
|
+
rootmodel.add_deal(deal)
|
223
|
+
}.to raise_error(GoImport::IntegrationIdIsRequiredError)
|
224
|
+
end
|
196
225
|
|
197
|
-
|
198
|
-
|
199
|
-
|
226
|
+
it "will not add a deal when integration_id is empty" do
|
227
|
+
# given
|
228
|
+
deal = GoImport::Deal.new
|
229
|
+
deal.name = "The new deal"
|
230
|
+
deal.integration_id = ""
|
200
231
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
})
|
206
|
-
rootmodel.find_note_by_integration_id("123key").text.should eq "This is a note"
|
207
|
-
rootmodel.notes.length.should eq 1
|
232
|
+
# when, then
|
233
|
+
expect {
|
234
|
+
rootmodel.add_deal(deal)
|
235
|
+
}.to raise_error(GoImport::IntegrationIdIsRequiredError)
|
208
236
|
end
|
209
237
|
|
238
|
+
it "will only add notes" do
|
239
|
+
# given
|
240
|
+
not_a_note = { :integration_id => "123", :text => "This is not a note"}
|
241
|
+
|
242
|
+
# when, then
|
243
|
+
expect {
|
244
|
+
rootmodel.add_note(not_a_note)
|
245
|
+
}.to raise_error(ArgumentError)
|
246
|
+
rootmodel.notes.length.should eq 0
|
247
|
+
end
|
248
|
+
|
210
249
|
it "can add a note from a new note" do
|
211
250
|
# given
|
212
251
|
note = GoImport::Note.new
|
@@ -221,6 +260,34 @@ describe "RootModel" do
|
|
221
260
|
rootmodel.notes.length.should eq 1
|
222
261
|
end
|
223
262
|
|
263
|
+
it "will generate an integration id if the new note dont have one" do
|
264
|
+
# given
|
265
|
+
note = GoImport::Note.new
|
266
|
+
note.text = "This is a note"
|
267
|
+
|
268
|
+
# when
|
269
|
+
rootmodel.add_note(note)
|
270
|
+
|
271
|
+
# then
|
272
|
+
note.integration_id.length.should be > 0
|
273
|
+
end
|
274
|
+
|
275
|
+
it "will generate unique integration ids for each note" do
|
276
|
+
# given
|
277
|
+
note1 = GoImport::Note.new
|
278
|
+
note1.text = "This is a note"
|
279
|
+
|
280
|
+
note2 = GoImport::Note.new
|
281
|
+
note2.text = "This is a different note"
|
282
|
+
|
283
|
+
# when
|
284
|
+
rootmodel.add_note note1
|
285
|
+
rootmodel.add_note note2
|
286
|
+
|
287
|
+
# then
|
288
|
+
note1.integration_id.should be != note2.integration_id
|
289
|
+
end
|
290
|
+
|
224
291
|
it "will not add a nil note" do
|
225
292
|
# given, when
|
226
293
|
rootmodel.add_note(nil)
|
@@ -282,20 +349,22 @@ describe "RootModel" do
|
|
282
349
|
rootmodel.documents.files.length.should eq 1
|
283
350
|
end
|
284
351
|
|
285
|
-
it "will not add a new
|
352
|
+
it "will not add a new note when the note is already added (same integration id)" do
|
286
353
|
# given
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
354
|
+
note = GoImport::Note.new({
|
355
|
+
:integration_id => "123key",
|
356
|
+
:text => "This is a note"
|
357
|
+
})
|
358
|
+
rootmodel.add_note(note)
|
291
359
|
rootmodel.notes.length.should eq 1
|
292
360
|
|
293
361
|
# when, then
|
362
|
+
note2 = GoImport::Note.new({
|
363
|
+
:integration_id => "123key",
|
364
|
+
:text => "This is another note"
|
365
|
+
})
|
294
366
|
expect {
|
295
|
-
rootmodel.add_note(
|
296
|
-
:integration_id => "123key",
|
297
|
-
:text => "This is another note"
|
298
|
-
})
|
367
|
+
rootmodel.add_note(note2)
|
299
368
|
}.to raise_error(GoImport::AlreadyAddedError)
|
300
369
|
rootmodel.notes.length.should eq 1
|
301
370
|
rootmodel.find_note_by_integration_id("123key").text.should eq "This is a note"
|
@@ -305,6 +374,7 @@ describe "RootModel" do
|
|
305
374
|
# given
|
306
375
|
organization = GoImport::Organization.new
|
307
376
|
organization.name = "Hubba Bubba"
|
377
|
+
organization.integration_id = "321"
|
308
378
|
organization.add_employee({
|
309
379
|
:integration_id => "123",
|
310
380
|
:first_name => "Billy",
|
@@ -326,6 +396,7 @@ describe "RootModel" do
|
|
326
396
|
# given
|
327
397
|
organization = GoImport::Organization.new
|
328
398
|
organization.name = "Hubba Bubba"
|
399
|
+
organization.integration_id = "321"
|
329
400
|
organization.add_employee({
|
330
401
|
:integration_id => "123",
|
331
402
|
:first_name => "Billy",
|
@@ -348,53 +419,6 @@ describe "RootModel" do
|
|
348
419
|
found_person.last_name.should eq "Bob"
|
349
420
|
end
|
350
421
|
|
351
|
-
it "will ignore empty integration ids during sanity check" do
|
352
|
-
org1 = GoImport::Organization.new
|
353
|
-
org1.name = "company 1"
|
354
|
-
rootmodel.organizations.push org1
|
355
|
-
|
356
|
-
org2 = GoImport::Organization.new
|
357
|
-
org2.name = "company 2"
|
358
|
-
rootmodel.organizations.push org2
|
359
|
-
|
360
|
-
rootmodel.sanity_check.should eq ""
|
361
|
-
end
|
362
|
-
|
363
|
-
it "will report when the same integration id is used during sanity check" do
|
364
|
-
org1 = GoImport::Organization.new
|
365
|
-
org1.integration_id = "1"
|
366
|
-
org1.name = "company 1"
|
367
|
-
rootmodel.organizations.push org1
|
368
|
-
|
369
|
-
org2 = GoImport::Organization.new
|
370
|
-
org2.integration_id = "1"
|
371
|
-
org2.name = "company 2"
|
372
|
-
rootmodel.organizations.push org2
|
373
|
-
|
374
|
-
rootmodel.sanity_check.should eq "Duplicate organization integration_id: 1."
|
375
|
-
end
|
376
|
-
|
377
|
-
it "will report when the same integrationid on person is used during sanity check" do
|
378
|
-
org1 = GoImport::Organization.new
|
379
|
-
org1.integration_id = "1"
|
380
|
-
org1.name = "company 1"
|
381
|
-
person1 = GoImport::Person.new
|
382
|
-
person1.integration_id = '1'
|
383
|
-
org1.add_employee person1
|
384
|
-
|
385
|
-
rootmodel.organizations.push org1
|
386
|
-
|
387
|
-
org2 = GoImport::Organization.new
|
388
|
-
org2.integration_id = "2"
|
389
|
-
org2.name = "company 2"
|
390
|
-
person2 = GoImport::Person.new
|
391
|
-
person2.integration_id = '1'
|
392
|
-
org2.add_employee person2
|
393
|
-
rootmodel.organizations.push org2
|
394
|
-
|
395
|
-
rootmodel.sanity_check.should eq "Duplicate person integration_id: 1."
|
396
|
-
end
|
397
|
-
|
398
422
|
it "will report when two links has the same integration id during sanity check" do
|
399
423
|
# given
|
400
424
|
link1 = GoImport::Link.new
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: go_import
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.29
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Petter Sandholdt
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2015-
|
15
|
+
date: 2015-04-15 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: iso_country_codes
|