aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/metafiles.rb
blob: 9870aea2b4fdde0338727cac68b9ad4cb5bcfc29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class Metafiles
  EXTENSIONS = %w[.md .html .rtf .txt]
  BASENAMES = %w[
    about authors changelog changes copying copyright history license licence
    news notes notice readme todo
  ]

  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?(path)
    path = path.to_s.downcase
    ext  = File.extname(path)

    if EXTENSIONS.include?(ext)
      basename = File.basename(path, ext)
    else
      basename = File.basename(path)
    end

    return BASENAMES.include?(basename)
  end
end