Implement ARGV.named in terms of ARGV.options_only
This commit is contained in:
parent
7a5e4f5cca
commit
e18da89f3c
@ -1,10 +1,10 @@
|
||||
module HomebrewArgvExtension
|
||||
def named
|
||||
@named ||= reject{|arg| arg[0..0] == '-'}
|
||||
@named ||= self - options_only
|
||||
end
|
||||
|
||||
def options_only
|
||||
select {|arg| arg[0..0] == '-'}
|
||||
select { |arg| arg.start_with?("-") }
|
||||
end
|
||||
|
||||
def formulae
|
||||
|
@ -21,8 +21,13 @@ class ArgvExtensionTests < Homebrew::TestCase
|
||||
end
|
||||
|
||||
def test_argv_named
|
||||
@argv << 'mxcl' << '--debug' << '-v'
|
||||
assert_equal 1, @argv.named.length
|
||||
@argv << "foo" << "--debug" << "-v"
|
||||
assert_equal %w[foo], @argv.named
|
||||
end
|
||||
|
||||
def test_options_only
|
||||
@argv << "--foo" << "-vds" << "a" << "b" << "cdefg"
|
||||
assert_equal %w[--foo -vds], @argv.options_only
|
||||
end
|
||||
|
||||
def test_empty_argv
|
||||
|
Loading…
x
Reference in New Issue
Block a user