brew/Library/Homebrew/metafiles.rb

33 lines
959 B
Ruby
Raw Normal View History

2020-10-10 14:16:11 +02:00
# typed: true
# frozen_string_literal: true
2020-08-17 19:48:09 +02:00
# Helper for checking if a file is considered a metadata file.
#
# @api private
module Metafiles
2020-08-26 14:28:23 -04:00
LICENSES = Set.new(%w[copying copyright license licence]).freeze
# https://github.com/github/markup#markups
2019-04-19 21:46:20 +09:00
EXTENSIONS = Set.new(%w[
.adoc .asc .asciidoc .creole .html .markdown .md .mdown .mediawiki .mkdn
.org .pod .rdoc .rst .rtf .textile .txt .wiki
]).freeze
2020-08-26 14:28:23 -04:00
BASENAMES = Set.new(%w[about authors changelog changes history news notes notice readme todo]).freeze
module_function
def list?(file)
2014-06-07 17:49:07 -05:00
return false if %w[.DS_Store INSTALL_RECEIPT.json].include?(file)
2018-09-17 02:45:00 +02:00
!copy?(file)
end
def copy?(file)
2014-06-07 23:40:26 -05:00
file = file.downcase
return true if LICENSES.include? file.split(/\.|-/).first
2020-08-26 14:28:23 -04:00
2014-06-07 23:40:26 -05:00
ext = File.extname(file)
file = File.basename(file, ext) if EXTENSIONS.include?(ext)
BASENAMES.include?(file)
end
end