Use a class for FORMULA_META_FILES
* lets more text types get picked up * better filter for `brew list`
This commit is contained in:
parent
ff55e7d82e
commit
4b72e44461
@ -144,19 +144,22 @@ def install f
|
||||
end
|
||||
|
||||
# Find and link metafiles
|
||||
FORMULA_META_FILES.each do |filename|
|
||||
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
|
||||
install_meta_files Pathname.pwd, f.prefix
|
||||
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
|
||||
path = if f.linked_keg.directory? and f.linked_keg.symlink?
|
||||
f.linked_keg.realpath
|
||||
|
||||
@ -64,7 +64,7 @@ class PrettyListing
|
||||
else
|
||||
print_dir pn
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
@ -83,7 +83,8 @@ module Homebrew extend self
|
||||
alias_method :failed?, :failed
|
||||
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"
|
||||
|
||||
unless ARGV.include? "--no-compat" or ENV['HOMEBREW_NO_COMPAT']
|
||||
|
||||
36
Library/Homebrew/metafiles.rb
Normal file
36
Library/Homebrew/metafiles.rb
Normal 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
|
||||
Loading…
x
Reference in New Issue
Block a user