summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Rakefile2
-rw-r--r--lib/slop.rb3
-rw-r--r--lib/slop/option.rb4
3 files changed, 6 insertions, 3 deletions
diff --git a/Rakefile b/Rakefile
index 2029133..8300a41 100644
--- a/Rakefile
+++ b/Rakefile
@@ -3,7 +3,7 @@ task :test do
require 'slop'
require 'minitest/autorun'
begin; require 'turn'; rescue LoadError; end
- Dir.glob("test/**/*_test.rb").each { |test| require_relative test }
+ Dir.glob("test/**/*_test.rb").each { |test| require "./#{test}" }
end
task :default => :test \ No newline at end of file
diff --git a/lib/slop.rb b/lib/slop.rb
index 1a00bc3..0f34ea0 100644
--- a/lib/slop.rb
+++ b/lib/slop.rb
@@ -118,7 +118,8 @@ class Slop
options = args.pop if args.last.is_a?(Hash)
options ||= {}
- option = Option.new(self, *clean_options(args), options, &block)
+ short, long, desc, arg = clean_options(args)
+ option = Option.new(self, short, long, desc, arg, options, &block)
@options << option
option
diff --git a/lib/slop/option.rb b/lib/slop/option.rb
index f7987a4..7fda15c 100644
--- a/lib/slop/option.rb
+++ b/lib/slop/option.rb
@@ -1,11 +1,13 @@
class Slop
class Options < Array
def to_hash(symbols)
- each_with_object({}) do |option, out|
+ out = {}
+ each do |option|
key = option.key
key = key.to_sym if symbols
out[key] = option.argument_value
end
+ out
end
def [](item)