fruit_to_lime 2.1.4 → 2.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module FruitToLime
2
3
  class Coworker
3
4
  include SerializeHelper
@@ -44,5 +45,27 @@ module FruitToLime
44
45
 
45
46
  return false
46
47
  end
48
+
49
+ def parse_name_to_firstname_lastname_se(name)
50
+ splitted = name.split(' ')
51
+ @first_name = splitted[0]
52
+ if splitted.length > 1
53
+ @last_name = splitted.drop(1).join(' ')
54
+ end
55
+ end
56
+
57
+ def to_email_chars(s)
58
+ s.tr " åäöèé", "-aaoee"
59
+ end
60
+
61
+ def guess_email(domain)
62
+ return '' if @last_name.nil? || @last_name.empty?
63
+ return '' if @first_name.nil? || @first_name.empty?
64
+
65
+ firstname = to_email_chars @first_name.downcase
66
+ lastname = to_email_chars @last_name.downcase
67
+ return "#{firstname}.#{lastname}@#{domain}"
68
+ end
69
+
47
70
  end
48
71
  end
@@ -117,5 +117,13 @@ module FruitToLime
117
117
 
118
118
  return error
119
119
  end
120
+
121
+ def parse_name_to_firstname_lastname_se(name)
122
+ splitted = name.split(' ')
123
+ @first_name = splitted[0]
124
+ if splitted.length > 1
125
+ @last_name = splitted.drop(1).join(' ')
126
+ end
127
+ end
120
128
  end
121
129
  end
@@ -0,0 +1,82 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+ require 'fruit_to_lime'
4
+
5
+ describe "Coworker" do
6
+ let(:coworker) {
7
+ FruitToLime::Coworker.new
8
+ }
9
+
10
+ describe "parse_name_to_firstname_lastname_se" do
11
+ it "can parse 'Kalle Nilsson' into firstname 'Kalle' and lastname 'Nilsson'" do
12
+ coworker.parse_name_to_firstname_lastname_se 'Kalle Nilsson'
13
+
14
+ coworker.first_name.should eq 'Kalle'
15
+ coworker.last_name.should eq 'Nilsson'
16
+
17
+ end
18
+
19
+ it "can parse 'Kalle Svensson Nilsson' into firstname 'Kalle' and lastname 'Svensson Nilsson'" do
20
+ coworker.parse_name_to_firstname_lastname_se 'Kalle Svensson Nilsson'
21
+
22
+ coworker.first_name.should eq 'Kalle'
23
+ coworker.last_name.should eq 'Svensson Nilsson'
24
+ end
25
+ end
26
+
27
+ describe "gues_email" do
28
+ it "guesses kalle.nilsson@x.com for coworker with firstname 'Kalle', lastname 'Nilsson' and domain set to 'x.com" do
29
+ coworker.first_name = 'Kalle'
30
+ coworker.last_name = 'Nilsson'
31
+
32
+ guessed = coworker.guess_email 'x.com'
33
+
34
+ guessed.should eq 'kalle.nilsson@x.com'
35
+ end
36
+
37
+ it "guesses '' when lastname is missing" do
38
+ coworker.first_name = 'Kalle'
39
+ coworker.last_name = ''
40
+
41
+ guessed = coworker.guess_email 'x.com'
42
+
43
+ guessed.should eq ''
44
+ end
45
+
46
+ it "guesses '' when firstname is missing" do
47
+ coworker.first_name = nil
48
+ coworker.last_name = 'Nilsson'
49
+
50
+ guessed = coworker.guess_email 'x.com'
51
+
52
+ guessed.should eq ''
53
+ end
54
+
55
+ it "guesses åäöèé to be aaoee" do
56
+ coworker.first_name = 'åäöèé'
57
+ coworker.last_name = 'Nilsson'
58
+
59
+ guessed = coworker.guess_email 'x.com'
60
+
61
+ guessed.should eq 'aaoee.nilsson@x.com'
62
+ end
63
+
64
+ it "guesses 'sven-erik.nilsson@x.com' when firstname has two names with ' ' between them" do
65
+ coworker.first_name = 'Sven Erik'
66
+ coworker.last_name = 'Nilsson'
67
+
68
+ guessed = coworker.guess_email 'x.com'
69
+
70
+ guessed.should eq 'sven-erik.nilsson@x.com'
71
+ end
72
+
73
+ it "guesses 'sven.nilsson-svensson@x.com' when lastnames has two names with ' ' between them" do
74
+ coworker.first_name = 'Sven'
75
+ coworker.last_name = 'Nilsson Svensson'
76
+
77
+ guessed = coworker.guess_email 'x.com'
78
+
79
+ guessed.should eq 'sven.nilsson-svensson@x.com'
80
+ end
81
+ end
82
+ end
data/spec/person_spec.rb CHANGED
@@ -79,5 +79,22 @@ describe "Person" do
79
79
  error = person.validate
80
80
  error.should start_with("A firstname or lastname is required for person")
81
81
  end
82
+
83
+ describe "parse_name_to_firstname_lastname_se" do
84
+ it "can parse 'Kalle Nilsson' into firstname 'Kalle' and lastname 'Nilsson'" do
85
+ person.parse_name_to_firstname_lastname_se 'Kalle Nilsson'
86
+
87
+ person.first_name.should eq 'Kalle'
88
+ person.last_name.should eq 'Nilsson'
89
+
90
+ end
91
+
92
+ it "can parse 'Kalle Svensson Nilsson' into firstname 'Kalle' and lastname 'Svensson Nilsson'" do
93
+ person.parse_name_to_firstname_lastname_se 'Kalle Svensson Nilsson'
94
+
95
+ person.first_name.should eq 'Kalle'
96
+ person.last_name.should eq 'Svensson Nilsson'
97
+ end
98
+ end
82
99
  end
83
100
 
@@ -0,0 +1,152 @@
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
+ >
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.1.4
4
+ version: 2.2.4
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-30 00:00:00.000000000 Z
14
+ date: 2014-05-02 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: iso_country_codes
@@ -158,6 +158,7 @@ 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
161
162
  - templates/csv/Gemfile
162
163
  - templates/csv/lib/tomodel.rb
163
164
  - templates/csv/Rakefile.rb
@@ -182,6 +183,7 @@ files:
182
183
  - templates/sqlserver/spec/tomodel_spec.rb
183
184
  - spec/address_spec.rb
184
185
  - spec/class_settings_spec.rb
186
+ - spec/coworker_spec.rb
185
187
  - spec/custom_field_spec.rb
186
188
  - spec/helpers/csv_helper_spec.rb
187
189
  - spec/helpers/roo_helper_spec.rb
@@ -218,6 +220,7 @@ summary: Library to generate Lime Go xml import format
218
220
  test_files:
219
221
  - spec/address_spec.rb
220
222
  - spec/class_settings_spec.rb
223
+ - spec/coworker_spec.rb
221
224
  - spec/custom_field_spec.rb
222
225
  - spec/helpers/csv_helper_spec.rb
223
226
  - spec/helpers/roo_helper_spec.rb
@@ -227,4 +230,3 @@ test_files:
227
230
  - spec/rootmodel_spec.rb
228
231
  - spec/spec_helper.rb
229
232
  - spec/templating_spec.rb
230
- has_rdoc: