From 59238cd343630104f53b56565f039391d08abd6a Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 20 Oct 2017 10:19:11 +0100 Subject: [PATCH] commands: tweak find_internal_commands. Use a more typical Ruby style. --- Library/Homebrew/cmd/commands.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/cmd/commands.rb b/Library/Homebrew/cmd/commands.rb index 13395a8c20..0dfc6c4512 100644 --- a/Library/Homebrew/cmd/commands.rb +++ b/Library/Homebrew/cmd/commands.rb @@ -51,11 +51,8 @@ module Homebrew end def find_internal_commands(directory) - directory.children.each_with_object([]) do |f, cmds| - if f.file? - next if f.basename.to_s =~ /^\./ - cmds << f.basename.to_s.sub(/\.(?:rb|sh)$/, "") - end - end + Pathname.glob(directory/"*") + .select(&:file?) + .map { |f| f.basename.to_s.sub(/\.(?:rb|sh)$/, "") } end end