class Object
Public Instance Methods
file_task_name(name)
click to toggle source
# File lib/vendor/thor/bin/rake2thor, line 28 def file_task_name(name) "compile_" + name.gsub('/', '_slash_').gsub('.', '_dot_').gsub(/\W/, '_') end
method_for_task(task)
click to toggle source
# File lib/vendor/thor/bin/rake2thor, line 32 def method_for_task(task) file_task = task.is_a?(Rake::FileTask) comment = task.instance_variable_get('@comment') prereqs = task.instance_variable_get('@prerequisites').select(&Rake::Task.method(:task_defined?)) actions = task.instance_variable_get('@actions') name = task.name.gsub(/^([^:]+:)+/, '') name = file_task_name(name) if file_task meth = '' meth << "desc #{name.inspect}, #{comment.inspect}\n" if comment meth << "def #{name}\n" meth << prereqs.map do |pre| pre = pre.to_s pre = file_task_name(pre) if Rake::Task[pre].is_a?(Rake::FileTask) ' ' + pre end.join("\n") meth << "\n\n" unless prereqs.empty? || actions.empty? meth << actions.map do |act| act = act.to_ruby unless act.gsub!(/^proc \{ \|(\w+)\|\n/, " \\1 = Struct.new(:name).new(#{name.inspect}) # A crude mock Rake::Task object\n") act.gsub!(/^proc \{\n/, '') end act.gsub(/\n\}$/, '') end.join("\n") meth << "\nend" if file_task @private_methods << meth return end meth end
namespace(name)
click to toggle source
Calls superclass method
# File lib/vendor/thor/lib/thor/rake_compat.rb, line 59 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)) new_klass = klass.const_get(const_name) Thor::RakeCompat.rake_classes << new_klass end super Thor::RakeCompat.rake_classes.pop end
Also aliased as: rake_namespace
task(*)
click to toggle source
Calls superclass method
# File lib/vendor/thor/lib/thor/rake_compat.rb, line 39 def task(*) task = super if klass = Thor::RakeCompat.rake_classes.last non_namespaced_name = task.name.split(':').last description = non_namespaced_name 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.send :define_method, non_namespaced_name do |*args| Rake::Task[task.name.to_sym].invoke(*args) end end task end