diff options
author | danielsdeleo <dan@getchef.com> | 2015-02-06 15:40:27 -0800 |
---|---|---|
committer | danielsdeleo <dan@getchef.com> | 2015-02-11 10:52:49 -0800 |
commit | a164ceb6cac2808088920e36e35b5e9c16a8496b (patch) | |
tree | b993a8b68ecf2817e800d3c5fd5fb9b39cf84a95 /lib/chef/cookbook_version.rb | |
parent | 6c9f246b04c23906dd5297d178a423c96bc7b369 (diff) | |
download | chef-a164ceb6cac2808088920e36e35b5e9c16a8496b.tar.gz |
Change hard errors to warnings for deprecated methods
Diffstat (limited to 'lib/chef/cookbook_version.rb')
-rw-r--r-- | lib/chef/cookbook_version.rb | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb index 4e3e8069a6..1f55ff8b72 100644 --- a/lib/chef/cookbook_version.rb +++ b/lib/chef/cookbook_version.rb @@ -63,47 +63,48 @@ class Chef cookbook_manifest.update_from(new_manifest) end + private def deprecated!(message) + if Chef::Config[:treat_deprecation_warnings_as_errors] + raise Exceptions::DeprecatedFeatureError, message + else + Chef::Log.warn(message) + end + end + def save_url # TODO: double check this code suggestion - msg = <<-WARNING + deprecated!(<<-DEPRECATED) Cookbooks now have multiple save URLs based on the capabilities of the Chef Server. To get the default save URL, use code like `Chef::CookbookManifest.new(cookbook_version).save_url` -WARNING - raise msg - # TODO: change to warning +DEPRECATED + cookbook_manifest.save_url end def force_save_url # TODO: double check this code suggestion - msg = <<-WARNING + deprecated!(<<-DEPRECATED) Cookbooks now have multiple save URLs based on the capabilities of the Chef Server. To get the default save URL, use code like `Chef::CookbookManifest.new(cookbook_version).force_save_url` -WARNING - raise msg - # TODO: change to warning +DEPRECATED cookbook_manifest.force_save_url end def to_hash # TODO: double check this code suggestion - msg = <<-WARNING + deprecated!(<<-DEPRECATED) Cookbooks now have multiple JSON representations based on the capabilities of the Chef Server. To get the Hash representation, use code like `Chef::CookbookManifest.new(cookbook_version).to_hash` -WARNING - raise msg - # TODO: change to warning +DEPRECATED cookbook_manifest.to_hash end def to_json(*a) # TODO: double check this code suggestion - msg = <<-WARNING + deprecated!(<<-DEPRECATED) Cookbooks now have multiple JSON representations based on the capabilities of the Chef Server. To get the JSON representation, use code like `Chef::CookbookManifest.new(cookbook_version).to_json` -WARNING - raise msg - # TODO: change to warning +DEPRECATED cookbook_manifest.to_json end |