compat_resource 12.5.19 → 12.5.20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed2ecdd1297aa8a03bbca891cff1174ba781795b
4
- data.tar.gz: 33b5746d177b125bf0728714a29bae2a66ddcc69
3
+ metadata.gz: dcc44231613d35471cb0378bd77c57cdcf7f788b
4
+ data.tar.gz: 67886e5fff8f5c789dbdefb320966dd0a0534d32
5
5
  SHA512:
6
- metadata.gz: 4dcf6ebf7059ab9d56b600b25ce940120ec9418ac33dcd0fcdaf7ee5f563f0226818814c6dc92ea338bffe2f49eb3495c299896674d1c52f0e378287588f8f5b
7
- data.tar.gz: 48b108286a417bd3459157f54af57a3ce5e7d820851ad0d1fa1e9b5639078800ea35503bdcd2dcec8d391cbcd2e0af4ff8de67c54713e363a411376f083ecd6c
6
+ metadata.gz: 620e7fb90243c24c3ec80cfe532e8d67634a93253e27e8724a0fa48c0246203783864034857195fa6eb2cb99bd87dc48e204d7a99ede6c64a42116279d2c92db
7
+ data.tar.gz: e6e2986f4ffe22a66fa138718d19f030145d0baf2070a4ab5403d297164942c015eceb9b0fbe0d9b875ef2c585745bca682d1d677a3742cc26baa1dece0edf71
@@ -120,6 +120,10 @@ super if defined?(::Chef::Property)
120
120
  options[:instance_variable_name] = options[:instance_variable_name].to_sym if options[:instance_variable_name]
121
121
  end
122
122
 
123
+ def to_s
124
+ name
125
+ end
126
+
123
127
  #
124
128
  # The name of this property.
125
129
  #
@@ -251,16 +255,19 @@ super if defined?(::Chef::Property)
251
255
  return get(resource)
252
256
  end
253
257
 
254
- # myprop nil is sometimes a get (backcompat)
255
258
  if value.nil? && !explicitly_accepts_nil?(resource)
256
- # If you say "my_property nil" and the property explicitly accepts
257
- # nil values, we consider this a get.
258
- Chef.log_deprecation("#{name} nil currently does not overwrite the value of #{name}. This will change in Chef 13, and the value will be set to nil instead. Please change your code to explicitly accept nil using \"property :#{name}, [MyType, nil]\", or stop setting this value to nil.")
259
- return get(resource)
259
+ # In Chef 12, value(nil) does a *get* instead of a set, so we
260
+ # warn if the value would have been changed. In Chef 13, it will be
261
+ # equivalent to value = nil.
262
+ result = get(resource)
263
+ if !result.nil?
264
+ Chef.log_deprecation("#{name} nil currently does not overwrite the value of #{name}. This will change in Chef 13, and the value will be set to nil instead. Please change your code to explicitly accept nil using \"property :#{name}, [MyType, nil]\", or stop setting this value to nil.")
265
+ end
266
+ result
267
+ else
268
+ # Anything else, such as myprop(value) is a set
269
+ set(resource, value)
260
270
  end
261
-
262
- # Anything else (myprop value) is a set
263
- set(resource, value)
264
271
  end
265
272
 
266
273
  #
@@ -296,6 +303,28 @@ super if defined?(::Chef::Property)
296
303
  value
297
304
 
298
305
  else
306
+ # If the user does something like this:
307
+ #
308
+ # ```
309
+ # class MyResource < Chef::Resource
310
+ # property :content
311
+ # action :create do
312
+ # file '/x.txt' do
313
+ # content content
314
+ # end
315
+ # end
316
+ # end
317
+ # ```
318
+ #
319
+ # It won't do what they expect. This checks whether you try to *read*
320
+ # `content` while we are compiling the resource.
321
+ if resource.respond_to?(:enclosing_provider) && resource.enclosing_provider &&
322
+ !resource.currently_running_action &&
323
+ !name_property? &&
324
+ resource.enclosing_provider.respond_to?(name)
325
+ Chef::Log.warn("#{Chef::Log.caller_location}: property #{name} is declared in both #{resource} and #{resource.enclosing_provider}. Use new_resource.#{name} instead. At #{Chef::Log.caller_location}")
326
+ end
327
+
299
328
  if has_default?
300
329
  value = default
301
330
  if value.is_a?(DelayedEvaluator)
@@ -452,18 +481,22 @@ super if defined?(::Chef::Property)
452
481
  # stack trace if you use `define_method`.
453
482
  declared_in.class_eval <<-EOM, __FILE__, __LINE__+1
454
483
  def #{name}(value=NOT_PASSED)
484
+ raise "Property #{name} of \#{self} cannot be passed a block! If you meant to create a resource named #{name} instead, you'll need to first rename the property." if block_given?
455
485
  self.class.properties[#{name.inspect}].call(self, value)
456
486
  end
457
487
  def #{name}=(value)
488
+ raise "Property #{name} of \#{self} cannot be passed a block! If you meant to create a resource named #{name} instead, you'll need to first rename the property." if block_given?
458
489
  self.class.properties[#{name.inspect}].set(self, value)
459
490
  end
460
491
  EOM
461
492
  rescue SyntaxError
462
493
  # If the name is not a valid ruby name, we use define_method.
463
- declared_in.define_method(name) do |value=NOT_PASSED|
494
+ declared_in.define_method(name) do |value=NOT_PASSED, &block|
495
+ raise "Property #{name} of #{self} cannot be passed a block! If you meant to create a resource named #{name} instead, you'll need to first rename the property." if block
464
496
  self.class.properties[name].call(self, value)
465
497
  end
466
- declared_in.define_method("#{name}=") do |value|
498
+ declared_in.define_method("#{name}=") do |value, &block|
499
+ raise "Property #{name} of #{self} cannot be passed a block! If you meant to create a resource named #{name} instead, you'll need to first rename the property." if block
467
500
  self.class.properties[name].set(self, value)
468
501
  end
469
502
  end
@@ -150,26 +150,29 @@ super if defined?(::Chef::Resource)
150
150
  def current_value_does_not_exist!
151
151
  raise Chef::Exceptions::CurrentValueDoesNotExist
152
152
  end
153
- def self.action_class
154
- @action_class ||
155
- # If the superclass needed one, then we need one as well.
156
- if superclass.respond_to?(:action_class) && superclass.action_class
157
- declare_action_class
158
- end
159
- end
160
- def self.declare_action_class
161
- return @action_class if @action_class
162
-
163
- if superclass.respond_to?(:action_class)
164
- base_provider = superclass.action_class
153
+ def self.action_class(&block)
154
+ return @action_class if @action_class && !block
155
+ # If the superclass needed one, then we need one as well.
156
+ if block || (superclass.respond_to?(:action_class) && superclass.action_class)
157
+ @action_class = declare_action_class(&block)
165
158
  end
166
- base_provider ||= Chef::Provider
159
+ @action_class
160
+ end
161
+ def self.declare_action_class(&block)
162
+ @action_class ||= begin
163
+ if superclass.respond_to?(:action_class)
164
+ base_provider = superclass.action_class
165
+ end
166
+ base_provider ||= Chef::Provider
167
167
 
168
- resource_class = self
169
- @action_class = Class.new(base_provider) do
170
- include ActionClass
171
- self.resource_class = resource_class
168
+ resource_class = self
169
+ Class.new(base_provider) do
170
+ include ActionClass
171
+ self.resource_class = resource_class
172
+ end
172
173
  end
174
+ @action_class.class_eval(&block) if block
175
+ @action_class
173
176
  end
174
177
  FORBIDDEN_IVARS = [:@run_context, :@not_if, :@only_if, :@enclosing_provider]
175
178
  HIDDEN_IVARS = [:@allowed_actions, :@resource_name, :@source_line, :@run_context, :@name, :@not_if, :@only_if, :@elapsed_time, :@enclosing_provider]
@@ -25,6 +25,10 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
25
25
  class Resource < (defined?(::Chef::Resource) ? ::Chef::Resource : Object)
26
26
  module ActionClass
27
27
  CopiedFromChef.extend_chef_module(::Chef::Resource::ActionClass, self) if defined?(::Chef::Resource::ActionClass)
28
+ def to_s
29
+ "#{new_resource || "<no resource>"} action #{action ? action.inspect : "<no action>"}"
30
+ end
31
+
28
32
  #
29
33
  # If load_current_value! is defined on the resource, use that.
30
34
  #
@@ -1,3 +1,3 @@
1
1
  module CompatResource
2
- VERSION = '12.5.19'
2
+ VERSION = '12.5.20'
3
3
  end
@@ -1,8 +1,10 @@
1
- GEM
1
+ GIT
2
+ remote: git://github.com/chef/chef.git
3
+ revision: ac73c07e4183a083b5ca9a6fbe0ec5a9f9177219
4
+ branch: master
2
5
  specs:
3
- builder (3.2.2)
4
- chef (12.5.1)
5
- chef-config (= 12.5.1)
6
+ chef (12.6.0)
7
+ chef-config (= 12.6.0)
6
8
  chef-zero (~> 4.2, >= 4.2.2)
7
9
  diff-lcs (~> 1.2, >= 1.2.4)
8
10
  erubis (~> 2.7)
@@ -16,17 +18,22 @@ GEM
16
18
  net-ssh-multi (~> 1.1)
17
19
  ohai (>= 8.6.0.alpha.1, < 9)
18
20
  plist (~> 3.1.0)
21
+ proxifier (~> 1.0)
19
22
  pry (~> 0.9)
20
- rspec-core (~> 3.2)
21
- rspec-expectations (~> 3.2)
22
- rspec-mocks (~> 3.2)
23
+ rspec-core (~> 3.4)
24
+ rspec-expectations (~> 3.4)
25
+ rspec-mocks (~> 3.4)
23
26
  rspec_junit_formatter (~> 0.2.0)
24
27
  serverspec (~> 2.7)
25
28
  specinfra (~> 2.10)
26
29
  syslog-logger (~> 1.6)
27
- chef-config (12.5.1)
30
+ chef-config (12.6.0)
28
31
  mixlib-config (~> 2.0)
29
32
  mixlib-shellout (~> 2.0)
33
+
34
+ GEM
35
+ specs:
36
+ builder (3.2.2)
30
37
  chef-zero (4.3.2)
31
38
  ffi-yajl (~> 2.2)
32
39
  hashie (>= 2.0, < 4.0)
@@ -73,6 +80,7 @@ GEM
73
80
  systemu (~> 2.6.4)
74
81
  wmi-lite (~> 1.0)
75
82
  plist (3.1.0)
83
+ proxifier (1.0.3)
76
84
  pry (0.10.3)
77
85
  coderay (~> 1.1.0)
78
86
  method_source (~> 0.8.1)
@@ -119,7 +127,7 @@ PLATFORMS
119
127
  ruby
120
128
 
121
129
  DEPENDENCIES
122
- chef
130
+ chef!
123
131
 
124
132
  BUNDLED WITH
125
133
  1.10.6
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compat_resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.5.19
4
+ version: 12.5.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Keiser
8
8
  autorequire:
9
9
  bindir: files/bin
10
10
  cert_chain: []
11
- date: 2015-12-10 00:00:00.000000000 Z
11
+ date: 2015-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake