Permalink
Browse files

Fixed bug with global options

  • Loading branch information...
1 parent 5c061cc commit e97df90878a7e0aa65dc2e9a5b00aa91da670b86 @fabien fabien committed Oct 24, 2008
Showing with 18 additions and 8 deletions.
  1. +4 −0 CHANGELOG.rdoc
  2. +1 −1 Thorfile
  3. +0 −5 lib/thor/task.rb
  4. +12 −1 spec/thor_spec.rb
  5. +1 −1 thor.gemspec
View
@@ -5,6 +5,10 @@
* Improve help output to list shorthand switches, too
* Investigate and fix deep namespacing ("foo:bar:baz") issues
+== 0.9.8, released 2008-10-20
+
+* Fixed some tiny issues that were introduced lately.
+
== 0.9.7, released 2008-10-13
* Setting global method options on the initialize method works as expected:
View
@@ -3,7 +3,7 @@ require 'rubygems/specification'
require 'thor/tasks'
GEM = "thor"
-GEM_VERSION = "0.9.7"
+GEM_VERSION = "0.9.8"
AUTHOR = "Yehuda Katz"
EMAIL = "wycats@gmail.com"
HOMEPAGE = "http://yehudakatz.com"
View
@@ -62,10 +62,6 @@ def full_opts
@_full_opts ||= Options.new((klass.opts || {}).merge(@options))
end
- def options?
- @options.kind_of?(Hash) && !@options.empty?
- end
-
def formatted_usage(namespace = false)
(namespace ? self.namespace + ':' : '') + usage +
(opts ? " " + opts.formatted_usage : "")
@@ -75,7 +71,6 @@ def formatted_usage(namespace = false)
def parse_args(args)
return [[], {}] if args.nil?
- return [args, {}] unless options?
hash = full_opts.parse(args)
list = full_opts.non_opts
[list, hash]
View
@@ -71,6 +71,11 @@ def animal(type)
[type, options]
end
+ desc "zoo", "zoo around"
+ def zoo
+ options
+ end
+
end
describe "thor" do
@@ -123,7 +128,13 @@ def animal(type)
MyApp.start(["unk", "hello"]).must == [:unk, ["hello"]]
end
- it "allows global options to be set on the initialize method" do
+ it "allows global options to be set" do
+ args = ["zoo", "--force", "--param", "feathers"]
+ options = GlobalOptionsTasks.start(args)
+ options.must == { "force"=>true, "param"=>"feathers" }
+ end
+
+ it "allows global options to be merged with method options" do
args = ["animal", "bird", "--force", "--param", "feathers", "--other", "tweets"]
arg, options = GlobalOptionsTasks.start(args)
arg.must == 'bird'
View
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = %q{thor}
- s.version = "0.9.7"
+ s.version = "0.9.8"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Yehuda Katz"]

0 comments on commit e97df90

Please sign in to comment.