itamae 1.0.0.beta49 → 1.0.0.beta50

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b37f53d2a4a61e4cd6c8dd6a2693f288ce8da97
4
- data.tar.gz: 110468b24b81c63dc09d2106d4da354db4ab9d8f
3
+ metadata.gz: 613d6fd0d20ee53c9d137d2262accac8a00782d5
4
+ data.tar.gz: 95900b2da4cee352834a7fc7f012a47f8b4eb62b
5
5
  SHA512:
6
- metadata.gz: 8ad905062073bbab497a56175390a6222853977fad875c23c045739222d4b2b70bfd8283be962e050172e0e661eaa01a1ce7e91b1bbb9f83fd34f43f6c033ac0
7
- data.tar.gz: 3bf7eb7d3e69ad208bb98ccc1f21338da49c52d1dab5fba7741826300a4e44ffa4b9f0e61ff6e45bce22fe37a17838916f5bd1355d26e473d69060d3d812e345
6
+ metadata.gz: 723341847d55096272ab9520b52f9982f1131fc95d470c2a6a033b5b511936673ce43842cc1593dd6cb9f6916dad9167622fdb47b28c7df6d863c4af72b8d828
7
+ data.tar.gz: cb9115ddb3f54c1a8c89cd6dec2771a993b606b4fc164dcab4250e17a525625bca8b2609c5adfcc955fef36f12a74af21979707207c1677effcfa6069ec890fc
data/lib/itamae/recipe.rb CHANGED
@@ -9,17 +9,29 @@ module Itamae
9
9
  attr_reader :children
10
10
  attr_reader :delayed_notifications
11
11
 
12
+ class << self
13
+ def find_recipe_in_gem(recipe)
14
+ target = recipe.gsub('::', '/')
15
+ target += '.rb' if target !~ /\.rb$/
16
+ plugin_name = recipe.split('::')[0]
17
+
18
+ spec = Gem.loaded_specs.values.find do |spec|
19
+ spec.name == "itamae-plugin-recipe-#{plugin_name}"
20
+ end
21
+
22
+ return nil unless spec
23
+
24
+ File.join(spec.lib_dirs_glob, 'itamae', 'plugin', 'recipe', target)
25
+ end
26
+ end
27
+
12
28
  def initialize(runner, path)
13
29
  @runner = runner
14
30
  @path = path
15
- @children = RecipeChildren.new
16
31
  @delayed_notifications = []
17
32
 
18
- load_children
19
- end
20
-
21
- def node
22
- @runner.node
33
+ context = EvalContext.new(self)
34
+ @children = context.children
23
35
  end
24
36
 
25
37
  def run(options = {})
@@ -36,72 +48,71 @@ module Itamae
36
48
  end
37
49
  end
38
50
 
39
- private
51
+ class EvalContext
52
+ attr_reader :children
40
53
 
41
- def load_children
42
- instance_eval(File.read(@path), @path, 1)
43
- end
44
-
45
- def respond_to_missing?(method, include_private = false)
46
- Resource.get_resource_class(method)
47
- true
48
- rescue NameError
49
- false
50
- end
54
+ def initialize(recipe)
55
+ @recipe = recipe
56
+ @children = RecipeChildren.new
51
57
 
52
- def method_missing(*args, &block)
53
- super unless args.size == 2
58
+ instance_eval(File.read(@recipe.path), @recipe.path, 1)
59
+ end
54
60
 
55
- method, name = args
56
- begin
57
- klass = Resource.get_resource_class(method)
61
+ def respond_to_missing?(method, include_private = false)
62
+ Resource.get_resource_class(method)
63
+ true
58
64
  rescue NameError
59
- super
65
+ false
60
66
  end
61
67
 
62
- resource = klass.new(self, name, &block)
63
- @children << resource
64
- end
68
+ def method_missing(*args, &block)
69
+ super unless args.size == 2
65
70
 
66
- def include_recipe(recipe)
67
- candidate_paths = [
68
- ::File.expand_path(recipe, File.dirname(@path)),
69
- find_recipe_from_load_path(recipe),
70
- ].compact
71
- target = candidate_paths.find {|path| File.exist?(path) }
71
+ method, name = args
72
+ begin
73
+ klass = Resource.get_resource_class(method)
74
+ rescue NameError
75
+ super
76
+ end
72
77
 
73
- unless target
74
- raise NotFoundError, "Recipe not found. (#{recipe})"
78
+ resource = klass.new(@recipe, name, &block)
79
+ @children << resource
75
80
  end
76
81
 
77
- if runner.children.find_recipe_by_path(target)
78
- Logger.debug "Recipe, #{target}, is skipped because it is already included"
79
- return
82
+ def define(name, params = {}, &block)
83
+ Resource.const_set(
84
+ Resource.get_resource_class_name(name),
85
+ Definition.create_class(name, params, &block)
86
+ )
80
87
  end
81
88
 
82
- recipe = Recipe.new(@runner, target)
83
- @children << recipe
84
- end
89
+ def include_recipe(target)
90
+ candidate_paths = [
91
+ ::File.expand_path(target, File.dirname(@recipe.path)),
92
+ Recipe.find_recipe_in_gem(target),
93
+ ].compact
94
+ path = candidate_paths.find {|path| File.exist?(path) }
85
95
 
86
- def find_recipe_from_load_path(recipe)
87
- target = recipe.gsub('::', '/')
88
- target += '.rb' if target !~ /\.rb$/
89
- plugin_name = recipe.split('::')[0]
96
+ unless path
97
+ raise NotFoundError, "Recipe not found. (#{target})"
98
+ end
90
99
 
91
- spec = Gem.loaded_specs.values.find do |spec|
92
- spec.name == "itamae-plugin-recipe-#{plugin_name}"
93
- end
100
+ if runner.children.find_recipe_by_path(path)
101
+ Logger.debug "Recipe, #{target}, is skipped because it is already included"
102
+ return
103
+ end
94
104
 
95
- return nil unless spec
105
+ recipe = Recipe.new(runner, path)
106
+ @children << recipe
107
+ end
96
108
 
97
- File.join(spec.lib_dirs_glob, 'itamae', 'plugin', 'recipe', target)
98
- end
109
+ def node
110
+ runner.node
111
+ end
99
112
 
100
- def define(name, params = {}, &block)
101
- Resource.const_set(
102
- Resource.get_resource_class_name(name),
103
- Definition.create_class(name, params, &block)
104
- )
113
+ def runner
114
+ @recipe.runner
115
+ end
105
116
  end
106
117
  end
107
118
  end
data/lib/itamae/runner.rb CHANGED
@@ -21,8 +21,13 @@ module Itamae
21
21
  if options[:ohai]
22
22
  unless Backend.instance.run_command("which ohai", error: false).exit_status == 0
23
23
  # install Ohai
24
- Logger.info "Installing ohai gem..."
25
- Backend.instance.run_command("gem install ohai --no-ri --no-rdoc")
24
+ Logger.info "Installing ohai package..."
25
+ begin
26
+ Backend.instance.run_specinfra(:install_package, "ohai")
27
+ rescue Itamae::Backend::CommandExecutionError
28
+ Logger.info "Installing Chef package... (because installing ohai package failed)"
29
+ Backend.instance.run_command("curl -L https://www.opscode.com/chef/install.sh | bash")
30
+ end
26
31
  end
27
32
 
28
33
  Logger.info "Loading node data via ohai..."
@@ -1 +1 @@
1
- 1.0.0.beta49
1
+ 1.0.0.beta50
data/wercker.yml CHANGED
@@ -9,6 +9,10 @@ build:
9
9
  - rvm-use:
10
10
  version: 2.1.1
11
11
 
12
+ - script:
13
+ name: update bundler
14
+ code: gem update bundler
15
+
12
16
  # A step that executes `bundle install` command
13
17
  - bundle-install
14
18
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itamae
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta49
4
+ version: 1.0.0.beta50
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryota Arai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-12 00:00:00.000000000 Z
11
+ date: 2014-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor