Prefer Dir.glob when iterating over the result

This commit is contained in:
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"]
libexec.install Dir["*"]
Dir["#{libexec}/bin/*"].each do |path|
Dir.glob("#{libexec}/bin/*") do |path|
bin_name = File.basename(path)
(bin+bin_name).write shim_script(bin_name)
end

View file

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

View file

@ -36,7 +36,7 @@ class Elixir < Formula
system "make"
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))
(lib/app).install path
end

View file

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

View file

@ -12,7 +12,7 @@ class Groovy < Formula
rm_f Dir["bin/*.bat"]
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_path = File.join('lib', dst_file)
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 }
doc.install ['javadoc-arq', 'javadoc-core', 'javadoc-sdb', 'javadoc-tdb', 'src-examples']
libexec.install Dir['*']
Dir["#{libexec}/bin/*"].each do |path|
Dir.glob("#{libexec}/bin/*") do |path|
bin_name = File.basename(path)
(bin+bin_name).write shim_script(bin_name)
end

View file

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

View file

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

View file

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

View file

@ -20,8 +20,7 @@ class ShrewsoftVpnClient < Formula
# 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
["package/macosx/vpn-client-install.packproj"] +
Dir["source/*/CMakeLists.txt"].each do |path|
Dir.glob(%w[source/*/CMakeLists.txt package/macosx/vpn-client-install.packproj]) do |path|
next unless File.read(path).include? "/Library/Frameworks"
inreplace path, "/Library/Frameworks", frameworks
end
@ -51,7 +50,7 @@ class ShrewsoftVpnClient < Formula
system "cmake", *cmake_args
# 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"
end