summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLee Jarvis <lee@jarvis.co>2010-12-04 00:29:06 +0000
committerLee Jarvis <lee@jarvis.co>2010-12-04 00:29:06 +0000
commitf80987b9c24935e5ede3d789113d3b0051302924 (patch)
treee8c80241d049453f7c28def87149467d8df5e1b2
parentdd26cf6d228374981ab0930a90728d200d0a53ec (diff)
parentb1b76be7272853aecb84d948379d59dbfff426fc (diff)
downloadslop-f80987b9c24935e5ede3d789113d3b0051302924.tar.gz
Merge branch 'fix_options_hash' of https://github.com/gregf/slop
-rw-r--r--lib/slop.rb4
-rw-r--r--spec/slop_spec.rb8
2 files changed, 9 insertions, 3 deletions
diff --git a/lib/slop.rb b/lib/slop.rb
index d1e710e..e83d82e 100644
--- a/lib/slop.rb
+++ b/lib/slop.rb
@@ -106,7 +106,7 @@ class Slop
# @return [Hash]
def options_hash
out = {}
- each_option do |opt|
+ options.each do |opt|
if opt.requires_argument? or opt.has_default?
out[opt.key] = opt.argument_value || opt.default
end
@@ -155,4 +155,4 @@ class Slop
return unless flag
flag[1, 2].include?('-')
end
-end \ No newline at end of file
+end
diff --git a/spec/slop_spec.rb b/spec/slop_spec.rb
index 42b9658..bacd686 100644
--- a/spec/slop_spec.rb
+++ b/spec/slop_spec.rb
@@ -44,6 +44,12 @@ describe Slop do
end
end
+ describe "options_hash" do
+ it "returns a hash" do
+ @slop.options_hash.should be_kind_of(Hash)
+ end
+ end
+
describe "option_for" do
it "returns an option" do
@slop.option_for(:v).should be_kind_of(Slop::Option)
@@ -110,4 +116,4 @@ describe Slop do
end
end
-end \ No newline at end of file
+end