fruit_to_lime 0.7.0 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
data/bin/fruit_to_lime CHANGED
@@ -1,46 +1,23 @@
1
1
  #!/usr/bin/env ruby
2
2
  require "thor"
3
- require "fileutils"
4
-
5
- class Templating
6
- def initialize(path = nil)
7
- if path == nil
8
- path = File.expand_path("../templates", File.dirname(__FILE__))
9
- end
10
- @path = path
11
- end
12
-
13
- def list()
14
- Dir.entries(@path).select { |d| d != '.' && d != '..' }
15
- end
16
-
17
- def unpack(name, path)
18
- template = list.find { |t| t == name }
19
- if template
20
- puts "Unpacking template #{name} to #{path}"
21
-
22
- FileUtils.cp_r File.expand_path(name, @path), path
23
-
24
- true
25
- else
26
- puts "Unable to find template #{name}"
27
- false
28
- end
29
- end
30
- end
3
+ require "fruit_to_lime"
31
4
 
32
5
  class Cli < Thor
33
6
  desc "unpack_template NAME PATH", "Unpacks template with NAME in specified PATH or current directory if missing."
34
7
  def unpack_template(name, path = nil)
35
8
  path = '.' if path == nil
36
9
  path = File.absolute_path(path)
37
- Templating.new.unpack(name, path)
10
+ templates_path = File.expand_path("../templates", File.dirname(__FILE__))
11
+ templating = FruitToLime::Templating.new templates_path
12
+ templating.unpack(name, path)
38
13
  end
39
14
 
40
15
  desc "list_templates", "Lists all templates"
41
16
  def list_templates()
42
- templates = Templating.new.list
43
- puts templates
17
+ templates_path = File.expand_path("../templates", File.dirname(__FILE__))
18
+ templating = FruitToLime::Templating.new templates_path
19
+ list_of_templates = templating.list
20
+ puts list_of_templates
44
21
  end
45
22
  end
46
23
 
@@ -19,7 +19,7 @@ module FruitToLime
19
19
  r[@map[col]] = val
20
20
  end
21
21
  rs.push(r)
22
- end
22
+ end
23
23
  return rs
24
24
  end
25
25
 
@@ -43,10 +43,12 @@ module FruitToLime
43
43
  onecell.to_s
44
44
  when :time
45
45
  Roo::Base.integer_to_timestring(onecell)
46
+ when :formula
47
+ onecell.to_s
46
48
  else
47
- raise "unhandled celltype #{@data.celltype(row,col,sheet)}"
49
+ raise "unhandled celltype #{@data.celltype(row,col,sheet)} for cell at row: #{row}, col: #{col} in sheet #{sheet}"
48
50
  end || ""
49
51
  end
50
52
  end
51
53
  end
52
- end
54
+ end
@@ -0,0 +1,33 @@
1
+ require "fileutils"
2
+
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 unpack(name, path)
14
+ template = list.find { |t| t == name }
15
+ if template
16
+ unpackedname = name
17
+
18
+ puts "Unpacking template #{name} to #{path}"
19
+ FileUtils.cp_r File.expand_path(name, @path), path
20
+
21
+ # Now make sure all gems in template are installed
22
+ puts "Making sure all needed gems are present"
23
+ Dir.chdir(File.expand_path(unpackedname, path)) do
24
+ `bundle install`
25
+ end
26
+ true
27
+ else
28
+ puts "Unable to find template #{name}"
29
+ false
30
+ end
31
+ end
32
+ end
33
+ end
data/lib/fruit_to_lime.rb CHANGED
@@ -8,4 +8,5 @@ module FruitToLime
8
8
  FruitToLime::require_all_in 'fruit_to_lime/model/*.rb'
9
9
  require 'fruit_to_lime/csv_helper'
10
10
  require 'fruit_to_lime/roo_helper'
11
+ require 'fruit_to_lime/templating'
11
12
  end
@@ -0,0 +1,33 @@
1
+ require 'fileutils'
2
+ require 'tmpdir'
3
+
4
+ describe 'Templating' do
5
+ let(:templating) { FruitToLime::Templating.new(File.expand_path("../templates", File.dirname(__FILE__))) }
6
+
7
+ describe 'list' do
8
+ it 'can find some templates' do
9
+ templating.list().length.should > 0
10
+ end
11
+ end
12
+
13
+ describe 'unpack' do
14
+ unpack_path = File.expand_path("unpacked", Dir.tmpdir)
15
+ before {
16
+ FileUtils.remove_dir(unpack_path, true)
17
+ FileUtils.mkdir(unpack_path)
18
+ }
19
+
20
+ it 'can unpack all templates and run the template tests' do
21
+ templating.list().each {|t|
22
+ templating.unpack t, unpack_path
23
+ Dir.chdir(File.expand_path(t, unpack_path)) do
24
+ `rake spec`
25
+ end
26
+ }
27
+ end
28
+
29
+ after {
30
+ FileUtils.remove_dir(unpack_path, true)
31
+ }
32
+ end
33
+ end
@@ -2,3 +2,4 @@ source 'http://rubygems.org'
2
2
 
3
3
  gem 'thor'
4
4
  gem 'fruit_to_lime'
5
+ gem 'rspec'
@@ -1,5 +1,6 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
+ gem 'rspec'
3
4
  gem 'roo'
4
5
  gem 'thor'
5
- gem 'fruit_to_lime'
6
+ gem 'fruit_to_lime'
@@ -1,5 +1,6 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
+ gem 'rspec'
3
4
  gem 'thor'
4
5
  gem 'fruit_to_lime'
5
6
  gem 'tiny_tds'
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fruit_to_lime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Oskar Gewalli
9
9
  - Peter Wilhelmsson
10
+ - Anders Pålsson
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2013-11-26 00:00:00.000000000 Z
14
+ date: 2013-11-29 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: iso_country_codes
@@ -28,6 +29,22 @@ dependencies:
28
29
  - - ! '>='
29
30
  - !ruby/object:Gem::Version
30
31
  version: '0'
32
+ - !ruby/object:Gem::Dependency
33
+ name: bundler
34
+ requirement: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
31
48
  - !ruby/object:Gem::Dependency
32
49
  name: rspec
33
50
  requirement: !ruby/object:Gem::Requirement
@@ -60,6 +77,22 @@ dependencies:
60
77
  - - ! '>='
61
78
  - !ruby/object:Gem::Version
62
79
  version: '0'
80
+ - !ruby/object:Gem::Dependency
81
+ name: roo
82
+ requirement: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
63
96
  description: ! ' With this small library it should be much easier to generate import
64
97
  file to LimeGo.
65
98
 
@@ -83,6 +116,7 @@ files:
83
116
  - lib/fruit_to_lime/model/tag.rb
84
117
  - lib/fruit_to_lime/roo_helper.rb
85
118
  - lib/fruit_to_lime/serialize_helper.rb
119
+ - lib/fruit_to_lime/templating.rb
86
120
  - lib/fruit_to_lime.rb
87
121
  - bin/fruit_to_lime
88
122
  - templates/csv/convert.rb
@@ -111,6 +145,7 @@ files:
111
145
  - spec/helpers/serialize_helper_spec.rb
112
146
  - spec/person_spec.rb
113
147
  - spec/spec_helper.rb
148
+ - spec/templating_spec.rb
114
149
  homepage:
115
150
  licenses: []
116
151
  post_install_message:
@@ -142,3 +177,4 @@ test_files:
142
177
  - spec/helpers/serialize_helper_spec.rb
143
178
  - spec/person_spec.rb
144
179
  - spec/spec_helper.rb
180
+ - spec/templating_spec.rb