Module: Thor::RakeCompat

Defined in:
lib/vendor/thor/lib/thor/rake_compat.rb

Overview

Adds a compatibility layer to your Thor classes which allows you to use rake package tasks. For example, to use rspec rake tasks, one can do:

require 'thor/rake_compat'

class Default < Thor
  include Thor::RakeCompat

  Spec::Rake::SpecTask.new(:spec) do |t|
    t.spec_opts = ['--options', "spec/spec.opts"]
    t.spec_files = FileList['spec/**/*_spec.rb']
  end
end

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



23
24
25
26
27
28
# File 'lib/vendor/thor/lib/thor/rake_compat.rb', line 23

def self.included(base)
  # Hack. Make rakefile point to invoker, so rdoc task is generated properly.
  rakefile = File.basename(caller[0].match(/(.*):\d+/)[1])
  Rake.application.instance_variable_set(:@rakefile, rakefile)
  self.rake_classes << base
end

.rake_classesObject



19
20
21
# File 'lib/vendor/thor/lib/thor/rake_compat.rb', line 19

def self.rake_classes
  @rake_classes ||= []
end