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.

T.let(Set.new(%w[copying copyright license licence]).freeze, T::Set[String])
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

T.let(Set.new(%w[
  .adoc .asc .asciidoc .creole .html .markdown .md .mdown .mediawiki .mkdn
  .org .pod .rdoc .rst .rtf .textile .txt .wiki
]).freeze, T::Set[String])
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.

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

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.

Parameters:

Returns:

  • (Boolean)


26
27
28
29
30
31
32
33
34
35
# File 'metafiles.rb', line 26

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

  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.

Parameters:

Returns:

  • (Boolean)


19
20
21
22
23
# File 'metafiles.rb', line 19

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

  !copy?(file)
end