halite 1.0.9 → 1.0.10

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: fc5fe984b0094eeefa760ff15c5753f57fdb123f
4
- data.tar.gz: 2fc9844e4861e76ed8d02e7341a861d8aba565b3
3
+ metadata.gz: bfddd38f30a6b70f4d5c636a50311acc6a6c2268
4
+ data.tar.gz: d6d37b99036f8f509c850f09b18ce6a2d0a0f4a6
5
5
  SHA512:
6
- metadata.gz: 21781d4eb22ec0225fa959f25f0453c61a25ab1847fc6a8ad867683b7c543076cdb5183f8ba41c54641e97a1d65a6e4b0f8225217962377220d1696122b1ce80
7
- data.tar.gz: fe34c9ed0e7eafa2b09ddbc83f35f5423dc9502834f51a61a7e6bf89a0c38c935b71945e75eda9f96146747b26e671bb29c9f1819fb40c0ef1449a17e6fbed4c
6
+ metadata.gz: 40e107d045a947e952122a4120f9531cbb2ca0e19dd13935a6aaa7ba0e1f945102ccaf6656d5f9d70cc9b656238cfc32ba9ef6188c0a1f013f0d747d6d7036f0
7
+ data.tar.gz: c80e0e7c0a7fe6ef816cd6eac1fc8c272432a17d1031dacd7ced3d2a7f1d9af0920eb07527c86906856418c1a8e2e34777d16644e8a330704ee760f4e6b9fe32
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.0.10
4
+
5
+ * Fewer potential pitfalls when using the Halite spec helper in a non-gem
6
+ cookbook. Still not 100%, but better.
7
+
3
8
  ## v1.0.9
4
9
 
5
10
  * Additional `StubSpecifications` fixes.
@@ -37,20 +37,25 @@ module Halite
37
37
  def install
38
38
  extend Rake::DSL
39
39
  # Core Halite tasks
40
- desc "Convert #{gemspec.name}-#{gemspec.version} to a cookbook in the pkg directory"
41
- task 'chef:build' do
42
- build_cookbook
43
- end
40
+ unless options[:no_gem]
41
+ desc "Convert #{gemspec.name}-#{gemspec.version} to a cookbook in the pkg directory"
42
+ task 'chef:build' do
43
+ build_cookbook
44
+ end
44
45
 
45
- desc "Push #{gemspec.name}-#{gemspec.version} to Supermarket"
46
- task 'chef:release' => ['chef:build'] do
47
- release_cookbook
48
- end
46
+ desc "Push #{gemspec.name}-#{gemspec.version} to Supermarket"
47
+ task 'chef:release' => ['chef:build'] do
48
+ release_cookbook(pkg_path)
49
+ end
49
50
 
50
- # Patch the core gem tasks to run ours too
51
- unless options[:no_gem]
51
+ # Patch the core gem tasks to run ours too
52
52
  task 'build' => ['chef:build']
53
53
  task 'release' => ['chef:release']
54
+ else
55
+ desc "Push #{gem_name} to Supermarket"
56
+ task 'chef:release' do
57
+ release_cookbook(base)
58
+ end
54
59
  end
55
60
 
56
61
  # Foodcritic doesn't have a config file, so just always try to add it.
@@ -75,9 +80,14 @@ module Halite
75
80
 
76
81
  desc 'Run Foodcritic linter'
77
82
  task 'chef:foodcritic' do
78
- Dir.mktmpdir('halite_test') do |path|
79
- Halite.convert(gemspec, path)
80
- sh("foodcritic --chef-version #{Chef::VERSION} --epic-fail any --tags ~FC054 '#{path}'")
83
+ foodcritic_cmd = "foodcritic --chef-version #{Chef::VERSION} --epic-fail any --tags ~FC054 '%{path}'"
84
+ if options[:no_gem]
85
+ sh(foodcritic_cmd % {path: base})
86
+ else
87
+ Dir.mktmpdir('halite_test') do |path|
88
+ Halite.convert(gemspec, path)
89
+ sh(foodcritic_cmd % {path: path})
90
+ end
81
91
  end
82
92
  end
83
93
 
@@ -111,10 +121,10 @@ module Halite
111
121
  shell.say("#{gemspec.name} #{gemspec.version} converted to pkg/#{gemspec.name}-#{gemspec.version}/.", :green)
112
122
  end
113
123
 
114
- def release_cookbook
115
- Dir.chdir(pkg_path) do
124
+ def release_cookbook(path)
125
+ Dir.chdir(path) do
116
126
  sh('stove --no-git')
117
- shell.say("Pushed #{gemspec.name} #{gemspec.version} to supermarket.chef.io.", :green)
127
+ shell.say("Pushed #{gemspec.name} #{gemspec.version} to supermarket.chef.io.", :green) unless options[:no_gem]
118
128
  end
119
129
  end
120
130
 
@@ -56,7 +56,7 @@ module Halite
56
56
  def converge(*recipe_names, &block)
57
57
  raise Halite::Error.new('Cannot pass both recipe names and a recipe block to converge') if !recipe_names.empty? && block
58
58
  super(*recipe_names) do
59
- add_halite_cookbook(node, @halite_gemspec) if @halite_gemspec
59
+ add_halite_cookbooks(node, @halite_gemspec) if @halite_gemspec
60
60
  if block
61
61
  recipe = Chef::Recipe.new(nil, nil, run_context)
62
62
  recipe.instance_exec(&block)
@@ -66,19 +66,21 @@ module Halite
66
66
 
67
67
  private
68
68
 
69
- def add_halite_cookbook(node, gemspec)
70
- gem_data = Halite::Gem.new(gemspec)
71
- # Catch any dependency loops.
72
- return if run_context.cookbook_collection.include?(gem_data.cookbook_name)
73
- run_context.cookbook_collection[gem_data.cookbook_name] = gem_data.as_cookbook_version
74
- gem_data.cookbook_dependencies.each do |dep|
75
- add_halite_cookbook(node, dep.spec) if dep.spec
76
- end
77
- # Load attributes if any.
78
- gem_data.each_file('chef/attributes') do |_full_path, rel_path|
79
- raise Halite::Error.new("Chef does not support nested attribute files: #{rel_path}") if rel_path.include?(File::SEPARATOR)
80
- name = File.basename(rel_path, '.rb')
81
- node.include_attribute("#{gem_data.cookbook_name}::#{name}")
69
+ def add_halite_cookbooks(node, gemspecs)
70
+ Array(gemspecs).each do |gemspec|
71
+ gem_data = Halite::Gem.new(gemspec)
72
+ # Catch any dependency loops.
73
+ next if run_context.cookbook_collection.include?(gem_data.cookbook_name) && run_context.cookbook_collection[gem_data.cookbook_name].respond_to?(:halite_root)
74
+ run_context.cookbook_collection[gem_data.cookbook_name] = gem_data.as_cookbook_version
75
+ gem_data.cookbook_dependencies.each do |dep|
76
+ add_halite_cookbooks(node, dep.spec) if dep.spec
77
+ end
78
+ # Load attributes if any.
79
+ gem_data.each_file('chef/attributes') do |_full_path, rel_path|
80
+ raise Halite::Error.new("Chef does not support nested attribute files: #{rel_path}") if rel_path.include?(File::SEPARATOR)
81
+ name = File.basename(rel_path, '.rb')
82
+ node.include_attribute("#{gem_data.cookbook_name}::#{name}")
83
+ end
82
84
  end
83
85
  end
84
86
 
@@ -17,5 +17,5 @@
17
17
 
18
18
  module Halite
19
19
  # Halite version.
20
- VERSION = '1.0.9'
20
+ VERSION = '1.0.10'
21
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: halite
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noah Kantrowitz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-17 00:00:00.000000000 Z
11
+ date: 2015-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef