lib/getopt/long.rb in getopt-1.4.1 vs lib/getopt/long.rb in getopt-1.4.2
- old
+ new
@@ -15,11 +15,11 @@
# Error raised if an illegal option or argument is passed
class Error < StandardError; end
# The version of the getopt library
- VERSION = '1.4.1'
+ VERSION = '1.4.2'
# Takes an array of switches. Each array consists of up to three
# elements that indicate the name and type of switch. Returns a hash
# containing each switch name, minus the '-', as a key. The value
# for each key depends on the type of switch and/or the value provided
@@ -67,19 +67,19 @@
switch[2] ||= BOOLEAN
types[switch[0]] = switch[2]
switch[1] ||= switch[0][1..2]
end
- # Create synonym hash. Default to first char of long switch for
+ # Create synonym hash. Default to first char of long switch for
# short switch, e.g. "--verbose" creates a "-v" synonym. The same
# synonym can only be used once - first one wins.
syns[switch[0]] = switch[1] unless syns[switch[1]]
syns[switch[1]] = switch[0] unless syns[switch[1]]
switch[1] = [switch[1]] if RUBY_VERSION.to_f >= 1.9
- switch[1].each{ |char|
+ switch[1].each{ |char|
types[char] = switch[2] # Set type for short switch
valid.push(char) # Set valid short switches
}
}
@@ -93,11 +93,11 @@
# Allow either -x -v or -xv style for single char args
if re_short_sq.match(opt)
chars = opt.split("")[1..-1].map{ |s| s = "-#{s}" }
chars.each_with_index{ |char, i|
- unless valid.include?(char)
+ unless valid.include?(char)
raise Error, "invalid switch '#{char}'"
end
# Grab the next arg if the switch takes a required arg
if types[char] == REQUIRED
@@ -217,10 +217,10 @@
# the same value
hash.dup.each{ |switch, val|
if syns.keys.include?(switch)
syns[switch] = [syns[switch]] if RUBY_VERSION.to_f >= 1.9
syns[switch].each{ |key|
- hash[key] = val
+ hash[key] = val
}
end
}
# Get rid of leading "--" and "-" to make it easier to reference