From fcacb25cd5ca92b12a19a92b5e1a562d82392aec Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Sat, 7 Jun 2014 17:49:07 -0500 Subject: [PATCH] Eliminate FORMULA_META_FILES constant --- Library/Homebrew/cmd/list.rb | 4 +++- Library/Homebrew/extend/pathname.rb | 3 ++- Library/Homebrew/global.rb | 2 -- Library/Homebrew/metafiles.rb | 6 +++--- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/cmd/list.rb b/Library/Homebrew/cmd/list.rb index 8952f48732..4ca2d85319 100644 --- a/Library/Homebrew/cmd/list.rb +++ b/Library/Homebrew/cmd/list.rb @@ -1,3 +1,5 @@ +require "metafiles" + module Homebrew extend self def list @@ -100,7 +102,7 @@ class PrettyListing else print_dir pn end - elsif FORMULA_META_FILES.should_list? pn.basename.to_s + elsif Metafiles.list?(pn.basename.to_s) puts pn end end diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index b9730a89f8..91dd6d5a1d 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -1,6 +1,7 @@ require 'pathname' require 'mach' require 'resource' +require 'metafiles' # we enhance pathname to make our code more readable class Pathname @@ -381,7 +382,7 @@ class Pathname from.children.each do |p| next if p.directory? - next unless FORMULA_META_FILES.should_copy? p + next unless Metafiles.copy?(p) # Some software symlinks these files (see help2man.rb) filename = p.resolved_path # Some software links metafiles together, so by the time we iterate to one of them diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index 5c1155f33b..6fd01d1494 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -94,8 +94,6 @@ module Homebrew extend self alias_method :failed?, :failed end -require 'metafiles' -FORMULA_META_FILES = Metafiles.new ISSUES_URL = "https://github.com/Homebrew/homebrew/wiki/troubleshooting" HOMEBREW_PULL_OR_COMMIT_URL_REGEX = 'https:\/\/github.com\/(\w+)\/homebrew(-\w+)?\/(pull\/(\d+)|commit\/\w{4,40})' diff --git a/Library/Homebrew/metafiles.rb b/Library/Homebrew/metafiles.rb index 37e646bb5a..a6a2652922 100644 --- a/Library/Homebrew/metafiles.rb +++ b/Library/Homebrew/metafiles.rb @@ -5,12 +5,12 @@ class Metafiles news notes notice readme todo ] - def should_list? file - return false if %w[.DS_Store INSTALL_RECEIPT.json].include? file + def self.list?(file) + return false if %w[.DS_Store INSTALL_RECEIPT.json].include?(file) !copy?(file) end - def should_copy?(path) + def self.copy?(path) path = path.to_s.downcase ext = File.extname(path)