kameleon-builder 2.2.1 → 2.2.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/CHANGELOG.rst CHANGED
@@ -1,13 +1,22 @@
1
1
  Kameleon CHANGELOG
2
2
  ==================
3
3
 
4
+ version 2.2.2
5
+ -------------
6
+
7
+ Released on July 23rd 2014
8
+
9
+ - [core] Added ``-h`` CLI option to print help
10
+ - [core] Added ``--templates-path`` CLI option to set different templates directory
11
+ - [core] Fixed regression about recipe ancestors loading
12
+
4
13
  version 2.2.1
5
14
  -------------
6
15
 
7
- Released on July 21st 2014
16
+ Released on July 22nd 2014
8
17
 
9
18
  - [core] Switch to default yaml parser (psych) and removed syck from dependencies
10
-
19
+ - [core] Loaded a recipe with all ancestors
11
20
 
12
21
  version 2.2.0
13
22
  -------------
data/lib/kameleon.rb CHANGED
@@ -15,9 +15,6 @@ module Kameleon
15
15
  attr_writer :env
16
16
  attr_writer :ui
17
17
  attr_writer :source_root
18
- attr_writer :templates_path
19
- attr_writer :templates_names
20
- attr_writer :templates_files
21
18
  attr_writer :log_on_progress
22
19
 
23
20
  # The source root is the path to the root directory of the kameleon gem.
@@ -25,28 +22,8 @@ module Kameleon
25
22
  @source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
26
23
  end
27
24
 
28
- def templates_path
29
- @templates_path ||= Pathname.new(File.join(source_root, 'templates'))
30
- end
31
-
32
- def templates_files
33
- if @templates.nil?
34
- files = Dir.foreach(templates_path).map do |f|
35
- Pathname.new(File.join(templates_path, f)) if f.include?(".yaml")
36
- end
37
- @templates = files.compact
38
- end
39
- @templates
40
- end
41
-
42
- def templates_names
43
- if @templates_names.nil?
44
- names = templates_files.map do |f|
45
- f.basename(f.extname).to_s
46
- end
47
- @templates_names = names
48
- end
49
- @templates_names
25
+ def default_templates_path
26
+ File.join(Kameleon.source_root, 'templates')
50
27
  end
51
28
 
52
29
  def env
data/lib/kameleon/cli.rb CHANGED
@@ -16,6 +16,9 @@ module Kameleon
16
16
  map %w(-h --help) => :help
17
17
 
18
18
  desc "import [TEMPLATE_NAME]", "Imports the given template"
19
+ method_option :templates_path, :type => :string ,
20
+ :default => Kameleon.default_templates_path, :aliases => "-t",
21
+ :desc => "Using another templates directory"
19
22
  def import(template_name)
20
23
  templates_path = Kameleon.env.templates_path
21
24
  template_path = File.join(templates_path, template_name) + '.yaml'
@@ -36,6 +39,9 @@ module Kameleon
36
39
  end
37
40
 
38
41
  desc "new [RECIPE_NAME] [TEMPLATE_NAME]", "Creates a new recipe"
42
+ method_option :templates_path, :type => :string ,
43
+ :default => Kameleon.default_templates_path, :aliases => "-t",
44
+ :desc => "Using another templates directory"
39
45
  def new(recipe_name, template_name)
40
46
  if recipe_name == template_name
41
47
  fail RecipeError, "Recipe name should be different from template name"
@@ -59,7 +65,7 @@ module Kameleon
59
65
  recipe_path = File.join(tmp_dir, recipe_name + '.yaml')
60
66
  ## copying recipe
61
67
  File.open(recipe_path, 'w+') do |file|
62
- extend_erb_tpl = File.join(Kameleon.env.templates_path, "extend.erb")
68
+ extend_erb_tpl = File.join(Kameleon.default_templates_path, "extend.erb")
63
69
  erb = ERB.new(File.open(extend_erb_tpl, 'rb') { |f| f.read })
64
70
  result = erb.result(binding)
65
71
  file.write(result)
@@ -71,9 +77,12 @@ module Kameleon
71
77
  end
72
78
 
73
79
  desc "templates", "Lists all defined templates"
80
+ method_option :templates_path, :type => :string ,
81
+ :default => Kameleon.default_templates_path, :aliases => "-t",
82
+ :desc => "Using another templates directory"
74
83
  def templates
75
84
  puts "The following templates are available in " \
76
- "#{ Kameleon.templates_path }:"
85
+ "#{ Kameleon.env.templates_path }:"
77
86
  templates_hash = []
78
87
  templates_path = File.join(Kameleon.env.templates_path, "/")
79
88
  all_yaml_files = Dir["#{templates_path}**/*.yaml"]
@@ -90,9 +99,11 @@ module Kameleon
90
99
  raise e if Kameleon.env.debug
91
100
  end
92
101
  end
102
+ unless templates_hash.empty?
93
103
  templates_hash = templates_hash.sort_by{ |k| k["name"] }
94
104
  name_width = templates_hash.map { |k| k['name'].size }.max
95
105
  desc_width = Kameleon.ui.shell.terminal_width - name_width - 3
106
+ end
96
107
  tp(templates_hash,
97
108
  {"name" => {:width => name_width}},
98
109
  { "description" => {:width => desc_width}})
@@ -195,7 +206,7 @@ module Kameleon
195
206
  Kameleon.ui.level = "debug" if self.options["debug"]
196
207
  opts = args[1]
197
208
  cmd_name = args[2][:current_command].name
198
- if opts.include? "--help"
209
+ if opts.include? "--help" or opts.include? "-h"
199
210
  CLI.command_help(Kameleon.ui.shell, cmd_name)
200
211
  raise Kameleon::Exit
201
212
  end
@@ -18,17 +18,15 @@ module Kameleon
18
18
  # symbolify commandline options
19
19
  options = options.inject({}) {|result,(key,value)| result.update({key.to_sym => value})}
20
20
  workspace = File.expand_path(Dir.pwd)
21
+ templates_path = File.expand_path(options[:templates_path] || Kameleon.default_templates_path)
21
22
  build_path = File.expand_path(options[:build_path] || File.join(workspace, "build"))
22
23
  cache_path = File.expand_path(options[:cache_path] || File.join(build_path, "cache"))
23
- defaults = {
24
+ options = {
24
25
  :workspace => Pathname.new(workspace),
25
- :templates_path => Kameleon.templates_path,
26
- :templates_names => Kameleon.templates_names,
26
+ :templates_path => Pathname.new(templates_path),
27
27
  :build_path => Pathname.new(build_path),
28
28
  :cache_path => Pathname.new(cache_path),
29
- :script => options[:script],
30
29
  }
31
- options = defaults.merge(options)
32
30
  Kameleon.ui.debug("Environment initialized (#{self})")
33
31
  # Injecting all variables of the options and assign the variables
34
32
  options.each do |key, value|
@@ -46,8 +46,12 @@ module Kameleon
46
46
  Kameleon.ui.debug("Loading #{@path}")
47
47
  fail RecipeError, "Could not find this following recipe : #{@path}" \
48
48
  unless File.file? @path
49
+ yaml_recipe = YAML.load_file @path
50
+ unless yaml_recipe.kind_of? Hash
51
+ fail RecipeError, "Invalid yaml error"
52
+ end
49
53
  # Load entended recipe variables
50
- yaml_recipe = load_base_recipe(@path)
54
+ yaml_recipe = load_base_recipe(yaml_recipe, @path)
51
55
  yaml_recipe.delete("extend")
52
56
 
53
57
  # Load Global variables
@@ -137,12 +141,7 @@ module Kameleon
137
141
  }
138
142
  end
139
143
 
140
- def load_base_recipe(path)
141
- yaml_recipe = YAML.load_file path
142
-
143
- unless yaml_recipe.kind_of? Hash
144
- fail RecipeError, "Invalid yaml error, #{path}"
145
- end
144
+ def load_base_recipe(yaml_recipe, path)
146
145
  base_recipe_name = yaml_recipe.fetch("extend", "")
147
146
  return yaml_recipe if base_recipe_name.empty?
148
147
 
@@ -188,7 +187,7 @@ module Kameleon
188
187
  end
189
188
  end
190
189
  @base_recipes_files.push(Pathname.new(base_recipe_path))
191
- return load_base_recipe(base_recipe_path)
190
+ return load_base_recipe(base_yaml_recipe, base_recipe_path)
192
191
  end
193
192
 
194
193
  def load_aliases(yaml_recipe)
data/version.txt CHANGED
@@ -1 +1 @@
1
- 2.2.1
1
+ 2.2.2
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kameleon-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.2
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Salem Harrache
@@ -11,51 +12,56 @@ authors:
11
12
  autorequire:
12
13
  bindir: bin
13
14
  cert_chain: []
14
- date: 2014-07-22 00:00:00.000000000 Z
15
+ date: 2014-07-23 00:00:00.000000000 Z
15
16
  dependencies:
16
17
  - !ruby/object:Gem::Dependency
17
18
  name: childprocess
18
19
  requirement: !ruby/object:Gem::Requirement
20
+ none: false
19
21
  requirements:
20
22
  - - ~>
21
23
  - !ruby/object:Gem::Version
22
24
  version: 0.5.3
23
- - - '>='
25
+ - - ! '>='
24
26
  - !ruby/object:Gem::Version
25
27
  version: 0.3.0
26
28
  type: :runtime
27
29
  prerelease: false
28
30
  version_requirements: !ruby/object:Gem::Requirement
31
+ none: false
29
32
  requirements:
30
33
  - - ~>
31
34
  - !ruby/object:Gem::Version
32
35
  version: 0.5.3
33
- - - '>='
36
+ - - ! '>='
34
37
  - !ruby/object:Gem::Version
35
38
  version: 0.3.0
36
39
  - !ruby/object:Gem::Dependency
37
40
  name: thor
38
41
  requirement: !ruby/object:Gem::Requirement
42
+ none: false
39
43
  requirements:
40
44
  - - ~>
41
45
  - !ruby/object:Gem::Version
42
46
  version: '0.19'
43
- - - '>='
47
+ - - ! '>='
44
48
  - !ruby/object:Gem::Version
45
49
  version: 0.15.0
46
50
  type: :runtime
47
51
  prerelease: false
48
52
  version_requirements: !ruby/object:Gem::Requirement
53
+ none: false
49
54
  requirements:
50
55
  - - ~>
51
56
  - !ruby/object:Gem::Version
52
57
  version: '0.19'
53
- - - '>='
58
+ - - ! '>='
54
59
  - !ruby/object:Gem::Version
55
60
  version: 0.15.0
56
61
  - !ruby/object:Gem::Dependency
57
62
  name: table_print
58
63
  requirement: !ruby/object:Gem::Requirement
64
+ none: false
59
65
  requirements:
60
66
  - - ~>
61
67
  - !ruby/object:Gem::Version
@@ -63,6 +69,7 @@ dependencies:
63
69
  type: :runtime
64
70
  prerelease: false
65
71
  version_requirements: !ruby/object:Gem::Requirement
72
+ none: false
66
73
  requirements:
67
74
  - - ~>
68
75
  - !ruby/object:Gem::Version
@@ -261,26 +268,27 @@ files:
261
268
  homepage: http://kameleon.readthedocs.org/
262
269
  licenses:
263
270
  - GPL-2
264
- metadata: {}
265
271
  post_install_message:
266
272
  rdoc_options: []
267
273
  require_paths:
268
274
  - lib
269
275
  required_ruby_version: !ruby/object:Gem::Requirement
276
+ none: false
270
277
  requirements:
271
- - - '>='
278
+ - - ! '>='
272
279
  - !ruby/object:Gem::Version
273
280
  version: '0'
274
281
  required_rubygems_version: !ruby/object:Gem::Requirement
282
+ none: false
275
283
  requirements:
276
- - - '>='
284
+ - - ! '>='
277
285
  - !ruby/object:Gem::Version
278
286
  version: '0'
279
287
  requirements: []
280
288
  rubyforge_project:
281
- rubygems_version: 2.1.11
289
+ rubygems_version: 1.8.23
282
290
  signing_key:
283
- specification_version: 4
291
+ specification_version: 3
284
292
  summary: Kameleon is a tool to build virtual machines from scratch
285
293
  test_files:
286
294
  - tests/helper.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 1eeb84f0518b9bf6cd2f84f448e0abf99b3384e6
4
- data.tar.gz: 1cae83863b12c6fb9ffab9f435c6d8bce27c456a
5
- SHA512:
6
- metadata.gz: 318367937e2f8525195ec158b0217c901ffa95b4c87e5711867e40aad830cec076be5380d94167c2f59a692e3efd355e4f635c328ec1283fa2ed8df22be78c92
7
- data.tar.gz: 81e853c7b87824f8d8bccfe5f7bd1ec0e8783e13a4a8a493f2f8ebfb3cdf836b2f26a72651e911705dbbebba8c9212e708aae32c73df9b9ae5927afd7a6f3110