fruit_to_lime 0.9.3 → 2.0.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.
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+ module FruitToLime
3
+ class ClassSettings
4
+ include SerializeHelper
5
+ attr_reader :custom_fields
6
+
7
+ def initialize(opt = nil)
8
+ if opt != nil
9
+ serialize_variables.each do |myattr|
10
+ val = opt[myattr[:id]]
11
+ instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
12
+ end
13
+ end
14
+ end
15
+
16
+ def serialize_variables
17
+ [{:id => :custom_fields, :type => :custom_fields} ]
18
+ end
19
+
20
+ def serialize_name
21
+ "ClassSettings"
22
+ end
23
+
24
+ def set_custom_field(obj)
25
+ @custom_fields = [] if @custom_fields==nil
26
+
27
+ field = CustomField.new(obj)
28
+
29
+ index = @custom_fields.find_index do |custom_field|
30
+ custom_field.same_as?(field)
31
+ end
32
+ if index
33
+ @custom_fields.delete_at index
34
+ end
35
+
36
+ @custom_fields.push field
37
+
38
+ return field
39
+ end
40
+
41
+ def add_custom_field(obj)
42
+ @custom_fields = [] if @custom_fields==nil
43
+
44
+ field = CustomField.new(obj)
45
+ @custom_fields.push field
46
+
47
+ return field
48
+ end
49
+ end
50
+ end
@@ -1,8 +1,8 @@
1
1
  module FruitToLime
2
- class CustomField
2
+ class CustomFieldReference
3
3
  include SerializeHelper, ModelWithIntegrationIdSameAs
4
4
 
5
- attr_accessor :id, :integration_id, :title, :value
5
+ attr_accessor :id, :integration_id
6
6
 
7
7
  def initialize(opt=nil)
8
8
  if opt != nil
@@ -14,7 +14,35 @@ module FruitToLime
14
14
  end
15
15
 
16
16
  def serialize_variables
17
- [:id, :integration_id, :title, :value].map {|p| { :id => p, :type => :string } }
17
+ [:id, :integration_id].map {|p| { :id => p, :type => :string } }
18
+ end
19
+
20
+ def get_import_rows
21
+ serialize_variables.map do |p|
22
+ map_to_row p
23
+ end
24
+ end
25
+
26
+ def serialize_name
27
+ "CustomFieldReference"
28
+ end
29
+ end
30
+
31
+ class CustomField
32
+ include SerializeHelper, ModelWithIntegrationIdSameAs
33
+ attr_accessor :id, :integration_id, :title, :type
34
+
35
+ def initialize(opt=nil)
36
+ if opt != nil
37
+ serialize_variables.each do |myattr|
38
+ val = opt[myattr[:id]]
39
+ instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
40
+ end
41
+ end
42
+ end
43
+
44
+ def serialize_variables
45
+ [:id, :integration_id, :title, :type].map {|p| { :id => p, :type => :string } }
18
46
  end
19
47
 
20
48
  def get_import_rows
@@ -27,4 +55,33 @@ module FruitToLime
27
55
  "CustomField"
28
56
  end
29
57
  end
58
+
59
+ class CustomValue
60
+ include SerializeHelper
61
+ attr_accessor :field, :value
62
+
63
+ def initialize(opt=nil)
64
+ if opt != nil
65
+ serialize_variables.each do |myattr|
66
+ val = opt[myattr[:id]]
67
+ instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
68
+ end
69
+ end
70
+ end
71
+
72
+ def serialize_variables
73
+ [ { :id =>:field, :type => :custom_field_reference },
74
+ { :id =>:value, :type => :string }]
75
+ end
76
+
77
+ def get_import_rows
78
+ serialize_variables.map do |p|
79
+ map_to_row p
80
+ end
81
+ end
82
+
83
+ def serialize_name
84
+ "CustomValue"
85
+ end
86
+ end
30
87
  end
@@ -6,7 +6,7 @@ module FruitToLime
6
6
  attr_accessor :id, :integration_id, :name, :description, :probability, :value, :order_date, :offer_date, :customer,
7
7
  :responsible_coworker, :customer_contact, :status
8
8
 
9
- attr_reader :custom_fields
9
+ attr_reader :custom_values
10
10
 
11
11
  def serialize_variables
12
12
  [ :id, :integration_id, :name, :description, :probability, :value, :offer_date, :order_date ].map {
@@ -19,7 +19,7 @@ module FruitToLime
19
19
  { :id => :customer, :type => :organization_reference },
20
20
  { :id => :responsible_coworker, :type => :coworker_reference },
21
21
  { :id => :customer_contact, :type => :person_reference },
22
- { :id => :custom_fields, :type => :custom_fields },
22
+ { :id => :custom_values, :type => :custom_values },
23
23
  { :id => :tags, :type => :tags },
24
24
  { :id => :status, :type => :deal_status }
25
25
  ]
@@ -102,22 +102,22 @@ module FruitToLime
102
102
  end
103
103
 
104
104
  def serialize_variables
105
- [
106
- { :id => :id, :type => :string },
107
- { :id => :integration_id, :type => :string },
108
- { :id => :source, :type => :source_ref },
109
- { :id => :name, :type => :string },
110
- { :id => :organization_number, :type => :string },
111
- { :id => :postal_address, :type => :address },
112
- { :id => :visit_address, :type => :address },
113
- { :id => :central_phone_number, :type => :string },
114
- { :id => :email, :type => :string },
115
- { :id => :web_site, :type => :string },
116
- { :id => :employees, :type => :persons },
117
- { :id => :custom_fields, :type => :custom_fields },
118
- { :id => :tags, :type => :tags },
119
- { :id => :responsible_coworker, :type => :coworker_reference}
120
- ]
105
+ [
106
+ { :id => :id, :type => :string },
107
+ { :id => :integration_id, :type => :string },
108
+ { :id => :source, :type => :source_ref },
109
+ { :id => :name, :type => :string },
110
+ { :id => :organization_number, :type => :string },
111
+ { :id => :postal_address, :type => :address },
112
+ { :id => :visit_address, :type => :address },
113
+ { :id => :central_phone_number, :type => :string },
114
+ { :id => :email, :type => :string },
115
+ { :id => :web_site, :type => :string },
116
+ { :id => :employees, :type => :persons },
117
+ { :id => :custom_values, :type => :custom_values },
118
+ { :id => :tags, :type => :tags },
119
+ { :id => :responsible_coworker, :type => :coworker_reference}
120
+ ]
121
121
  end
122
122
 
123
123
  def serialize_name
@@ -35,7 +35,7 @@ module FruitToLime
35
35
  :direct_phone_number, :fax_phone_number, :mobile_phone_number, :home_phone_number,
36
36
  :position, :email, :alternative_email, :postal_address, :currently_employed,
37
37
  :organization
38
- attr_reader :custom_fields
38
+ attr_reader :custom_values
39
39
 
40
40
  def initialize(opt = nil)
41
41
  @currently_employed = true
@@ -86,7 +86,7 @@ module FruitToLime
86
86
  {:id => :alternative_email, :type => :string},
87
87
 
88
88
  {:id => :postal_address, :type => :address},
89
- {:id => :custom_fields, :type => :custom_fields},
89
+ {:id => :custom_values, :type => :custom_values},
90
90
  {:id => :currently_employed, :type => :bool},
91
91
  {:id => :organization, :type => :organization_reference},
92
92
 
@@ -3,11 +3,12 @@ module FruitToLime
3
3
  class RootModel
4
4
  # the import_coworker is a special coworker that is set as
5
5
  # responsible for objects that requires a coworker, eg a note.
6
- attr_accessor :organizations, :coworkers, :deals, :notes, :import_coworker
6
+ attr_accessor :settings, :organizations, :coworkers, :deals, :notes, :import_coworker
7
7
  def serialize_variables
8
8
  [
9
- {:id => :organizations, :type => :organizations},
9
+ {:id => :settings, :type => :settings},
10
10
  {:id => :coworkers, :type => :coworkers},
11
+ {:id => :organizations, :type => :organizations},
11
12
  {:id => :deals, :type => :deals},
12
13
  {:id => :notes, :type => :notes},
13
14
  ]
@@ -20,6 +21,7 @@ module FruitToLime
20
21
  include SerializeHelper
21
22
 
22
23
  def initialize()
24
+ @settings = Settings.new
23
25
  @organizations = []
24
26
  @coworkers = []
25
27
  @import_coworker = Coworker.new
@@ -142,7 +144,7 @@ module FruitToLime
142
144
 
143
145
  def to_rexml(doc)
144
146
  element_name = serialize_name
145
- elem = doc.add_element(element_name,{"Version"=>"v1_0"})
147
+ elem = doc.add_element(element_name,{"Version"=>"v2_0"})
146
148
  SerializeHelper::serialize_variables_rexml(elem, self)
147
149
  end
148
150
  end
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ module FruitToLime
3
+ class Settings
4
+ include SerializeHelper
5
+ attr_reader :organization, :person, :deal
6
+ def with_organization
7
+ @organization = ClassSettings.new if @organization ==nil
8
+ yield @organization
9
+ end
10
+ def with_person
11
+ @person = ClassSettings.new if @person ==nil
12
+ yield @person
13
+ end
14
+ def with_deal
15
+ @deal = ClassSettings.new if @deal ==nil
16
+ yield @deal
17
+ end
18
+ def initialize(opt = nil)
19
+ if opt != nil
20
+ serialize_variables.each do |myattr|
21
+ val = opt[myattr[:id]]
22
+ instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
23
+ end
24
+ end
25
+ end
26
+
27
+ def serialize_variables
28
+ [:organization, :person, :deal].map {|p| {:id => p, :type => :class_settings} }
29
+ end
30
+
31
+ def serialize_name
32
+ "Settings"
33
+ end
34
+ end
35
+ end
@@ -1,29 +1,30 @@
1
1
  module FruitToLime
2
2
  module ModelHasCustomFields
3
- def set_custom_field(obj)
4
- @custom_fields = [] if @custom_fields==nil
5
- new_custom_field = CustomField.new(obj)
6
- index = @custom_fields.find_index do |custom_field|
7
- custom_field.same_as?(new_custom_field)
3
+ def set_custom_value(value, field)
4
+ @custom_values = [] if @custom_values==nil
5
+ custom_value = CustomValue.new()
6
+ custom_value.value = value
7
+ custom_value.field = field
8
+ index = @custom_values.find_index do |custom_value|
9
+ custom_value.field.same_as?(field)
8
10
  end
9
11
  if index
10
- @custom_fields.delete_at index
12
+ @custom_values.delete_at index
11
13
  end
12
- @custom_fields.push new_custom_field
13
- return new_custom_field
14
- end
15
14
 
16
- def add_custom_field(obj)
17
- @custom_fields = [] if @custom_fields==nil
18
- custom_field = CustomField.new(obj)
19
- @custom_fields.push custom_field
20
- return custom_field
15
+ @custom_values.push custom_value
16
+ return custom_value
17
+ end
18
+ def set_custom_field(obj)
19
+ value = obj[:value]
20
+ ref = CustomFieldReference.new(obj)
21
+ return set_custom_value(value, ref)
21
22
  end
22
23
  end
23
24
 
24
25
  module ModelWithIntegrationIdSameAs
25
26
  def same_as?(other)
26
- if @integration_id!=nil && @integration_id == other.integration_id
27
+ if @integration_id!=nil && @integration_id == other.integration_id
27
28
  return true
28
29
  end
29
30
  if @id != nil && @id == other.id
@@ -40,7 +41,7 @@ module FruitToLime
40
41
  end
41
42
  def set_tag(str)
42
43
  @tags = [] if @tags == nil
43
- if ! @tags.any? {|tag| tag.value = str }
44
+ if ! @tags.any? {|tag| tag.value = str }
44
45
  @tags.push(Tag.new(str))
45
46
  end
46
47
  end
@@ -119,6 +119,13 @@ module FruitToLime
119
119
  :name => symbol_to_name(p[:id]),
120
120
  :models => SerializeHelper.get_import_rows(:custom_field)
121
121
  }
122
+ when :custom_values then
123
+ {
124
+ :id => p[:id].to_s,
125
+ :type => p[:type],
126
+ :name => symbol_to_name(p[:id]),
127
+ :models => SerializeHelper.get_import_rows(:custom_value)
128
+ }
122
129
  else
123
130
  {
124
131
  :id => p[:id].to_s,
@@ -153,6 +160,14 @@ module FruitToLime
153
160
  OrganizationReference.new
154
161
  when :custom_field then
155
162
  CustomField.new
163
+ when :custom_value then
164
+ CustomValue.new
165
+ when :custom_field_reference then
166
+ CustomFieldReference.new
167
+ when :settings then
168
+ Settings.new
169
+ when :class_settings then
170
+ ClassSettings.new
156
171
  else
157
172
  raise "Unknown type: #{type}"
158
173
  end.get_import_rows
@@ -5,19 +5,16 @@ describe "CustomField" do
5
5
  before (:all) do
6
6
  @custom_field = FruitToLime::CustomField.new({:id => 'the id',
7
7
  :integration_id=>'the key',
8
- :title=> 'the title',
9
8
  :value=> 'the value'})
10
9
  end
11
10
 
12
11
  it "is the same as a custom field with the same integration_id" do
13
12
  @custom_field.same_as?(FruitToLime::CustomField.new({:integration_id=>'the key',
14
- :title=> 'the title 2',
15
13
  :value=> 'the value 2'})).should eq true
16
14
  end
17
15
 
18
16
  it "is the same as a custom field with the same id" do
19
17
  @custom_field.same_as?(FruitToLime::CustomField.new({:id=>'the id',
20
- :title=> 'the title 2',
21
18
  :value=> 'the value 2'})).should eq true
22
19
  end
23
20
 
@@ -31,6 +31,20 @@ describe FruitToLime::SerializeHelper do
31
31
  end
32
32
  end
33
33
 
34
+ describe "Serialize custom value with xml inside" do
35
+ let(:serialized) {
36
+ v = FruitToLime::CustomValue.new
37
+ v.value = "<text>"
38
+ v.field = FruitToLime::CustomFieldReference.new()
39
+ v.field.id = "1"
40
+ FruitToLime::SerializeHelper::serialize(v,-1)
41
+ }
42
+ it "should contain encoded text" do
43
+ serialized.should match(/<Value>[\n ]*&lt;text&gt;[\n ]*<\/Value>/)
44
+ end
45
+
46
+ end
47
+
34
48
  describe "Serialize without data" do
35
49
  let(:serialized) {
36
50
  p = FruitToLime::Person.new
@@ -41,7 +55,7 @@ describe FruitToLime::SerializeHelper do
41
55
  serialized.should_not match(/<Position>/)
42
56
  serialized.should_not match(/<AlternativeEmail>/)
43
57
  serialized.should_not match(/<Tags>/)
44
- serialized.should_not match(/<CustomFields>/)
58
+ serialized.should_not match(/<CustomValues>/)
45
59
  end
46
60
  it "should be utf-8" do
47
61
  serialized.encoding.should equal Encoding::UTF_8
@@ -65,9 +79,9 @@ describe FruitToLime::SerializeHelper do
65
79
  p.add_tag("tag:anka")
66
80
  p.add_tag("tag:Bj\u{00F6}rk")
67
81
  p.add_tag("tag:<Bj\u{00F6}rk>")
68
- p.set_custom_field({:id=>"2", :title=>"cf title", :value=>"cf value"})
69
- p.set_custom_field({:id=>"3", :title=>"cf title2", :value=>"cf Bj\u{00F6}rk"})
70
- p.set_custom_field({:id=>"4", :title=>"cf <title3>", :value=>"cf <Bj\u{00F6}rk>"})
82
+ p.set_custom_field({:integration_id=>"2", :value=>"cf value"})
83
+ p.set_custom_field({:integration_id=>"3", :value=>"cf Bj\u{00F6}rk"})
84
+ p.set_custom_field({:integration_id=>"4", :value=>"cf <Bj\u{00F6}rk>"})
71
85
  FruitToLime::SerializeHelper::serialize(p,-1)
72
86
  }
73
87
  it "should contain first and last name" do
@@ -84,7 +98,6 @@ describe FruitToLime::SerializeHelper do
84
98
  serialized.should match(/Ankeborg/)
85
99
  end
86
100
  it "should contain custom field" do
87
- serialized.should match(/cf title/)
88
101
  serialized.should match(/cf value/)
89
102
  end
90
103
  it "should contain reference to source" do
@@ -116,8 +129,8 @@ describe FruitToLime::SerializeHelper do
116
129
  #o.source_ref = {:name=>'Go',:id=>"PASE122345"}
117
130
  o.add_tag("tag:bibliotek")
118
131
  o.add_tag("tag:Bj\u{00F6}rk")
119
- o.set_custom_field({:id=>"2", :title=>"cf title", :value=>"cf value"})
120
- o.set_custom_field({:id=>"3", :title=>"cf title2", :value=>"cf Bj\u{00F6}rk"})
132
+ o.set_custom_field({:integration_id=>"2", :value=>"cf value"})
133
+ o.set_custom_field({:integration_id=>"3", :value=>"cf Bj\u{00F6}rk"})
121
134
  o.with_postal_address do |addr|
122
135
  addr.city = "Ankeborg"
123
136
  end
@@ -125,7 +138,7 @@ describe FruitToLime::SerializeHelper do
125
138
  addr.city = "Gaaseborg"
126
139
  end
127
140
  o.add_employee({
128
- :id => "1",
141
+ :integration_id => "1",
129
142
  :first_name => "Kalle",
130
143
  :last_name => "Anka"
131
144
  })
@@ -146,7 +159,6 @@ describe FruitToLime::SerializeHelper do
146
159
  serialized.should match(/<Tag>[\n ]*tag:bibliotek[\n ]*<\/Tag>/)
147
160
  end
148
161
  it "should contain custom field" do
149
- serialized.should match(/cf title/)
150
162
  serialized.should match(/cf value/)
151
163
  #puts serialized
152
164
  end
@@ -175,6 +187,9 @@ describe FruitToLime::SerializeHelper do
175
187
  it "should contain name" do
176
188
  serialized.should match(/Ankeborgs bibliotek/)
177
189
  end
190
+ it "should have version" do
191
+ serialized.should match(/<GoImport Version='v2_0'/)
192
+ end
178
193
  it "should be utf-8" do
179
194
  serialized.encoding.should equal Encoding::UTF_8
180
195
  end
@@ -7,6 +7,10 @@ describe FruitToLime::SerializeHelper do
7
7
  describe "Validate according to xsd" do
8
8
  let(:validate_result) {
9
9
  i = FruitToLime::RootModel.new
10
+ i.settings.with_organization do |s|
11
+ s.set_custom_field({:integration_id=>"2", :title=>"cf title"})
12
+ s.set_custom_field({:integration_id=>"3", :title=>"cf title2"})
13
+ end
10
14
  o = FruitToLime::Organization.new
11
15
  o.name = "Ankeborgs bibliotek"
12
16
  o.with_source do |source|
@@ -15,8 +19,8 @@ describe FruitToLime::SerializeHelper do
15
19
  #o.source_ref = {:name=>'Go',:id=>"PASE122345"}
16
20
  o.add_tag("tag:bibliotek")
17
21
  o.add_tag("tag:Bj\u{00F6}rk")
18
- o.set_custom_field({:id=>"2", :title=>"cf title", :value=>"cf value"})
19
- o.set_custom_field({:id=>"3", :title=>"cf title2", :value=>"cf Bj\u{00F6}rk"})
22
+ o.set_custom_field({:integration_id=>"2", :value=>"cf value"})
23
+ o.set_custom_field({:integration_id=>"3", :value=>"cf Bj\u{00F6}rk"})
20
24
  o.with_postal_address do |addr|
21
25
  addr.city = "Ankeborg"
22
26
  end
@@ -24,10 +28,10 @@ describe FruitToLime::SerializeHelper do
24
28
  addr.city = "Gaaseborg"
25
29
  end
26
30
  o.add_responsible_coworker({
27
- :id => "1"
31
+ :integration_id => "1"
28
32
  })
29
33
  emp = o.add_employee({
30
- :id => "1",
34
+ :integration_id => "1",
31
35
  :first_name => "Kalle",
32
36
  :last_name => "Anka"
33
37
  })
data/spec/person_spec.rb CHANGED
@@ -8,43 +8,48 @@ describe "Person" do
8
8
 
9
9
  it "can set a customfield" do
10
10
  person.set_custom_field({:integration_id=>'the key',
11
- :title=> 'the title',
12
11
  :value=> 'the value'})
13
12
 
14
- field = person.custom_fields[0]
13
+ value = person.custom_values[0]
14
+ field = value.field
15
15
  field.integration_id.should eq 'the key'
16
- field.title.should eq 'the title'
17
- field.value.should eq 'the value'
16
+ value.value.should eq 'the value'
18
17
  end
19
18
 
20
19
  it "will set custom field with same integration_id to the last value" do
21
20
  person.set_custom_field({:integration_id=>'the key',
22
- :title=> 'the title',
23
21
  :value=> 'the value'})
24
22
 
25
23
  person.set_custom_field({:integration_id=>'the key',
26
- :title=> 'the title 2',
27
24
  :value=> 'the value 2'})
28
- person.custom_fields.length.should eq 1
29
- field = person.custom_fields[0]
25
+ value = person.custom_values[0]
26
+ field = value.field
27
+
28
+ person.custom_values.length.should eq 1
30
29
  field.integration_id.should eq 'the key'
31
- field.title.should eq 'the title 2'
32
- field.value.should eq 'the value 2'
30
+ value.value.should eq 'the value 2'
33
31
  end
34
32
 
35
33
  it "will set custom field with same id to the last value" do
36
34
  person.set_custom_field({:id=>'the id',
37
- :title=> 'the title',
38
35
  :value=> 'the value'})
39
36
 
40
37
  person.set_custom_field({:id=>'the id',
41
- :title=> 'the title 2',
42
38
  :value=> 'the value 2'})
43
- person.custom_fields.length.should eq 1
44
- field = person.custom_fields[0]
39
+ value = person.custom_values[0]
40
+ field = value.field
41
+
42
+ person.custom_values.length.should eq 1
45
43
  field.id.should eq 'the id'
46
- field.title.should eq 'the title 2'
47
- field.value.should eq 'the value 2'
44
+ value.value.should eq 'the value 2'
45
+ end
46
+
47
+ it "will only set tag once" do
48
+ person.set_tag('tag1')
49
+ person.set_tag('tag1')
50
+ person.tags.length.should eq 1
51
+ tag = person.tags[0]
52
+ tag.value.should eq 'tag1'
48
53
  end
49
54
 
50
55
  it "should have a firstname if no lastname" do
@@ -8,8 +8,20 @@ class ToModel
8
8
  return organization
9
9
  end
10
10
 
11
+ def configure(model)
12
+ # add custom field to your model here. Custom fields can be
13
+ # added to organization, deal and person. Valid types are
14
+ # :String and :Link. If no type is specified :String is used
15
+ # as default.
16
+
17
+ model.settings.with_deal do |deal|
18
+ deal.set_custom_field( { :integrationid => 'discount_url', :title => 'Rabatt url', :type => :Link } )
19
+ end
20
+ end
21
+
11
22
  def to_model(organization_file_name)
12
23
  rootmodel = FruitToLime::RootModel.new
24
+ configure model
13
25
  if organization_file_name != nil
14
26
  organization_file_data = File.open(organization_file_name, 'r').read.encode('UTF-8',"ISO-8859-1")
15
27
  rows = FruitToLime::CsvHelper::text_to_hashes(organization_file_data)
@@ -11,11 +11,23 @@ class ToModel
11
11
  return organization
12
12
  end
13
13
 
14
+ def configure(model)
15
+ # add custom field to your model here. Custom fields can be
16
+ # added to organization, deal and person. Valid types are
17
+ # :String and :Link. If no type is specified :String is used
18
+ # as default.
19
+
20
+ model.settings.with_deal do |deal|
21
+ deal.set_custom_field( { :integrationid => 'discount_url', :title => 'Rabatt url', :type => :Link } )
22
+ end
23
+ end
24
+
14
25
  def to_model(organization_file_name)
15
26
  # from excel to csv
16
27
  organization_file_data = Roo::Excelx.new(organization_file_name)
17
28
 
18
29
  model = FruitToLime::RootModel.new
30
+ configure model
19
31
  rows = FruitToLime::RooHelper.new(organization_file_data).rows
20
32
  rows.each do |row|
21
33
  model.organizations.push(to_organization(row))
@@ -10,8 +10,20 @@ class ToModel
10
10
  return organization
11
11
  end
12
12
 
13
+ def configure(model)
14
+ # add custom field to your model here. Custom fields can be
15
+ # added to organization, deal and person. Valid types are
16
+ # :String and :Link. If no type is specified :String is used
17
+ # as default.
18
+
19
+ model.settings.with_deal do |deal|
20
+ deal.set_custom_field( { :integrationid => 'discount_url', :title => 'Rabatt url', :type => :Link } )
21
+ end
22
+ end
23
+
13
24
  def to_model(organization_rows)
14
25
  model = FruitToLime::RootModel.new
26
+ configure model
15
27
 
16
28
  organization_rows.each do |row|
17
29
  model.organizations.push(to_organization(row))
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: 0.9.3
4
+ version: 2.0.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-04-03 00:00:00.000000000 Z
14
+ date: 2014-04-10 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: iso_country_codes
@@ -138,6 +138,7 @@ files:
138
138
  - lib/fruit_to_lime/address_helper.rb
139
139
  - lib/fruit_to_lime/csv_helper.rb
140
140
  - lib/fruit_to_lime/model/address.rb
141
+ - lib/fruit_to_lime/model/class_settings.rb
141
142
  - lib/fruit_to_lime/model/coworker.rb
142
143
  - lib/fruit_to_lime/model/coworker_reference.rb
143
144
  - lib/fruit_to_lime/model/customfield.rb
@@ -148,6 +149,7 @@ files:
148
149
  - lib/fruit_to_lime/model/person.rb
149
150
  - lib/fruit_to_lime/model/referencetosource.rb
150
151
  - lib/fruit_to_lime/model/rootmodel.rb
152
+ - lib/fruit_to_lime/model/settings.rb
151
153
  - lib/fruit_to_lime/model/tag.rb
152
154
  - lib/fruit_to_lime/model_helpers.rb
153
155
  - lib/fruit_to_lime/roo_helper.rb