diff options
| author | Adam Vandenberg | 2012-09-09 13:19:53 -0700 |
|---|---|---|
| committer | Adam Vandenberg | 2012-11-11 10:27:03 -0800 |
| commit | 4b72e444613509b3102a94de1d1029a9318fcbad (patch) | |
| tree | e721a0f1810d016d601957031ce289c880afc368 | |
| parent | ff55e7d82e7087567c9a370817d25e1542ff31f9 (diff) | |
| download | brew-4b72e444613509b3102a94de1d1029a9318fcbad.tar.bz2 | |
Use a class for FORMULA_META_FILES
* lets more text types get picked up
* better filter for `brew list`
| -rwxr-xr-x | Library/Homebrew/build.rb | 21 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/list.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/global.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/metafiles.rb | 36 |
4 files changed, 51 insertions, 11 deletions
diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb index 85ff88705..656b5e8c0 100755 --- a/Library/Homebrew/build.rb +++ b/Library/Homebrew/build.rb @@ -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 diff --git a/Library/Homebrew/cmd/list.rb b/Library/Homebrew/cmd/list.rb index 50e40c649..ba33f2bde 100644 --- a/Library/Homebrew/cmd/list.rb +++ b/Library/Homebrew/cmd/list.rb @@ -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 diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index d7071eafb..0d5a5c6a7 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -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'] diff --git a/Library/Homebrew/metafiles.rb b/Library/Homebrew/metafiles.rb new file mode 100644 index 000000000..f73cb36fa --- /dev/null +++ b/Library/Homebrew/metafiles.rb @@ -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 |
