summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-02-09 16:16:43 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2015-02-09 16:16:43 -0800
commit5a69125a49ebb10848cc87cb3e31a540b517c633 (patch)
tree2ecea98b9f88ec43de28775469ce61ad89439ee0
parentf9ca811feb8560a9b8e054030d6cf5ea62d8cfda (diff)
downloadchef-5a69125a49ebb10848cc87cb3e31a540b517c633.tar.gz
peer review feedback for deprecation warnings
-rw-r--r--lib/chef/deprecation/warnings.rb8
-rw-r--r--lib/chef/exceptions.rb4
-rw-r--r--lib/chef/log.rb4
3 files changed, 9 insertions, 7 deletions
diff --git a/lib/chef/deprecation/warnings.rb b/lib/chef/deprecation/warnings.rb
index 68b1d0e202..34f468ff53 100644
--- a/lib/chef/deprecation/warnings.rb
+++ b/lib/chef/deprecation/warnings.rb
@@ -24,9 +24,11 @@ class Chef
method_names.each do |name|
m = instance_method(name)
define_method(name) do |*args|
- Chef::Log.deprecation "Method '#{name}' of '#{self.class}' is deprecated. It will be removed in Chef 12."
- Chef::Log.deprecation "Please update your cookbooks accordingly. Accessed from:"
- caller[0..3].each {|l| Chef::Log.warn l}
+ message = []
+ message << "Method '#{name}' of '#{self.class}' is deprecated. It will be removed in Chef 12."
+ message << "Please update your cookbooks accordingly. Accessed from:"
+ caller[0..3].each {|l| message << l}
+ Chef::Log.deprecation message
super(*args)
end
end
diff --git a/lib/chef/exceptions.rb b/lib/chef/exceptions.rb
index 498970468a..38ba984ea7 100644
--- a/lib/chef/exceptions.rb
+++ b/lib/chef/exceptions.rb
@@ -213,8 +213,8 @@ class Chef
class NoProviderAvailable < RuntimeError; end
class DeprecatedFeatureError < RuntimeError;
- def initalize
- super("raising deprecation error due to treat_deprecation_warnings_as_errors being set")
+ def initalize(message)
+ super("#{message} (raising error due to treat_deprecation_warnings_as_errors being set)")
end
end
diff --git a/lib/chef/log.rb b/lib/chef/log.rb
index 56c0ef022c..5c737699bc 100644
--- a/lib/chef/log.rb
+++ b/lib/chef/log.rb
@@ -37,10 +37,10 @@ class Chef
def self.deprecation(msg=nil, &block)
if Chef::Config[:treat_deprecation_warnings_as_errors]
- error(msg, *block)
+ error(msg, &block)
raise Chef::Exceptions::DeprecatedFeatureError
else
- warn(msg, *block)
+ warn(msg, &block)
end
end