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,16 +144,19 @@ 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
|
end
|
||||||
target_file = filename
|
end
|
||||||
target_file = "#{filename}.txt" if File.exists? "#{filename}.txt"
|
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)
|
# Some software symlinks these files (see help2man.rb)
|
||||||
target_file = Pathname.new(target_file).resolved_path
|
filename = p.resolved_path
|
||||||
f.prefix.install target_file => filename rescue nil
|
filename.chmod 0644
|
||||||
(f.prefix/filename).chmod 0644 rescue nil
|
dst_path.install filename
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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']
|
||||||
|
|||||||
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