diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-02-05 15:00:00 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-02-05 15:00:00 -0800 |
commit | 686113531d23f30e9973d659c456ae33eb9cff1f (patch) | |
tree | f225de7251a8b49b8d183dd168bab0a0addbe23f /lib/chef/mixin/deprecation.rb | |
parent | d1cf34b059a16a81e0fc48de52ba29863bb41fe6 (diff) | |
download | chef-686113531d23f30e9973d659c456ae33eb9cff1f.tar.gz |
autofixing whitespace cops
4174 Style/SpaceInsideHashLiteralBraces
1860 Style/SpaceAroundOperators
1336 Style/SpaceInsideBlockBraces
1292 Style/AlignHash
997 Style/SpaceAfterComma
860 Style/SpaceAroundEqualsInParameterDefault
310 Style/EmptyLines
294 Style/IndentationConsistency
267 Style/TrailingWhitespace
238 Style/ExtraSpacing
212 Style/SpaceBeforeBlockBraces
166 Style/MultilineOperationIndentation
144 Style/TrailingBlankLines
120 Style/EmptyLineBetweenDefs
101 Style/IndentationWidth
82 Style/SpaceAroundBlockParameters
40 Style/EmptyLinesAroundMethodBody
29 Style/EmptyLinesAroundAccessModifier
1 Style/RescueEnsureAlignment
Diffstat (limited to 'lib/chef/mixin/deprecation.rb')
-rw-r--r-- | lib/chef/mixin/deprecation.rb | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/lib/chef/mixin/deprecation.rb b/lib/chef/mixin/deprecation.rb index 04c40dcf29..0f059a215f 100644 --- a/lib/chef/mixin/deprecation.rb +++ b/lib/chef/mixin/deprecation.rb @@ -19,10 +19,9 @@ class Chef module Mixin - - def self.deprecated_constants - @deprecated_constants ||= {} - end + def self.deprecated_constants + @deprecated_constants ||= {} + end # Add a deprecated constant to the Chef::Mixin namespace. # === Arguments @@ -33,34 +32,34 @@ class Chef # deprecate_constant(:RecipeDefinitionDSLCore, Chef::DSL::Recipe, <<-EOM) # Chef::Mixin::RecipeDefinitionDSLCore is deprecated, use Chef::DSL::Recipe instead. # EOM - def self.deprecate_constant(name, replacement, message) - deprecated_constants[name] = {:replacement => replacement, :message => message} - end + def self.deprecate_constant(name, replacement, message) + deprecated_constants[name] = { :replacement => replacement, :message => message } + end # Const missing hook to look up deprecated constants defined with # deprecate_constant. Emits a warning to the logger and returns the # replacement constant. Will call super, most likely causing an exception # for the missing constant, if +name+ is not found in the # deprecated_constants collection. - def self.const_missing(name) - if new_const = deprecated_constants[name] - Chef::Log.warn(new_const[:message]) - Chef::Log.warn("Called from: \n#{caller[0...3].map {|l| "\t#{l}"}.join("\n")}") - new_const[:replacement] - else - super - end + def self.const_missing(name) + if new_const = deprecated_constants[name] + Chef::Log.warn(new_const[:message]) + Chef::Log.warn("Called from: \n#{caller[0...3].map { |l| "\t#{l}" }.join("\n")}") + new_const[:replacement] + else + super end + end module Deprecation class DeprecatedObjectProxyBase KEEPERS = %w{__id__ __send__ instance_eval == equal? initialize object_id} - instance_methods.each { |method_name| undef_method(method_name) unless KEEPERS.include?(method_name.to_s)} + instance_methods.each { |method_name| undef_method(method_name) unless KEEPERS.include?(method_name.to_s) } end class DeprecatedInstanceVariable < DeprecatedObjectProxyBase - def initialize(target, ivar_name, level=nil) + def initialize(target, ivar_name, level = nil) @target, @ivar_name = target, ivar_name @level ||= :warn end @@ -80,7 +79,7 @@ class Chef called_from = called_from.flatten log("Accessing #{@ivar_name} by the variable @#{@ivar_name} is deprecated. Support will be removed in a future release.") log("Please update your cookbooks to use #{@ivar_name} in place of @#{@ivar_name}. Accessed from:") - called_from.each {|l| log(l)} + called_from.each { |l| log(l) } end def log(msg) @@ -91,7 +90,7 @@ class Chef end - def deprecated_ivar(obj, name, level=nil) + def deprecated_ivar(obj, name, level = nil) DeprecatedInstanceVariable.new(obj, name, level) end @@ -100,22 +99,22 @@ class Chef deprecated_attr_writer(name, alternative) end - def deprecated_attr_reader(name, alternative, level=:warn) + def deprecated_attr_reader(name, alternative, level = :warn) define_method(name) do Chef.log_deprecation("#{self.class}.#{name} is deprecated. Support will be removed in a future release.") Chef.log_deprecation(alternative) Chef.log_deprecation("Called from:") - caller[0..3].each {|c| Chef.log_deprecation(c)} + caller[0..3].each { |c| Chef.log_deprecation(c) } instance_variable_get("@#{name}") end end - def deprecated_attr_writer(name, alternative, level=:warn) + def deprecated_attr_writer(name, alternative, level = :warn) define_method("#{name}=") do |value| Chef.log_deprecation("Writing to #{self.class}.#{name} with #{name}= is deprecated. Support will be removed in a future release.") Chef.log_deprecation(alternative) Chef.log_deprecation("Called from:") - caller[0..3].each {|c| Chef.log_deprecation(c)} + caller[0..3].each { |c| Chef.log_deprecation(c) } instance_variable_set("@#{name}", value) end end |