fruit_to_lime 0.8.1 → 0.8.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.
- data/lib/fruit_to_lime/templating.rb +26 -8
- data/spec/templating_spec.rb +10 -2
- data/templates/csv/spec/tomodel_spec.rb +1 -1
- data/templates/excel/lib/tomodel.rb +2 -2
- metadata +18 -2
@@ -1,5 +1,5 @@
|
|
1
1
|
require "fileutils"
|
2
|
-
|
2
|
+
require 'open3'
|
3
3
|
module FruitToLime
|
4
4
|
class Templating
|
5
5
|
def initialize(path)
|
@@ -10,19 +10,37 @@ module FruitToLime
|
|
10
10
|
Dir.entries(@path).select { |d| d != '.' && d != '..' }
|
11
11
|
end
|
12
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
|
+
|
13
31
|
def unpack(name, path)
|
14
32
|
template = list.find { |t| t == name }
|
15
33
|
if template
|
16
34
|
unpackedname = name
|
17
35
|
|
18
|
-
|
19
|
-
|
36
|
+
puts "Unpacking template #{name} to #{path}"
|
37
|
+
FileUtils.cp_r File.expand_path(name, @path), path
|
20
38
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
26
44
|
true
|
27
45
|
else
|
28
46
|
puts "Unable to find template #{name}"
|
data/spec/templating_spec.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'tmpdir'
|
3
3
|
|
4
|
+
def execute_command_with_success(cmd)
|
5
|
+
system(cmd)
|
6
|
+
if ! $?.success?
|
7
|
+
puts "Failed with #{$?}"
|
8
|
+
raise "failed! #{cmd}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
4
12
|
describe 'Templating' do
|
5
13
|
let(:templating) { FruitToLime::Templating.new(File.expand_path("../templates", File.dirname(__FILE__))) }
|
6
14
|
|
@@ -21,8 +29,8 @@ describe 'Templating' do
|
|
21
29
|
templating.list().each {|t|
|
22
30
|
templating.unpack t, unpack_path
|
23
31
|
Dir.chdir(File.expand_path(t, unpack_path)) do
|
24
|
-
|
25
|
-
|
32
|
+
execute_command_with_success('rake spec')
|
33
|
+
end
|
26
34
|
}
|
27
35
|
end
|
28
36
|
|
@@ -5,7 +5,7 @@ describe 'ToModel' do
|
|
5
5
|
before(:all) do
|
6
6
|
toModel = ToModel.new
|
7
7
|
organizations_file =File.join(File.dirname(__FILE__), 'sample_data', 'organizations.csv')
|
8
|
-
@model = toModel.to_model(organizations_file
|
8
|
+
@model = toModel.to_model(organizations_file)
|
9
9
|
end
|
10
10
|
it "will find something with a name" do
|
11
11
|
organization = @model.organizations[0]
|
@@ -32,8 +32,8 @@ class Cli < Thor
|
|
32
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
33
|
def to_go(organizations, file = nil)
|
34
34
|
file = 'export.xml' if file == nil
|
35
|
-
|
36
|
-
model =
|
35
|
+
toModel = ToModel.new()
|
36
|
+
model = toModel.to_model(organizations)
|
37
37
|
model.serialize_to_file(file)
|
38
38
|
end
|
39
39
|
end
|
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.8.
|
4
|
+
version: 0.8.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:
|
14
|
+
date: 2014-02-13 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: iso_country_codes
|
@@ -45,6 +45,22 @@ dependencies:
|
|
45
45
|
- - ! '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: thor
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
type: :runtime
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
48
64
|
- !ruby/object:Gem::Dependency
|
49
65
|
name: rspec
|
50
66
|
requirement: !ruby/object:Gem::Requirement
|