summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-04-05 11:36:18 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-04-06 16:36:58 -0700
commit0b97bd0df57dd6732db5f52fc7360f61e74dba2e (patch)
treec36647744c2b2aabb9cc25276ca13b8511f09061 /lib
parentf732d69552969698fdae7905284f01682bfd3441 (diff)
downloadpuppet-0b97bd0df57dd6732db5f52fc7360f61e74dba2e.tar.gz
puppet-0b97bd0df57dd6732db5f52fc7360f61e74dba2e.tar.xz
puppet-0b97bd0df57dd6732db5f52fc7360f61e74dba2e.zip
(#6972) Clean up OptParse name extraction a little.
During testing, an obvious cleanup showed up for the name extraction here, so we implement it. This extends the regexp to better extract the data we want rather than hacking it up post-match and having to do extra validation to make sure it actually worked. Reviewed-By: Dan Bode <dan@puppetlabs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/string/option.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/puppet/string/option.rb b/lib/puppet/string/option.rb
index f499e4b95..be7bbb76e 100644
--- a/lib/puppet/string/option.rb
+++ b/lib/puppet/string/option.rb
@@ -70,10 +70,10 @@ class Puppet::String::Option
end
def optparse_to_name(declaration)
- unless found = declaration.match(/^-+([^= ]+)/) or found.length != 1 then
+ unless found = declaration.match(/^-+(?:\[no-\])?([^ =]+)/) then
raise ArgumentError, "Can't find a name in the declaration #{declaration.inspect}"
end
- name = found.captures.first.sub('[no-]', '').tr('-', '_')
+ name = found.captures.first.tr('-', '_')
raise "#{name.inspect} is an invalid option name" unless name.to_s =~ /^[a-z]\w*$/
name.to_sym
end