fruit_to_lime 0.9.1 → 0.9.2

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 (44) hide show
  1. data/bin/fruit_to_lime +24 -24
  2. data/lib/fruit_to_lime/address_helper.rb +17 -17
  3. data/lib/fruit_to_lime/csv_helper.rb +32 -32
  4. data/lib/fruit_to_lime/model/address.rb +37 -37
  5. data/lib/fruit_to_lime/model/coworker.rb +44 -44
  6. data/lib/fruit_to_lime/model/coworker_reference.rb +17 -17
  7. data/lib/fruit_to_lime/model/customfield.rb +30 -30
  8. data/lib/fruit_to_lime/model/note.rb +38 -38
  9. data/lib/fruit_to_lime/model/organization.rb +140 -140
  10. data/lib/fruit_to_lime/model/person.rb +115 -115
  11. data/lib/fruit_to_lime/model/referencetosource.rb +42 -42
  12. data/lib/fruit_to_lime/model/rootmodel.rb +142 -142
  13. data/lib/fruit_to_lime/model/tag.rb +33 -33
  14. data/lib/fruit_to_lime/model_helpers.rb +19 -19
  15. data/lib/fruit_to_lime/roo_helper.rb +59 -59
  16. data/lib/fruit_to_lime/serialize_helper.rb +139 -139
  17. data/lib/fruit_to_lime/templating.rb +51 -51
  18. data/lib/fruit_to_lime.rb +13 -13
  19. data/spec/helpers/address_helper_spec.rb +48 -48
  20. data/spec/helpers/csv_helper_spec.rb +15 -15
  21. data/spec/helpers/roo_helper_spec.rb +10 -10
  22. data/spec/helpers/serialize_helper_spec.rb +211 -211
  23. data/spec/person_spec.rb +44 -44
  24. data/spec/spec_helper.rb +24 -24
  25. data/templates/csv/Gemfile +5 -5
  26. data/templates/csv/Rakefile.rb +7 -7
  27. data/templates/csv/convert.rb +2 -2
  28. data/templates/csv/lib/tomodel.rb +56 -56
  29. data/templates/csv/spec/sample_data/organizations.csv +2 -2
  30. data/templates/csv/spec/spec_helper.rb +24 -24
  31. data/templates/csv/spec/tomodel_spec.rb +14 -14
  32. data/templates/excel/Gemfile +6 -6
  33. data/templates/excel/Rakefile.rb +7 -7
  34. data/templates/excel/convert.rb +2 -2
  35. data/templates/excel/lib/tomodel.rb +53 -53
  36. data/templates/excel/spec/spec_helper.rb +20 -20
  37. data/templates/excel/spec/tomodel_spec.rb +18 -18
  38. data/templates/sqlserver/Gemfile +6 -6
  39. data/templates/sqlserver/Rakefile.rb +7 -7
  40. data/templates/sqlserver/convert.rb +2 -2
  41. data/templates/sqlserver/lib/tomodel.rb +67 -67
  42. data/templates/sqlserver/spec/spec_helper.rb +20 -20
  43. data/templates/sqlserver/spec/tomodel_spec.rb +9 -9
  44. metadata +2 -2
data/spec/person_spec.rb CHANGED
@@ -1,44 +1,44 @@
1
- require "spec_helper"
2
- require 'fruit_to_lime'
3
-
4
- describe "Person" do
5
- before (:all) do
6
- @person = FruitToLime::Person.new
7
- end
8
-
9
- it "can set a customfield" do
10
- @person.set_custom_field({:integration_id=>'the key',
11
- :title=> 'the title',
12
- :value=> 'the value'})
13
-
14
- field = @person.custom_fields[0]
15
- field.integration_id.should eq 'the key'
16
- field.title.should eq 'the title'
17
- field.value.should eq 'the value'
18
- end
19
-
20
- it "should have a firstname if no lastname" do
21
- @person.first_name = "Vincent"
22
- @person.last_name = nil
23
-
24
- error = @person.validate
25
- error.should be_empty
26
- end
27
-
28
- it "should have a lastname if no firstname" do
29
- @person.first_name = String.new
30
- @person.last_name = "Vega"
31
-
32
- error = @person.validate
33
- error.should be_empty
34
- end
35
-
36
- it "shouldnt pass validation with no firstname and lastname" do
37
- @person.first_name = String.new
38
- @person.last_name = nil
39
-
40
- error = @person.validate
41
- error.should start_with("A firstname or lastname is required for person")
42
- end
43
- end
44
-
1
+ require "spec_helper"
2
+ require 'fruit_to_lime'
3
+
4
+ describe "Person" do
5
+ before (:all) do
6
+ @person = FruitToLime::Person.new
7
+ end
8
+
9
+ it "can set a customfield" do
10
+ @person.set_custom_field({:integration_id=>'the key',
11
+ :title=> 'the title',
12
+ :value=> 'the value'})
13
+
14
+ field = @person.custom_fields[0]
15
+ field.integration_id.should eq 'the key'
16
+ field.title.should eq 'the title'
17
+ field.value.should eq 'the value'
18
+ end
19
+
20
+ it "should have a firstname if no lastname" do
21
+ @person.first_name = "Vincent"
22
+ @person.last_name = nil
23
+
24
+ error = @person.validate
25
+ error.should be_empty
26
+ end
27
+
28
+ it "should have a lastname if no firstname" do
29
+ @person.first_name = String.new
30
+ @person.last_name = "Vega"
31
+
32
+ error = @person.validate
33
+ error.should be_empty
34
+ end
35
+
36
+ it "shouldnt pass validation with no firstname and lastname" do
37
+ @person.first_name = String.new
38
+ @person.last_name = nil
39
+
40
+ error = @person.validate
41
+ error.should start_with("A firstname or lastname is required for person")
42
+ end
43
+ end
44
+
data/spec/spec_helper.rb CHANGED
@@ -1,24 +1,24 @@
1
- # This file is copied to spec/ when you run 'rails generate rspec:install'
2
- #require File.expand_path("../../config/environment", __FILE__)
3
- require 'rspec/autorun'
4
-
5
- # Requires supporting ruby files with custom matchers and macros, etc,
6
- # in spec/support/ and its subdirectories.
7
- Dir[File.join(File.dirname(File.absolute_path(__FILE__)),"support/**/*.rb")].each { |f| require f }
8
-
9
- RSpec.configure do |config|
10
- # ## Mock Framework
11
- #
12
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
13
- #
14
- # config.mock_with :mocha
15
- # config.mock_with :flexmock
16
- # config.mock_with :rr
17
-
18
- # Run specs in random order to surface order dependencies. If you find an
19
- # order dependency and want to debug it, you can fix the order by providing
20
- # the seed, which is printed after each run.
21
- # --seed 1234
22
- config.order = "random"
23
- end
24
-
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ #require File.expand_path("../../config/environment", __FILE__)
3
+ require 'rspec/autorun'
4
+
5
+ # Requires supporting ruby files with custom matchers and macros, etc,
6
+ # in spec/support/ and its subdirectories.
7
+ Dir[File.join(File.dirname(File.absolute_path(__FILE__)),"support/**/*.rb")].each { |f| require f }
8
+
9
+ RSpec.configure do |config|
10
+ # ## Mock Framework
11
+ #
12
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
13
+ #
14
+ # config.mock_with :mocha
15
+ # config.mock_with :flexmock
16
+ # config.mock_with :rr
17
+
18
+ # Run specs in random order to surface order dependencies. If you find an
19
+ # order dependency and want to debug it, you can fix the order by providing
20
+ # the seed, which is printed after each run.
21
+ # --seed 1234
22
+ config.order = "random"
23
+ end
24
+
@@ -1,5 +1,5 @@
1
- source 'http://rubygems.org'
2
-
3
- gem 'thor'
4
- gem 'fruit_to_lime'
5
- gem 'rspec'
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'thor'
4
+ gem 'fruit_to_lime'
5
+ gem 'rspec'
@@ -1,7 +1,7 @@
1
- #!/usr/bin/env rake
2
- require 'rspec/core/rake_task'
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
7
- task :test => :spec
1
+ #!/usr/bin/env rake
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+ task :test => :spec
@@ -1,3 +1,3 @@
1
- require "./lib/tomodel"
2
-
1
+ require "./lib/tomodel"
2
+
3
3
  Cli.start(ARGV)
@@ -1,56 +1,56 @@
1
- require 'fruit_to_lime'
2
-
3
- class ToModel
4
- def to_organization(row)
5
- organization = FruitToLime::Organization.new
6
- organization.integration_id = row['id']
7
- organization.name = row['name']
8
- return organization
9
- end
10
-
11
- def to_model(organization_file_name)
12
- rootmodel = FruitToLime::RootModel.new
13
- if organization_file_name != nil
14
- organization_file_data = File.open(organization_file_name, 'r').read.encode('UTF-8',"ISO-8859-1")
15
- rows = FruitToLime::CsvHelper::text_to_hashes(organization_file_data)
16
- rows.each do |row|
17
- rootmodel.organizations.push(to_organization(row))
18
- end
19
- end
20
- return rootmodel
21
- end
22
-
23
- def save_xml(file)
24
- File.open(file,'w') do |f|
25
- f.write(FruitToLime::SerializeHelper::serialize(to_xml_model))
26
- end
27
- end
28
- end
29
-
30
- require "thor"
31
- require "fileutils"
32
- require 'pathname'
33
-
34
- class Cli < Thor
35
- desc "to_go ORGANIZATIONS FILE", "Exports xml to FILE using for ORGANIZATIONS csv file."
36
- def to_go(organizations, file = nil)
37
- file = 'export.xml' if file == nil
38
- toModel = ToModel.new()
39
- model = toModel.to_model(organizations)
40
- error = model.sanity_check
41
- if error.empty?
42
- validation_errors = model.validate
43
-
44
- if validation_errors.empty?
45
- model.serialize_to_file(file)
46
- puts "'#{organizations}' has been converted into '#{file}'."
47
- else
48
- puts "'#{organizations}' could not be converted due to"
49
- puts validation_errors
50
- end
51
- else
52
- puts "'#{organizations}' could not be converted due to"
53
- puts error
54
- end
55
- end
56
- end
1
+ require 'fruit_to_lime'
2
+
3
+ class ToModel
4
+ def to_organization(row)
5
+ organization = FruitToLime::Organization.new
6
+ organization.integration_id = row['id']
7
+ organization.name = row['name']
8
+ return organization
9
+ end
10
+
11
+ def to_model(organization_file_name)
12
+ rootmodel = FruitToLime::RootModel.new
13
+ if organization_file_name != nil
14
+ organization_file_data = File.open(organization_file_name, 'r').read.encode('UTF-8',"ISO-8859-1")
15
+ rows = FruitToLime::CsvHelper::text_to_hashes(organization_file_data)
16
+ rows.each do |row|
17
+ rootmodel.organizations.push(to_organization(row))
18
+ end
19
+ end
20
+ return rootmodel
21
+ end
22
+
23
+ def save_xml(file)
24
+ File.open(file,'w') do |f|
25
+ f.write(FruitToLime::SerializeHelper::serialize(to_xml_model))
26
+ end
27
+ end
28
+ end
29
+
30
+ require "thor"
31
+ require "fileutils"
32
+ require 'pathname'
33
+
34
+ class Cli < Thor
35
+ desc "to_go ORGANIZATIONS FILE", "Exports xml to FILE using for ORGANIZATIONS csv file."
36
+ def to_go(organizations, file = nil)
37
+ file = 'export.xml' if file == nil
38
+ toModel = ToModel.new()
39
+ model = toModel.to_model(organizations)
40
+ error = model.sanity_check
41
+ if error.empty?
42
+ validation_errors = model.validate
43
+
44
+ if validation_errors.empty?
45
+ model.serialize_to_file(file)
46
+ puts "'#{organizations}' has been converted into '#{file}'."
47
+ else
48
+ puts "'#{organizations}' could not be converted due to"
49
+ puts validation_errors
50
+ end
51
+ else
52
+ puts "'#{organizations}' could not be converted due to"
53
+ puts error
54
+ end
55
+ end
56
+ end
@@ -1,2 +1,2 @@
1
- id;name;
2
- 6;Alfs Mjukvaruutveckling
1
+ id;name;
2
+ 6;Alfs Mjukvaruutveckling
@@ -1,24 +1,24 @@
1
- # This file is copied to spec/ when you run 'rails generate rspec:install'
2
- #require File.expand_path("../../config/environment", __FILE__)
3
- #require 'rspec/rails'
4
- require 'rspec/autorun'
5
-
6
- # Requires supporting ruby files with custom matchers and macros, etc,
7
- # in spec/support/ and its subdirectories.
8
- #Dir[File.join(File.dirname(File.absolute_path(__FILE__)),"support/**/*.rb")].each { |f| require f }
9
-
10
- RSpec.configure do |config|
11
- # ## Mock Framework
12
- #
13
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
14
- #
15
- # config.mock_with :mocha
16
- # config.mock_with :flexmock
17
- # config.mock_with :rr
18
-
19
- # Run specs in random order to surface order dependencies. If you find an
20
- # order dependency and want to debug it, you can fix the order by providing
21
- # the seed, which is printed after each run.
22
- # --seed 1234
23
- config.order = "random"
24
- end
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ #require File.expand_path("../../config/environment", __FILE__)
3
+ #require 'rspec/rails'
4
+ require 'rspec/autorun'
5
+
6
+ # Requires supporting ruby files with custom matchers and macros, etc,
7
+ # in spec/support/ and its subdirectories.
8
+ #Dir[File.join(File.dirname(File.absolute_path(__FILE__)),"support/**/*.rb")].each { |f| require f }
9
+
10
+ RSpec.configure do |config|
11
+ # ## Mock Framework
12
+ #
13
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
14
+ #
15
+ # config.mock_with :mocha
16
+ # config.mock_with :flexmock
17
+ # config.mock_with :rr
18
+
19
+ # Run specs in random order to surface order dependencies. If you find an
20
+ # order dependency and want to debug it, you can fix the order by providing
21
+ # the seed, which is printed after each run.
22
+ # --seed 1234
23
+ config.order = "random"
24
+ end
@@ -1,14 +1,14 @@
1
- require 'spec_helper'
2
- require 'tomodel'
3
-
4
- describe 'ToModel' do
5
- before(:all) do
6
- toModel = ToModel.new
7
- organizations_file =File.join(File.dirname(__FILE__), 'sample_data', 'organizations.csv')
8
- @model = toModel.to_model(organizations_file)
9
- end
10
- it "will find something with a name" do
11
- organization = @model.organizations[0]
12
- organization.name.length.should > 0
13
- end
14
- end
1
+ require 'spec_helper'
2
+ require 'tomodel'
3
+
4
+ describe 'ToModel' do
5
+ before(:all) do
6
+ toModel = ToModel.new
7
+ organizations_file =File.join(File.dirname(__FILE__), 'sample_data', 'organizations.csv')
8
+ @model = toModel.to_model(organizations_file)
9
+ end
10
+ it "will find something with a name" do
11
+ organization = @model.organizations[0]
12
+ organization.name.length.should > 0
13
+ end
14
+ end
@@ -1,6 +1,6 @@
1
- source 'http://rubygems.org'
2
-
3
- gem 'rspec'
4
- gem 'roo'
5
- gem 'thor'
6
- gem 'fruit_to_lime'
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rspec'
4
+ gem 'roo'
5
+ gem 'thor'
6
+ gem 'fruit_to_lime'
@@ -1,7 +1,7 @@
1
- #!/usr/bin/env rake
2
- require 'rspec/core/rake_task'
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
7
- task :test => :spec
1
+ #!/usr/bin/env rake
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+ task :test => :spec
@@ -1,3 +1,3 @@
1
- require "./lib/tomodel"
2
-
1
+ require "./lib/tomodel"
2
+
3
3
  Cli.start(ARGV)
@@ -1,53 +1,53 @@
1
- require 'fruit_to_lime'
2
- require 'roo'
3
-
4
- class ToModel
5
- def to_organization(row)
6
- organization = FruitToLime::Organization.new()
7
- # Map properties
8
- organization.integration_id = row['Id']
9
- organization.name = row['Name']
10
-
11
- return organization
12
- end
13
-
14
- def to_model(organization_file_name)
15
- # from excel to csv
16
- organization_file_data = Roo::Excelx.new(organization_file_name)
17
-
18
- model = FruitToLime::RootModel.new
19
- rows = FruitToLime::RooHelper.new(organization_file_data).rows
20
- rows.each do |row|
21
- model.organizations.push(to_organization(row))
22
- end
23
- return model
24
- end
25
- end
26
-
27
- require "thor"
28
- require "fileutils"
29
- require 'pathname'
30
-
31
- class Cli < Thor
32
- desc "to_go ORGANIZATION FILE", "Converts excel file to Go xml format. ORGANIZATIONS is path to input file. FILE is output file where Go xml will go."
33
- def to_go(organizations, file = nil)
34
- file = 'export.xml' if file == nil
35
- toModel = ToModel.new()
36
- model = toModel.to_model(organizations)
37
- error = model.sanity_check
38
- if error.empty?
39
- validation_errors = model.validate
40
-
41
- if validation_errors.empty?
42
- model.serialize_to_file(file)
43
- puts "'#{organizations}' has been converted into '#{file}'."
44
- else
45
- puts "'#{organizations}' could not be converted due to"
46
- puts validation_errors
47
- end
48
- else
49
- puts "'#{organizations}' could not be converted due to"
50
- puts error
51
- end
52
- end
53
- end
1
+ require 'fruit_to_lime'
2
+ require 'roo'
3
+
4
+ class ToModel
5
+ def to_organization(row)
6
+ organization = FruitToLime::Organization.new()
7
+ # Map properties
8
+ organization.integration_id = row['Id']
9
+ organization.name = row['Name']
10
+
11
+ return organization
12
+ end
13
+
14
+ def to_model(organization_file_name)
15
+ # from excel to csv
16
+ organization_file_data = Roo::Excelx.new(organization_file_name)
17
+
18
+ model = FruitToLime::RootModel.new
19
+ rows = FruitToLime::RooHelper.new(organization_file_data).rows
20
+ rows.each do |row|
21
+ model.organizations.push(to_organization(row))
22
+ end
23
+ return model
24
+ end
25
+ end
26
+
27
+ require "thor"
28
+ require "fileutils"
29
+ require 'pathname'
30
+
31
+ class Cli < Thor
32
+ desc "to_go ORGANIZATION FILE", "Converts excel file to Go xml format. ORGANIZATIONS is path to input file. FILE is output file where Go xml will go."
33
+ def to_go(organizations, file = nil)
34
+ file = 'export.xml' if file == nil
35
+ toModel = ToModel.new()
36
+ model = toModel.to_model(organizations)
37
+ error = model.sanity_check
38
+ if error.empty?
39
+ validation_errors = model.validate
40
+
41
+ if validation_errors.empty?
42
+ model.serialize_to_file(file)
43
+ puts "'#{organizations}' has been converted into '#{file}'."
44
+ else
45
+ puts "'#{organizations}' could not be converted due to"
46
+ puts validation_errors
47
+ end
48
+ else
49
+ puts "'#{organizations}' could not be converted due to"
50
+ puts error
51
+ end
52
+ end
53
+ end