fruit_to_lime 2.5.3 → 2.5.5

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.
Files changed (57) hide show
  1. data/lib/fruit_to_lime.rb +17 -17
  2. data/lib/fruit_to_lime/csv_helper.rb +47 -47
  3. data/lib/fruit_to_lime/email_helper.rb +10 -10
  4. data/lib/fruit_to_lime/errors.rb +16 -16
  5. data/lib/fruit_to_lime/excel_helper.rb +10 -10
  6. data/lib/fruit_to_lime/global_phone.json +6571 -6571
  7. data/lib/fruit_to_lime/model/address.rb +60 -60
  8. data/lib/fruit_to_lime/model/class_settings.rb +50 -50
  9. data/lib/fruit_to_lime/model/coworker.rb +76 -76
  10. data/lib/fruit_to_lime/model/coworker_reference.rb +33 -33
  11. data/lib/fruit_to_lime/model/customfield.rb +87 -87
  12. data/lib/fruit_to_lime/model/deal.rb +141 -145
  13. data/lib/fruit_to_lime/model/deal_status.rb +12 -12
  14. data/lib/fruit_to_lime/model/note.rb +79 -79
  15. data/lib/fruit_to_lime/model/organization.rb +203 -197
  16. data/lib/fruit_to_lime/model/person.rb +151 -151
  17. data/lib/fruit_to_lime/model/referencetosource.rb +45 -45
  18. data/lib/fruit_to_lime/model/relation.rb +23 -23
  19. data/lib/fruit_to_lime/model/rootmodel.rb +338 -330
  20. data/lib/fruit_to_lime/model/settings.rb +60 -60
  21. data/lib/fruit_to_lime/model/tag.rb +35 -35
  22. data/lib/fruit_to_lime/model_helpers.rb +54 -54
  23. data/lib/fruit_to_lime/phone_helper.rb +74 -74
  24. data/lib/fruit_to_lime/roo_helper.rb +72 -72
  25. data/lib/fruit_to_lime/serialize_helper.rb +186 -186
  26. data/lib/fruit_to_lime/templating.rb +52 -52
  27. data/spec/address_spec.rb +48 -48
  28. data/spec/class_settings_spec.rb +37 -37
  29. data/spec/coworker_spec.rb +94 -94
  30. data/spec/custom_field_spec.rb +22 -22
  31. data/spec/deal_spec.rb +101 -102
  32. data/spec/helpers/csv_helper_spec.rb +29 -29
  33. data/spec/helpers/email_helper_spec.rb +32 -32
  34. data/spec/helpers/phone_helper_spec.rb +97 -97
  35. data/spec/helpers/serialize_helper_spec.rb +249 -249
  36. data/spec/helpers/xsd_validate_spec.rb +58 -58
  37. data/spec/note_spec.rb +98 -67
  38. data/spec/organization_spec.rb +103 -89
  39. data/spec/person_spec.rb +134 -134
  40. data/spec/rootmodel_spec.rb +277 -230
  41. data/spec/templating_spec.rb +11 -11
  42. data/templates/csv/lib/tomodel.rb +230 -230
  43. data/templates/csv/spec/exporter_spec.rb +17 -17
  44. data/templates/csv/spec/sample_data/coworkers.csv +2 -2
  45. data/templates/csv/spec/sample_data/deals.csv +2 -2
  46. data/templates/csv/spec/sample_data/organizations.csv +2 -2
  47. data/templates/csv/spec/sample_data/persons.csv +2 -2
  48. data/templates/easy/Gemfile +5 -0
  49. data/templates/easy/Rakefile.rb +7 -0
  50. data/templates/easy/convert.rb +3 -0
  51. data/templates/easy/lib/tomodel.rb +330 -0
  52. data/templates/easy/spec/exporter_spec.rb +10 -0
  53. data/templates/easy/spec/sample_data/Company.txt +649 -0
  54. data/templates/easy/spec/spec_helper.rb +24 -0
  55. data/templates/excel/lib/tomodel.rb +207 -207
  56. data/templates/sqlserver/lib/tomodel.rb +79 -79
  57. metadata +10 -3
@@ -1,145 +1,141 @@
1
-
2
- module FruitToLime
3
- class DealReference
4
- include SerializeHelper
5
- attr_accessor :id, :integration_id
6
- def serialize_variables
7
- [ :id, :integration_id ].map { |prop| {:id => prop, :type => :string} }
8
- end
9
-
10
- def initalize()
11
- end
12
-
13
- def to_s
14
- return "(#{id}, #{integration_id})"
15
- end
16
-
17
- def empty?
18
- return !@integration_id && !@id
19
- end
20
-
21
- def self.from_deal(deal)
22
- if deal.nil?
23
- return nil
24
- elsif deal.is_a?(Deal)
25
- return deal.to_reference
26
- elsif person.is_a?(DealReference)
27
- return deal
28
- end
29
- end
30
- end
31
-
32
- class Deal
33
- include SerializeHelper, ModelHasCustomFields, ModelHasTags
34
-
35
- # Get/set the deal's status. Statuses must be configured in
36
- # LIME Go before the import.
37
- attr_accessor :status
38
-
39
- attr_accessor :id, :integration_id, :name, :description, :probability, :order_date
40
-
41
- # you add custom values by using {#set_custom_value}
42
- attr_reader :custom_values
43
-
44
- attr_reader :customer, :responsible_coworker, :customer_contact, :value
45
-
46
- def serialize_variables
47
- [ :id, :integration_id, :name, :description, :probability, :value, :order_date ].map {
48
- |p| {
49
- :id => p,
50
- :type => :string
51
- }
52
- } +
53
- [
54
- { :id => :customer, :type => :organization_reference },
55
- { :id => :responsible_coworker, :type => :coworker_reference },
56
- { :id => :customer_contact, :type => :person_reference },
57
- { :id => :custom_values, :type => :custom_values },
58
- { :id => :tags, :type => :tags },
59
- { :id => :status, :type => :deal_status }
60
- ]
61
- end
62
-
63
- def serialize_name
64
- "Deal"
65
- end
66
-
67
- def initialize(opt = nil)
68
- if !opt.nil?
69
- serialize_variables.each do |myattr|
70
- val = opt[myattr[:id]]
71
- instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
72
- end
73
- end
74
- end
75
-
76
- def to_s
77
- return "deal[id=#{@id}, integration_id=#{@integration_id}]"
78
- end
79
-
80
- def to_reference
81
- reference = DealReference.new
82
- reference.id = @id
83
- reference.integration_id = @integration_id
84
- return reference
85
- end
86
-
87
- def validate
88
- error = String.new
89
-
90
- if @name.nil? || @name.empty?
91
- error = "A name is required for deal.\n}"
92
- end
93
-
94
- if @customer.nil?
95
- error = "#{error}\nA customer is required for deal."
96
- end
97
-
98
- if error.length > 0
99
- error = "#{error}\n#{serialize()}"
100
- end
101
-
102
- return error
103
- end
104
-
105
- def with_status
106
- @status = DealStatus.new
107
- yield @status
108
- end
109
-
110
- def customer=(customer)
111
- @customer = OrganizationReference.from_organization(customer)
112
- end
113
-
114
- def responsible_coworker=(coworker)
115
- @responsible_coworker = CoworkerReference.from_coworker(coworker)
116
- end
117
-
118
- def customer_contact=(person)
119
- @customer_contact = PersonReference.from_person(person)
120
- end
121
-
122
- def value=(value)
123
- # we have had some issues with LIME Easy imports where the
124
- # value was in the format "357 000". We need to remove
125
- # those spaces.
126
- fixed_value = value.gsub(" ", "")
127
-
128
- if is_integer?(fixed_value)
129
- @value = fixed_value
130
- elsif is_float?(fixed_value)
131
- @value = fixed_value
132
- else
133
- raise InvalidValueError, value
134
- end
135
- end
136
-
137
- def is_integer?(value)
138
- true if Integer(value) rescue false
139
- end
140
-
141
- def is_float?(value)
142
- true if Float(value) rescue false
143
- end
144
- end
145
- end
1
+
2
+ module FruitToLime
3
+ class DealReference
4
+ include SerializeHelper
5
+ attr_accessor :id, :integration_id
6
+ def serialize_variables
7
+ [ :id, :integration_id ].map { |prop| {:id => prop, :type => :string} }
8
+ end
9
+
10
+ def initalize()
11
+ end
12
+
13
+ def to_s
14
+ return "(#{id}, #{integration_id})"
15
+ end
16
+
17
+ def empty?
18
+ return !@integration_id && !@id
19
+ end
20
+
21
+ def self.from_deal(deal)
22
+ if deal.nil?
23
+ return nil
24
+ elsif deal.is_a?(Deal)
25
+ return deal.to_reference
26
+ elsif person.is_a?(DealReference)
27
+ return deal
28
+ end
29
+ end
30
+ end
31
+
32
+ class Deal
33
+ include SerializeHelper, ModelHasCustomFields, ModelHasTags
34
+
35
+ # Get/set the deal's status. Statuses must be configured in
36
+ # LIME Go before the import.
37
+ attr_accessor :status
38
+
39
+ attr_accessor :id, :integration_id, :name, :description, :probability, :order_date
40
+
41
+ # you add custom values by using {#set_custom_value}
42
+ attr_reader :custom_values
43
+
44
+ attr_reader :customer, :responsible_coworker, :customer_contact, :value
45
+
46
+ def serialize_variables
47
+ [ :id, :integration_id, :name, :description, :probability, :value, :order_date ].map {
48
+ |p| {
49
+ :id => p,
50
+ :type => :string
51
+ }
52
+ } +
53
+ [
54
+ { :id => :customer, :type => :organization_reference },
55
+ { :id => :responsible_coworker, :type => :coworker_reference },
56
+ { :id => :customer_contact, :type => :person_reference },
57
+ { :id => :custom_values, :type => :custom_values },
58
+ { :id => :tags, :type => :tags },
59
+ { :id => :status, :type => :deal_status }
60
+ ]
61
+ end
62
+
63
+ def serialize_name
64
+ "Deal"
65
+ end
66
+
67
+ def initialize(opt = nil)
68
+ if !opt.nil?
69
+ serialize_variables.each do |myattr|
70
+ val = opt[myattr[:id]]
71
+ instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
72
+ end
73
+ end
74
+ end
75
+
76
+ def to_s
77
+ return "deal[id=#{@id}, integration_id=#{@integration_id}]"
78
+ end
79
+
80
+ def to_reference
81
+ reference = DealReference.new
82
+ reference.id = @id
83
+ reference.integration_id = @integration_id
84
+ return reference
85
+ end
86
+
87
+ def validate
88
+ error = String.new
89
+
90
+ if @name.nil? || @name.empty?
91
+ error = "A name is required for deal.\n}"
92
+ end
93
+
94
+ if error.length > 0
95
+ error = "#{error}\n#{serialize()}"
96
+ end
97
+
98
+ return error
99
+ end
100
+
101
+ def with_status
102
+ @status = DealStatus.new
103
+ yield @status
104
+ end
105
+
106
+ def customer=(customer)
107
+ @customer = OrganizationReference.from_organization(customer)
108
+ end
109
+
110
+ def responsible_coworker=(coworker)
111
+ @responsible_coworker = CoworkerReference.from_coworker(coworker)
112
+ end
113
+
114
+ def customer_contact=(person)
115
+ @customer_contact = PersonReference.from_person(person)
116
+ end
117
+
118
+ def value=(value)
119
+ # we have had some issues with LIME Easy imports where the
120
+ # value was in the format "357 000". We need to remove
121
+ # those spaces.
122
+ fixed_value = value.gsub(" ", "")
123
+
124
+ if is_integer?(fixed_value)
125
+ @value = fixed_value
126
+ elsif is_float?(fixed_value)
127
+ @value = fixed_value
128
+ else
129
+ raise InvalidValueError, value
130
+ end
131
+ end
132
+
133
+ def is_integer?(value)
134
+ true if Integer(value) rescue false
135
+ end
136
+
137
+ def is_float?(value)
138
+ true if Float(value) rescue false
139
+ end
140
+ end
141
+ end
@@ -1,12 +1,12 @@
1
- module FruitToLime
2
- class DealStatus
3
- include SerializeHelper
4
-
5
- attr_accessor :id, :label, :date, :note
6
-
7
- def serialize_variables
8
- [ :id, :label, :note ].map{ |p| { :id => p, :type => :string } } +
9
- [ :date ].map { |p| { :id => p, :type => :date } }
10
- end
11
- end
12
- end
1
+ module FruitToLime
2
+ class DealStatus
3
+ include SerializeHelper
4
+
5
+ attr_accessor :id, :label, :date, :note
6
+
7
+ def serialize_variables
8
+ [ :id, :label, :note ].map{ |p| { :id => p, :type => :string } } +
9
+ [ :date ].map { |p| { :id => p, :type => :date } }
10
+ end
11
+ end
12
+ end
@@ -1,79 +1,79 @@
1
- module FruitToLime
2
- class Note
3
- include SerializeHelper
4
- attr_accessor :id, :text, :integration_id, :classification, :date
5
-
6
- attr_reader :organization, :created_by, :person, :deal
7
-
8
- def initialize(opt = nil)
9
- if !opt.nil?
10
- serialize_variables.each do |myattr|
11
- val = opt[myattr[:id]]
12
- instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
13
- end
14
- end
15
- end
16
-
17
- def serialize_variables
18
- [ :id, :text, :integration_id, :classification ].map {
19
- |p| {
20
- :id => p,
21
- :type => :string
22
- }
23
- } +
24
- [
25
- { :id => :date, :type => :date },
26
- { :id => :created_by, :type => :coworker_reference },
27
- { :id => :organization, :type => :organization_reference },
28
- { :id => :person, :type => :person_reference }
29
- ]
30
- end
31
-
32
- def get_import_rows
33
- (serialize_variables+[
34
- {:id=>:organization, :type=>:organization_reference},
35
- {:id=>:person, :type=>:person_reference}
36
- ]).map do |p|
37
- map_to_row p
38
- end
39
- end
40
-
41
- def serialize_name
42
- "Note"
43
- end
44
-
45
- def organization=(org)
46
- @organization = OrganizationReference.from_organization(org)
47
- end
48
-
49
- def created_by=(coworker)
50
- @created_by = CoworkerReference.from_coworker(coworker)
51
- end
52
-
53
- def person=(person)
54
- @person = PersonReference.from_person(person)
55
- end
56
-
57
- def deal=(deal)
58
- @deal = DealReference.from_deal(deal)
59
- end
60
-
61
- def validate
62
- error = String.new
63
-
64
- if @text.nil? || @text.empty?
65
- error = "Text is required for note\n"
66
- end
67
-
68
- if @created_by.nil?
69
- error = "#{error}Created_by is required for note\n"
70
- end
71
-
72
- if @organization.nil?
73
- error = "#{error}Organization is required for note\n"
74
- end
75
-
76
- return error
77
- end
78
- end
79
- end
1
+ module FruitToLime
2
+ class Note
3
+ include SerializeHelper
4
+ attr_accessor :id, :text, :integration_id, :classification, :date
5
+
6
+ attr_reader :organization, :created_by, :person, :deal
7
+
8
+ def initialize(opt = nil)
9
+ if !opt.nil?
10
+ serialize_variables.each do |myattr|
11
+ val = opt[myattr[:id]]
12
+ instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
13
+ end
14
+ end
15
+ end
16
+
17
+ def serialize_variables
18
+ [ :id, :text, :integration_id, :classification ].map {
19
+ |p| {
20
+ :id => p,
21
+ :type => :string
22
+ }
23
+ } +
24
+ [
25
+ { :id => :date, :type => :date },
26
+ { :id => :created_by, :type => :coworker_reference },
27
+ { :id => :organization, :type => :organization_reference },
28
+ { :id => :person, :type => :person_reference }
29
+ ]
30
+ end
31
+
32
+ def get_import_rows
33
+ (serialize_variables+[
34
+ {:id=>:organization, :type=>:organization_reference},
35
+ {:id=>:person, :type=>:person_reference}
36
+ ]).map do |p|
37
+ map_to_row p
38
+ end
39
+ end
40
+
41
+ def serialize_name
42
+ "Note"
43
+ end
44
+
45
+ def organization=(org)
46
+ @organization = OrganizationReference.from_organization(org)
47
+ end
48
+
49
+ def created_by=(coworker)
50
+ @created_by = CoworkerReference.from_coworker(coworker)
51
+ end
52
+
53
+ def person=(person)
54
+ @person = PersonReference.from_person(person)
55
+ end
56
+
57
+ def deal=(deal)
58
+ @deal = DealReference.from_deal(deal)
59
+ end
60
+
61
+ def validate
62
+ error = String.new
63
+
64
+ if @text.nil? || @text.empty?
65
+ error = "Text is required for note\n"
66
+ end
67
+
68
+ if @created_by.nil?
69
+ error = "#{error}Created_by is required for note\n"
70
+ end
71
+
72
+ if @organization.nil? && @deal.nil? && @person.nil?
73
+ error = "#{error}Organization, deal or person is required for note\n"
74
+ end
75
+
76
+ return error
77
+ end
78
+ end
79
+ end