poise 2.7.2 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -2
  3. data/.travis.yml +61 -26
  4. data/.yardopts +2 -0
  5. data/.yo-rc.json +7 -0
  6. data/CHANGELOG.md +7 -0
  7. data/Gemfile +1 -1
  8. data/LICENSE +201 -202
  9. data/lib/poise.rb +1 -1
  10. data/lib/poise/helpers/option_collector.rb +2 -0
  11. data/lib/poise/helpers/resource_subclass.rb +5 -1
  12. data/lib/poise/version.rb +1 -1
  13. data/poise.gemspec +3 -1
  14. data/test/cookbook/libraries/app.rb +24 -17
  15. data/test/cookbook/libraries/app_config.rb +28 -20
  16. data/test/gemfiles/chef-12.0.gemfile +4 -0
  17. data/test/gemfiles/chef-12.1.gemfile +4 -0
  18. data/test/gemfiles/chef-12.10.gemfile +4 -0
  19. data/test/gemfiles/chef-12.11.gemfile +4 -0
  20. data/test/gemfiles/chef-12.12.gemfile +22 -0
  21. data/test/gemfiles/chef-12.13.gemfile +22 -0
  22. data/test/gemfiles/chef-12.14.gemfile +19 -0
  23. data/test/gemfiles/chef-12.15.gemfile +19 -0
  24. data/test/gemfiles/chef-12.16.gemfile +19 -0
  25. data/test/gemfiles/chef-12.17.gemfile +19 -0
  26. data/test/gemfiles/chef-12.18.gemfile +19 -0
  27. data/test/gemfiles/chef-12.19.gemfile +19 -0
  28. data/test/gemfiles/chef-12.2.gemfile +4 -0
  29. data/test/gemfiles/chef-12.3.gemfile +4 -0
  30. data/test/gemfiles/chef-12.4.gemfile +5 -2
  31. data/test/gemfiles/chef-12.5.gemfile +4 -0
  32. data/test/gemfiles/chef-12.6.gemfile +4 -0
  33. data/test/gemfiles/chef-12.7.gemfile +4 -0
  34. data/test/gemfiles/chef-12.8.gemfile +4 -0
  35. data/test/gemfiles/chef-12.9.gemfile +4 -0
  36. data/test/gemfiles/chef-12.gemfile +1 -1
  37. data/test/gemfiles/chef-13.0.gemfile +19 -0
  38. data/test/gemfiles/chef-13.gemfile +19 -0
  39. data/test/gemfiles/master.gemfile +8 -4
  40. data/test/spec/helpers/fused_spec.rb +4 -1
  41. data/test/spec/helpers/inversion_spec.rb +51 -48
  42. data/test/spec/helpers/option_collector_spec.rb +25 -3
  43. data/test/spec/helpers/resource_cloning_spec.rb +9 -7
  44. data/test/spec/utils_spec.rb +29 -17
  45. metadata +47 -5
@@ -69,7 +69,7 @@ end
69
69
  # include Poise(container: true)
70
70
  def Poise(options={})
71
71
  # Allow passing a class as a shortcut
72
- if options.is_a?(Class)
72
+ if options.is_a?(Class) || options.is_a?(Symbol)
73
73
  options = {parent: options}
74
74
  end
75
75
 
@@ -99,6 +99,8 @@ module Poise
99
99
  raise Poise::Error.new("Parser must be a Proc or Symbol: #{parser.inspect}") if parser && !(parser.is_a?(Proc) || parser.is_a?(Symbol))
100
100
  # Cast to a set at definition time.
101
101
  forced_keys = Set.new(forced_keys) unless forced_keys.is_a?(Set)
102
+ # Never allow name to be called accidentally since it does really wonky things.
103
+ forced_keys.add(:name)
102
104
  # Unlike LWRPBase.attribute, I don't care about Ruby 1.8. Worlds tiniest violin.
103
105
  define_method(name.to_sym) do |arg=nil, &block|
104
106
  iv_sym = :"@#{name}"
@@ -39,7 +39,11 @@ module Poise
39
39
  # Deal with the node maps.
40
40
  node_maps = {}
41
41
  node_maps['handler map'] = Chef.provider_handler_map if defined?(Chef.provider_handler_map)
42
- node_maps['priority map'] = Chef.provider_priority_map if defined?(Chef.provider_priority_map)
42
+ node_maps['priority map'] = if defined?(Chef.provider_priority_map)
43
+ Chef.provider_priority_map
44
+ else
45
+ Chef::Platform::ProviderPriorityMap.instance.send(:priority_map)
46
+ end
43
47
  # Patch anything in the descendants tracker.
44
48
  Chef::Provider.descendants.each do |provider|
45
49
  node_maps["#{provider} node map"] = provider.node_map if defined?(provider.node_map)
@@ -16,5 +16,5 @@
16
16
 
17
17
 
18
18
  module Poise
19
- VERSION = '2.7.2'
19
+ VERSION = '2.8.0'
20
20
  end
@@ -26,13 +26,15 @@ Gem::Specification.new do |spec|
26
26
  spec.description = "Helpers for writing extensible Chef cookbooks."
27
27
  spec.summary = spec.description
28
28
  spec.homepage = 'https://github.com/poise/poise'
29
- spec.license = 'Apache 2.0'
29
+ spec.license = 'Apache-2.0'
30
+ spec.metadata['platforms'] = 'any'
30
31
 
31
32
  spec.files = `git ls-files`.split($/)
32
33
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
33
34
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
34
35
  spec.require_paths = %w{lib}
35
36
 
37
+ spec.add_dependency 'chef', '>= 12', '< 14'
36
38
  spec.add_dependency 'halite', '~> 1.0'
37
39
 
38
40
  spec.add_development_dependency 'fauxhai', '>= 3.3.0' # For now.
@@ -14,31 +14,38 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
+ require 'chef/provider'
18
+ require 'chef/resource'
19
+
17
20
  require 'poise'
18
21
 
19
22
 
20
- class Chef
21
- class Resource::App < Resource
22
- include Poise(container: true)
23
- provides(:app)
24
- actions(:install)
23
+ module PoiseTest
24
+ module App
25
+ class Resource < Chef::Resource
26
+ include Poise(container: true)
27
+ provides(:app)
28
+ actions(:install)
25
29
 
26
- attribute(:path, kind_of: String, name_attribute: true)
27
- attribute(:user, kind_of: String, default: 'root')
28
- attribute(:group, kind_of: String, default: 'root')
29
- end
30
+ attribute(:path, kind_of: String, name_attribute: true)
31
+ attribute(:user, kind_of: String, default: 'root')
32
+ attribute(:group, kind_of: String, default: 'root')
33
+ end
30
34
 
31
- class Provider::App < Provider
32
- include Poise
35
+ class Provider < Chef::Provider
36
+ include Poise
37
+ provides(:app)
33
38
 
34
- def action_install
35
- notifying_block do
36
- directory new_resource.path do
37
- owner new_resource.user
38
- group new_resource.group
39
- mode '755'
39
+ def action_install
40
+ notifying_block do
41
+ directory new_resource.path do
42
+ owner new_resource.user
43
+ group new_resource.group
44
+ mode '755'
45
+ end
40
46
  end
41
47
  end
42
48
  end
49
+
43
50
  end
44
51
  end
@@ -14,34 +14,42 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require_relative 'app'
17
+ require 'chef/provider'
18
+ require 'chef/resource'
18
19
 
19
- class Chef
20
- class Resource::AppConfig < Resource
21
- include Poise(App)
22
- provides(:app_config)
23
- actions(:create)
20
+ require 'poise'
24
21
 
25
- attribute('', template: true, required: true)
26
- attribute(:config_name, kind_of: String, default: lazy { name.split('::').last })
27
22
 
28
- def path
29
- ::File.join(parent.path, config_name+'.conf')
23
+ module PoiseTest
24
+ module AppConfig
25
+ class Resource < Chef::Resource
26
+ include Poise(:app)
27
+ provides(:app_config)
28
+ actions(:create)
29
+
30
+ attribute('', template: true, required: true)
31
+ attribute(:config_name, kind_of: String, default: lazy { name.split('::').last })
32
+
33
+ def path
34
+ ::File.join(parent.path, config_name+'.conf')
35
+ end
30
36
  end
31
- end
32
37
 
33
- class Provider::AppConfig < Provider
34
- include Poise
38
+ class Provider < Chef::Provider
39
+ include Poise
40
+ provides(:app_config)
35
41
 
36
- def action_create
37
- notifying_block do
38
- file new_resource.path do
39
- owner new_resource.parent.user
40
- group new_resource.parent.group
41
- mode '644'
42
- content new_resource.content
42
+ def action_create
43
+ notifying_block do
44
+ file new_resource.path do
45
+ owner new_resource.parent.user
46
+ group new_resource.parent.group
47
+ mode '644'
48
+ content new_resource.content
49
+ end
43
50
  end
44
51
  end
45
52
  end
53
+
46
54
  end
47
55
  end
@@ -17,3 +17,7 @@
17
17
  eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
18
 
19
19
  gem 'chef', '~> 12.0.3'
20
+ gem 'chefspec', '< 6'
21
+ gem 'fauxhai', '<= 3.9.0'
22
+ gem 'foodcritic', '< 8'
23
+ gem 'rack', '< 2'
@@ -17,3 +17,7 @@
17
17
  eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
18
 
19
19
  gem 'chef', '~> 12.1.2'
20
+ gem 'chefspec', '< 6'
21
+ gem 'fauxhai', '<= 3.9.0'
22
+ gem 'foodcritic', '< 8'
23
+ gem 'rack', '< 2'
@@ -17,3 +17,7 @@
17
17
  eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
18
 
19
19
  gem 'chef', '~> 12.10.24'
20
+ gem 'chefspec', '< 6'
21
+ gem 'fauxhai', '<= 3.9.0'
22
+ gem 'foodcritic', '< 8'
23
+ gem 'rack', '< 2'
@@ -17,3 +17,7 @@
17
17
  eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
18
 
19
19
  gem 'chef', '~> 12.11.18'
20
+ gem 'chefspec', '< 6'
21
+ gem 'fauxhai', '<= 3.9.0'
22
+ gem 'foodcritic', '< 8'
23
+ gem 'rack', '< 2'
@@ -0,0 +1,22 @@
1
+ #
2
+ # Copyright 2017, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
+
19
+ gem 'chef', '~> 12.12.15'
20
+ gem 'chefspec', '< 6'
21
+ gem 'fauxhai', '<= 3.9.0'
22
+ gem 'foodcritic', '< 8'
@@ -0,0 +1,22 @@
1
+ #
2
+ # Copyright 2017, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
+
19
+ gem 'chef', '~> 12.13.37'
20
+ gem 'chefspec', '< 6'
21
+ gem 'fauxhai', '<= 3.9.0'
22
+ gem 'foodcritic', '< 8'
@@ -0,0 +1,19 @@
1
+ #
2
+ # Copyright 2017, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
+
19
+ gem 'chef', '~> 12.14.89'
@@ -0,0 +1,19 @@
1
+ #
2
+ # Copyright 2017, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
+
19
+ gem 'chef', '~> 12.15.19'
@@ -0,0 +1,19 @@
1
+ #
2
+ # Copyright 2017, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
+
19
+ gem 'chef', '~> 12.16.42'
@@ -0,0 +1,19 @@
1
+ #
2
+ # Copyright 2017, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
+
19
+ gem 'chef', '~> 12.17.44'
@@ -0,0 +1,19 @@
1
+ #
2
+ # Copyright 2017, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
+
19
+ gem 'chef', '~> 12.18.31'
@@ -0,0 +1,19 @@
1
+ #
2
+ # Copyright 2017, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
+
19
+ gem 'chef', '~> 12.19.36'
@@ -17,3 +17,7 @@
17
17
  eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
18
 
19
19
  gem 'chef', '~> 12.2.1'
20
+ gem 'chefspec', '< 6'
21
+ gem 'fauxhai', '<= 3.9.0'
22
+ gem 'foodcritic', '< 8'
23
+ gem 'rack', '< 2'
@@ -17,3 +17,7 @@
17
17
  eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
18
 
19
19
  gem 'chef', '~> 12.3.0'
20
+ gem 'chefspec', '< 6'
21
+ gem 'fauxhai', '<= 3.9.0'
22
+ gem 'foodcritic', '< 8'
23
+ gem 'rack', '< 2'
@@ -17,5 +17,8 @@
17
17
  eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
18
 
19
19
  gem 'chef', '~> 12.4.3'
20
- # Pending https://github.com/berkshelf/ridley/pull/335
21
- gem 'ridley', '4.4.1'
20
+ gem 'chefspec', '< 6'
21
+ gem 'fauxhai', '<= 3.9.0'
22
+ gem 'foodcritic', '< 8'
23
+ gem 'gh', '0.14.0'
24
+ gem 'rack', '< 2'
@@ -17,3 +17,7 @@
17
17
  eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
18
 
19
19
  gem 'chef', '~> 12.5.1'
20
+ gem 'chefspec', '< 6'
21
+ gem 'fauxhai', '<= 3.9.0'
22
+ gem 'foodcritic', '< 8'
23
+ gem 'rack', '< 2'
@@ -21,3 +21,7 @@ gem 'chef', '~> 12.6.0'
21
21
  # Disable "Thread.exclusive is deprecated, use Mutex" warnings because they
22
22
  # overflow the Travis logs.
23
23
  $VERBOSE = nil
24
+ gem 'chefspec', '< 6'
25
+ gem 'fauxhai', '<= 3.9.0'
26
+ gem 'foodcritic', '< 8'
27
+ gem 'rack', '< 2'
@@ -21,3 +21,7 @@ gem 'chef', '~> 12.7.2'
21
21
  # Disable "Thread.exclusive is deprecated, use Mutex" warnings because they
22
22
  # overflow the Travis logs.
23
23
  $VERBOSE = nil
24
+ gem 'chefspec', '< 6'
25
+ gem 'fauxhai', '<= 3.9.0'
26
+ gem 'foodcritic', '< 8'
27
+ gem 'rack', '< 2'
@@ -21,3 +21,7 @@ gem 'chef', '~> 12.8.1'
21
21
  # Disable "Thread.exclusive is deprecated, use Mutex" warnings because they
22
22
  # overflow the Travis logs.
23
23
  $VERBOSE = nil
24
+ gem 'chefspec', '< 6'
25
+ gem 'fauxhai', '<= 3.9.0'
26
+ gem 'foodcritic', '< 8'
27
+ gem 'rack', '< 2'