getopt 1.3.6 → 1.3.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,82 +1,82 @@
1
- ###################################################################
2
- # tc_getopt_std.rb
3
- #
4
- # Test suite for the Getopt::Std class. You should run this test
5
- # via the 'rake test' task.
6
- ###################################################################
7
- require 'test/unit'
8
- require 'getopt/std'
9
- include Getopt
10
-
11
- class TC_Getopt_Std < Test::Unit::TestCase
12
-
13
- def test_version
14
- assert_equal('1.3.6', Std::VERSION)
15
- end
16
-
17
- def test_getopts_basic
18
- assert_respond_to(Std, :getopts)
19
- assert_nothing_raised{ Std.getopts("ID") }
20
- assert_kind_of(Hash, Std.getopts("ID"))
21
- end
22
-
23
- def test_getopts_separated_switches
24
- ARGV.push("-I", "-D")
25
- assert_equal({"I"=>true, "D"=>true}, Std.getopts("ID"))
26
- end
27
-
28
- def test_getopts_joined_switches
29
- ARGV.push("-ID")
30
- assert_equal({"I"=>true, "D"=>true}, Std.getopts("ID"))
31
- end
32
-
33
- def test_getopts_separated_switches_with_mandatory_arg
34
- ARGV.push("-o", "hello", "-I", "-D")
35
- assert_equal({"o"=>"hello", "I"=>true, "D"=>true}, Std.getopts("o:ID"))
36
- end
37
-
38
- def test_getopts_joined_switches_with_mandatory_arg
39
- ARGV.push("-IDo", "hello")
40
- assert_equal({"o"=>"hello", "I"=>true, "D"=>true}, Std.getopts("o:ID"))
41
- end
42
-
43
- def test_getopts_no_args
44
- assert_nothing_raised{ Std.getopts("ID") }
45
- assert_equal({}, Std.getopts("ID"))
46
- assert_nil(Std.getopts("ID")["I"])
47
- assert_nil(Std.getopts("ID")["D"])
48
- end
49
-
50
- def test_getopts_expected_errors_missing_arg
51
- ARGV.push("-ID")
52
- assert_raises(Std::Error){ Std.getopts("I:D") }
53
-
54
- ARGV.push("-ID")
55
- assert_raises(Std::Error){ Std.getopts("ID:") }
56
- end
57
-
58
- def test_getopts_expected_errors_extra_arg
59
- ARGV.push("-I", "-D", "-X")
60
- assert_raises(Std::Error){ Std.getopts("ID") }
61
-
62
- ARGV.push("-IDX")
63
- assert_raises(Std::Error){ Std.getopts("ID") }
64
- end
65
-
66
- # If a switch that accepts an argument appears more than once, the values
67
- # are rolled into an array.
68
- def test_getopts_switch_repeated
69
- ARGV.push("-I", "-I", "-o", "hello", "-o", "world")
70
- assert_equal({"o" => ["hello","world"], "I"=>true}, Std.getopts("o:ID"))
71
- end
72
-
73
- def test_getopts_expected_errors_basic
74
- assert_raises(ArgumentError){ Std.getopts }
75
- assert_raises(NoMethodError){ Std.getopts(0) }
76
- assert_raises(NoMethodError){ Std.getopts(nil) }
77
- end
78
-
79
- def teardown
80
- ARGV.clear
81
- end
82
- end
1
+ ###################################################################
2
+ # tc_getopt_std.rb
3
+ #
4
+ # Test suite for the Getopt::Std class. You should run this test
5
+ # via the 'rake test' task.
6
+ ###################################################################
7
+ require 'test/unit'
8
+ require 'getopt/std'
9
+ include Getopt
10
+
11
+ class TC_Getopt_Std < Test::Unit::TestCase
12
+
13
+ def test_version
14
+ assert_equal('1.3.7', Std::VERSION)
15
+ end
16
+
17
+ def test_getopts_basic
18
+ assert_respond_to(Std, :getopts)
19
+ assert_nothing_raised{ Std.getopts("ID") }
20
+ assert_kind_of(Hash, Std.getopts("ID"))
21
+ end
22
+
23
+ def test_getopts_separated_switches
24
+ ARGV.push("-I", "-D")
25
+ assert_equal({"I"=>true, "D"=>true}, Std.getopts("ID"))
26
+ end
27
+
28
+ def test_getopts_joined_switches
29
+ ARGV.push("-ID")
30
+ assert_equal({"I"=>true, "D"=>true}, Std.getopts("ID"))
31
+ end
32
+
33
+ def test_getopts_separated_switches_with_mandatory_arg
34
+ ARGV.push("-o", "hello", "-I", "-D")
35
+ assert_equal({"o"=>"hello", "I"=>true, "D"=>true}, Std.getopts("o:ID"))
36
+ end
37
+
38
+ def test_getopts_joined_switches_with_mandatory_arg
39
+ ARGV.push("-IDo", "hello")
40
+ assert_equal({"o"=>"hello", "I"=>true, "D"=>true}, Std.getopts("o:ID"))
41
+ end
42
+
43
+ def test_getopts_no_args
44
+ assert_nothing_raised{ Std.getopts("ID") }
45
+ assert_equal({}, Std.getopts("ID"))
46
+ assert_nil(Std.getopts("ID")["I"])
47
+ assert_nil(Std.getopts("ID")["D"])
48
+ end
49
+
50
+ def test_getopts_expected_errors_missing_arg
51
+ ARGV.push("-ID")
52
+ assert_raises(Std::Error){ Std.getopts("I:D") }
53
+
54
+ ARGV.push("-ID")
55
+ assert_raises(Std::Error){ Std.getopts("ID:") }
56
+ end
57
+
58
+ def test_getopts_expected_errors_extra_arg
59
+ ARGV.push("-I", "-D", "-X")
60
+ assert_raises(Std::Error){ Std.getopts("ID") }
61
+
62
+ ARGV.push("-IDX")
63
+ assert_raises(Std::Error){ Std.getopts("ID") }
64
+ end
65
+
66
+ # If a switch that accepts an argument appears more than once, the values
67
+ # are rolled into an array.
68
+ def test_getopts_switch_repeated
69
+ ARGV.push("-I", "-I", "-o", "hello", "-o", "world")
70
+ assert_equal({"o" => ["hello","world"], "I"=>true}, Std.getopts("o:ID"))
71
+ end
72
+
73
+ def test_getopts_expected_errors_basic
74
+ assert_raises(ArgumentError){ Std.getopts }
75
+ assert_raises(NoMethodError){ Std.getopts(0) }
76
+ assert_raises(NoMethodError){ Std.getopts(nil) }
77
+ end
78
+
79
+ def teardown
80
+ ARGV.clear
81
+ end
82
+ end
metadata CHANGED
@@ -1,56 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
4
2
  name: getopt
5
3
  version: !ruby/object:Gem::Version
6
- version: 1.3.6
7
- date: 2007-08-08 00:00:00 -06:00
8
- summary: Getopt::Std and Getopt::Long option parsers for Ruby
9
- require_paths:
10
- - lib
11
- email: djberg96@gmail.com
12
- homepage: http://www.rubyforge.org/projects/shards
13
- rubyforge_project:
14
- description: Getopt::Std and Getopt::Long option parsers for Ruby
15
- autorequire:
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 1.3.7
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Daniel J. Berger
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-07-27 00:00:00 -06:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Getopt::Std and Getopt::Long option parsers for Ruby
17
+ email: djberg96@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ - CHANGES
25
+ - MANIFEST
31
26
  files:
32
27
  - lib/getopt/long.rb
33
28
  - lib/getopt/std.rb
34
29
  - CHANGES
30
+ - examples
31
+ - getopt.gemspec
32
+ - lib
35
33
  - MANIFEST
36
- - README
37
34
  - Rakefile
38
- - test/tc_getopt_long.rb
39
- - test/tc_getopt_std.rb
40
- - test/ts_all.rb
41
- test_files:
42
- - test/ts_all.rb
43
- rdoc_options: []
44
-
45
- extra_rdoc_files:
46
35
  - README
47
- - CHANGES
48
- - MANIFEST
49
- executables: []
50
-
51
- extensions: []
36
+ - test
37
+ - test/test_getopt_long.rb
38
+ - test/test_getopt_std.rb
39
+ - examples/example_long.rb
40
+ - examples/example_std.rb
41
+ has_rdoc: true
42
+ homepage: http://www.rubyforge.org/projects/shards
43
+ post_install_message:
44
+ rdoc_options: []
52
45
 
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ version:
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ version:
53
60
  requirements: []
54
61
 
55
- dependencies: []
56
-
62
+ rubyforge_project: shards
63
+ rubygems_version: 1.2.0
64
+ signing_key:
65
+ specification_version: 2
66
+ summary: Getopt::Std and Getopt::Long option parsers for Ruby
67
+ test_files:
68
+ - test/test_getopt_long.rb
69
+ - test/test_getopt_std.rb
@@ -1,5 +0,0 @@
1
- $LOAD_PATH.unshift(Dir.pwd)
2
- $LOAD_PATH.unshift(Dir.pwd + "/test")
3
-
4
- require "tc_getopt_std"
5
- require "tc_getopt_long"