extend/ARGV: remove/private unused methods.

This commit is contained in:
Mike McQuaid 2020-03-04 17:27:52 +00:00
parent 66155ea370
commit 495daf0aee
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
2 changed files with 6 additions and 13 deletions

View File

@ -1,18 +1,12 @@
# frozen_string_literal: true
module HomebrewArgvExtension
def named
# TODO: use @instance variable to ||= cache when moving to CLI::Parser
self - options_only
end
def flags_only
select { |arg| arg.start_with?("--") }
end
def formulae
require "formula"
# TODO: use @instance variable to ||= cache when moving to CLI::Parser
(downcased_unique_named - casks).map do |name|
if name.include?("/") || File.exist?(name)
Formulary.factory(name, spec)
@ -33,10 +27,6 @@ module HomebrewArgvExtension
flag_with_value&.delete_prefix(arg_prefix)
end
def verbose?
flag?("--verbose") || !ENV["VERBOSE"].nil? || !ENV["HOMEBREW_VERBOSE"].nil?
end
def debug?
flag?("--debug") || !ENV["HOMEBREW_DEBUG"].nil?
end
@ -150,9 +140,12 @@ module HomebrewArgvExtension
end
end
def named
self - options_only
end
def downcased_unique_named
# Only lowercase names, not paths, bottle filenames or URLs
# TODO: use @instance variable to ||= cache when moving to CLI::Parser
named.map do |arg|
if arg.include?("/") || arg.end_with?(".tar.gz") || File.exist?(arg)
arg

View File

@ -31,14 +31,14 @@ describe HomebrewArgvExtension do
let(:argv) { ["foo", "--debug", "-v"] }
it "returns an array of non-option arguments" do
expect(subject.named).to eq ["foo"]
expect(subject.send(:named)).to eq ["foo"]
end
context "when there are no named arguments" do
let(:argv) { [] }
it "returns an empty array" do
expect(subject.named).to be_empty
expect(subject.send(:named)).to be_empty
end
end
end