summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Danna <steve@opscode.com>2012-12-14 13:21:21 -0800
committerSteven Danna <steve@opscode.com>2013-01-23 22:37:36 -0800
commit786540e0b6754ebd1469142f678d598c64f7ebba (patch)
tree38ead1d52d61bbf8ecbe5228ca7429f23064c928
parentcc5f1632a82a339d6339aec4cace463c243610b5 (diff)
downloadchef-786540e0b6754ebd1469142f678d598c64f7ebba.tar.gz
[CHEF-3068] Fix test failures and guard against nil source_line
MatchData#matches doesn't appear to exist. Also, source_line will be nil for dynamically defined resources. The change in the regular expression is to account for the fact that the format of the source_line changes between unix-like and Windows platforms.
-rw-r--r--chef/lib/chef/resource.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/chef/lib/chef/resource.rb b/chef/lib/chef/resource.rb
index 364be3732b..9b4cb36243 100644
--- a/chef/lib/chef/resource.rb
+++ b/chef/lib/chef/resource.rb
@@ -553,7 +553,7 @@ F
end
def defined_at
- (file, line_no) = source_line.match(/(.*):(\d+)$/).matches
+ (file, line_no) = source_line.match(/(.*):(\d+):?.*$/).to_a[1,2] if source_line
if cookbook_name && recipe_name && source_line
"#{cookbook_name}::#{recipe_name} line #{line_no}"
elsif source_line