Move helper Pathname methods into Refinement
https://docs.ruby-lang.org/en/2.4.0/syntax/refinements_rdoc.html
This commit is contained in:
parent
466055a1be
commit
96ca1c561a
@ -7,6 +7,32 @@ require "cli/parser"
|
|||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
|
module Refinements
|
||||||
|
refine Pathname do
|
||||||
|
sig { returns(T::Boolean) }
|
||||||
|
def core_formula_path?
|
||||||
|
fnmatch?("**/homebrew-core/Formula/**.rb", File::FNM_DOTMATCH)
|
||||||
|
end
|
||||||
|
|
||||||
|
sig { returns(T::Boolean) }
|
||||||
|
def core_cask_path?
|
||||||
|
fnmatch?("**/homebrew-cask/Casks/**.rb", File::FNM_DOTMATCH)
|
||||||
|
end
|
||||||
|
|
||||||
|
sig { returns(T::Boolean) }
|
||||||
|
def core_formula_tap?
|
||||||
|
self == CoreTap.instance.path
|
||||||
|
end
|
||||||
|
|
||||||
|
sig { returns(T::Boolean) }
|
||||||
|
def core_cask_tap?
|
||||||
|
self == CoreCaskTap.instance.path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
using Refinements
|
||||||
|
|
||||||
sig { returns(CLI::Parser) }
|
sig { returns(CLI::Parser) }
|
||||||
def edit_args
|
def edit_args
|
||||||
Homebrew::CLI::Parser.new do
|
Homebrew::CLI::Parser.new do
|
||||||
|
|||||||
@ -488,26 +488,6 @@ class Pathname
|
|||||||
.encode(Encoding::UTF_8, invalid: :replace)
|
.encode(Encoding::UTF_8, invalid: :replace)
|
||||||
.split("\n")
|
.split("\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(T::Boolean) }
|
|
||||||
def core_formula_path?
|
|
||||||
fnmatch?("**/homebrew-core/Formula/**.rb", File::FNM_DOTMATCH)
|
|
||||||
end
|
|
||||||
|
|
||||||
sig { returns(T::Boolean) }
|
|
||||||
def core_cask_path?
|
|
||||||
fnmatch?("**/homebrew-cask/Casks/**.rb", File::FNM_DOTMATCH)
|
|
||||||
end
|
|
||||||
|
|
||||||
sig { returns(T::Boolean) }
|
|
||||||
def core_formula_tap?
|
|
||||||
self == CoreTap.instance.path
|
|
||||||
end
|
|
||||||
|
|
||||||
sig { returns(T::Boolean) }
|
|
||||||
def core_cask_tap?
|
|
||||||
self == CoreCaskTap.instance.path
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
require "extend/os/pathname"
|
require "extend/os/pathname"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user