Use a class for FORMULA_META_FILES

* lets more text types get picked up
* better filter for `brew list`
This commit is contained in:
Adam Vandenberg 2012-09-09 13:19:53 -07:00
parent ff55e7d82e
commit 4b72e44461
4 changed files with 51 additions and 11 deletions

View File

@ -144,19 +144,22 @@ def install f
end end
# Find and link metafiles # Find and link metafiles
FORMULA_META_FILES.each do |filename| install_meta_files Pathname.pwd, f.prefix
next if File.directory? filename
target_file = filename
target_file = "#{filename}.txt" if File.exists? "#{filename}.txt"
# Some software symlinks these files (see help2man.rb)
target_file = Pathname.new(target_file).resolved_path
f.prefix.install target_file => filename rescue nil
(f.prefix/filename).chmod 0644 rescue nil
end
end end
end end
end end
def install_meta_files src_path, dst_path
src_path.children.each do |p|
next if p.directory?
next unless FORMULA_META_FILES.should_copy? p
# Some software symlinks these files (see help2man.rb)
filename = p.resolved_path
filename.chmod 0644
dst_path.install filename
end
end
def fixopt f def fixopt f
path = if f.linked_keg.directory? and f.linked_keg.symlink? path = if f.linked_keg.directory? and f.linked_keg.symlink?
f.linked_keg.realpath f.linked_keg.realpath

View File

@ -64,7 +64,7 @@ class PrettyListing
else else
print_dir pn print_dir pn
end end
elsif not (FORMULA_META_FILES + %w[.DS_Store INSTALL_RECEIPT.json]).include? pn.basename.to_s elsif FORMULA_META_FILES.should_list? pn.basename.to_s
puts pn puts pn
end end
end end

View File

@ -83,7 +83,8 @@ module Homebrew extend self
alias_method :failed?, :failed alias_method :failed?, :failed
end end
FORMULA_META_FILES = %w[README README.md ChangeLog CHANGES COPYING LICENSE LICENCE COPYRIGHT AUTHORS] require 'metafiles'
FORMULA_META_FILES = Metafiles.new
ISSUES_URL = "https://github.com/mxcl/homebrew/wiki/troubleshooting" ISSUES_URL = "https://github.com/mxcl/homebrew/wiki/troubleshooting"
unless ARGV.include? "--no-compat" or ENV['HOMEBREW_NO_COMPAT'] unless ARGV.include? "--no-compat" or ENV['HOMEBREW_NO_COMPAT']

View File

@ -0,0 +1,36 @@
class Metafiles
def initialize
@exts = %w[.txt .md .html]
@metafiles = %w[readme changelog changes copying license licence copyright authors]
end
def + other
@metafiles + other
end
def should_copy? file
include? file
end
def should_list? file
return false if %w[.DS_Store INSTALL_RECEIPT.json].include? file
not include? file
end
private
def include? p
p = p.to_s # Might be a pathname
p = p.downcase
path = Pathname.new(p)
if @exts.include? path.extname
p = path.basename(path.extname)
else
p = path.basename
end
p = p.to_s
return @metafiles.include? p
end
end