fruit_to_lime 2.3.0 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fruit_to_lime/model/class_settings.rb +0 -23
- data/lib/fruit_to_lime/model_helpers.rb +12 -9
- data/spec/class_settings_spec.rb +0 -9
- data/spec/person_spec.rb +13 -0
- data/templates/csv/lib/tomodel.rb +1 -1
- metadata +2 -3
- data/templates/csv/export.xml +0 -152
@@ -43,28 +43,5 @@ module FruitToLime
|
|
43
43
|
return field
|
44
44
|
end
|
45
45
|
|
46
|
-
# Add custom field. If there is already an existing custom field, then an AlreadyAddedError will be raised.
|
47
|
-
def add_custom_field(obj)
|
48
|
-
@custom_fields = [] if @custom_fields==nil
|
49
|
-
|
50
|
-
if obj.is_a?(CustomField)
|
51
|
-
field = obj
|
52
|
-
else
|
53
|
-
field = CustomField.new(obj)
|
54
|
-
end
|
55
|
-
|
56
|
-
index = @custom_fields.find_index do |custom_field|
|
57
|
-
custom_field.same_as?(field)
|
58
|
-
end
|
59
|
-
|
60
|
-
if index
|
61
|
-
raise AlreadyAddedError, "Already added a custom same as #{obj}"
|
62
|
-
end
|
63
|
-
|
64
|
-
@custom_fields.push field
|
65
|
-
|
66
|
-
return field
|
67
|
-
end
|
68
|
-
|
69
46
|
end
|
70
47
|
end
|
@@ -1,10 +1,19 @@
|
|
1
1
|
module FruitToLime
|
2
2
|
module ModelHasCustomFields
|
3
3
|
# @example
|
4
|
-
#
|
5
|
-
|
4
|
+
# value = row['business_value_partner_info']
|
5
|
+
# obj.set_custom_value("partner_info", value)
|
6
|
+
def set_custom_value(integration_id, value)
|
7
|
+
return set_custom_field({integration_id: integration_id, value: value})
|
8
|
+
end
|
9
|
+
# @example
|
10
|
+
# value = row['business_value_partner_info']
|
11
|
+
# obj.set_custom_field({:integration_id=>"partner_info", :value=>value})
|
12
|
+
def set_custom_field(obj)
|
6
13
|
@custom_values = [] if @custom_values == nil
|
7
|
-
|
14
|
+
value = obj[:value]
|
15
|
+
field = CustomFieldReference.new(obj)
|
16
|
+
custom_value = CustomValue.new
|
8
17
|
custom_value.value = value
|
9
18
|
custom_value.field = field
|
10
19
|
index = @custom_values.find_index do |custom_value|
|
@@ -17,12 +26,6 @@ module FruitToLime
|
|
17
26
|
@custom_values.push custom_value
|
18
27
|
return custom_value
|
19
28
|
end
|
20
|
-
# Note that this method is obsolete and will be removed later on. Please use {#set_custom_value}
|
21
|
-
def set_custom_field(obj)
|
22
|
-
value = obj[:value]
|
23
|
-
ref = CustomFieldReference.new(obj)
|
24
|
-
return set_custom_value(value, ref)
|
25
|
-
end
|
26
29
|
end
|
27
30
|
|
28
31
|
module ModelWithIntegrationIdSameAs
|
data/spec/class_settings_spec.rb
CHANGED
@@ -13,14 +13,5 @@ describe "ClassSettings" do
|
|
13
13
|
class_settings.custom_fields[0].title.should eq "Link to BI system 2"
|
14
14
|
end
|
15
15
|
|
16
|
-
it "can add custom field and if there is already an existing custom field, then an AlreadyAddedError will be raised (and nothing is added)." do
|
17
|
-
class_settings.add_custom_field({:integration_id=>"link_to_bi_system", :title=>"Link to BI system"})
|
18
|
-
expect {
|
19
|
-
class_settings.add_custom_field({:integration_id=>"link_to_bi_system", :title=>"Link to BI system 2"})
|
20
|
-
}.to raise_error(FruitToLime::AlreadyAddedError)
|
21
|
-
class_settings.custom_fields.length.should eq 1
|
22
|
-
class_settings.custom_fields[0].title.should eq "Link to BI system"
|
23
|
-
end
|
24
|
-
|
25
16
|
end
|
26
17
|
|
data/spec/person_spec.rb
CHANGED
@@ -44,6 +44,19 @@ describe "Person" do
|
|
44
44
|
value.value.should eq 'the value 2'
|
45
45
|
end
|
46
46
|
|
47
|
+
it "will set custom field (using set_custom_value) with same integration_id to the last value" do
|
48
|
+
person.set_custom_value('the id','the value')
|
49
|
+
|
50
|
+
person.set_custom_value('the id','the value 2')
|
51
|
+
value = person.custom_values[0]
|
52
|
+
field = value.field
|
53
|
+
|
54
|
+
person.custom_values.length.should eq 1
|
55
|
+
field.integration_id.should eq 'the id'
|
56
|
+
value.value.should eq 'the value 2'
|
57
|
+
end
|
58
|
+
|
59
|
+
|
47
60
|
it "will only set tag once" do
|
48
61
|
person.set_tag('tag1')
|
49
62
|
person.set_tag('tag1')
|
@@ -52,7 +52,7 @@ class Exporter
|
|
52
52
|
# client will continue to use it can be useful to be
|
53
53
|
# able to link from Go to the same record in the ERP
|
54
54
|
# FOr instance Lime links
|
55
|
-
organization.set_custom_value("http://something.com?key=#{row['id']}"
|
55
|
+
organization.set_custom_value("external_url", "http://something.com?key=#{row['id']}")
|
56
56
|
|
57
57
|
return organization
|
58
58
|
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.3.
|
4
|
+
version: 2.3.1
|
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-07 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: iso_country_codes
|
@@ -158,7 +158,6 @@ files:
|
|
158
158
|
- lib/fruit_to_lime.rb
|
159
159
|
- bin/fruit_to_lime
|
160
160
|
- templates/csv/convert.rb
|
161
|
-
- templates/csv/export.xml
|
162
161
|
- templates/csv/Gemfile
|
163
162
|
- templates/csv/lib/tomodel.rb
|
164
163
|
- templates/csv/Rakefile.rb
|
data/templates/csv/export.xml
DELETED
@@ -1,152 +0,0 @@
|
|
1
|
-
<GoImport Version='v2_0'
|
2
|
-
><Settings
|
3
|
-
><Organization
|
4
|
-
><CustomFields
|
5
|
-
><CustomField
|
6
|
-
><Title
|
7
|
-
>Link to external system</Title
|
8
|
-
><Type
|
9
|
-
>Link</Type
|
10
|
-
></CustomField
|
11
|
-
></CustomFields
|
12
|
-
></Organization
|
13
|
-
></Settings
|
14
|
-
><Coworkers
|
15
|
-
><Coworker
|
16
|
-
><IntegrationId
|
17
|
-
>import</IntegrationId
|
18
|
-
><FirstName
|
19
|
-
>Import</FirstName
|
20
|
-
></Coworker
|
21
|
-
><Coworker
|
22
|
-
><IntegrationId
|
23
|
-
>666</IntegrationId
|
24
|
-
><FirstName
|
25
|
-
>Evil</FirstName
|
26
|
-
><LastName
|
27
|
-
>Elvis</LastName
|
28
|
-
><Email
|
29
|
-
>t@e.com</Email
|
30
|
-
><DirectPhoneNumber
|
31
|
-
>+46121212</DirectPhoneNumber
|
32
|
-
><MobilePhoneNumber
|
33
|
-
>+46324234</MobilePhoneNumber
|
34
|
-
><HomePhoneNumber
|
35
|
-
>+46234234</HomePhoneNumber
|
36
|
-
></Coworker
|
37
|
-
></Coworkers
|
38
|
-
><Organizations
|
39
|
-
><Organization
|
40
|
-
><IntegrationId
|
41
|
-
>6</IntegrationId
|
42
|
-
><Name
|
43
|
-
>Alfs Mjukvaruutveckling</Name
|
44
|
-
><OrganizationNumber
|
45
|
-
>a number</OrganizationNumber
|
46
|
-
><PostalAddress
|
47
|
-
><Street
|
48
|
-
>postal street</Street
|
49
|
-
><ZipCode
|
50
|
-
>226 48</ZipCode
|
51
|
-
><City
|
52
|
-
>LUND</City
|
53
|
-
></PostalAddress
|
54
|
-
><VisitAddress
|
55
|
-
><Street
|
56
|
-
>visit street</Street
|
57
|
-
><ZipCode
|
58
|
-
>visit zip</ZipCode
|
59
|
-
><City
|
60
|
-
>visit city</City
|
61
|
-
></VisitAddress
|
62
|
-
><CentralPhoneNumber
|
63
|
-
>0000</CentralPhoneNumber
|
64
|
-
><Email
|
65
|
-
>email to organizaiton, not the person</Email
|
66
|
-
><WebSite
|
67
|
-
>www.whatever.com</WebSite
|
68
|
-
><Employees
|
69
|
-
><Person
|
70
|
-
><IntegrationId
|
71
|
-
>123</IntegrationId
|
72
|
-
><FirstName
|
73
|
-
>Rune</FirstName
|
74
|
-
><LastName
|
75
|
-
>Rebellion</LastName
|
76
|
-
><DirectPhoneNumber
|
77
|
-
>+4611111</DirectPhoneNumber
|
78
|
-
><FaxPhoneNumber
|
79
|
-
>+4623234234234</FaxPhoneNumber
|
80
|
-
><MobilePhoneNumber
|
81
|
-
>+462321212</MobilePhoneNumber
|
82
|
-
><Email
|
83
|
-
>x@y.com</Email
|
84
|
-
><AlternativeEmail
|
85
|
-
>y@x.com</AlternativeEmail
|
86
|
-
><PostalAddress
|
87
|
-
><Street
|
88
|
-
>postal street</Street
|
89
|
-
><ZipCode
|
90
|
-
>226 48</ZipCode
|
91
|
-
><City
|
92
|
-
>LUND</City
|
93
|
-
></PostalAddress
|
94
|
-
><CurrentlyEmployed
|
95
|
-
>true</CurrentlyEmployed
|
96
|
-
></Person
|
97
|
-
></Employees
|
98
|
-
><CustomValues
|
99
|
-
><CustomValue
|
100
|
-
><Field
|
101
|
-
>external_url</Field
|
102
|
-
><Value
|
103
|
-
>http://something.com?key=6</Value
|
104
|
-
></CustomValue
|
105
|
-
></CustomValues
|
106
|
-
><Tags
|
107
|
-
><Tag
|
108
|
-
>Imported</Tag
|
109
|
-
></Tags
|
110
|
-
><ResponsibleCoworker
|
111
|
-
><Heading
|
112
|
-
>Evil Elvis</Heading
|
113
|
-
><IntegrationId
|
114
|
-
>666</IntegrationId
|
115
|
-
></ResponsibleCoworker
|
116
|
-
></Organization
|
117
|
-
></Organizations
|
118
|
-
><Deals
|
119
|
-
><Deal
|
120
|
-
><IntegrationId
|
121
|
-
>333</IntegrationId
|
122
|
-
><Name
|
123
|
-
>Feta affären</Name
|
124
|
-
><Probability
|
125
|
-
>50</Probability
|
126
|
-
><Value
|
127
|
-
>10000</Value
|
128
|
-
><OfferDate
|
129
|
-
>2013-12-01</OfferDate
|
130
|
-
><OrderDate
|
131
|
-
>2014-01-05</OrderDate
|
132
|
-
><Customer
|
133
|
-
><IntegrationId
|
134
|
-
>6</IntegrationId
|
135
|
-
><Heading
|
136
|
-
>Alfs Mjukvaruutveckling</Heading
|
137
|
-
></Customer
|
138
|
-
><ResponsibleCoworker
|
139
|
-
><Heading
|
140
|
-
>Evil Elvis</Heading
|
141
|
-
><IntegrationId
|
142
|
-
>666</IntegrationId
|
143
|
-
></ResponsibleCoworker
|
144
|
-
><CustomerContact
|
145
|
-
><IntegrationId
|
146
|
-
>123</IntegrationId
|
147
|
-
></CustomerContact
|
148
|
-
></Deal
|
149
|
-
></Deals
|
150
|
-
><Notes
|
151
|
-
/></GoImport
|
152
|
-
>
|