getopt 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/CHANGES +5 -0
  2. data/README +6 -1
  3. data/test/tc_getopt_std.rb +24 -12
  4. metadata +2 -2
data/CHANGES CHANGED
@@ -1,2 +1,7 @@
1
+ == 7-Oct-2005
2
+ * Changed parser, added a bit stricter enforcement
3
+ * Now handles squished arguments properly, e.g. "-ID" as well as "-I -D"
4
+ * Some test suite changes
5
+
1
6
  == 5-Oct-2005
2
7
  * Initial commit
data/README CHANGED
@@ -36,7 +36,12 @@
36
36
  * Add a replacement for Getopt::Long.
37
37
 
38
38
  == Known Bugs
39
- None that I'm aware of. If you find any, please log them on the project
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
@@ -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.0.0", Std::VERSION)
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 test_getopts_advanced
38
- ARGV.push(*@mixed_opts)
39
- assert_nothing_raised{ Std.getopts("o:ID") }
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(*@basic_opts)
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(*@extra_opts)
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.0.0
7
- date: 2005-10-06 00:00:00 -06:00
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