diff options
Diffstat (limited to 'lib/bundler/vendor/thor/rake_compat.rb')
-rw-r--r-- | lib/bundler/vendor/thor/rake_compat.rb | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/lib/bundler/vendor/thor/rake_compat.rb b/lib/bundler/vendor/thor/rake_compat.rb index c86e8405..0d0757fd 100644 --- a/lib/bundler/vendor/thor/rake_compat.rb +++ b/lib/bundler/vendor/thor/rake_compat.rb @@ -1,5 +1,4 @@ require 'rake' -require 'rake/dsl_definition' class Thor # Adds a compatibility layer to your Thor classes which allows you to use @@ -17,8 +16,6 @@ class Thor # end # module RakeCompat - include Rake::DSL if defined?(Rake::DSL) - def self.rake_classes @rake_classes ||= [] end @@ -32,12 +29,12 @@ class Thor end end -# override task on (main), for compatibility with Rake 0.9 -self.instance_eval do - alias rake_namespace namespace +class Object #:nodoc: + alias :rake_task :task + alias :rake_namespace :namespace - def task(*) - task = super + def task(*args, &block) + task = rake_task(*args, &block) if klass = Thor::RakeCompat.rake_classes.last non_namespaced_name = task.name.split(':').last @@ -46,8 +43,7 @@ self.instance_eval do description << task.arg_names.map{ |n| n.to_s.upcase }.join(' ') description.strip! - klass.desc description, Rake.application.last_description || non_namespaced_name - Rake.application.last_description = nil + klass.desc description, task.comment || non_namespaced_name klass.send :define_method, non_namespaced_name do |*args| Rake::Task[task.name.to_sym].invoke(*args) end @@ -56,7 +52,7 @@ self.instance_eval do task end - def namespace(name) + def namespace(name, &block) 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)) @@ -64,8 +60,7 @@ self.instance_eval do Thor::RakeCompat.rake_classes << new_klass end - super + rake_namespace(name, &block) Thor::RakeCompat.rake_classes.pop end end - |