diff options
author | John Keiser <jkeiser@opscode.com> | 2014-04-22 20:46:59 -0700 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2014-04-22 20:46:59 -0700 |
commit | 9c38c558f0c280edec9e91a97aa9ecafc41938e4 (patch) | |
tree | 43aa415d572b8cf4bf6ab6132b2cd5324d990891 | |
parent | d89b956b954c5c62bb59fe5cf84a932206a76e85 (diff) | |
download | chef-9c38c558f0c280edec9e91a97aa9ecafc41938e4.tar.gz |
Work around 1.8.7 issue with Pathname.each_filename
-rw-r--r-- | lib/chef/cookbook_version.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb index b4c62c8453..21d435141c 100644 --- a/lib/chef/cookbook_version.rb +++ b/lib/chef/cookbook_version.rb @@ -617,11 +617,23 @@ class Chef # This happens to also support cookbook name != directory name. if root_dir pathname = Pathname.new(segment_file).relative_path_from(Pathname.new(root_dir)) + + # This insane dance brought to you by Ruby 1.8.7. + # Rather do specificity = pathname.each_filename.to_a? Me too. + i = 0 + parts = [] + pathname.each_filename do |part| + parts << part + break if i == 1 + i += 1 + end + # If the path is actually under root_dir ... - if pathname.each_filename.first != '..' + if parts[0] != '..' + # Grab the file name and specificity file_name = pathname.basename if segment == :templates || segment == :files - specificity = pathname.each_filename.to_a[1] + specificity = parts[1] else specificity = 'default' end |