模块 Bundler::Thor::RakeCompat

为您的 Bundler::Thor 类添加一个兼容层,允许您使用 rake 包任务。例如,要使用 rspec rake 任务,可以这样做

require 'bundler/vendor/thor/lib/thor/rake_compat'
require 'rspec/core/rake_task'

class Default < Bundler::Thor
  include Bundler::Thor::RakeCompat

  RSpec::Core::RakeTask.new(:spec) do |t|
    t.spec_opts = ['--options', './.rspec']
    t.spec_files = FileList['spec/**/*_spec.rb']
  end
end

公共类方法

included(base) 点击切换源代码
调用超类方法
# File bundler/vendor/thor/lib/thor/rake_compat.rb, line 27
def self.included(base)
  super(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)
  rake_classes << base
end
rake_classes() 点击切换源代码
# File bundler/vendor/thor/lib/thor/rake_compat.rb, line 23
def self.rake_classes
  @rake_classes ||= []
end