aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Nagel2014-08-28 22:11:08 -0500
committerJack Nagel2014-08-28 22:11:08 -0500
commite18da89f3c4331d65ef32f75c3271242b41246dc (patch)
treec66dc707ee5fb941d817cb20ae29640f93a325fa
parent7a5e4f5ccab58bd6f7b8ff86fdf53e572d7d1723 (diff)
downloadbrew-e18da89f3c4331d65ef32f75c3271242b41246dc.tar.bz2
Implement ARGV.named in terms of ARGV.options_only
-rw-r--r--Library/Homebrew/extend/ARGV.rb4
-rw-r--r--Library/Homebrew/test/test_ARGV.rb9
2 files changed, 9 insertions, 4 deletions
diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb
index 25707a2e3..fb96d9abc 100644
--- a/Library/Homebrew/extend/ARGV.rb
+++ b/Library/Homebrew/extend/ARGV.rb
@@ -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
diff --git a/Library/Homebrew/test/test_ARGV.rb b/Library/Homebrew/test/test_ARGV.rb
index 6d2c19f53..7403acf7c 100644
--- a/Library/Homebrew/test/test_ARGV.rb
+++ b/Library/Homebrew/test/test_ARGV.rb
@@ -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