diff options
author | John Keiser <john@johnkeiser.com> | 2015-12-10 09:18:15 -0800 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-12-10 14:55:20 -0800 |
commit | 1910740592068982a4b6f9ee58452375d60281d5 (patch) | |
tree | 58e358d3911f769ea3052a14b8e1bc2747b56378 /lib/chef/log.rb | |
parent | d8a869814a0cbe1a44ee47e5c3ac1802a8fef2f2 (diff) | |
download | chef-1910740592068982a4b6f9ee58452375d60281d5.tar.gz |
Warn when user sets a property of an inline resource to itself.
(User will expect "x x" to grab the parent property.)
Diffstat (limited to 'lib/chef/log.rb')
-rw-r--r-- | lib/chef/log.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/chef/log.rb b/lib/chef/log.rb index bf846c2072..93c0cbbe68 100644 --- a/lib/chef/log.rb +++ b/lib/chef/log.rb @@ -37,6 +37,20 @@ class Chef end end + # + # Get the location of the caller (from the recipe). Grabs the first caller + # that is *not* in the chef gem proper (allowing us to weed out internal + # calls and give the user a more useful perspective). + # + # @return [String] The location of the caller (file:line#) from caller(0..20), or nil if no non-chef caller is found. + # + def self.caller_location + # Pick the first caller that is *not* part of the Chef gem, that's the + # thing the user wrote. + chef_gem_path = File.expand_path("../..", __FILE__) + caller(0..20).select { |c| !c.start_with?(chef_gem_path) }.first + end + def self.deprecation(msg=nil, location=caller(2..2)[0], &block) if msg msg << " at #{Array(location).join("\n")}" |