halite 1.0.13 → 1.1.0

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: e66ab65e7c5063df1c488321abb0195686fbf0ca
4
- data.tar.gz: e604f24d753db8d091b1b42657b2f74cf9574fc6
3
+ metadata.gz: 35d989833c7bbf082dd1025c03c64fd7fa678f5c
4
+ data.tar.gz: a8b72aea467f681b63a5a35de73323811b5be3a6
5
5
  SHA512:
6
- metadata.gz: e3e86e39e18f6940f45392764754bf3b08464c7e48ba5c7a28f86f3c308d6dfd07a23312ab71e3e4e6bf46b33da67ce273fd8900b7e529c7b51d84ba999e8f04
7
- data.tar.gz: 421b19411862494f282275d98f443676dc77c5d3aa35277205906b0aacf3c6e6300bfa65b9a8ed01b2ce9bb9f1cbc6bb7d72191f6a9e1fa5f6d791caf7462144
6
+ metadata.gz: 2b2904e09a894cd47f2e74a919c88749958edbc6c9cf158b6d5ba5b435aea7d7ce61e923434018872c2ea81348f41b7b35c21fa23ff7bb812fd8d402fda8e463
7
+ data.tar.gz: 18615c97d14307608a9ebf8f6fde591e3543ee65e9257001eaa17a498f5f042431e5b99b19f681a66763cb4454a0c96ac34de1d4a5e4d3829decb97781ce8e6a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Halite Changelog
2
2
 
3
+ ## v1.1.0
4
+
5
+ * Support the new `chef_version` metadata field through gem metadata. Defaults
6
+ to `~> 12` for now.
7
+ * Make spec helper resources look more like normal Chef resources when in auto
8
+ mode.
9
+ * Add Halite's synthetic cookbooks to the cookbook compiler too, for
10
+ include_recipe and friends.
11
+
3
12
  ## v1.0.13
4
13
 
5
14
  * Additional cookbook metadata to work with Foodcritic 5.1.
data/README.md CHANGED
@@ -48,6 +48,17 @@ automatically converted to cookbook dependencies.
48
48
  Any files under `chef/` in the gem will be written as is in to the cookbook.
49
49
  For example you can add a recipe to your gem via `chef/recipes/default.rb`.
50
50
 
51
+ ## Chef Version
52
+
53
+ By default cookbooks will be generated with `chef_version '~> 12'` to require
54
+ Chef 12.x. This can be overridden using the `halite_chef_version` metadata field:
55
+
56
+ ```ruby
57
+ Gem::Specification.new do |spec|
58
+ spec.metadata['halite_dependencies'] = '>= 12.0.0'
59
+ end
60
+ ```
61
+
51
62
  ## Rake Tasks
52
63
 
53
64
  The `halite/rake_tasks` module provides quick defaults. Gem name will be
@@ -46,6 +46,7 @@ module Halite
46
46
  buf << ", #{dep.requirement.inspect}" if dep.requirement != '>= 0'
47
47
  buf << "\n"
48
48
  end
49
+ buf << "chef_version #{(gem_data.spec.metadata['halite_chef_version'] || '~> 12').inspect} if defined?(chef_version)\n"
49
50
  end
50
51
  end
51
52
 
@@ -304,6 +304,9 @@ module Halite
304
304
  @action = :run
305
305
  @allowed_actions |= [:run]
306
306
  end
307
+ if defined?(self.class.default_action) && Array(self.class.default_action) == [:nothing]
308
+ self.class.default_action(:run)
309
+ end
307
310
  end
308
311
  end
309
312
  end
@@ -75,6 +75,10 @@ module Halite
75
75
  gem_data.cookbook_dependencies.each do |dep|
76
76
  add_halite_cookbooks(node, dep.spec) if dep.spec
77
77
  end
78
+ # Add to the compiler for RunContext#unreachable_cookbook?
79
+ cookbook_order = run_context.instance_variable_get(:@cookbook_compiler).cookbook_order
80
+ name_sym = gem_data.cookbook_name.to_sym
81
+ cookbook_order << name_sym unless cookbook_order.include?(name_sym)
78
82
  # Load attributes if any.
79
83
  gem_data.each_file('chef/attributes') do |_full_path, rel_path|
80
84
  raise Halite::Error.new("Chef does not support nested attribute files: #{rel_path}") if rel_path.include?(File::SEPARATOR)
@@ -17,5 +17,5 @@
17
17
 
18
18
  module Halite
19
19
  # Halite version.
20
- VERSION = '1.0.13'
20
+ VERSION = '1.1.0'
21
21
  end
@@ -23,6 +23,7 @@ describe Halite::Converter::Metadata do
23
23
  let(:version) { '1.0.0' }
24
24
  let(:cookbook_version) { version }
25
25
  let(:cookbook_dependencies) { [] }
26
+ let(:gem_metadata) { {} }
26
27
  let(:spec) do
27
28
  instance_double('Gem::Specification',
28
29
  author: nil,
@@ -32,6 +33,7 @@ describe Halite::Converter::Metadata do
32
33
  homepage: nil,
33
34
  license: nil,
34
35
  licenses: [],
36
+ metadata: gem_metadata,
35
37
  )
36
38
  end
37
39
  let(:gem_data) do
@@ -52,6 +54,7 @@ describe Halite::Converter::Metadata do
52
54
  it { is_expected.to eq <<-EOH }
53
55
  name "mygem"
54
56
  version "1.0.0"
57
+ chef_version "~> 12" if defined?(chef_version)
55
58
  EOH
56
59
  end # /context with simple data
57
60
 
@@ -63,6 +66,7 @@ EOH
63
66
  # header
64
67
  name "mygem"
65
68
  version "1.0.0"
69
+ chef_version "~> 12" if defined?(chef_version)
66
70
  EOH
67
71
  end # /context with a license header
68
72
 
@@ -72,6 +76,7 @@ EOH
72
76
  name "mygem"
73
77
  version "1.0.0"
74
78
  depends "other"
79
+ chef_version "~> 12" if defined?(chef_version)
75
80
  EOH
76
81
  end # /context with one dependency
77
82
 
@@ -82,6 +87,7 @@ name "mygem"
82
87
  version "1.0.0"
83
88
  depends "other", "~> 1.0"
84
89
  depends "another", "~> 2.0.0"
90
+ chef_version "~> 12" if defined?(chef_version)
85
91
  EOH
86
92
  end # /context with two dependencies
87
93
 
@@ -94,6 +100,7 @@ EOH
94
100
  name "mygem"
95
101
  version "1.0.0"
96
102
  description "My awesome library!"
103
+ chef_version "~> 12" if defined?(chef_version)
97
104
  EOH
98
105
  end # /context with a description
99
106
 
@@ -103,12 +110,23 @@ EOH
103
110
  allow(IO).to receive(:read).with('/source/README.md').and_return("My awesome readme!\nCopyright me.\n")
104
111
  end
105
112
 
106
- it { is_expected.to eq <<-'EOH' }
113
+ it { is_expected.to eq <<-EOH }
107
114
  name "mygem"
108
115
  version "1.0.0"
109
- long_description "My awesome readme!\nCopyright me.\n"
116
+ long_description "My awesome readme!\\nCopyright me.\\n"
117
+ chef_version "~> 12" if defined?(chef_version)
110
118
  EOH
111
119
  end # /context with a readme
120
+
121
+ context 'with a chef_version' do
122
+ let(:gem_metadata) { {'halite_chef_version' => '>= 0'} }
123
+
124
+ it { is_expected.to eq <<-EOH }
125
+ name "mygem"
126
+ version "1.0.0"
127
+ chef_version ">= 0" if defined?(chef_version)
128
+ EOH
129
+ end # /context with a chef_version
112
130
  end # /describe #generate
113
131
 
114
132
  describe '#write' do
@@ -6,3 +6,4 @@ maintainer "Noah Kantrowitz"
6
6
  maintainer_email "noah@coderanger.net"
7
7
  source_url "http://example.com/" if defined?(source_url)
8
8
  license "Apache 2.0"
9
+ chef_version "~> 12" if defined?(chef_version)
@@ -6,3 +6,4 @@ maintainer_email "noah@coderanger.net"
6
6
  source_url "http://example.com/" if defined?(source_url)
7
7
  license "Apache 2.0"
8
8
  depends "testdep"
9
+ chef_version "~> 12" if defined?(chef_version)
@@ -6,3 +6,4 @@ maintainer_email "noah@coderanger.net"
6
6
  source_url "http://example.com/" if defined?(source_url)
7
7
  license "Apache 2.0"
8
8
  depends "test2", "~> 4.5.6"
9
+ chef_version "~> 12" if defined?(chef_version)
@@ -59,7 +59,7 @@ describe Halite::SpecHelper do
59
59
  it { is_expected.to be < Chef::Resource }
60
60
  its(:resource_name) { is_expected.to eq :halite_test } if defined?(Chef::Resource.resource_name)
61
61
  it { expect(subject.new(nil, nil).resource_name).to eq(:halite_test) }
62
- it { expect(subject.new(nil, nil).action).to eq(:run) }
62
+ it { expect(Array(subject.new(nil, nil).action)).to eq([:run]) }
63
63
  it { expect(subject.new(nil, nil).allowed_actions).to eq([:nothing, :run]) }
64
64
  end # /context with defaults
65
65
 
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.13
4
+ version: 1.1.0
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-11-13 00:00:00.000000000 Z
11
+ date: 2015-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef