fruit_to_lime 2.2.4 → 2.3.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.
- data/lib/fruit_to_lime/model/coworker.rb +6 -1
- data/lib/fruit_to_lime/model/deal.rb +7 -2
- data/lib/fruit_to_lime/model/deal_status.rb +3 -2
- data/lib/fruit_to_lime/model/organization.rb +1 -0
- data/lib/fruit_to_lime/model/person.rb +6 -1
- data/lib/fruit_to_lime/model/rootmodel.rb +7 -0
- data/spec/coworker_spec.rb +12 -0
- data/spec/deal_spec.rb +18 -0
- data/spec/person_spec.rb +12 -0
- data/spec/rootmodel_spec.rb +22 -0
- data/templates/csv/lib/tomodel.rb +0 -1
- metadata +4 -2
@@ -46,7 +46,12 @@ module FruitToLime
|
|
46
46
|
return false
|
47
47
|
end
|
48
48
|
|
49
|
-
def parse_name_to_firstname_lastname_se(name)
|
49
|
+
def parse_name_to_firstname_lastname_se(name, when_missing = '')
|
50
|
+
if name.nil? or name.empty?
|
51
|
+
@first_name = when_missing
|
52
|
+
return
|
53
|
+
end
|
54
|
+
|
50
55
|
splitted = name.split(' ')
|
51
56
|
@first_name = splitted[0]
|
52
57
|
if splitted.length > 1
|
@@ -3,13 +3,13 @@ module FruitToLime
|
|
3
3
|
class Deal
|
4
4
|
include SerializeHelper, ModelHasCustomFields, ModelHasTags
|
5
5
|
|
6
|
-
attr_accessor :id, :integration_id, :name, :description, :probability, :value, :order_date, :
|
6
|
+
attr_accessor :id, :integration_id, :name, :description, :probability, :value, :order_date, :customer,
|
7
7
|
:responsible_coworker, :customer_contact, :status
|
8
8
|
# you add custom values by using {#set_custom_value}
|
9
9
|
attr_reader :custom_values
|
10
10
|
|
11
11
|
def serialize_variables
|
12
|
-
[ :id, :integration_id, :name, :description, :probability, :value, :
|
12
|
+
[ :id, :integration_id, :name, :description, :probability, :value, :order_date ].map {
|
13
13
|
|p| {
|
14
14
|
:id => p,
|
15
15
|
:type => :string
|
@@ -46,5 +46,10 @@ module FruitToLime
|
|
46
46
|
return error
|
47
47
|
end
|
48
48
|
|
49
|
+
def with_status
|
50
|
+
@status = DealStatus.new
|
51
|
+
yield @status
|
52
|
+
end
|
53
|
+
|
49
54
|
end
|
50
55
|
end
|
@@ -2,10 +2,11 @@ module FruitToLime
|
|
2
2
|
class DealStatus
|
3
3
|
include SerializeHelper
|
4
4
|
|
5
|
-
attr_accessor :id, :label
|
5
|
+
attr_accessor :id, :label, :date, :note
|
6
6
|
|
7
7
|
def serialize_variables
|
8
|
-
[ :id, :label ].map{ |p| { :id => p, :type => :string } }
|
8
|
+
[ :id, :label, :note ].map{ |p| { :id => p, :type => :string } } +
|
9
|
+
[ :date ].map { |p| { :id => p, :type => :date } }
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
@@ -118,7 +118,12 @@ module FruitToLime
|
|
118
118
|
return error
|
119
119
|
end
|
120
120
|
|
121
|
-
def parse_name_to_firstname_lastname_se(name)
|
121
|
+
def parse_name_to_firstname_lastname_se(name, when_missing = '')
|
122
|
+
if name.nil? or name.empty?
|
123
|
+
@first_name = when_missing
|
124
|
+
return
|
125
|
+
end
|
126
|
+
|
122
127
|
splitted = name.split(' ')
|
123
128
|
@first_name = splitted[0]
|
124
129
|
if splitted.length > 1
|
@@ -135,6 +135,13 @@ module FruitToLime
|
|
135
135
|
error = "#{error}\nDuplicate deal integration_id: #{dups_error_items.join(", ")}."
|
136
136
|
end
|
137
137
|
|
138
|
+
persons = @organizations.collect{|o| o.employees}.flatten.compact
|
139
|
+
dups = get_integration_id_duplicates(with_non_empty_integration_id(persons))
|
140
|
+
dups_error_items = (dups.collect{|person| person.integration_id}).compact
|
141
|
+
if dups_error_items.length > 0
|
142
|
+
error = "#{error}\nDuplicate person integration_id: #{dups_error_items.join(", ")}."
|
143
|
+
end
|
144
|
+
|
138
145
|
return error.strip
|
139
146
|
end
|
140
147
|
|
data/spec/coworker_spec.rb
CHANGED
@@ -22,6 +22,18 @@ describe "Coworker" do
|
|
22
22
|
coworker.first_name.should eq 'Kalle'
|
23
23
|
coworker.last_name.should eq 'Svensson Nilsson'
|
24
24
|
end
|
25
|
+
|
26
|
+
it "sets default name when name is empty" do
|
27
|
+
coworker.parse_name_to_firstname_lastname_se '', 'a default'
|
28
|
+
|
29
|
+
coworker.first_name.should eq 'a default'
|
30
|
+
end
|
31
|
+
|
32
|
+
it "sets default name when name is nil" do
|
33
|
+
coworker.parse_name_to_firstname_lastname_se nil, 'a default'
|
34
|
+
|
35
|
+
coworker.first_name.should eq 'a default'
|
36
|
+
end
|
25
37
|
end
|
26
38
|
|
27
39
|
describe "gues_email" do
|
data/spec/deal_spec.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require 'fruit_to_lime'
|
3
|
+
|
4
|
+
describe "Deal" do
|
5
|
+
let(:deal){
|
6
|
+
FruitToLime::Deal.new
|
7
|
+
}
|
8
|
+
|
9
|
+
it "can attach a current status" do
|
10
|
+
deal.with_status do |status|
|
11
|
+
status.label = 'xyz'
|
12
|
+
status.id = '123'
|
13
|
+
status.date = DateTime.now
|
14
|
+
status.note = 'ho ho'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/spec/person_spec.rb
CHANGED
@@ -95,6 +95,18 @@ describe "Person" do
|
|
95
95
|
person.first_name.should eq 'Kalle'
|
96
96
|
person.last_name.should eq 'Svensson Nilsson'
|
97
97
|
end
|
98
|
+
|
99
|
+
it "sets default name when name is empty" do
|
100
|
+
person.parse_name_to_firstname_lastname_se '', 'a default'
|
101
|
+
|
102
|
+
person.first_name.should eq 'a default'
|
103
|
+
end
|
104
|
+
|
105
|
+
it "sets default name when name is nil" do
|
106
|
+
person.parse_name_to_firstname_lastname_se nil, 'a default'
|
107
|
+
|
108
|
+
person.first_name.should eq 'a default'
|
109
|
+
end
|
98
110
|
end
|
99
111
|
end
|
100
112
|
|
data/spec/rootmodel_spec.rb
CHANGED
@@ -79,4 +79,26 @@ describe "RootModel" do
|
|
79
79
|
|
80
80
|
rootmodel.sanity_check.should eq "Duplicate organization integration_id: 1."
|
81
81
|
end
|
82
|
+
|
83
|
+
it "will report when the same integrationid on person is used during sanity check" do
|
84
|
+
org1 = FruitToLime::Organization.new
|
85
|
+
org1.integration_id = "1"
|
86
|
+
org1.name = "company 1"
|
87
|
+
person1 = FruitToLime::Person.new
|
88
|
+
person1.integration_id = '1'
|
89
|
+
org1.add_employee person1
|
90
|
+
|
91
|
+
rootmodel.organizations.push org1
|
92
|
+
|
93
|
+
org2 = FruitToLime::Organization.new
|
94
|
+
org2.integration_id = "2"
|
95
|
+
org2.name = "company 2"
|
96
|
+
person2 = FruitToLime::Person.new
|
97
|
+
person2.integration_id = '1'
|
98
|
+
org2.add_employee person2
|
99
|
+
rootmodel.organizations.push org2
|
100
|
+
|
101
|
+
rootmodel.sanity_check.should eq "Duplicate person integration_id: 1."
|
102
|
+
|
103
|
+
end
|
82
104
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fruit_to_lime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-05-
|
14
|
+
date: 2014-05-06 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: iso_country_codes
|
@@ -185,6 +185,7 @@ files:
|
|
185
185
|
- spec/class_settings_spec.rb
|
186
186
|
- spec/coworker_spec.rb
|
187
187
|
- spec/custom_field_spec.rb
|
188
|
+
- spec/deal_spec.rb
|
188
189
|
- spec/helpers/csv_helper_spec.rb
|
189
190
|
- spec/helpers/roo_helper_spec.rb
|
190
191
|
- spec/helpers/serialize_helper_spec.rb
|
@@ -222,6 +223,7 @@ test_files:
|
|
222
223
|
- spec/class_settings_spec.rb
|
223
224
|
- spec/coworker_spec.rb
|
224
225
|
- spec/custom_field_spec.rb
|
226
|
+
- spec/deal_spec.rb
|
225
227
|
- spec/helpers/csv_helper_spec.rb
|
226
228
|
- spec/helpers/roo_helper_spec.rb
|
227
229
|
- spec/helpers/serialize_helper_spec.rb
|