- Add patches for the failing tests. - Removed unnecessary ParseTree dependency.epel9
parent
64c45f6db6
commit
58c6ee7167
@ -0,0 +1,29 @@
|
|||||||
|
commit fb1a829d173a633446c56b4d0ed665312882e83b
|
||||||
|
Author: Brian Donovan <me@brian-donovan.com>
|
||||||
|
Date: Tue Sep 20 09:31:49 2011 -0700
|
||||||
|
|
||||||
|
Replace ARGV with an empty array before each spec run.
|
||||||
|
|
||||||
|
Some of the specs were leaving ARGV in a non-pristine state (such as
|
||||||
|
those in runner_spec.rb), which was then implicitly used in
|
||||||
|
Thor::Base.start et al. It happened to be the case that the order in
|
||||||
|
which rspec was loading and running the specs made this not a problem,
|
||||||
|
but if the specs were run in a randomized order it could be a problem.
|
||||||
|
|
||||||
|
Closes #171.
|
||||||
|
|
||||||
|
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
|
||||||
|
index 00181ad..175637d 100644
|
||||||
|
--- a/spec/spec_helper.rb
|
||||||
|
+++ b/spec/spec_helper.rb
|
||||||
|
@@ -29,6 +29,10 @@ load File.join(File.dirname(__FILE__), "fixtures", "script.thor")
|
||||||
|
load File.join(File.dirname(__FILE__), "fixtures", "invoke.thor")
|
||||||
|
|
||||||
|
RSpec.configure do |config|
|
||||||
|
+ config.before :each do
|
||||||
|
+ ARGV.replace []
|
||||||
|
+ end
|
||||||
|
+
|
||||||
|
def capture(stream)
|
||||||
|
begin
|
||||||
|
stream = stream.to_s
|
@ -0,0 +1,120 @@
|
|||||||
|
commit 018b25811118c3bb95162324b3feae3a1e2b9923
|
||||||
|
Author: Yehuda Katz <wycats@gmail.com>
|
||||||
|
Date: Sat Jul 2 20:51:23 2011 -0700
|
||||||
|
|
||||||
|
Get method_missing working again. I'm not sure how it was working before, but the tests didn't pass.
|
||||||
|
|
||||||
|
# Altered a bit to work with this version.
|
||||||
|
diff --git a/lib/thor/task.rb b/lib/thor/task.rb
|
||||||
|
index 8dcff53..f94d5b6 100644
|
||||||
|
--- a/lib/thor/task.rb
|
||||||
|
+++ b/lib/thor/task.rb
|
||||||
|
@@ -18,8 +18,15 @@ class Thor
|
||||||
|
# By default, a task invokes a method in the thor class. You can change this
|
||||||
|
# implementation to create custom tasks.
|
||||||
|
def run(instance, args=[])
|
||||||
|
- public_method?(instance) ?
|
||||||
|
- instance.send(name, *args) : instance.class.handle_no_task_error(name)
|
||||||
|
+ if private_method?(instance)
|
||||||
|
+ instance.class.handle_no_task_error(name)
|
||||||
|
+ elsif public_method?(instance)
|
||||||
|
+ instance.send(name, *args)
|
||||||
|
+ elsif local_method?(instance, :method_missing)
|
||||||
|
+ instance.send(:method_missing, name.to_sym, *args)
|
||||||
|
+ else
|
||||||
|
+ instance.class.handle_no_task_error(name)
|
||||||
|
+ end
|
||||||
|
rescue ArgumentError => e
|
||||||
|
handle_argument_error?(instance, e, caller) ?
|
||||||
|
instance.class.handle_argument_error(self, e) : (raise e)
|
||||||
|
@@ -71,6 +78,15 @@ class Thor
|
||||||
|
(collection & [name.to_s, name.to_sym]).empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
+ def private_method?(instance)
|
||||||
|
+ !(instance.private_methods & [name.to_s, name.to_sym]).empty?
|
||||||
|
+ end
|
||||||
|
+
|
||||||
|
+ def local_method?(instance, name)
|
||||||
|
+ methods = instance.public_methods(false) + instance.private_methods(false) + instance.protected_methods(false)
|
||||||
|
+ !(methods & [name.to_s, name.to_sym]).empty?
|
||||||
|
+ end
|
||||||
|
+
|
||||||
|
def sans_backtrace(backtrace, caller) #:nodoc:
|
||||||
|
saned = backtrace.reject { |frame| frame =~ FILE_REGEXP }
|
||||||
|
saned -= caller
|
||||||
|
@@ -105,11 +121,7 @@ class Thor
|
||||||
|
|
||||||
|
def run(instance, args=[])
|
||||||
|
if (instance.methods & [name.to_s, name.to_sym]).empty?
|
||||||
|
- if ((instance.protected_methods + instance.public_methods) & ([:method_missing, "method_missing"])).empty?
|
||||||
|
- super
|
||||||
|
- else
|
||||||
|
- instance.send(:method_missing, name.to_sym, *args)
|
||||||
|
- end
|
||||||
|
+ super
|
||||||
|
else
|
||||||
|
instance.class.handle_no_task_error(name)
|
||||||
|
end
|
||||||
|
diff --git a/spec/task_spec.rb b/spec/task_spec.rb
|
||||||
|
index 1c7ea7c..3372de1 100644
|
||||||
|
--- a/spec/task_spec.rb
|
||||||
|
+++ b/spec/task_spec.rb
|
||||||
|
@@ -11,21 +11,18 @@ describe Thor::Task do
|
||||||
|
|
||||||
|
describe "#formatted_usage" do
|
||||||
|
it "includes namespace within usage" do
|
||||||
|
- Object.stub!(:namespace).and_return("foo")
|
||||||
|
- Object.stub!(:arguments).and_return([])
|
||||||
|
- task(:bar => :required).formatted_usage(Object).should == "foo:can_has --bar=BAR"
|
||||||
|
+ object = Struct.new(:namespace, :arguments).new("foo", [])
|
||||||
|
+ task(:bar => :required).formatted_usage(object).should == "foo:can_has --bar=BAR"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "removes default from namespace" do
|
||||||
|
- Object.stub!(:namespace).and_return("default:foo")
|
||||||
|
- Object.stub!(:arguments).and_return([])
|
||||||
|
- task(:bar => :required).formatted_usage(Object).should == ":foo:can_has --bar=BAR"
|
||||||
|
+ object = Struct.new(:namespace, :arguments).new("default:foo", [])
|
||||||
|
+ task(:bar => :required).formatted_usage(object).should == ":foo:can_has --bar=BAR"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "injects arguments into usage" do
|
||||||
|
- Object.stub!(:namespace).and_return("foo")
|
||||||
|
- Object.stub!(:arguments).and_return([ Thor::Argument.new(:bar, nil, true, :string) ])
|
||||||
|
- task(:foo => :required).formatted_usage(Object).should == "foo:can_has BAR --foo=FOO"
|
||||||
|
+ object = Struct.new(:namespace, :arguments).new("foo", [Thor::Argument.new(:bar, nil, true, :string)])
|
||||||
|
+ task(:foo => :required).formatted_usage(object).should == "foo:can_has BAR --foo=FOO"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@@ -55,15 +52,23 @@ describe Thor::Task do
|
||||||
|
describe "#run" do
|
||||||
|
it "runs a task by calling a method in the given instance" do
|
||||||
|
mock = mock()
|
||||||
|
- mock.should_receive(:send).with("can_has", 1, 2, 3)
|
||||||
|
- task.run(mock, [1, 2, 3])
|
||||||
|
+ mock.should_receive(:can_has).and_return {|*args| args }
|
||||||
|
+ task.run(mock, [1, 2, 3]).should == [1, 2, 3]
|
||||||
|
end
|
||||||
|
|
||||||
|
it "raises an error if the method to be invoked is private" do
|
||||||
|
- mock = mock()
|
||||||
|
- mock.should_receive(:private_methods).and_return(['can_has'])
|
||||||
|
- mock.class.should_receive(:handle_no_task_error).with("can_has")
|
||||||
|
- task.run(mock)
|
||||||
|
+ klass = Class.new do
|
||||||
|
+ def self.handle_no_task_error(name)
|
||||||
|
+ name
|
||||||
|
+ end
|
||||||
|
+
|
||||||
|
+ private
|
||||||
|
+ def can_has
|
||||||
|
+ "fail"
|
||||||
|
+ end
|
||||||
|
+ end
|
||||||
|
+
|
||||||
|
+ task.run(klass.new).should == "can_has"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,20 @@
|
|||||||
|
commit 36603c1811451d370da4915e24eed665fe805ae4
|
||||||
|
Author: Gabriel Horner <gabriel.horner@gmail.com>
|
||||||
|
Date: Mon Jul 4 14:44:07 2011 -0400
|
||||||
|
|
||||||
|
Fix rake desc not being passed to thor
|
||||||
|
|
||||||
|
diff --git a/lib/thor/rake_compat.rb b/lib/thor/rake_compat.rb
|
||||||
|
index b3a8beb..c86e840 100644
|
||||||
|
--- a/lib/thor/rake_compat.rb
|
||||||
|
+++ b/lib/thor/rake_compat.rb
|
||||||
|
@@ -46,7 +46,8 @@ self.instance_eval do
|
||||||
|
description << task.arg_names.map{ |n| n.to_s.upcase }.join(' ')
|
||||||
|
description.strip!
|
||||||
|
|
||||||
|
- klass.desc description, task.comment || non_namespaced_name
|
||||||
|
+ klass.desc description, Rake.application.last_description || non_namespaced_name
|
||||||
|
+ Rake.application.last_description = nil
|
||||||
|
klass.send :define_method, non_namespaced_name do |*args|
|
||||||
|
Rake::Task[task.name.to_sym].invoke(*args)
|
||||||
|
end
|
@ -0,0 +1,115 @@
|
|||||||
|
commit 11c8748933cc611972f32831657ab99e6701bd93
|
||||||
|
Author: Yehuda Katz <wycats@gmail.com>
|
||||||
|
Date: Sat Jul 2 20:50:39 2011 -0700
|
||||||
|
|
||||||
|
Upgrade Rake compatibility for the more constrained Rake 0.9
|
||||||
|
|
||||||
|
diff --git a/lib/thor/rake_compat.rb b/lib/thor/rake_compat.rb
|
||||||
|
index 0d0757f..b3a8beb 100644
|
||||||
|
--- a/lib/thor/rake_compat.rb
|
||||||
|
+++ b/lib/thor/rake_compat.rb
|
||||||
|
@@ -1,4 +1,5 @@
|
||||||
|
require 'rake'
|
||||||
|
+require 'rake/dsl_definition'
|
||||||
|
|
||||||
|
class Thor
|
||||||
|
# Adds a compatibility layer to your Thor classes which allows you to use
|
||||||
|
@@ -16,6 +17,8 @@ class Thor
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
module RakeCompat
|
||||||
|
+ include Rake::DSL if defined?(Rake::DSL)
|
||||||
|
+
|
||||||
|
def self.rake_classes
|
||||||
|
@rake_classes ||= []
|
||||||
|
end
|
||||||
|
@@ -29,12 +32,12 @@ class Thor
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-class Object #:nodoc:
|
||||||
|
- alias :rake_task :task
|
||||||
|
- alias :rake_namespace :namespace
|
||||||
|
+# override task on (main), for compatibility with Rake 0.9
|
||||||
|
+self.instance_eval do
|
||||||
|
+ alias rake_namespace namespace
|
||||||
|
|
||||||
|
- def task(*args, &block)
|
||||||
|
- task = rake_task(*args, &block)
|
||||||
|
+ def task(*)
|
||||||
|
+ task = super
|
||||||
|
|
||||||
|
if klass = Thor::RakeCompat.rake_classes.last
|
||||||
|
non_namespaced_name = task.name.split(':').last
|
||||||
|
@@ -52,7 +55,7 @@ class Object #:nodoc:
|
||||||
|
task
|
||||||
|
end
|
||||||
|
|
||||||
|
- def namespace(name, &block)
|
||||||
|
+ def namespace(name)
|
||||||
|
if klass = Thor::RakeCompat.rake_classes.last
|
||||||
|
const_name = Thor::Util.camel_case(name.to_s).to_sym
|
||||||
|
klass.const_set(const_name, Class.new(Thor))
|
||||||
|
@@ -60,7 +63,8 @@ class Object #:nodoc:
|
||||||
|
Thor::RakeCompat.rake_classes << new_klass
|
||||||
|
end
|
||||||
|
|
||||||
|
- rake_namespace(name, &block)
|
||||||
|
+ super
|
||||||
|
Thor::RakeCompat.rake_classes.pop
|
||||||
|
end
|
||||||
|
end
|
||||||
|
+
|
||||||
|
diff --git a/lib/thor/task.rb b/lib/thor/task.rb
|
||||||
|
index 6db3b60..8dcff53 100644
|
||||||
|
--- a/lib/thor/task.rb
|
||||||
|
+++ b/lib/thor/task.rb
|
||||||
|
@@ -104,7 +104,11 @@ class Thor
|
||||||
|
|
||||||
|
def run(instance, args=[])
|
||||||
|
if (instance.methods & [name.to_s, name.to_sym]).empty?
|
||||||
|
- super
|
||||||
|
+ if ((instance.protected_methods + instance.public_methods) & ([:method_missing, "method_missing"])).empty?
|
||||||
|
+ super
|
||||||
|
+ else
|
||||||
|
+ instance.send(:method_missing, name.to_sym, *args)
|
||||||
|
+ end
|
||||||
|
else
|
||||||
|
instance.class.handle_no_task_error(name)
|
||||||
|
end
|
||||||
|
diff --git a/spec/rake_compat_spec.rb b/spec/rake_compat_spec.rb
|
||||||
|
index f8d694c..0b642aa 100644
|
||||||
|
--- a/spec/rake_compat_spec.rb
|
||||||
|
+++ b/spec/rake_compat_spec.rb
|
||||||
|
@@ -2,20 +2,24 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
||||||
|
require 'thor/rake_compat'
|
||||||
|
require 'rake/tasklib'
|
||||||
|
|
||||||
|
+$main = self
|
||||||
|
+
|
||||||
|
class RakeTask < Rake::TaskLib
|
||||||
|
def initialize
|
||||||
|
define
|
||||||
|
end
|
||||||
|
|
||||||
|
def define
|
||||||
|
- desc "Say it's cool"
|
||||||
|
- task :cool do
|
||||||
|
- puts "COOL"
|
||||||
|
- end
|
||||||
|
+ $main.instance_eval do
|
||||||
|
+ desc "Say it's cool"
|
||||||
|
+ task :cool do
|
||||||
|
+ puts "COOL"
|
||||||
|
+ end
|
||||||
|
|
||||||
|
- namespace :hiper_mega do
|
||||||
|
- task :super do
|
||||||
|
- puts "HIPER MEGA SUPER"
|
||||||
|
+ namespace :hiper_mega do
|
||||||
|
+ task :super do
|
||||||
|
+ puts "HIPER MEGA SUPER"
|
||||||
|
+ end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in new issue