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.
- 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 -0
- data/lib/fruit_to_lime/model/coworker_reference.rb +17 -14
- data/lib/fruit_to_lime/model/customfield.rb +30 -29
- data/lib/fruit_to_lime/model/deal.rb +49 -0
- data/lib/fruit_to_lime/model/note.rb +38 -27
- data/lib/fruit_to_lime/model/organization.rb +140 -121
- data/lib/fruit_to_lime/model/person.rb +115 -111
- data/lib/fruit_to_lime/model/referencetosource.rb +42 -42
- data/lib/fruit_to_lime/model/rootmodel.rb +142 -39
- data/lib/fruit_to_lime/model/tag.rb +33 -28
- data/lib/fruit_to_lime/model_helpers.rb +19 -0
- data/lib/fruit_to_lime/roo_helper.rb +59 -54
- 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 -12
- 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/spec/templating_spec.rb +40 -40
- 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 -42
- 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 -39
- 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 -53
- data/templates/sqlserver/spec/spec_helper.rb +20 -20
- data/templates/sqlserver/spec/tomodel_spec.rb +9 -9
- metadata +23 -4
@@ -1,51 +1,51 @@
|
|
1
|
-
require "fileutils"
|
2
|
-
require 'open3'
|
3
|
-
module FruitToLime
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
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 exec_but_dont_show_unless_error(cmd)
|
14
|
+
std_out_value = []
|
15
|
+
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
|
16
|
+
while std_line = stdout.gets
|
17
|
+
std_out_value << std_line
|
18
|
+
end
|
19
|
+
|
20
|
+
exit_status = wait_thr.value
|
21
|
+
if !exit_status.success?
|
22
|
+
puts "Failed with #{exit_status}"
|
23
|
+
puts "std_out_value"
|
24
|
+
puts std_out_value
|
25
|
+
|
26
|
+
raise "failed exec #{cmd}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def unpack(name, path)
|
32
|
+
template = list.find { |t| t == name }
|
33
|
+
if template
|
34
|
+
unpackedname = name
|
35
|
+
|
36
|
+
puts "Unpacking template #{name} to #{path}"
|
37
|
+
FileUtils.cp_r File.expand_path(name, @path), path
|
38
|
+
|
39
|
+
# Now make sure all gems in template are installed
|
40
|
+
puts "Making sure all needed gems are present"
|
41
|
+
Dir.chdir(File.expand_path(unpackedname, path)) do
|
42
|
+
exec_but_dont_show_unless_error('bundle install --verbose')
|
43
|
+
end
|
44
|
+
true
|
45
|
+
else
|
46
|
+
puts "Unable to find template #{name}"
|
47
|
+
false
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/fruit_to_lime.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
-
module FruitToLime
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
1
|
+
module FruitToLime
|
2
|
+
def self.require_all_in(folder)
|
3
|
+
Dir.glob(File.join( File.dirname(File.absolute_path(__FILE__)),folder), &method(:require))
|
4
|
+
end
|
5
|
+
|
6
|
+
require 'fruit_to_lime/serialize_helper'
|
7
|
+
require 'fruit_to_lime/address_helper'
|
8
|
+
require 'fruit_to_lime/model_helpers'
|
9
|
+
FruitToLime::require_all_in 'fruit_to_lime/model/*.rb'
|
10
|
+
require 'fruit_to_lime/csv_helper'
|
11
|
+
require 'fruit_to_lime/roo_helper'
|
12
|
+
require 'fruit_to_lime/templating'
|
13
|
+
end
|
@@ -1,49 +1,49 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'fruit_to_lime'
|
3
|
-
|
4
|
-
describe FruitToLime::AddressHelper 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::AddressHelper 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,15 +1,15 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'fruit_to_lime'
|
3
|
-
|
4
|
-
describe FruitToLime::CsvHelper do
|
5
|
-
it "should" do
|
6
|
-
v = FruitToLime::CsvHelper.text_to_hashes("id;navn
|
7
|
-
1;Noerrebro")
|
8
|
-
v.should include({"id"=>"1","navn"=>"Noerrebro"})
|
9
|
-
end
|
10
|
-
it "should handle sv chars" do
|
11
|
-
v = FruitToLime::CsvHelper.text_to_hashes("id;navn
|
12
|
-
1;Bj\u{00F6}rk")
|
13
|
-
v.should include({"id"=>"1","navn"=>"Bj\u{00F6}rk"})
|
14
|
-
end
|
15
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fruit_to_lime'
|
3
|
+
|
4
|
+
describe FruitToLime::CsvHelper do
|
5
|
+
it "should" do
|
6
|
+
v = FruitToLime::CsvHelper.text_to_hashes("id;navn
|
7
|
+
1;Noerrebro")
|
8
|
+
v.should include({"id"=>"1","navn"=>"Noerrebro"})
|
9
|
+
end
|
10
|
+
it "should handle sv chars" do
|
11
|
+
v = FruitToLime::CsvHelper.text_to_hashes("id;navn
|
12
|
+
1;Bj\u{00F6}rk")
|
13
|
+
v.should include({"id"=>"1","navn"=>"Bj\u{00F6}rk"})
|
14
|
+
end
|
15
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'fruit_to_lime'
|
3
|
-
require 'roo'
|
4
|
-
describe FruitToLime::RooHelper do
|
5
|
-
it "should handle sv chars" do
|
6
|
-
samplefile = File.join(File.dirname(__FILE__), '..', 'sample_data', 'excel.xlsx')
|
7
|
-
rows = FruitToLime::RooHelper.new(Roo::Excelx.new(samplefile)).rows
|
8
|
-
rows.should include({"Alpha"=>"L\u00E5s","Beta"=>"m\u00E4sk","\u00D6rjan"=>"l\u00E4sk","\u00C4skil"=>""})
|
9
|
-
end
|
10
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fruit_to_lime'
|
3
|
+
require 'roo'
|
4
|
+
describe FruitToLime::RooHelper do
|
5
|
+
it "should handle sv chars" do
|
6
|
+
samplefile = File.join(File.dirname(__FILE__), '..', 'sample_data', 'excel.xlsx')
|
7
|
+
rows = FruitToLime::RooHelper.new(Roo::Excelx.new(samplefile)).rows
|
8
|
+
rows.should include({"Alpha"=>"L\u00E5s","Beta"=>"m\u00E4sk","\u00D6rjan"=>"l\u00E4sk","\u00C4skil"=>""})
|
9
|
+
end
|
10
|
+
end
|