move-to-go 5.0.11 → 5.1.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
  SHA1:
3
- metadata.gz: 68470b38e6ceee63e4f08e8e0e822e9ac5e88914
4
- data.tar.gz: 7b0cd299cf400387f843dcfd8860534fd13b6276
3
+ metadata.gz: 8f042ff622541d2aa5cf2987b704fb6a1cd76534
4
+ data.tar.gz: 1776284c54c50843e08d7277570abc0911dc5f16
5
5
  SHA512:
6
- metadata.gz: 1694855855c926ab157726b1fda8f76103e3c06dca35ab99e32971e78a4f5a27163c3e4b1b1ee5fae668a42a502ae52f3f8bc4b179af39c67a8b67ba588ca231
7
- data.tar.gz: d5d4abd51e0c1c6dd260201eb945a9fd41150dbc8b04f82bf073bb6cab043770b78c130ef7a65c24cfa9c71d6088c2ed018b9dd9d15450e1501b0849840561e2
6
+ metadata.gz: 8bfd040fb52a40c0eb9bf4efd75601a961f36c66fce3159042ee74cbc94a626560a3a88fbc8da0bd062b4ba13275aa6ea23842e4c5dd4f79f2541af6138c7f8b
7
+ data.tar.gz: 3fabcda3d33f0ea662e34ca0ba620913e12e8a315208d3e66330e69aabe6ff34ee0069f50c85911f458db4c2889510ae5b9afe72c5d5ef360bc98b043e03a914
@@ -241,6 +241,10 @@ class MoveToGoCommandLine < Thor
241
241
 
242
242
  private
243
243
  def check_current_version()
244
+ if Gem.loaded_specs["move-to-go"] == nil
245
+ puts "Running source version, no version check"
246
+ return
247
+ end
244
248
  uri = URI('https://rubygems.org/api/v1/versions/move-to-go/latest.json')
245
249
 
246
250
  Net::HTTP.start(uri.host, uri.port,
@@ -264,7 +268,13 @@ class MoveToGoCommandLine < Thor
264
268
 
265
269
  private
266
270
  def display_current_version()
267
- puts "Version: #{Gem.loaded_specs["move-to-go"].version}"
271
+ if Gem.loaded_specs["move-to-go"] == nil
272
+ current_version = "source"
273
+ else
274
+ current_version = Gem.loaded_specs["move-to-go"].version
275
+ end
276
+
277
+ puts "Version: #{current_version}"
268
278
  puts
269
279
  end
270
280
  end
@@ -11,7 +11,7 @@ module MoveToGo
11
11
  include SerializeHelper
12
12
  attr_accessor :id, :integration_id, :description
13
13
 
14
- attr_reader :organization, :created_by, :deal
14
+ attr_reader :organization, :created_by, :deal, :person
15
15
 
16
16
  attr_reader :path
17
17
 
@@ -45,6 +45,7 @@ module MoveToGo
45
45
  [
46
46
  { :id => :created_by_reference, :type => :coworker_reference, :element_name => :created_by },
47
47
  { :id => :organization_reference, :type => :organization_reference, :element_name => :organization },
48
+ { :id => :person_reference, :type => :person_reference, :element_name => :person },
48
49
  { :id => :deal_reference, :type => :deal_reference, :element_name => :deal }
49
50
  ]
50
51
  end
@@ -90,6 +91,14 @@ module MoveToGo
90
91
  end
91
92
  end
92
93
 
94
+ def person=(person)
95
+ @person_reference = PersonReference.from_person(person)
96
+
97
+ if person.is_a?(Person)
98
+ @person = person
99
+ end
100
+ end
101
+
93
102
  def deal=(deal)
94
103
  @deal_reference = DealReference.from_deal(deal)
95
104
 
@@ -179,12 +188,8 @@ module MoveToGo
179
188
  error = "#{error}Created_by is required for file (#{@name}).\n"
180
189
  end
181
190
 
182
- if @organization_reference.nil? && @deal_reference.nil?
183
- error = "#{error}The file (#{@name}) must have either an organization or a deal.\n"
184
- end
185
-
186
- if !@organization_reference.nil? && !@deal_reference.nil?
187
- error = "#{error}The file (#{@name}) can't be attached to both an organization and a deal."
191
+ if @organization_reference.nil? && @deal_reference.nil? && @person_reference.nil?
192
+ error = "#{error}The file (#{@name}) must have either an organization, person or a deal.\n"
188
193
  end
189
194
 
190
195
  return error
@@ -3,7 +3,7 @@ module MoveToGo
3
3
  include SerializeHelper
4
4
  attr_accessor :id, :integration_id, :url, :name, :description
5
5
 
6
- attr_reader :organization, :created_by, :deal
6
+ attr_reader :organization, :created_by, :deal, :person
7
7
 
8
8
  def initialize(opt = nil)
9
9
  if !opt.nil?
@@ -28,6 +28,7 @@ module MoveToGo
28
28
  [
29
29
  { :id => :created_by_reference, :type => :coworker_reference, :element_name => :created_by },
30
30
  { :id => :organization_reference, :type => :organization_reference, :element_name => :organization },
31
+ { :id => :person_reference, :type => :person_reference, :element_name => :person },
31
32
  { :id => :deal_reference, :type => :deal_reference, :element_name => :deal }
32
33
  ]
33
34
  end
@@ -40,6 +41,14 @@ module MoveToGo
40
41
  end
41
42
  end
42
43
 
44
+ def person=(person)
45
+ @person_reference = PersonReference.from_person(person)
46
+
47
+ if person.is_a?(Person)
48
+ @person = person
49
+ end
50
+ end
51
+
43
52
  def deal=(deal)
44
53
  @deal_reference = DealReference.from_deal(deal)
45
54
 
@@ -67,12 +76,8 @@ module MoveToGo
67
76
  error = "#{error}Created_by is required for link\n"
68
77
  end
69
78
 
70
- if @organization_reference.nil? && @deal_reference.nil?
71
- error = "#{error}A link must have either an organization or a deal\n"
72
- end
73
-
74
- if !@organization_reference.nil? && !@deal_reference.nil?
75
- error = "#{error}A link can't be attached to both an organization and a deal"
79
+ if @organization_reference.nil? && @deal_reference.nil? && @person_reference.nil?
80
+ error = "#{error}A link must have either an organization, person or a deal\n"
76
81
  end
77
82
 
78
83
  return error
@@ -6,7 +6,13 @@ module MoveToGo
6
6
  [ :id, :integration_id ].map { |prop| {:id=>prop,:type=>:string} }
7
7
  end
8
8
 
9
- def initalize()
9
+ def initialize(opt = nil)
10
+ if opt != nil
11
+ serialize_variables.each do |var|
12
+ value = opt[var[:id]]
13
+ instance_variable_set("@" + var[:id].to_s, value) if value != nil
14
+ end
15
+ end
10
16
  end
11
17
 
12
18
  def to_s
@@ -368,7 +368,7 @@ module MoveToGo
368
368
  # Returns the first found matching organization
369
369
  # Method is much slower then using find_organization_by_integration_id
370
370
  # @example Finds a organization on its name
371
- # rm.find_organization {|org| org.name == "Lundalogik" }
371
+ # rm.find_organization {|org| org.name == "Lime Technologies" }
372
372
  def find_organization(report_result=!!configuration[:report_result], &block)
373
373
  result = find(@organizations.values.flatten, &block)
374
374
  report_failed_to_find_object("organization") if result.nil? and report_result
@@ -378,7 +378,7 @@ module MoveToGo
378
378
  # Finds organizations based on one of their property.
379
379
  # Returns all matching organizations
380
380
  # @example Selects organizations on their names
381
- # rm.select_organizations {|org| org.name == "Lundalogik" }
381
+ # rm.select_organizations {|org| org.name == "Lime Technologies" }
382
382
  def select_organizations(report_result=!!configuration[:report_result], &block)
383
383
  result = select(@organizations.values.flatten, &block)
384
384
  report_failed_to_find_object("organization") if result.empty? and report_result
@@ -34,7 +34,9 @@ module MoveToGo
34
34
  def rows_for_sheet(sheet)
35
35
  column_headers = {}
36
36
  1.upto(@data.last_column(sheet)) do |col|
37
- column_headers[col] = @data.cell(1, col, sheet).encode('UTF-8')
37
+ header = @data.cell(1, col, sheet)
38
+ raise "Missing header in row 1, col #{col} in sheet '#{sheet}'" if header == nil
39
+ column_headers[col] = header.encode('UTF-8')
38
40
  end
39
41
 
40
42
  rs = []
@@ -73,6 +73,14 @@ def convert_source
73
73
  end
74
74
  end
75
75
 
76
+ if defined?(LINK_SHEET)
77
+ if excel_workbook.has_sheet?(LINK_SHEET)
78
+ link_rows = excel_workbook.rows_for_sheet LINK_SHEET
79
+ else
80
+ puts "WARNING: can't find sheet '#{LINK_SHEET}'"
81
+ end
82
+ end
83
+
76
84
  # Then we create a rootmodel that will contain all data that
77
85
  # should be exported to LIME Go.
78
86
  rootmodel = MoveToGo::RootModel.new
@@ -135,6 +143,12 @@ def convert_source
135
143
  end
136
144
  end
137
145
 
146
+ if defined?(link_rows) && !link_rows.nil?
147
+ puts "Trying to convert links..."
148
+ link_rows.with_progress().each do |row|
149
+ rootmodel.add_link(converter.to_link(row, rootmodel))
150
+ end
151
+ end
138
152
  return rootmodel
139
153
  end
140
154
 
@@ -17,6 +17,7 @@ PERSON_SHEET = "Kontaktperson"
17
17
  DEAL_SHEET = "Affär"
18
18
  HISTORY_SHEET = "Anteckningar"
19
19
  FILE_SHEET = "Dokument"
20
+ LINK_SHEET = "Links"
20
21
 
21
22
  # Then you need to modify the script below according to the TODO
22
23
  # comments.
@@ -162,6 +163,8 @@ class Converter
162
163
  file = MoveToGo::File.new()
163
164
 
164
165
  file.organization = rootmodel.find_organization_by_integration_id(row['Företag'])
166
+ file.person = rootmodel.find_person_by_integration_id(row['Person'])
167
+ file.deal = rootmodel.find_deal_by_integration_id(row['Affär'])
165
168
  file.created_by = rootmodel.find_coworker_by_integration_id(row['Skapad Av'])
166
169
  file.name = row['Namn']
167
170
  file.description = row['Kommentar']
@@ -170,6 +173,20 @@ class Converter
170
173
  return file
171
174
  end
172
175
 
176
+ def to_link(row, rootmodel)
177
+ link = MoveToGo::Link.new()
178
+
179
+ link.organization = rootmodel.find_organization_by_integration_id(row['Företag'])
180
+ link.person = rootmodel.find_person_by_integration_id(row['Person'])
181
+ link.deal = rootmodel.find_deal_by_integration_id(row['Affär'])
182
+ link.created_by = rootmodel.find_coworker_by_integration_id(row['Skapad Av'])
183
+ link.name = row['Namn']
184
+ link.description = row['Kommentar']
185
+ link.path = row['URL']
186
+
187
+ return link
188
+ end
189
+
173
190
  # HOOKS
174
191
  #
175
192
  # Sometimes you need to add exra information to the rootmodel, this can be done
@@ -27,6 +27,19 @@ describe "File" do
27
27
  file.validate.should eq ""
28
28
  end
29
29
 
30
+ it "is valid when it has name, path, created_by, deal, person and organization" do
31
+ # given
32
+ file.name = "Offert"
33
+ file.path = "spec/sample_data/offert.docx"
34
+ file.created_by = MoveToGo::CoworkerReference.new( { :integration_id => "123" } )
35
+ file.deal = MoveToGo::DealReference.new( { :integration_id => "456" } )
36
+ file.person = MoveToGo::PersonReference.new( { :integration_id => "456" } )
37
+ file.organization = MoveToGo::OrganizationReference.new( { :integration_id => "456" } )
38
+
39
+ # when, then
40
+ file.validate.should eq ""
41
+ end
42
+
30
43
  it "is valid when it has name, invalid path, created_by and deal but ignores the path" do
31
44
  # given
32
45
  file.name = "Offert"
@@ -138,6 +151,20 @@ describe "File" do
138
151
  file.instance_variable_get(:@deal_reference).is_a?(MoveToGo::DealReference).should eq true
139
152
  end
140
153
 
154
+ it "will set person ref when person is assigned" do
155
+ # given
156
+ person = MoveToGo::Person.new({:integration_id => "123" })
157
+ person.first_name = "The"
158
+ person.last_name = "Limer"
159
+
160
+ # when
161
+ file.person = person
162
+
163
+ # then
164
+ file.person.is_a?(MoveToGo::Person).should eq true
165
+ file.instance_variable_get(:@person_reference).is_a?(MoveToGo::PersonReference).should eq true
166
+ end
167
+
141
168
  it "will set coworker ref when coworker is assinged" do
142
169
  # given
143
170
  coworker = MoveToGo::Coworker.new({:integration_id => "123" })
@@ -3,25 +3,30 @@ require 'move-to-go'
3
3
  require 'nokogiri'
4
4
  describe MoveToGo::SerializeHelper do
5
5
  describe "Validate according to xsd" do
6
- let(:validate_result) {
6
+ let(:rootmodel) do
7
7
  rootmodel = MoveToGo::RootModel.new
8
8
  rootmodel.settings.with_organization do |s|
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
- coworker = MoveToGo::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)
12
+ rootmodel
13
+ end
14
+
15
+ let(:coworker) do
16
+ MoveToGo::Coworker.new({
17
+ :integration_id => "123",
18
+ :first_name => "Kalle",
19
+ :last_name => "Anka",
20
+ :email => "kalle.anka@vonanka.com"
21
+ })
22
+ end
23
+
24
+ let(:organization) do
19
25
  organization = MoveToGo::Organization.new
20
26
  organization.name = "Ankeborgs bibliotek"
21
27
  organization.with_source do |source|
22
28
  source.par_se('122345')
23
29
  end
24
- #organization.source_ref = {:name => 'Go',:id => "PASE122345"}
25
30
  organization.set_tag("tag:bibliotek")
26
31
  organization.set_tag("tag:Bj\u{00F6}rk")
27
32
  organization.set_custom_value("2", "cf value")
@@ -33,25 +38,90 @@ describe MoveToGo::SerializeHelper do
33
38
  organization.with_visit_address do |addr|
34
39
  addr.city = "Gaaseborg"
35
40
  end
36
- coworker = MoveToGo::Coworker.new({:integration_id => "1", :first_name => "Vincent", :last_name => "Vega"})
37
- organization.responsible_coworker = coworker
41
+ organization
42
+ end
38
43
 
44
+ let(:employee) do
39
45
  emp = MoveToGo::Person.new
40
- emp.integration_id = "1"
46
+ emp.integration_id = "12345"
41
47
  emp.first_name = "Kalle"
42
48
  emp.last_name = "Anka"
43
49
  emp.direct_phone_number = '234234234'
44
50
  emp.currently_employed = true
51
+ emp
52
+ end
53
+
54
+ let(:deal) do
55
+ deal = MoveToGo::Deal.new
56
+ deal.integration_id = "42"
57
+ deal.name = "foo"
58
+ deal.offer_date = "2012-12-12T00:00:00"
59
+ deal.order_date = "2012-12-01T00:00:00"
60
+ deal.value = "0"
61
+ deal.probability = "20"
62
+ deal
63
+ end
64
+
65
+ let(:link) do
66
+ link = MoveToGo::Link.new
67
+ link.integration_id = "12"
68
+ link.url = "https://go.lime-go.com"
69
+ link
70
+ end
71
+
72
+ let(:file) do
73
+ file = MoveToGo::File.new
74
+ file.integration_id = "12"
75
+ file.name = "smallfile.txt"
76
+ file
77
+ end
78
+
79
+ it "Should not contain validation errors" do
80
+ rootmodel.add_coworker(coworker)
81
+ organization.responsible_coworker = MoveToGo::Coworker.new({:integration_id => "1", :first_name => "Vincent", :last_name => "Vega"})
82
+ organization.add_employee employee
45
83
  rootmodel.add_organization organization
84
+
85
+ doc = Nokogiri::XML(MoveToGo::SerializeHelper::serialize(rootmodel, -1))
86
+
46
87
  xsd_file = File.join(File.dirname(__FILE__), '..', 'sample_data', 'schema0.xsd')
88
+ xsd = Nokogiri::XML::Schema(File.read(xsd_file))
89
+ expect(xsd.validate(doc)).to eq([])
90
+ end
91
+
92
+ it "Documents can have many references" do
93
+ rootmodel.add_coworker(coworker)
94
+ organization.add_employee employee
95
+ rootmodel.add_organization organization
96
+ deal.customer = organization
97
+ rootmodel.add_deal deal
98
+
99
+ link.deal = deal
100
+ link.organization = organization
101
+ link.person = employee
102
+ rootmodel.add_link link
103
+
104
+ file.deal = deal
105
+ file.organization = organization
106
+ file.person = employee
107
+ rootmodel.add_file file
47
108
 
48
- xsd = Nokogiri::XML::Schema(File.read(xsd_file))
49
109
  doc = Nokogiri::XML(MoveToGo::SerializeHelper::serialize(rootmodel, -1))
50
- xsd.validate(doc)
51
- }
110
+ xsd_file = File.join(File.dirname(__FILE__), '..', 'sample_data', 'schema0.xsd')
111
+ xsd = Nokogiri::XML::Schema(File.read(xsd_file))
112
+ expect(xsd.validate(doc)).to eq([])
113
+ end
52
114
 
53
- it "Should not contain validation errors" do
54
- expect(validate_result).to eq([])
115
+ it "valudate deals" do
116
+ rootmodel.add_coworker(coworker)
117
+ rootmodel.add_organization organization
118
+ deal.customer = organization
119
+ rootmodel.add_deal deal
120
+
121
+ doc = Nokogiri::XML(MoveToGo::SerializeHelper::serialize(rootmodel, -1))
122
+ xsd_file = File.join(File.dirname(__FILE__), '..', 'sample_data', 'schema0.xsd')
123
+ xsd = Nokogiri::XML::Schema(File.read(xsd_file))
124
+ expect(xsd.validate(doc)).to eq([])
55
125
  end
56
126
  end
57
127
  end
@@ -56,7 +56,7 @@ describe "Link" do
56
56
  link.validate.length.should be > 0
57
57
  end
58
58
 
59
- it "is not valid when it has url, created_by, deal and orgaization" do
59
+ it "is valid when it has url, created_by, deal and orgaization" do
60
60
  # given
61
61
  link.url = "http://dropbox.com/"
62
62
  link.created_by = MoveToGo::CoworkerReference.new( { :integration_id => "123", :heading => "billy bob" } )
@@ -64,7 +64,19 @@ describe "Link" do
64
64
  link.organization = MoveToGo::OrganizationReference.new({ :integration_id => "456", :heading => "Lundalogik" })
65
65
 
66
66
  # when, then
67
- link.validate.length.should be > 0
67
+ link.validate.should eq ""
68
+ end
69
+
70
+ it "is valid when it has url, created_by, deal, person and orgaization" do
71
+ # given
72
+ link.url = "http://dropbox.com/"
73
+ link.created_by = MoveToGo::CoworkerReference.new( { :integration_id => "123", :heading => "billy bob" } )
74
+ link.deal = MoveToGo::DealReference.new({ :integration_id => "456", :heading => "The new deal" })
75
+ link.person = MoveToGo::PersonReference.new({ :integration_id => "456", :heading => "Limer" })
76
+ link.organization = MoveToGo::OrganizationReference.new({ :integration_id => "456", :heading => "Lundalogik" })
77
+
78
+ # when, then
79
+ link.validate.should eq ""
68
80
  end
69
81
 
70
82
  it "will set organization ref when organization is assigned" do
@@ -92,6 +104,20 @@ describe "Link" do
92
104
  link.instance_variable_get(:@deal_reference).is_a?(MoveToGo::DealReference).should eq true
93
105
  end
94
106
 
107
+ it "will set person ref when person is assigned" do
108
+ # given
109
+ person = MoveToGo::Person.new({:integration_id => "123" })
110
+ person.first_name = "The"
111
+ person.last_name = "Limer"
112
+
113
+ # when
114
+ link.person = person
115
+
116
+ # then
117
+ link.person.is_a?(MoveToGo::Person).should eq true
118
+ link.instance_variable_get(:@person_reference).is_a?(MoveToGo::PersonReference).should eq true
119
+ end
120
+
95
121
  it "will set coworker ref when coworker is assigned" do
96
122
  # given
97
123
  coworker = MoveToGo::Coworker.new({:integration_id => "123" })
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: move-to-go
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.11
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Petter Sandholdt
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2018-02-08 00:00:00.000000000 Z
17
+ date: 2018-04-05 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: iso_country_codes
@@ -173,7 +173,7 @@ dependencies:
173
173
  description: " move-to-go is an migration tool for Lime Go. It can take virtually
174
174
  any input source and create zip-files that LIME Go likes. \n move-to-go has some
175
175
  predefined sources that makes will help you migrate your data.\n"
176
- email: support@lundalogik.se
176
+ email: support@lime.tech
177
177
  executables:
178
178
  - move-to-go
179
179
  extensions: []
@@ -319,7 +319,8 @@ files:
319
319
  - spec/spec_helper.rb
320
320
  homepage:
321
321
  licenses: []
322
- metadata: {}
322
+ metadata:
323
+ changelog_uri: https://github.com/Lundalogik/move-to-go/blob/master/CHANGELOG.md
323
324
  post_install_message:
324
325
  rdoc_options: []
325
326
  require_paths: