fruit_to_lime 2.4.1 → 2.5.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/errors.rb +3 -0
- data/lib/fruit_to_lime/model/coworker_reference.rb +1 -1
- data/lib/fruit_to_lime/model/organization.rb +20 -19
- data/lib/fruit_to_lime/model/person.rb +1 -1
- data/lib/fruit_to_lime/model/relation.rb +23 -0
- data/spec/helpers/xsd_validate_spec.rb +6 -7
- data/spec/organization_spec.rb +32 -0
- data/templates/excel/lib/tomodel.rb +4 -0
- metadata +3 -2
data/lib/fruit_to_lime/errors.rb
CHANGED
@@ -41,9 +41,9 @@ module FruitToLime
|
|
41
41
|
include SerializeHelper, ModelHasCustomFields, ModelHasTags
|
42
42
|
|
43
43
|
attr_accessor :id, :integration_id, :name, :organization_number, :email, :web_site,
|
44
|
-
:postal_address, :visit_address, :central_phone_number, :
|
44
|
+
:postal_address, :visit_address, :central_phone_number, :source_data
|
45
45
|
|
46
|
-
attr_reader :employees
|
46
|
+
attr_reader :employees, :responsible_coworker, :relation
|
47
47
|
# you add custom values by using {#set_custom_value}
|
48
48
|
attr_reader :custom_values
|
49
49
|
|
@@ -54,6 +54,8 @@ module FruitToLime
|
|
54
54
|
instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
|
55
55
|
end
|
56
56
|
end
|
57
|
+
|
58
|
+
@relation = Relation::NoRelation if @relation.nil?
|
57
59
|
end
|
58
60
|
|
59
61
|
def to_reference()
|
@@ -106,16 +108,6 @@ module FruitToLime
|
|
106
108
|
yield @source
|
107
109
|
end
|
108
110
|
|
109
|
-
# @example Set the responsible coworker of the organization to the coworker with integration id 943
|
110
|
-
# o.with_responsible_coworker do |responsible_coworker|
|
111
|
-
# responsible_coworker.integration_id = "943"
|
112
|
-
# end
|
113
|
-
# @see CoworkerReference responsible_coworker
|
114
|
-
def with_responsible_coworker
|
115
|
-
@responsible_coworker = CoworkerReference.new if @responsible_coworker==nil
|
116
|
-
yield @responsible_coworker
|
117
|
-
end
|
118
|
-
|
119
111
|
# @example Add an employee and then add additional info to that employee
|
120
112
|
# employee = o.add_employee({
|
121
113
|
# :integration_id => "79654",
|
@@ -132,12 +124,20 @@ module FruitToLime
|
|
132
124
|
person
|
133
125
|
end
|
134
126
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
127
|
+
def responsible_coworker=(coworker)
|
128
|
+
@responsible_coworker = CoworkerReference.from_coworker(coworker)
|
129
|
+
end
|
130
|
+
|
131
|
+
# Sets the organization's relation to the specified value. The
|
132
|
+
# relation must be a valid value from the Relation module
|
133
|
+
# otherwise an InvalidRelationError error will be thrown.
|
134
|
+
def relation=(relation)
|
135
|
+
if relation == Relation::NoRelation || relation == Relation::WorkingOnIt ||
|
136
|
+
relation == Relation::IsACustomer || relation == Relation::WasACustomer || relation == Relation::BeenInTouch
|
137
|
+
@relation = relation
|
138
|
+
else
|
139
|
+
raise InvalidRelationError
|
140
|
+
end
|
141
141
|
end
|
142
142
|
|
143
143
|
def find_employee_by_integration_id(integration_id)
|
@@ -162,7 +162,8 @@ module FruitToLime
|
|
162
162
|
{ :id => :employees, :type => :persons },
|
163
163
|
{ :id => :custom_values, :type => :custom_values },
|
164
164
|
{ :id => :tags, :type => :tags },
|
165
|
-
{ :id => :responsible_coworker, :type => :coworker_reference}
|
165
|
+
{ :id => :responsible_coworker, :type => :coworker_reference},
|
166
|
+
{ :id => :relation, :type => :string }
|
166
167
|
]
|
167
168
|
end
|
168
169
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module FruitToLime
|
2
|
+
module Relation
|
3
|
+
# This is the default, we have not been in contact with this
|
4
|
+
# organization in any way.
|
5
|
+
NoRelation = 0
|
6
|
+
|
7
|
+
# Something is happening with this organization, we might have
|
8
|
+
# booked a meeting with them or created a deal, etc.
|
9
|
+
WorkingOnIt = 1
|
10
|
+
|
11
|
+
# We have made a deal with this organization.
|
12
|
+
IsACustomer = 2
|
13
|
+
|
14
|
+
# We have made a deal with this organization but it was some
|
15
|
+
# time ago and we don't consider them a customer any more.
|
16
|
+
WasACustomer = 3
|
17
|
+
|
18
|
+
# We had something going with this organization but we
|
19
|
+
# couldn't close the deal and we don't think they will be a
|
20
|
+
# customer to us in the foreseeable future.
|
21
|
+
BeenInTouch = 4
|
22
|
+
end
|
23
|
+
end
|
@@ -33,9 +33,9 @@ describe FruitToLime::SerializeHelper do
|
|
33
33
|
o.with_visit_address do |addr|
|
34
34
|
addr.city = "Gaaseborg"
|
35
35
|
end
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
coworker = FruitToLime::Coworker.new({:integration_id => "1", :first_name => "Vincent", :last_name => "Vega"})
|
37
|
+
o.responsible_coworker = coworker
|
38
|
+
|
39
39
|
emp = o.add_employee({
|
40
40
|
:integration_id => "1",
|
41
41
|
:first_name => "Kalle",
|
@@ -45,15 +45,14 @@ describe FruitToLime::SerializeHelper do
|
|
45
45
|
emp.currently_employed = true
|
46
46
|
i.organizations.push(o)
|
47
47
|
xsd_file = File.join(File.dirname(__FILE__), '..', 'sample_data', 'schema0.xsd')
|
48
|
-
|
48
|
+
|
49
49
|
xsd = Nokogiri::XML::Schema(File.read(xsd_file))
|
50
|
-
#puts FruitToLime::SerializeHelper::serialize(i)
|
51
50
|
doc = Nokogiri::XML(FruitToLime::SerializeHelper::serialize(i,-1))
|
52
51
|
xsd.validate(doc)
|
53
52
|
}
|
54
53
|
it "Should not contain validation errors" do
|
55
54
|
expect(validate_result).to eq([])
|
56
55
|
end
|
57
|
-
|
56
|
+
|
58
57
|
end
|
59
|
-
end
|
58
|
+
end
|
data/spec/organization_spec.rb
CHANGED
@@ -17,6 +17,38 @@ describe "Organization" do
|
|
17
17
|
|
18
18
|
organization.validate.length > 0
|
19
19
|
end
|
20
|
+
|
21
|
+
it "will auto convert coworker to coworker.ref during assignment" do
|
22
|
+
# given
|
23
|
+
coworker = FruitToLime::Coworker.new({:integration_id => "456", :first_name => "Billy", :last_name => "Bob"})
|
24
|
+
|
25
|
+
# when
|
26
|
+
organization.responsible_coworker = coworker
|
27
|
+
|
28
|
+
# then
|
29
|
+
organization.responsible_coworker.is_a?(FruitToLime::CoworkerReference).should eq true
|
30
|
+
end
|
31
|
+
|
32
|
+
it "will have a no relation as default" do
|
33
|
+
# given, when, then
|
34
|
+
organization.relation.should eq FruitToLime::Relation::NoRelation
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should only accept relations from Relations enum" do
|
38
|
+
# given, when
|
39
|
+
organization.relation = FruitToLime::Relation::IsACustomer
|
40
|
+
|
41
|
+
# then
|
42
|
+
organization.relation.should eq FruitToLime::Relation::IsACustomer
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should not accept invalid relations" do
|
46
|
+
# when, then
|
47
|
+
expect {
|
48
|
+
organization.relation = "hubbabubba"
|
49
|
+
}.to raise_error(FruitToLime::InvalidRelationError)
|
50
|
+
end
|
51
|
+
|
20
52
|
end
|
21
53
|
|
22
54
|
describe "OrganizationReference" do
|
@@ -75,6 +75,10 @@ class Converter
|
|
75
75
|
# same file more than once without creating duplicates
|
76
76
|
organization.integration_id = row['ID']
|
77
77
|
|
78
|
+
# Sets the organization's relation. Relation must be a value
|
79
|
+
# from FruitToLime::Relation.
|
80
|
+
organization.relation = FruitToLime::Relation::IsACustomer
|
81
|
+
|
78
82
|
# *** TODO:
|
79
83
|
#
|
80
84
|
# Set organization properties from the 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: 2.
|
4
|
+
version: 2.5.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-26 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: iso_country_codes
|
@@ -182,6 +182,7 @@ files:
|
|
182
182
|
- lib/fruit_to_lime/model/organization.rb
|
183
183
|
- lib/fruit_to_lime/model/person.rb
|
184
184
|
- lib/fruit_to_lime/model/referencetosource.rb
|
185
|
+
- lib/fruit_to_lime/model/relation.rb
|
185
186
|
- lib/fruit_to_lime/model/rootmodel.rb
|
186
187
|
- lib/fruit_to_lime/model/settings.rb
|
187
188
|
- lib/fruit_to_lime/model/tag.rb
|