getopt 1.1.0 → 1.2.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.
Files changed (4) hide show
  1. data/CHANGES +7 -3
  2. data/README +13 -1
  3. data/test/tc_getopt_std.rb +8 -1
  4. metadata +2 -2
data/CHANGES CHANGED
@@ -1,7 +1,11 @@
1
- == 7-Oct-2005
1
+ == 24-Oct-2005 - 1.2.0
2
+ * Altered the way multiple occurrences of the same switch are handled, for
3
+ those switches that accept arguments.
4
+
5
+ == 7-Oct-2005 - 1.1.0
2
6
  * Changed parser, added a bit stricter enforcement
3
7
  * Now handles squished arguments properly, e.g. "-ID" as well as "-I -D"
4
8
  * Some test suite changes
5
9
 
6
- == 5-Oct-2005
7
- * Initial commit
10
+ == 5-Oct-2005 - 1.0.0
11
+ * Initial commit
data/README CHANGED
@@ -32,6 +32,18 @@
32
32
  end
33
33
  end
34
34
 
35
+ == Class Methods
36
+ Std.getopts(switches)
37
+ Takes a series of single character switches that can be accepted on the
38
+ command line. Those characters followed by a ':' require an argument. The
39
+ rest are considered boolean switches. Returns a hash, with the switches
40
+ as the key (sans the leading '-'). For boolean switches, the value is
41
+ either true or false. Switches that were not passed on the command line
42
+ do not appear in the hash.
43
+
44
+ In the event that a switch that accepts an argument appears multiple times
45
+ the value for that key becomes an array of values.
46
+
35
47
  == Future Plans
36
48
  * Add a replacement for Getopt::Long.
37
49
 
@@ -59,4 +71,4 @@
59
71
  == Author
60
72
  Daniel J. Berger
61
73
  djberg96 at gmail.com
62
- imperator on IRC (freenode)
74
+ imperator on IRC (freenode)
@@ -18,7 +18,7 @@ include Getopt
18
18
  class TC_Getopt_Std < Test::Unit::TestCase
19
19
 
20
20
  def test_version
21
- assert_equal("1.1.0", Std::VERSION)
21
+ assert_equal("1.2.0", Std::VERSION)
22
22
  end
23
23
 
24
24
  def test_getopts_basic
@@ -70,6 +70,13 @@ class TC_Getopt_Std < Test::Unit::TestCase
70
70
  assert_raises(StdError){ Std.getopts("ID") }
71
71
  end
72
72
 
73
+ # If a switch that accepts an argument appears more than once, the values
74
+ # are rolled into an array.
75
+ def test_getopts_switch_repeated
76
+ ARGV.push("-I", "-I", "-o", "hello", "-o", "world")
77
+ assert_equal({"o" => ["hello","world"], "I"=>true}, Std.getopts("o:ID"))
78
+ end
79
+
73
80
  def test_getopts_expected_errors_basic
74
81
  assert_raises(ArgumentError){ Std.getopts }
75
82
  assert_raises(NoMethodError){ Std.getopts(0) }
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.1.0
7
- date: 2005-10-07 00:00:00 -06:00
6
+ version: 1.2.0
7
+ date: 2005-10-24 00:00:00 -06:00
8
8
  summary: Getopt::Std for Ruby
9
9
  require_paths:
10
10
  - lib