extend/ARGV: remove/private unused methods.
This commit is contained in:
parent
66155ea370
commit
495daf0aee
@ -1,18 +1,12 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module HomebrewArgvExtension
|
module HomebrewArgvExtension
|
||||||
def named
|
|
||||||
# TODO: use @instance variable to ||= cache when moving to CLI::Parser
|
|
||||||
self - options_only
|
|
||||||
end
|
|
||||||
|
|
||||||
def flags_only
|
def flags_only
|
||||||
select { |arg| arg.start_with?("--") }
|
select { |arg| arg.start_with?("--") }
|
||||||
end
|
end
|
||||||
|
|
||||||
def formulae
|
def formulae
|
||||||
require "formula"
|
require "formula"
|
||||||
# TODO: use @instance variable to ||= cache when moving to CLI::Parser
|
|
||||||
(downcased_unique_named - casks).map do |name|
|
(downcased_unique_named - casks).map do |name|
|
||||||
if name.include?("/") || File.exist?(name)
|
if name.include?("/") || File.exist?(name)
|
||||||
Formulary.factory(name, spec)
|
Formulary.factory(name, spec)
|
||||||
@ -33,10 +27,6 @@ module HomebrewArgvExtension
|
|||||||
flag_with_value&.delete_prefix(arg_prefix)
|
flag_with_value&.delete_prefix(arg_prefix)
|
||||||
end
|
end
|
||||||
|
|
||||||
def verbose?
|
|
||||||
flag?("--verbose") || !ENV["VERBOSE"].nil? || !ENV["HOMEBREW_VERBOSE"].nil?
|
|
||||||
end
|
|
||||||
|
|
||||||
def debug?
|
def debug?
|
||||||
flag?("--debug") || !ENV["HOMEBREW_DEBUG"].nil?
|
flag?("--debug") || !ENV["HOMEBREW_DEBUG"].nil?
|
||||||
end
|
end
|
||||||
@ -150,9 +140,12 @@ module HomebrewArgvExtension
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def named
|
||||||
|
self - options_only
|
||||||
|
end
|
||||||
|
|
||||||
def downcased_unique_named
|
def downcased_unique_named
|
||||||
# Only lowercase names, not paths, bottle filenames or URLs
|
# Only lowercase names, not paths, bottle filenames or URLs
|
||||||
# TODO: use @instance variable to ||= cache when moving to CLI::Parser
|
|
||||||
named.map do |arg|
|
named.map do |arg|
|
||||||
if arg.include?("/") || arg.end_with?(".tar.gz") || File.exist?(arg)
|
if arg.include?("/") || arg.end_with?(".tar.gz") || File.exist?(arg)
|
||||||
arg
|
arg
|
||||||
|
|||||||
@ -31,14 +31,14 @@ describe HomebrewArgvExtension do
|
|||||||
let(:argv) { ["foo", "--debug", "-v"] }
|
let(:argv) { ["foo", "--debug", "-v"] }
|
||||||
|
|
||||||
it "returns an array of non-option arguments" do
|
it "returns an array of non-option arguments" do
|
||||||
expect(subject.named).to eq ["foo"]
|
expect(subject.send(:named)).to eq ["foo"]
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when there are no named arguments" do
|
context "when there are no named arguments" do
|
||||||
let(:argv) { [] }
|
let(:argv) { [] }
|
||||||
|
|
||||||
it "returns an empty array" do
|
it "returns an empty array" do
|
||||||
expect(subject.named).to be_empty
|
expect(subject.send(:named)).to be_empty
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user