fruit_to_lime 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/fruit_to_lime +24 -24
- data/lib/fruit_to_lime/address_helper.rb +17 -17
- data/lib/fruit_to_lime/csv_helper.rb +32 -32
- data/lib/fruit_to_lime/model/address.rb +37 -37
- data/lib/fruit_to_lime/model/coworker.rb +44 -44
- data/lib/fruit_to_lime/model/coworker_reference.rb +17 -17
- data/lib/fruit_to_lime/model/customfield.rb +30 -30
- data/lib/fruit_to_lime/model/note.rb +38 -38
- data/lib/fruit_to_lime/model/organization.rb +140 -140
- data/lib/fruit_to_lime/model/person.rb +115 -115
- data/lib/fruit_to_lime/model/referencetosource.rb +42 -42
- data/lib/fruit_to_lime/model/rootmodel.rb +142 -142
- data/lib/fruit_to_lime/model/tag.rb +33 -33
- data/lib/fruit_to_lime/model_helpers.rb +19 -19
- data/lib/fruit_to_lime/roo_helper.rb +59 -59
- data/lib/fruit_to_lime/serialize_helper.rb +139 -139
- data/lib/fruit_to_lime/templating.rb +51 -51
- data/lib/fruit_to_lime.rb +13 -13
- data/spec/helpers/address_helper_spec.rb +48 -48
- data/spec/helpers/csv_helper_spec.rb +15 -15
- data/spec/helpers/roo_helper_spec.rb +10 -10
- data/spec/helpers/serialize_helper_spec.rb +211 -211
- data/spec/person_spec.rb +44 -44
- data/spec/spec_helper.rb +24 -24
- data/templates/csv/Gemfile +5 -5
- data/templates/csv/Rakefile.rb +7 -7
- data/templates/csv/convert.rb +2 -2
- data/templates/csv/lib/tomodel.rb +56 -56
- data/templates/csv/spec/sample_data/organizations.csv +2 -2
- data/templates/csv/spec/spec_helper.rb +24 -24
- data/templates/csv/spec/tomodel_spec.rb +14 -14
- data/templates/excel/Gemfile +6 -6
- data/templates/excel/Rakefile.rb +7 -7
- data/templates/excel/convert.rb +2 -2
- data/templates/excel/lib/tomodel.rb +53 -53
- data/templates/excel/spec/spec_helper.rb +20 -20
- data/templates/excel/spec/tomodel_spec.rb +18 -18
- data/templates/sqlserver/Gemfile +6 -6
- data/templates/sqlserver/Rakefile.rb +7 -7
- data/templates/sqlserver/convert.rb +2 -2
- data/templates/sqlserver/lib/tomodel.rb +67 -67
- data/templates/sqlserver/spec/spec_helper.rb +20 -20
- data/templates/sqlserver/spec/tomodel_spec.rb +9 -9
- metadata +2 -2
@@ -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
|
+
|
data/templates/sqlserver/Gemfile
CHANGED
@@ -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,67 +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
|
-
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
|
+
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
|
+
|
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: 0.9.
|
4
|
+
version: 0.9.2
|
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-03-
|
14
|
+
date: 2014-03-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: iso_country_codes
|