Prefer Dir.glob when iterating over the result

master
Jack Nagel 2014-05-31 10:00:24 -05:00
parent 6402ffc02b
commit 00b5f1b825
10 changed files with 14 additions and 19 deletions

View File

@ -18,7 +18,7 @@ class CouchdbLucene < Formula
rm_rf Dir["bin/*.bat"] rm_rf Dir["bin/*.bat"]
libexec.install Dir["*"] libexec.install Dir["*"]
Dir["#{libexec}/bin/*"].each do |path| Dir.glob("#{libexec}/bin/*") do |path|
bin_name = File.basename(path) bin_name = File.basename(path)
(bin+bin_name).write shim_script(bin_name) (bin+bin_name).write shim_script(bin_name)
end end

View File

@ -13,7 +13,7 @@ class Dex2jar < Formula
prefix.install_metafiles prefix.install_metafiles
libexec.install Dir['*'] libexec.install Dir['*']
Dir["#{libexec}/*.sh"].each do |script| Dir.glob("#{libexec}/*.sh") do |script|
bin.install_symlink script => File.basename(script, '.sh') bin.install_symlink script => File.basename(script, '.sh')
end end
end end

View File

@ -36,7 +36,7 @@ class Elixir < Formula
system "make" system "make"
bin.install Dir['bin/*'] - Dir['bin/*.bat'] bin.install Dir['bin/*'] - Dir['bin/*.bat']
Dir['lib/*/ebin'].each do |path| Dir.glob("lib/*/ebin") do |path|
app = File.basename(File.dirname(path)) app = File.basename(File.dirname(path))
(lib/app).install path (lib/app).install path
end end

View File

@ -289,7 +289,7 @@ class Gdal < Formula
system 'make', 'man' if build.head? system 'make', 'man' if build.head?
system 'make', 'install-man' system 'make', 'install-man'
# Clean up any stray doxygen files. # Clean up any stray doxygen files.
Dir[bin + '*.dox'].each { |p| rm p } Dir.glob("#{bin}/*.dox") { |p| rm p }
end end
def caveats def caveats

View File

@ -12,7 +12,7 @@ class Groovy < Formula
rm_f Dir["bin/*.bat"] rm_f Dir["bin/*.bat"]
if build.include? 'invokedynamic' if build.include? 'invokedynamic'
Dir['indy/*.jar'].each do |src_path| Dir.glob("indy/*.jar") do |src_path|
dst_file = File.basename(src_path, '-indy.jar') + '.jar' dst_file = File.basename(src_path, '-indy.jar') + '.jar'
dst_path = File.join('lib', dst_file) dst_path = File.join('lib', dst_file)
mv src_path, dst_path mv src_path, dst_path

View File

@ -19,7 +19,7 @@ class Jena < Formula
prefix.install %w{ LICENSE ReleaseNotes-Jena.txt NOTICE ReleaseNotes-TDB.txt README ReleaseNotes-ARQ.txt } prefix.install %w{ LICENSE ReleaseNotes-Jena.txt NOTICE ReleaseNotes-TDB.txt README ReleaseNotes-ARQ.txt }
doc.install ['javadoc-arq', 'javadoc-core', 'javadoc-sdb', 'javadoc-tdb', 'src-examples'] doc.install ['javadoc-arq', 'javadoc-core', 'javadoc-sdb', 'javadoc-tdb', 'src-examples']
libexec.install Dir['*'] libexec.install Dir['*']
Dir["#{libexec}/bin/*"].each do |path| Dir.glob("#{libexec}/bin/*") do |path|
bin_name = File.basename(path) bin_name = File.basename(path)
(bin+bin_name).write shim_script(bin_name) (bin+bin_name).write shim_script(bin_name)
end end

View File

@ -11,12 +11,12 @@ class Jetty < Formula
(libexec+'logs').mkpath (libexec+'logs').mkpath
bin.mkpath bin.mkpath
Dir["#{libexec}/bin/*.sh"].each do |f| Dir.glob("#{libexec}/bin/*.sh") do |f|
scriptname = File.basename(f, '.sh') scriptname = File.basename(f, '.sh')
(bin+scriptname).write <<-EOS.undent (bin+scriptname).write <<-EOS.undent
#!/bin/bash #!/bin/bash
JETTY_HOME=#{libexec} JETTY_HOME=#{libexec}
#{f} $@ #{f} "$@"
EOS EOS
chmod 0755, bin+scriptname chmod 0755, bin+scriptname
end end

View File

@ -21,7 +21,7 @@ class Luciddb < Formula
ENV['JAVA_HOME'] = `/usr/libexec/java_home`.chomp ENV['JAVA_HOME'] = `/usr/libexec/java_home`.chomp
system "./install.sh" system "./install.sh"
end end
Dir["#{libexec}/bin/*"].each do |b| Dir.glob("#{libexec}/bin/*") do |b|
next if b =~ /classpath.gen/ or b =~ /defineFarragoRuntime/ next if b =~ /classpath.gen/ or b =~ /defineFarragoRuntime/
n = File.basename(b) n = File.basename(b)
(bin+n).write shim_script(n) (bin+n).write shim_script(n)

View File

@ -38,22 +38,18 @@ class Nss < Formula
# rather than copying the referenced file. # rather than copying the referenced file.
cd "../dist" cd "../dist"
bin.mkdir bin.mkdir
Dir["Darwin*/bin/*"].each do |file| Dir.glob("Darwin*/bin/*") do |file|
cp file, bin unless file.include? ".dylib" cp file, bin unless file.include? ".dylib"
end end
include.mkdir include.mkdir
include_target = include + "nss" include_target = include + "nss"
include_target.mkdir include_target.mkdir
["dbm", "nss"].each do |dir| Dir.glob("public/{dbm,nss}/*") { |file| cp file, include_target }
Dir["public/#{dir}/*"].each do |file|
cp file, include_target
end
end
lib.mkdir lib.mkdir
libexec.mkdir libexec.mkdir
Dir["Darwin*/lib/*"].each do |file| Dir.glob("Darwin*/lib/*") do |file|
cp file, lib unless file.include? ".chk" cp file, lib unless file.include? ".chk"
cp file, libexec if file.include? ".chk" cp file, libexec if file.include? ".chk"
end end

View File

@ -20,8 +20,7 @@ class ShrewsoftVpnClient < Formula
# https://lists.shrew.net/pipermail/vpn-devel/2014-January/000636.html # https://lists.shrew.net/pipermail/vpn-devel/2014-January/000636.html
# there is no suport for an alternate Frameworks folder, must change hard-coded paths # there is no suport for an alternate Frameworks folder, must change hard-coded paths
["package/macosx/vpn-client-install.packproj"] + Dir.glob(%w[source/*/CMakeLists.txt package/macosx/vpn-client-install.packproj]) do |path|
Dir["source/*/CMakeLists.txt"].each do |path|
next unless File.read(path).include? "/Library/Frameworks" next unless File.read(path).include? "/Library/Frameworks"
inreplace path, "/Library/Frameworks", frameworks inreplace path, "/Library/Frameworks", frameworks
end end
@ -51,7 +50,7 @@ class ShrewsoftVpnClient < Formula
system "cmake", *cmake_args system "cmake", *cmake_args
# change relative framework paths to absolute ones (otherwise /Library/Frameworks is assumed) # change relative framework paths to absolute ones (otherwise /Library/Frameworks is assumed)
Dir["source/*/cmake_install.cmake"].each do |path| Dir.glob("source/*/cmake_install.cmake") do |path|
inreplace path, /"(ShrewSoft.+?\.framework)/, "\"#{frameworks}/\\1" inreplace path, /"(ShrewSoft.+?\.framework)/, "\"#{frameworks}/\\1"
end end