mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
metafiles: Bump to Sorbet typed: strict
This commit is contained in:
parent
102dec893b
commit
87e5fedc16
@ -1,27 +1,33 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Helper for checking if a file is considered a metadata file.
|
# Helper for checking if a file is considered a metadata file.
|
||||||
module Metafiles
|
module Metafiles
|
||||||
LICENSES = Set.new(%w[copying copyright license licence]).freeze
|
LICENSES = T.let(Set.new(%w[copying copyright license licence]).freeze, T::Set[String])
|
||||||
# {https://github.com/github/markup#markups}
|
# {https://github.com/github/markup#markups}
|
||||||
EXTENSIONS = Set.new(%w[
|
EXTENSIONS = T.let(Set.new(%w[
|
||||||
.adoc .asc .asciidoc .creole .html .markdown .md .mdown .mediawiki .mkdn
|
.adoc .asc .asciidoc .creole .html .markdown .md .mdown .mediawiki .mkdn
|
||||||
.org .pod .rdoc .rst .rtf .textile .txt .wiki
|
.org .pod .rdoc .rst .rtf .textile .txt .wiki
|
||||||
]).freeze
|
]).freeze, T::Set[String])
|
||||||
BASENAMES = Set.new(%w[about authors changelog changes history news notes notice readme todo]).freeze
|
BASENAMES = T.let(Set.new(%w[
|
||||||
|
about authors changelog changes history news notes notice readme todo
|
||||||
|
]).freeze, T::Set[String])
|
||||||
|
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
|
sig { params(file: String).returns(T::Boolean) }
|
||||||
def list?(file)
|
def list?(file)
|
||||||
return false if %w[.DS_Store INSTALL_RECEIPT.json].include?(file)
|
return false if %w[.DS_Store INSTALL_RECEIPT.json].include?(file)
|
||||||
|
|
||||||
!copy?(file)
|
!copy?(file)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(file: String).returns(T::Boolean) }
|
||||||
def copy?(file)
|
def copy?(file)
|
||||||
file = file.downcase
|
file = file.downcase
|
||||||
return true if LICENSES.include? file.split(/\.|-/).first
|
license = file.split(/\.|-/).first
|
||||||
|
return false unless license
|
||||||
|
return true if LICENSES.include?(license)
|
||||||
|
|
||||||
ext = File.extname(file)
|
ext = File.extname(file)
|
||||||
file = File.basename(file, ext) if EXTENSIONS.include?(ext)
|
file = File.basename(file, ext) if EXTENSIONS.include?(ext)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user