fruit_to_lime 0.8.2 → 0.9.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.
Files changed (46) 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 -0
  6. data/lib/fruit_to_lime/model/coworker_reference.rb +17 -14
  7. data/lib/fruit_to_lime/model/customfield.rb +30 -29
  8. data/lib/fruit_to_lime/model/deal.rb +49 -0
  9. data/lib/fruit_to_lime/model/note.rb +38 -27
  10. data/lib/fruit_to_lime/model/organization.rb +140 -121
  11. data/lib/fruit_to_lime/model/person.rb +115 -111
  12. data/lib/fruit_to_lime/model/referencetosource.rb +42 -42
  13. data/lib/fruit_to_lime/model/rootmodel.rb +142 -39
  14. data/lib/fruit_to_lime/model/tag.rb +33 -28
  15. data/lib/fruit_to_lime/model_helpers.rb +19 -0
  16. data/lib/fruit_to_lime/roo_helper.rb +59 -54
  17. data/lib/fruit_to_lime/serialize_helper.rb +139 -139
  18. data/lib/fruit_to_lime/templating.rb +51 -51
  19. data/lib/fruit_to_lime.rb +13 -12
  20. data/spec/helpers/address_helper_spec.rb +48 -48
  21. data/spec/helpers/csv_helper_spec.rb +15 -15
  22. data/spec/helpers/roo_helper_spec.rb +10 -10
  23. data/spec/helpers/serialize_helper_spec.rb +211 -211
  24. data/spec/person_spec.rb +44 -44
  25. data/spec/spec_helper.rb +24 -24
  26. data/spec/templating_spec.rb +40 -40
  27. data/templates/csv/Gemfile +5 -5
  28. data/templates/csv/Rakefile.rb +7 -7
  29. data/templates/csv/convert.rb +2 -2
  30. data/templates/csv/lib/tomodel.rb +56 -42
  31. data/templates/csv/spec/sample_data/organizations.csv +2 -2
  32. data/templates/csv/spec/spec_helper.rb +24 -24
  33. data/templates/csv/spec/tomodel_spec.rb +14 -14
  34. data/templates/excel/Gemfile +6 -6
  35. data/templates/excel/Rakefile.rb +7 -7
  36. data/templates/excel/convert.rb +2 -2
  37. data/templates/excel/lib/tomodel.rb +53 -39
  38. data/templates/excel/spec/spec_helper.rb +20 -20
  39. data/templates/excel/spec/tomodel_spec.rb +18 -18
  40. data/templates/sqlserver/Gemfile +6 -6
  41. data/templates/sqlserver/Rakefile.rb +7 -7
  42. data/templates/sqlserver/convert.rb +2 -2
  43. data/templates/sqlserver/lib/tomodel.rb +67 -53
  44. data/templates/sqlserver/spec/spec_helper.rb +20 -20
  45. data/templates/sqlserver/spec/tomodel_spec.rb +9 -9
  46. metadata +23 -4
@@ -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,42 +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
- model.serialize_to_file(file)
41
- end
42
- 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,39 +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
- model.serialize_to_file(file)
38
- end
39
- 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
@@ -1,20 +1,20 @@
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
- RSpec.configure do |config|
6
- # ## Mock Framework
7
- #
8
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
9
- #
10
- # config.mock_with :mocha
11
- # config.mock_with :flexmock
12
- # config.mock_with :rr
13
-
14
- # Run specs in random order to surface order dependencies. If you find an
15
- # order dependency and want to debug it, you can fix the order by providing
16
- # the seed, which is printed after each run.
17
- # --seed 1234
18
- config.order = "random"
19
- end
20
-
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
+ RSpec.configure do |config|
6
+ # ## Mock Framework
7
+ #
8
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
9
+ #
10
+ # config.mock_with :mocha
11
+ # config.mock_with :flexmock
12
+ # config.mock_with :rr
13
+
14
+ # Run specs in random order to surface order dependencies. If you find an
15
+ # order dependency and want to debug it, you can fix the order by providing
16
+ # the seed, which is printed after each run.
17
+ # --seed 1234
18
+ config.order = "random"
19
+ end
20
+
@@ -1,18 +1,18 @@
1
- # Encoding: utf-8
2
-
3
- require 'spec_helper'
4
- require 'tomodel'
5
-
6
-
7
- describe 'Model' do
8
- before(:all) do
9
- toModel = ToModel.new
10
- samplefile =File.join(File.dirname(__FILE__), 'sample_data', 'sample.xlsx')
11
- @model = toModel.to_model(samplefile)
12
- end
13
- it "will find something with a name" do
14
- organization = @model.organizations[0]
15
- organization.name.length.should > 0
16
- end
17
- end
18
-
1
+ # Encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+ require 'tomodel'
5
+
6
+
7
+ describe 'Model' do
8
+ before(:all) do
9
+ toModel = ToModel.new
10
+ samplefile =File.join(File.dirname(__FILE__), 'sample_data', 'sample.xlsx')
11
+ @model = toModel.to_model(samplefile)
12
+ end
13
+ it "will find something with a name" do
14
+ organization = @model.organizations[0]
15
+ organization.name.length.should > 0
16
+ end
17
+ end
18
+
@@ -1,6 +1,6 @@
1
- source 'http://rubygems.org'
2
-
3
- gem 'rspec'
4
- gem 'thor'
5
- gem 'fruit_to_lime'
6
- gem 'tiny_tds'
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rspec'
4
+ gem 'thor'
5
+ gem 'fruit_to_lime'
6
+ gem 'tiny_tds'
@@ -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,67 @@
1
- require 'fruit_to_lime'
2
- require 'roo'
3
- require 'date'
4
-
5
- class ToModel
6
- def to_organization(row)
7
- organization = FruitToLime::Organization.new()
8
- organization.integration_id = row['id']
9
- organization.name = row['name']
10
- return organization
11
- end
12
-
13
- def to_model(organization_rows)
14
- model = FruitToLime::RootModel.new
15
-
16
- organization_rows.each do |row|
17
- model.organizations.push(to_organization(row))
18
- end
19
-
20
- return model
21
- end
22
- end
23
-
24
- require "thor"
25
- require "fileutils"
26
- require 'pathname'
27
- require 'tiny_tds'
28
-
29
- class Cli < Thor
30
- desc "to_go", "Connects to sql server and queries for organizations to Go xml format. HOST, DATABASE, USERNAME and PASSWORD for Sql server connection. FILE is output file where Go xml will go."
31
- def to_go(host, database, username, password, file = nil)
32
- puts "Connecting to database #{database} on server #{host} as user #{username}"
33
- client = TinyTds::Client.new(
34
- :username => username,
35
- :password => password,
36
- :host => host,
37
- :database => database)
38
-
39
- organizationSql =
40
- "SELECT
41
- c.id,
42
- c.name,
43
- FROM
44
- company c"
45
-
46
- organization_rows = client.execute(organizationSql)
47
-
48
- file = 'export.xml' if file == nil
49
- tomodel = ToModel.new()
50
- model = tomodel.to_model(organization_rows)
51
- model.serialize_to_file(file)
52
- end
53
- end
1
+ require 'fruit_to_lime'
2
+ require 'roo'
3
+ require 'date'
4
+
5
+ class ToModel
6
+ def to_organization(row)
7
+ organization = FruitToLime::Organization.new()
8
+ organization.integration_id = row['id']
9
+ organization.name = row['name']
10
+ return organization
11
+ end
12
+
13
+ def to_model(organization_rows)
14
+ model = FruitToLime::RootModel.new
15
+
16
+ organization_rows.each do |row|
17
+ model.organizations.push(to_organization(row))
18
+ end
19
+
20
+ return model
21
+ end
22
+ end
23
+
24
+ require "thor"
25
+ require "fileutils"
26
+ require 'pathname'
27
+ require 'tiny_tds'
28
+
29
+ class Cli < Thor
30
+ desc "to_go", "Connects to sql server and queries for organizations to Go xml format. HOST, DATABASE, USERNAME and PASSWORD for Sql server connection. FILE is output file where Go xml will go."
31
+ def to_go(host, database, username, password, file = nil)
32
+ puts "Connecting to database #{database} on server #{host} as user #{username}"
33
+ client = TinyTds::Client.new(
34
+ :username => username,
35
+ :password => password,
36
+ :host => host,
37
+ :database => database)
38
+
39
+ organizationSql =
40
+ "SELECT
41
+ c.id,
42
+ c.name,
43
+ FROM
44
+ company c"
45
+
46
+ organization_rows = client.execute(organizationSql)
47
+
48
+ file = 'export.xml' if file == nil
49
+ tomodel = ToModel.new()
50
+ model = tomodel.to_model(organization_rows)
51
+ error = model.sanity_check
52
+ if error.empty?
53
+ validation_errors = model.validate
54
+
55
+ if validation_errors.empty?
56
+ model.serialize_to_file(file)
57
+ puts "'#{organizations}' has been converted into '#{file}'."
58
+ else
59
+ puts "'#{organizations}' could not be converted due to"
60
+ puts validation_errors
61
+ end
62
+ else
63
+ puts "'#{organizations}' could not be converted due to"
64
+ puts error
65
+ end
66
+ end
67
+ end
@@ -1,20 +1,20 @@
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
- RSpec.configure do |config|
6
- # ## Mock Framework
7
- #
8
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
9
- #
10
- # config.mock_with :mocha
11
- # config.mock_with :flexmock
12
- # config.mock_with :rr
13
-
14
- # Run specs in random order to surface order dependencies. If you find an
15
- # order dependency and want to debug it, you can fix the order by providing
16
- # the seed, which is printed after each run.
17
- # --seed 1234
18
- config.order = "random"
19
- end
20
-
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
+ RSpec.configure do |config|
6
+ # ## Mock Framework
7
+ #
8
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
9
+ #
10
+ # config.mock_with :mocha
11
+ # config.mock_with :flexmock
12
+ # config.mock_with :rr
13
+
14
+ # Run specs in random order to surface order dependencies. If you find an
15
+ # order dependency and want to debug it, you can fix the order by providing
16
+ # the seed, which is printed after each run.
17
+ # --seed 1234
18
+ config.order = "random"
19
+ end
20
+
@@ -1,9 +1,9 @@
1
- # Encoding: utf-8
2
-
3
- require 'spec_helper'
4
- require 'tomodel'
5
-
6
- describe 'Model' do
7
-
8
- end
9
-
1
+ # Encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+ require 'tomodel'
5
+
6
+ describe 'Model' do
7
+
8
+ end
9
+