From 495daf0aee2b059c3e874010c39f3bb4305d0109 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 4 Mar 2020 17:27:52 +0000 Subject: [PATCH] extend/ARGV: remove/private unused methods. --- Library/Homebrew/extend/ARGV.rb | 15 ++++----------- Library/Homebrew/test/ARGV_spec.rb | 4 ++-- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb index 3f9856ce78..dfb0045f4a 100644 --- a/Library/Homebrew/extend/ARGV.rb +++ b/Library/Homebrew/extend/ARGV.rb @@ -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 diff --git a/Library/Homebrew/test/ARGV_spec.rb b/Library/Homebrew/test/ARGV_spec.rb index 1fa852f60e..d0c00a993b 100644 --- a/Library/Homebrew/test/ARGV_spec.rb +++ b/Library/Homebrew/test/ARGV_spec.rb @@ -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