Browse files

Merge pull request #251 from GutenYe/fix-250

'send' as a task name. #250
  • Loading branch information...
2 parents 4aecda3 + 39dc2ba commit ebd21372679cb204ee53959e0a2cfdac0170512b @wycats wycats committed Sep 10, 2012
Showing with 12 additions and 3 deletions.
  1. +1 −1 lib/thor/base.rb
  2. +2 −2 lib/thor/task.rb
  3. +5 −0 spec/fixtures/script.thor
  4. +4 −0 spec/thor_spec.rb
View
2 lib/thor/base.rb
@@ -74,7 +74,7 @@ def initialize(args=[], options={}, config={})
to_parse += opts.remaining unless self.class.strict_args_position?(config)
thor_args = Thor::Arguments.new(self.class.arguments)
- thor_args.parse(to_parse).each { |k,v| send("#{k}=", v) }
+ thor_args.parse(to_parse).each { |k,v| __send__("#{k}=", v) }
@args = thor_args.remaining
end
View
4 lib/thor/task.rb
@@ -24,9 +24,9 @@ def run(instance, args=[])
instance.class.handle_no_task_error(name)
elsif public_method?(instance)
arity = instance.method(name).arity
- instance.send(name, *args)
+ instance.__send__(name, *args)
elsif local_method?(instance, :method_missing)
- instance.send(:method_missing, name.to_sym, *args)
+ instance.__send__(:method_missing, name.to_sym, *args)
else
instance.class.handle_no_task_error(name)
end
View
5 spec/fixtures/script.thor
@@ -93,6 +93,11 @@ END
end
end
+ desc "send", "send as a task name"
+ def send
+ true
+ end
+
private
def method_missing(meth, *args)
View
4 spec/thor_spec.rb
@@ -414,5 +414,9 @@ def unknown(*args)
klass.start(["unknown", "--bar", "baz"]).should == []
klass.start(["unknown", "foo", "--bar", "baz"]).should == ["foo"]
end
+
+ it "send as a task name" do
+ MyScript.start(["send"]).should == true
+ end
end
end

0 comments on commit ebd2137

Please sign in to comment.