Skip to content

Commit 2a5f39b

Browse files
committed
No more String#each it is gone from ruby 1.9
1 parent e702ec1 commit 2a5f39b

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

‎chef/lib/chef/client.rb‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,15 @@ def converge(solo=false)
316316
# Check for cookbooks in the path given
317317
# Chef::Config[:cookbook_path] can be a string or an array
318318
# if it's an array, go through it and check each one, raise error at the last one if no files are found
319-
Chef::Config[:cookbook_path].each_with_index do |cookbook_path, index|
320-
if file_exists?(cookbook_path)
319+
Chef::Log.fatal "BUGBUG: cookbook_path: #{Chef::Config[:cookbook_path]}"
320+
Array(Chef::Config[:cookbook_path]).each_with_index do |cookbook_path, index|
321+
if directory_not_empty?(cookbook_path)
322+
Chef::Log.fatal "BUGBUG: cb path not empty: #{cookbook_path}"
321323
break
322324
else
323-
(Chef::Log.fatal(e = "No cookbook found in #{Chef::Config[:cookbook_path].inspect}, make sure cookboook_path is set correctly."); (raise Chef::Exceptions::CookbookNotFound, e)) if is_last_element?(index, Chef::Config[:cookbook_path])
325+
msg = "No cookbook found in #{Chef::Config[:cookbook_path].inspect}, make sure cookboook_path is set correctly."
326+
Chef::Log.fatal(msg)
327+
raise Chef::Exceptions::CookbookNotFound, msg if is_last_element?(index, Chef::Config[:cookbook_path])
324328
end
325329
end
326330
end
@@ -333,12 +337,12 @@ def converge(solo=false)
333337

334338
private
335339

336-
def file_exists?(path)
337-
(File.exists?(path) and Dir.entries(path).size > 2) ? true : false
340+
def directory_not_empty?(path)
341+
File.exists?(path) && (Dir.entries(path).size > 2)
338342
end
339343

340344
def is_last_element?(index, object)
341-
object.class == Array ? index == object.size - 1 : true
345+
object.kind_of?(Array) ? index == object.size - 1 : true
342346
end
343347

344348
end

0 commit comments

Comments
 (0)