fruit_to_lime 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/fruit_to_lime +24 -24
- data/lib/fruit_to_lime/address_helper.rb +17 -17
- data/lib/fruit_to_lime/csv_helper.rb +32 -32
- data/lib/fruit_to_lime/model/address.rb +37 -37
- data/lib/fruit_to_lime/model/coworker.rb +44 -44
- data/lib/fruit_to_lime/model/coworker_reference.rb +17 -17
- data/lib/fruit_to_lime/model/customfield.rb +30 -30
- data/lib/fruit_to_lime/model/note.rb +38 -38
- data/lib/fruit_to_lime/model/organization.rb +140 -140
- data/lib/fruit_to_lime/model/person.rb +115 -115
- data/lib/fruit_to_lime/model/referencetosource.rb +42 -42
- data/lib/fruit_to_lime/model/rootmodel.rb +142 -142
- data/lib/fruit_to_lime/model/tag.rb +33 -33
- data/lib/fruit_to_lime/model_helpers.rb +19 -19
- data/lib/fruit_to_lime/roo_helper.rb +59 -59
- data/lib/fruit_to_lime/serialize_helper.rb +139 -139
- data/lib/fruit_to_lime/templating.rb +51 -51
- data/lib/fruit_to_lime.rb +13 -13
- data/spec/helpers/address_helper_spec.rb +48 -48
- data/spec/helpers/csv_helper_spec.rb +15 -15
- data/spec/helpers/roo_helper_spec.rb +10 -10
- data/spec/helpers/serialize_helper_spec.rb +211 -211
- data/spec/person_spec.rb +44 -44
- data/spec/spec_helper.rb +24 -24
- data/templates/csv/Gemfile +5 -5
- data/templates/csv/Rakefile.rb +7 -7
- data/templates/csv/convert.rb +2 -2
- data/templates/csv/lib/tomodel.rb +56 -56
- data/templates/csv/spec/sample_data/organizations.csv +2 -2
- data/templates/csv/spec/spec_helper.rb +24 -24
- data/templates/csv/spec/tomodel_spec.rb +14 -14
- data/templates/excel/Gemfile +6 -6
- data/templates/excel/Rakefile.rb +7 -7
- data/templates/excel/convert.rb +2 -2
- data/templates/excel/lib/tomodel.rb +53 -53
- data/templates/excel/spec/spec_helper.rb +20 -20
- data/templates/excel/spec/tomodel_spec.rb +18 -18
- data/templates/sqlserver/Gemfile +6 -6
- data/templates/sqlserver/Rakefile.rb +7 -7
- data/templates/sqlserver/convert.rb +2 -2
- data/templates/sqlserver/lib/tomodel.rb +67 -67
- data/templates/sqlserver/spec/spec_helper.rb +20 -20
- data/templates/sqlserver/spec/tomodel_spec.rb +9 -9
- metadata +2 -2
@@ -1,140 +1,140 @@
|
|
1
|
-
module FruitToLime
|
2
|
-
class OrganizationReference
|
3
|
-
include SerializeHelper
|
4
|
-
attr_accessor :id, :integration_id, :heading
|
5
|
-
def serialize_variables
|
6
|
-
[ :id, :integration_id, :heading ].map { |prop| {
|
7
|
-
:id => prop, :type => :string
|
8
|
-
}
|
9
|
-
}
|
10
|
-
end
|
11
|
-
|
12
|
-
def initalize()
|
13
|
-
end
|
14
|
-
|
15
|
-
def to_s
|
16
|
-
return "(#{id}, #{integration_id}, #{heading})"
|
17
|
-
end
|
18
|
-
|
19
|
-
def empty?
|
20
|
-
return !@integration_id && !@id && !@heading
|
21
|
-
end
|
22
|
-
|
23
|
-
# *** TODO: delete this?
|
24
|
-
def same_as_this_method()
|
25
|
-
if @integration_id
|
26
|
-
return lambda { |org|
|
27
|
-
org.integration_id == @integration_id
|
28
|
-
}
|
29
|
-
elsif @id
|
30
|
-
return lambda { |org|
|
31
|
-
org.id == @id
|
32
|
-
}
|
33
|
-
elsif @heading
|
34
|
-
return lambda { |org|
|
35
|
-
org.heading == @heading
|
36
|
-
}
|
37
|
-
else
|
38
|
-
raise "No reference!"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
class Organization
|
44
|
-
include SerializeHelper, ModelHasCustomFields, ModelHasTags
|
45
|
-
|
46
|
-
attr_accessor :id, :integration_id, :name, :organization_number, :email, :web_site,
|
47
|
-
:postal_address, :visit_address, :central_phone_number, :responsible_coworker, :source_data
|
48
|
-
|
49
|
-
attr_reader :employees
|
50
|
-
|
51
|
-
def initialize()
|
52
|
-
end
|
53
|
-
|
54
|
-
def to_reference()
|
55
|
-
reference = OrganizationReference.new
|
56
|
-
reference.id = @id
|
57
|
-
reference.integration_id = @integration_id
|
58
|
-
reference.heading = @name
|
59
|
-
return reference
|
60
|
-
end
|
61
|
-
|
62
|
-
def ==(that)
|
63
|
-
if that.nil?
|
64
|
-
return false
|
65
|
-
end
|
66
|
-
|
67
|
-
if that.is_a? Organization
|
68
|
-
return @integration_id == that.integration_id
|
69
|
-
elsif that.is_a? String
|
70
|
-
return @integration_id == that
|
71
|
-
end
|
72
|
-
|
73
|
-
return false
|
74
|
-
end
|
75
|
-
|
76
|
-
def with_postal_address
|
77
|
-
@postal_address = Address.new
|
78
|
-
yield @postal_address
|
79
|
-
end
|
80
|
-
|
81
|
-
def with_visit_address
|
82
|
-
@visit_address = Address.new
|
83
|
-
yield @visit_address
|
84
|
-
end
|
85
|
-
|
86
|
-
def with_source
|
87
|
-
@source = ReferenceToSource.new
|
88
|
-
yield @source
|
89
|
-
end
|
90
|
-
|
91
|
-
def add_employee(val)
|
92
|
-
@employees = [] if @employees==nil
|
93
|
-
@employees.push(if val.is_a? Person then val else Person.new(val) end)
|
94
|
-
end
|
95
|
-
|
96
|
-
def serialize_variables
|
97
|
-
[
|
98
|
-
:id, :integration_id, :name, :organization_number,
|
99
|
-
:email, :web_site, :central_phone_number ].map {
|
100
|
-
|prop| { :id => prop, :type => :string }
|
101
|
-
} +
|
102
|
-
[
|
103
|
-
{ :id => :postal_address, :type => :address },
|
104
|
-
{ :id => :visit_address, :type => :address },
|
105
|
-
{ :id => :employees, :type => :persons },
|
106
|
-
{ :id => :tags, :type => :tags },
|
107
|
-
{ :id => :custom_fields, :type => :custom_fields },
|
108
|
-
{ :id => :source, :type => :source_ref },
|
109
|
-
{ :id => :responsible_coworker, :type => :coworker_reference}
|
110
|
-
]
|
111
|
-
end
|
112
|
-
|
113
|
-
def serialize_name
|
114
|
-
"Organization"
|
115
|
-
end
|
116
|
-
|
117
|
-
def to_s
|
118
|
-
return "#{name}"
|
119
|
-
end
|
120
|
-
|
121
|
-
def validate
|
122
|
-
error = String.new
|
123
|
-
|
124
|
-
if @name.nil? || @name.empty?
|
125
|
-
error = "A name is required for organization.\n#{serialize()}"
|
126
|
-
end
|
127
|
-
|
128
|
-
if @employees != nil
|
129
|
-
@employees.each do |person|
|
130
|
-
validation_message = person.validate()
|
131
|
-
if !validation_message.empty?
|
132
|
-
error = "#{error}\n#{validation_message}"
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
return error
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
1
|
+
module FruitToLime
|
2
|
+
class OrganizationReference
|
3
|
+
include SerializeHelper
|
4
|
+
attr_accessor :id, :integration_id, :heading
|
5
|
+
def serialize_variables
|
6
|
+
[ :id, :integration_id, :heading ].map { |prop| {
|
7
|
+
:id => prop, :type => :string
|
8
|
+
}
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
def initalize()
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_s
|
16
|
+
return "(#{id}, #{integration_id}, #{heading})"
|
17
|
+
end
|
18
|
+
|
19
|
+
def empty?
|
20
|
+
return !@integration_id && !@id && !@heading
|
21
|
+
end
|
22
|
+
|
23
|
+
# *** TODO: delete this?
|
24
|
+
def same_as_this_method()
|
25
|
+
if @integration_id
|
26
|
+
return lambda { |org|
|
27
|
+
org.integration_id == @integration_id
|
28
|
+
}
|
29
|
+
elsif @id
|
30
|
+
return lambda { |org|
|
31
|
+
org.id == @id
|
32
|
+
}
|
33
|
+
elsif @heading
|
34
|
+
return lambda { |org|
|
35
|
+
org.heading == @heading
|
36
|
+
}
|
37
|
+
else
|
38
|
+
raise "No reference!"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class Organization
|
44
|
+
include SerializeHelper, ModelHasCustomFields, ModelHasTags
|
45
|
+
|
46
|
+
attr_accessor :id, :integration_id, :name, :organization_number, :email, :web_site,
|
47
|
+
:postal_address, :visit_address, :central_phone_number, :responsible_coworker, :source_data
|
48
|
+
|
49
|
+
attr_reader :employees
|
50
|
+
|
51
|
+
def initialize()
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_reference()
|
55
|
+
reference = OrganizationReference.new
|
56
|
+
reference.id = @id
|
57
|
+
reference.integration_id = @integration_id
|
58
|
+
reference.heading = @name
|
59
|
+
return reference
|
60
|
+
end
|
61
|
+
|
62
|
+
def ==(that)
|
63
|
+
if that.nil?
|
64
|
+
return false
|
65
|
+
end
|
66
|
+
|
67
|
+
if that.is_a? Organization
|
68
|
+
return @integration_id == that.integration_id
|
69
|
+
elsif that.is_a? String
|
70
|
+
return @integration_id == that
|
71
|
+
end
|
72
|
+
|
73
|
+
return false
|
74
|
+
end
|
75
|
+
|
76
|
+
def with_postal_address
|
77
|
+
@postal_address = Address.new
|
78
|
+
yield @postal_address
|
79
|
+
end
|
80
|
+
|
81
|
+
def with_visit_address
|
82
|
+
@visit_address = Address.new
|
83
|
+
yield @visit_address
|
84
|
+
end
|
85
|
+
|
86
|
+
def with_source
|
87
|
+
@source = ReferenceToSource.new
|
88
|
+
yield @source
|
89
|
+
end
|
90
|
+
|
91
|
+
def add_employee(val)
|
92
|
+
@employees = [] if @employees==nil
|
93
|
+
@employees.push(if val.is_a? Person then val else Person.new(val) end)
|
94
|
+
end
|
95
|
+
|
96
|
+
def serialize_variables
|
97
|
+
[
|
98
|
+
:id, :integration_id, :name, :organization_number,
|
99
|
+
:email, :web_site, :central_phone_number ].map {
|
100
|
+
|prop| { :id => prop, :type => :string }
|
101
|
+
} +
|
102
|
+
[
|
103
|
+
{ :id => :postal_address, :type => :address },
|
104
|
+
{ :id => :visit_address, :type => :address },
|
105
|
+
{ :id => :employees, :type => :persons },
|
106
|
+
{ :id => :tags, :type => :tags },
|
107
|
+
{ :id => :custom_fields, :type => :custom_fields },
|
108
|
+
{ :id => :source, :type => :source_ref },
|
109
|
+
{ :id => :responsible_coworker, :type => :coworker_reference}
|
110
|
+
]
|
111
|
+
end
|
112
|
+
|
113
|
+
def serialize_name
|
114
|
+
"Organization"
|
115
|
+
end
|
116
|
+
|
117
|
+
def to_s
|
118
|
+
return "#{name}"
|
119
|
+
end
|
120
|
+
|
121
|
+
def validate
|
122
|
+
error = String.new
|
123
|
+
|
124
|
+
if @name.nil? || @name.empty?
|
125
|
+
error = "A name is required for organization.\n#{serialize()}"
|
126
|
+
end
|
127
|
+
|
128
|
+
if @employees != nil
|
129
|
+
@employees.each do |person|
|
130
|
+
validation_message = person.validate()
|
131
|
+
if !validation_message.empty?
|
132
|
+
error = "#{error}\n#{validation_message}"
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
return error
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
@@ -1,115 +1,115 @@
|
|
1
|
-
module FruitToLime
|
2
|
-
class PersonReference
|
3
|
-
include SerializeHelper
|
4
|
-
attr_accessor :id, :integration_id
|
5
|
-
def serialize_variables
|
6
|
-
[ :id, :integration_id ].map { |prop| {:id=>prop,:type=>:string} }
|
7
|
-
end
|
8
|
-
|
9
|
-
def initalize()
|
10
|
-
end
|
11
|
-
def to_s
|
12
|
-
return "(#{id}, #{integration_id})"
|
13
|
-
end
|
14
|
-
def empty?
|
15
|
-
return !@integration_id && !@id
|
16
|
-
end
|
17
|
-
def same_as_this_method()
|
18
|
-
if @integration_id
|
19
|
-
return lambda { |person|
|
20
|
-
person.integration_id == @integration_id
|
21
|
-
}
|
22
|
-
elsif @id
|
23
|
-
return lambda { |person|
|
24
|
-
person.id == @id
|
25
|
-
}
|
26
|
-
else
|
27
|
-
raise "No reference!"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
class Person < PersonReference
|
33
|
-
include SerializeHelper
|
34
|
-
attr_accessor :first_name, :last_name,
|
35
|
-
:direct_phone_number, :fax_phone_number, :mobile_phone_number, :home_phone_number,
|
36
|
-
:position, :email, :alternative_email, :postal_address, :currently_employed,
|
37
|
-
:organization
|
38
|
-
attr_reader :custom_fields
|
39
|
-
|
40
|
-
def initialize(opt = nil)
|
41
|
-
if opt != nil
|
42
|
-
serialize_variables.each do |myattr|
|
43
|
-
val = opt[myattr[:id]]
|
44
|
-
instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def with_postal_address
|
50
|
-
@postal_address = Address.new
|
51
|
-
yield @postal_address
|
52
|
-
end
|
53
|
-
|
54
|
-
def set_custom_field(obj)
|
55
|
-
@custom_fields = [] if @custom_fields==nil
|
56
|
-
@custom_fields.push CustomField.new(obj)
|
57
|
-
end
|
58
|
-
|
59
|
-
def with_source
|
60
|
-
@source = ReferenceToSource.new
|
61
|
-
yield @source
|
62
|
-
end
|
63
|
-
|
64
|
-
def tags
|
65
|
-
@tags
|
66
|
-
end
|
67
|
-
|
68
|
-
def add_tag(str)
|
69
|
-
@tags = [] if @tags == nil
|
70
|
-
@tags.push(Tag.new(str))
|
71
|
-
end
|
72
|
-
|
73
|
-
def serialize_name
|
74
|
-
"Person"
|
75
|
-
end
|
76
|
-
|
77
|
-
def serialize_variables
|
78
|
-
[
|
79
|
-
:id, :integration_id, :first_name, :last_name,
|
80
|
-
:direct_phone_number, :fax_phone_number, :mobile_phone_number, :home_phone_number,
|
81
|
-
:position, :email, :alternative_email
|
82
|
-
].map {
|
83
|
-
|prop| {:id => prop, :type => :string}
|
84
|
-
}+[
|
85
|
-
{:id => :postal_address, :type => :address},
|
86
|
-
{:id => :currently_employed, :type => :bool},
|
87
|
-
{:id => :tags, :type => :tags},
|
88
|
-
{:id => :custom_fields, :type => :custom_fields},
|
89
|
-
{:id => :source, :type => :source_ref},
|
90
|
-
{:id => :organization, :type => :organization_reference}
|
91
|
-
]
|
92
|
-
end
|
93
|
-
|
94
|
-
def get_import_rows
|
95
|
-
(serialize_variables + [ { :id => :organization, :type => :organization_reference } ]).map do |p|
|
96
|
-
map_to_row p
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def to_s
|
101
|
-
return "#{first_name} #{last_name}"
|
102
|
-
end
|
103
|
-
|
104
|
-
def validate
|
105
|
-
error = String.new
|
106
|
-
|
107
|
-
if (@first_name.nil? || @first_name.empty?) &&
|
108
|
-
(@last_name.nil? || @last_name.empty?)
|
109
|
-
error = "A firstname or lastname is required for person.\n#{serialize()}"
|
110
|
-
end
|
111
|
-
|
112
|
-
return error
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
1
|
+
module FruitToLime
|
2
|
+
class PersonReference
|
3
|
+
include SerializeHelper
|
4
|
+
attr_accessor :id, :integration_id
|
5
|
+
def serialize_variables
|
6
|
+
[ :id, :integration_id ].map { |prop| {:id=>prop,:type=>:string} }
|
7
|
+
end
|
8
|
+
|
9
|
+
def initalize()
|
10
|
+
end
|
11
|
+
def to_s
|
12
|
+
return "(#{id}, #{integration_id})"
|
13
|
+
end
|
14
|
+
def empty?
|
15
|
+
return !@integration_id && !@id
|
16
|
+
end
|
17
|
+
def same_as_this_method()
|
18
|
+
if @integration_id
|
19
|
+
return lambda { |person|
|
20
|
+
person.integration_id == @integration_id
|
21
|
+
}
|
22
|
+
elsif @id
|
23
|
+
return lambda { |person|
|
24
|
+
person.id == @id
|
25
|
+
}
|
26
|
+
else
|
27
|
+
raise "No reference!"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class Person < PersonReference
|
33
|
+
include SerializeHelper
|
34
|
+
attr_accessor :first_name, :last_name,
|
35
|
+
:direct_phone_number, :fax_phone_number, :mobile_phone_number, :home_phone_number,
|
36
|
+
:position, :email, :alternative_email, :postal_address, :currently_employed,
|
37
|
+
:organization
|
38
|
+
attr_reader :custom_fields
|
39
|
+
|
40
|
+
def initialize(opt = nil)
|
41
|
+
if opt != nil
|
42
|
+
serialize_variables.each do |myattr|
|
43
|
+
val = opt[myattr[:id]]
|
44
|
+
instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def with_postal_address
|
50
|
+
@postal_address = Address.new
|
51
|
+
yield @postal_address
|
52
|
+
end
|
53
|
+
|
54
|
+
def set_custom_field(obj)
|
55
|
+
@custom_fields = [] if @custom_fields==nil
|
56
|
+
@custom_fields.push CustomField.new(obj)
|
57
|
+
end
|
58
|
+
|
59
|
+
def with_source
|
60
|
+
@source = ReferenceToSource.new
|
61
|
+
yield @source
|
62
|
+
end
|
63
|
+
|
64
|
+
def tags
|
65
|
+
@tags
|
66
|
+
end
|
67
|
+
|
68
|
+
def add_tag(str)
|
69
|
+
@tags = [] if @tags == nil
|
70
|
+
@tags.push(Tag.new(str))
|
71
|
+
end
|
72
|
+
|
73
|
+
def serialize_name
|
74
|
+
"Person"
|
75
|
+
end
|
76
|
+
|
77
|
+
def serialize_variables
|
78
|
+
[
|
79
|
+
:id, :integration_id, :first_name, :last_name,
|
80
|
+
:direct_phone_number, :fax_phone_number, :mobile_phone_number, :home_phone_number,
|
81
|
+
:position, :email, :alternative_email
|
82
|
+
].map {
|
83
|
+
|prop| {:id => prop, :type => :string}
|
84
|
+
}+[
|
85
|
+
{:id => :postal_address, :type => :address},
|
86
|
+
{:id => :currently_employed, :type => :bool},
|
87
|
+
{:id => :tags, :type => :tags},
|
88
|
+
{:id => :custom_fields, :type => :custom_fields},
|
89
|
+
{:id => :source, :type => :source_ref},
|
90
|
+
{:id => :organization, :type => :organization_reference}
|
91
|
+
]
|
92
|
+
end
|
93
|
+
|
94
|
+
def get_import_rows
|
95
|
+
(serialize_variables + [ { :id => :organization, :type => :organization_reference } ]).map do |p|
|
96
|
+
map_to_row p
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def to_s
|
101
|
+
return "#{first_name} #{last_name}"
|
102
|
+
end
|
103
|
+
|
104
|
+
def validate
|
105
|
+
error = String.new
|
106
|
+
|
107
|
+
if (@first_name.nil? || @first_name.empty?) &&
|
108
|
+
(@last_name.nil? || @last_name.empty?)
|
109
|
+
error = "A firstname or lastname is required for person.\n#{serialize()}"
|
110
|
+
end
|
111
|
+
|
112
|
+
return error
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|