getopt 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +5 -0
- data/README +6 -1
- data/test/tc_getopt_std.rb +24 -12
- metadata +2 -2
data/CHANGES
CHANGED
data/README
CHANGED
@@ -36,7 +36,12 @@
|
|
36
36
|
* Add a replacement for Getopt::Long.
|
37
37
|
|
38
38
|
== Known Bugs
|
39
|
-
|
39
|
+
You cannot squish switches that require arguments with the argument itself.
|
40
|
+
For example, if you do Getopt::Std.getopts("o:ID"), it will not parse
|
41
|
+
"-IDohello" properly. Instead, you must do "-IDo hello". Or, you can just
|
42
|
+
separate the argument, e.g. "-I -D -o hello".
|
43
|
+
|
44
|
+
If you find any other bugs, please log them on the project
|
40
45
|
page at http://www.rubyforge.org/projects/shards.
|
41
46
|
|
42
47
|
== Warranty
|
data/test/tc_getopt_std.rb
CHANGED
@@ -16,27 +16,34 @@ require "getopt/std"
|
|
16
16
|
include Getopt
|
17
17
|
|
18
18
|
class TC_Getopt_Std < Test::Unit::TestCase
|
19
|
-
def setup
|
20
|
-
@basic_opts = %w/-I -D/
|
21
|
-
@mixed_opts = %w/-o hello -I -D/
|
22
|
-
@extra_opts = %w/-I -D -X/
|
23
|
-
end
|
24
19
|
|
25
20
|
def test_version
|
26
|
-
assert_equal("1.
|
21
|
+
assert_equal("1.1.0", Std::VERSION)
|
27
22
|
end
|
28
23
|
|
29
24
|
def test_getopts_basic
|
30
|
-
ARGV.push(*@basic_opts)
|
31
25
|
assert_respond_to(Std, :getopts)
|
32
26
|
assert_nothing_raised{ Std.getopts("ID") }
|
33
27
|
assert_kind_of(Hash, Std.getopts("ID"))
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_getopts_separated_switches
|
31
|
+
ARGV.push("-I", "-D")
|
32
|
+
assert_equal({"I"=>true, "D"=>true}, Std.getopts("ID"))
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_getopts_joined_switches
|
36
|
+
ARGV.push("-ID")
|
34
37
|
assert_equal({"I"=>true, "D"=>true}, Std.getopts("ID"))
|
35
38
|
end
|
36
39
|
|
37
|
-
def
|
38
|
-
ARGV.push(
|
39
|
-
|
40
|
+
def test_getopts_separated_switches_with_mandatory_arg
|
41
|
+
ARGV.push("-o", "hello", "-I", "-D")
|
42
|
+
assert_equal({"o"=>"hello", "I"=>true, "D"=>true}, Std.getopts("o:ID"))
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_getopts_joined_switches_with_mandatory_arg
|
46
|
+
ARGV.push("-IDo", "hello")
|
40
47
|
assert_equal({"o"=>"hello", "I"=>true, "D"=>true}, Std.getopts("o:ID"))
|
41
48
|
end
|
42
49
|
|
@@ -48,13 +55,18 @@ class TC_Getopt_Std < Test::Unit::TestCase
|
|
48
55
|
end
|
49
56
|
|
50
57
|
def test_getopts_expected_errors_missing_arg
|
51
|
-
ARGV.push(
|
58
|
+
ARGV.push("-ID")
|
52
59
|
assert_raises(StdError){ Std.getopts("I:D") }
|
60
|
+
|
61
|
+
ARGV.push("-ID")
|
53
62
|
assert_raises(StdError){ Std.getopts("ID:") }
|
54
63
|
end
|
55
64
|
|
56
65
|
def test_getopts_expected_errors_extra_arg
|
57
|
-
ARGV.push(
|
66
|
+
ARGV.push("-I", "-D", "-X")
|
67
|
+
assert_raises(StdError){ Std.getopts("ID") }
|
68
|
+
|
69
|
+
ARGV.push("-IDX")
|
58
70
|
assert_raises(StdError){ Std.getopts("ID") }
|
59
71
|
end
|
60
72
|
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: getopt
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.
|
7
|
-
date: 2005-10-
|
6
|
+
version: 1.1.0
|
7
|
+
date: 2005-10-07 00:00:00 -06:00
|
8
8
|
summary: Getopt::Std for Ruby
|
9
9
|
require_paths:
|
10
10
|
- lib
|