Module: Metafiles Private

Defined in:
metafiles.rb

Overview

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Helper for checking if a file is considered a metadata file.

Constant Summary collapse

LICENSES =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

Set.new(%w[copying copyright license licence]).freeze
EXTENSIONS =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

https://github.com/github/markup#markups

Set.new(%w[
  .adoc .asc .asciidoc .creole .html .markdown .md .mdown .mediawiki .mkdn
  .org .pod .rdoc .rst .rtf .textile .txt .wiki
]).freeze
BASENAMES =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

Set.new(%w[about authors changelog changes history news notes notice readme todo]).freeze

Class Method Summary collapse

Class Method Details

.copy?(file) ⇒ Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:

  • (Boolean)


22
23
24
25
26
27
28
29
# File 'metafiles.rb', line 22

def copy?(file)
  file = file.downcase
  return true if LICENSES.include? file.split(/\.|-/).first

  ext  = File.extname(file)
  file = File.basename(file, ext) if EXTENSIONS.include?(ext)
  BASENAMES.include?(file)
end

.list?(file) ⇒ Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:

  • (Boolean)


16
17
18
19
20
# File 'metafiles.rb', line 16

def list?(file)
  return false if %w[.DS_Store INSTALL_RECEIPT.json].include?(file)

  !copy?(file)
end