fruit_to_lime 2.5.5 → 2.5.6

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 (55) 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 -141
  13. data/lib/fruit_to_lime/model/deal_status.rb +12 -12
  14. data/lib/fruit_to_lime/model/note.rb +80 -79
  15. data/lib/fruit_to_lime/model/organization.rb +203 -203
  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 +342 -338
  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 -101
  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 -98
  38. data/spec/organization_spec.rb +103 -103
  39. data/spec/person_spec.rb +134 -134
  40. data/spec/rootmodel_spec.rb +306 -277
  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 -5
  49. data/templates/easy/Rakefile.rb +7 -7
  50. data/templates/easy/convert.rb +2 -2
  51. data/templates/easy/spec/exporter_spec.rb +10 -10
  52. data/templates/easy/spec/spec_helper.rb +24 -24
  53. data/templates/excel/lib/tomodel.rb +207 -207
  54. data/templates/sqlserver/lib/tomodel.rb +79 -79
  55. metadata +3 -3
@@ -1,52 +1,52 @@
1
- require "fileutils"
2
- require 'open3'
3
- module FruitToLime
4
- class Templating
5
- def initialize(path)
6
- @path = path
7
- end
8
-
9
- def list()
10
- Dir.entries(@path).select { |d| d != '.' && d != '..' }
11
- end
12
-
13
- def unpack(name, path)
14
- template = list.find { |t| t == name }
15
- if template
16
- unpackedname = name
17
-
18
- puts "Unpacking template #{name} to #{path}"
19
- FileUtils.cp_r File.expand_path(name, @path), path
20
-
21
- # Now make sure all gems in template are installed
22
- puts "Making sure all needed gems are present"
23
- Dir.chdir(File.expand_path(unpackedname, path)) do
24
- exec_but_dont_show_unless_error('bundle install --verbose')
25
- end
26
- true
27
- else
28
- puts "Unable to find template #{name}"
29
- false
30
- end
31
- end
32
-
33
- private
34
- def exec_but_dont_show_unless_error(cmd)
35
- std_out_value = []
36
- Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
37
- while std_line = stdout.gets
38
- std_out_value << std_line
39
- end
40
-
41
- exit_status = wait_thr.value
42
- if !exit_status.success?
43
- puts "Failed with #{exit_status}"
44
- puts "std_out_value"
45
- puts std_out_value
46
-
47
- raise "failed exec #{cmd}"
48
- end
49
- end
50
- end
51
- end
52
- end
1
+ require "fileutils"
2
+ require 'open3'
3
+ module FruitToLime
4
+ class Templating
5
+ def initialize(path)
6
+ @path = path
7
+ end
8
+
9
+ def list()
10
+ Dir.entries(@path).select { |d| d != '.' && d != '..' }
11
+ end
12
+
13
+ def unpack(name, path)
14
+ template = list.find { |t| t == name }
15
+ if template
16
+ unpackedname = name
17
+
18
+ puts "Unpacking template #{name} to #{path}"
19
+ FileUtils.cp_r File.expand_path(name, @path), path
20
+
21
+ # Now make sure all gems in template are installed
22
+ puts "Making sure all needed gems are present"
23
+ Dir.chdir(File.expand_path(unpackedname, path)) do
24
+ exec_but_dont_show_unless_error('bundle install --verbose')
25
+ end
26
+ true
27
+ else
28
+ puts "Unable to find template #{name}"
29
+ false
30
+ end
31
+ end
32
+
33
+ private
34
+ def exec_but_dont_show_unless_error(cmd)
35
+ std_out_value = []
36
+ Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
37
+ while std_line = stdout.gets
38
+ std_out_value << std_line
39
+ end
40
+
41
+ exit_status = wait_thr.value
42
+ if !exit_status.success?
43
+ puts "Failed with #{exit_status}"
44
+ puts "std_out_value"
45
+ puts std_out_value
46
+
47
+ raise "failed exec #{cmd}"
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
data/spec/address_spec.rb CHANGED
@@ -1,49 +1,49 @@
1
- require 'spec_helper'
2
- require 'fruit_to_lime'
3
-
4
- describe FruitToLime::Address do
5
- describe "Parse line with swedish zip and city into zipcode" do
6
- let (:zip_code) {
7
- address = FruitToLime::Address.new
8
- line = "114 45 STOCKHOLM"
9
- address.parse_zip_and_address_se(line).zip_code
10
- }
11
- it "should have zipcode equal to '114 45'" do
12
- zip_code.should eq '114 45'
13
- end
14
- end
15
-
16
- describe "Parse line with swedish zip and city into city" do
17
- let (:city){
18
- address = FruitToLime::Address.new
19
- line = "114 45 STOCKHOLM"
20
- address.parse_zip_and_address_se(line).city
21
- }
22
- it "should have city equal to 'STOCKHOLM'" do
23
- city.should eq 'STOCKHOLM'
24
- end
25
- end
26
-
27
- describe "Parse line with non-swedish zip and city assuming swedish format" do
28
- describe "praha example" do
29
- let (:parse_result){
30
- address = FruitToLime::Address.new
31
- line = "CZ-140 00 PRAHA 4"
32
- address.parse_zip_and_address_se(line)
33
- }
34
- it "should be nil" do
35
- parse_result.should == nil
36
- end
37
- end
38
- describe "finnish example" do
39
- let (:parse_result){
40
- address = FruitToLime::Address.new
41
- line = "0511 HELSINKI"
42
- address.parse_zip_and_address_se(line)
43
- }
44
- it "should be nil" do
45
- parse_result.should == nil
46
- end
47
- end
48
- end
1
+ require 'spec_helper'
2
+ require 'fruit_to_lime'
3
+
4
+ describe FruitToLime::Address do
5
+ describe "Parse line with swedish zip and city into zipcode" do
6
+ let (:zip_code) {
7
+ address = FruitToLime::Address.new
8
+ line = "114 45 STOCKHOLM"
9
+ address.parse_zip_and_address_se(line).zip_code
10
+ }
11
+ it "should have zipcode equal to '114 45'" do
12
+ zip_code.should eq '114 45'
13
+ end
14
+ end
15
+
16
+ describe "Parse line with swedish zip and city into city" do
17
+ let (:city){
18
+ address = FruitToLime::Address.new
19
+ line = "114 45 STOCKHOLM"
20
+ address.parse_zip_and_address_se(line).city
21
+ }
22
+ it "should have city equal to 'STOCKHOLM'" do
23
+ city.should eq 'STOCKHOLM'
24
+ end
25
+ end
26
+
27
+ describe "Parse line with non-swedish zip and city assuming swedish format" do
28
+ describe "praha example" do
29
+ let (:parse_result){
30
+ address = FruitToLime::Address.new
31
+ line = "CZ-140 00 PRAHA 4"
32
+ address.parse_zip_and_address_se(line)
33
+ }
34
+ it "should be nil" do
35
+ parse_result.should == nil
36
+ end
37
+ end
38
+ describe "finnish example" do
39
+ let (:parse_result){
40
+ address = FruitToLime::Address.new
41
+ line = "0511 HELSINKI"
42
+ address.parse_zip_and_address_se(line)
43
+ }
44
+ it "should be nil" do
45
+ parse_result.should == nil
46
+ end
47
+ end
48
+ end
49
49
  end
@@ -1,37 +1,37 @@
1
- require "spec_helper"
2
- require 'fruit_to_lime'
3
-
4
- describe "ClassSettings" do
5
- let(:class_settings) {
6
- FruitToLime::ClassSettings.new
7
- }
8
-
9
- it "can set custom field and if there is already an existing custom field, then it is overwritten." do
10
- class_settings.set_custom_field({:integration_id => "link_to_bi_system", :title => "Link to BI system"})
11
- class_settings.set_custom_field({:integration_id => "link_to_bi_system", :title => "Link to BI system 2"})
12
- class_settings.custom_fields.length.should eq 1
13
- class_settings.custom_fields[0].title.should eq "Link to BI system 2"
14
- end
15
-
16
- it "should not allow new custom fields without id and integration id" do
17
- begin
18
- class_settings.set_custom_field({:integration_id => "", :id => "", :title => "Link to BI system"})
19
- rescue
20
- end
21
-
22
- class_settings.custom_fields.length.should eq 0
23
- end
24
-
25
- it "should allow new custom field with integration_id" do
26
- class_settings.set_custom_field({:integration_id => "link_to_bi_system", :title => "Link to BI system"})
27
- class_settings.custom_fields.length.should eq 1
28
- class_settings.custom_fields[0].title.should eq "Link to BI system"
29
- end
30
-
31
- it "should allow new custom field with id" do
32
- class_settings.set_custom_field({:id => "123", :title => "Link to BI system"})
33
- class_settings.custom_fields.length.should eq 1
34
- class_settings.custom_fields[0].title.should eq "Link to BI system"
35
- end
36
- end
37
-
1
+ require "spec_helper"
2
+ require 'fruit_to_lime'
3
+
4
+ describe "ClassSettings" do
5
+ let(:class_settings) {
6
+ FruitToLime::ClassSettings.new
7
+ }
8
+
9
+ it "can set custom field and if there is already an existing custom field, then it is overwritten." do
10
+ class_settings.set_custom_field({:integration_id => "link_to_bi_system", :title => "Link to BI system"})
11
+ class_settings.set_custom_field({:integration_id => "link_to_bi_system", :title => "Link to BI system 2"})
12
+ class_settings.custom_fields.length.should eq 1
13
+ class_settings.custom_fields[0].title.should eq "Link to BI system 2"
14
+ end
15
+
16
+ it "should not allow new custom fields without id and integration id" do
17
+ begin
18
+ class_settings.set_custom_field({:integration_id => "", :id => "", :title => "Link to BI system"})
19
+ rescue
20
+ end
21
+
22
+ class_settings.custom_fields.length.should eq 0
23
+ end
24
+
25
+ it "should allow new custom field with integration_id" do
26
+ class_settings.set_custom_field({:integration_id => "link_to_bi_system", :title => "Link to BI system"})
27
+ class_settings.custom_fields.length.should eq 1
28
+ class_settings.custom_fields[0].title.should eq "Link to BI system"
29
+ end
30
+
31
+ it "should allow new custom field with id" do
32
+ class_settings.set_custom_field({:id => "123", :title => "Link to BI system"})
33
+ class_settings.custom_fields.length.should eq 1
34
+ class_settings.custom_fields[0].title.should eq "Link to BI system"
35
+ end
36
+ end
37
+
@@ -1,94 +1,94 @@
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
-
26
- it "sets default name when name is empty" do
27
- coworker.parse_name_to_firstname_lastname_se '', 'a default'
28
-
29
- coworker.first_name.should eq 'a default'
30
- end
31
-
32
- it "sets default name when name is nil" do
33
- coworker.parse_name_to_firstname_lastname_se nil, 'a default'
34
-
35
- coworker.first_name.should eq 'a default'
36
- end
37
- end
38
-
39
- describe "guess_email" do
40
- it "guesses kalle.nilsson@x.com for coworker with firstname 'Kalle', lastname 'Nilsson' and domain set to 'x.com" do
41
- coworker.first_name = 'Kalle'
42
- coworker.last_name = 'Nilsson'
43
-
44
- guessed = coworker.guess_email 'x.com'
45
-
46
- guessed.should eq 'kalle.nilsson@x.com'
47
- end
48
-
49
- it "guesses '' when lastname is missing" do
50
- coworker.first_name = 'Kalle'
51
- coworker.last_name = ''
52
-
53
- guessed = coworker.guess_email 'x.com'
54
-
55
- guessed.should eq ''
56
- end
57
-
58
- it "guesses '' when firstname is missing" do
59
- coworker.first_name = nil
60
- coworker.last_name = 'Nilsson'
61
-
62
- guessed = coworker.guess_email 'x.com'
63
-
64
- guessed.should eq ''
65
- end
66
-
67
- it "guesses åäöèé to be aaoee" do
68
- coworker.first_name = 'åäöèé'
69
- coworker.last_name = 'Nilsson'
70
-
71
- guessed = coworker.guess_email 'x.com'
72
-
73
- guessed.should eq 'aaoee.nilsson@x.com'
74
- end
75
-
76
- it "guesses 'sven-erik.nilsson@x.com' when firstname has two names with ' ' between them" do
77
- coworker.first_name = 'Sven Erik'
78
- coworker.last_name = 'Nilsson'
79
-
80
- guessed = coworker.guess_email 'x.com'
81
-
82
- guessed.should eq 'sven-erik.nilsson@x.com'
83
- end
84
-
85
- it "guesses 'sven.nilsson-svensson@x.com' when lastnames has two names with ' ' between them" do
86
- coworker.first_name = 'Sven'
87
- coworker.last_name = 'Nilsson Svensson'
88
-
89
- guessed = coworker.guess_email 'x.com'
90
-
91
- guessed.should eq 'sven.nilsson-svensson@x.com'
92
- end
93
- end
94
- end
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
+
26
+ it "sets default name when name is empty" do
27
+ coworker.parse_name_to_firstname_lastname_se '', 'a default'
28
+
29
+ coworker.first_name.should eq 'a default'
30
+ end
31
+
32
+ it "sets default name when name is nil" do
33
+ coworker.parse_name_to_firstname_lastname_se nil, 'a default'
34
+
35
+ coworker.first_name.should eq 'a default'
36
+ end
37
+ end
38
+
39
+ describe "guess_email" do
40
+ it "guesses kalle.nilsson@x.com for coworker with firstname 'Kalle', lastname 'Nilsson' and domain set to 'x.com" do
41
+ coworker.first_name = 'Kalle'
42
+ coworker.last_name = 'Nilsson'
43
+
44
+ guessed = coworker.guess_email 'x.com'
45
+
46
+ guessed.should eq 'kalle.nilsson@x.com'
47
+ end
48
+
49
+ it "guesses '' when lastname is missing" do
50
+ coworker.first_name = 'Kalle'
51
+ coworker.last_name = ''
52
+
53
+ guessed = coworker.guess_email 'x.com'
54
+
55
+ guessed.should eq ''
56
+ end
57
+
58
+ it "guesses '' when firstname is missing" do
59
+ coworker.first_name = nil
60
+ coworker.last_name = 'Nilsson'
61
+
62
+ guessed = coworker.guess_email 'x.com'
63
+
64
+ guessed.should eq ''
65
+ end
66
+
67
+ it "guesses åäöèé to be aaoee" do
68
+ coworker.first_name = 'åäöèé'
69
+ coworker.last_name = 'Nilsson'
70
+
71
+ guessed = coworker.guess_email 'x.com'
72
+
73
+ guessed.should eq 'aaoee.nilsson@x.com'
74
+ end
75
+
76
+ it "guesses 'sven-erik.nilsson@x.com' when firstname has two names with ' ' between them" do
77
+ coworker.first_name = 'Sven Erik'
78
+ coworker.last_name = 'Nilsson'
79
+
80
+ guessed = coworker.guess_email 'x.com'
81
+
82
+ guessed.should eq 'sven-erik.nilsson@x.com'
83
+ end
84
+
85
+ it "guesses 'sven.nilsson-svensson@x.com' when lastnames has two names with ' ' between them" do
86
+ coworker.first_name = 'Sven'
87
+ coworker.last_name = 'Nilsson Svensson'
88
+
89
+ guessed = coworker.guess_email 'x.com'
90
+
91
+ guessed.should eq 'sven.nilsson-svensson@x.com'
92
+ end
93
+ end
94
+ end