module Rails::Sh::Rake

Public Class Methods

_invoke(line) click to toggle source
# File lib/rails/sh/rake.rb, line 28
def _invoke(line)
  line ||= 'default'
  name, *args = line.split(/\s+/)
  args.each do |arg|
    env, value = arg.split('=')
    next unless env && !env.empty? && value && !value.empty?
    ENV[env] = value
  end
  ::Rake.application[name].invoke
end
init() click to toggle source
# File lib/rails/sh/rake.rb, line 10
def init
  $stdout = StringIO.new

  before_fork do
    ActiveRecord::Base.remove_connection if defined?(ActiveRecord::Base)
  end
  after_fork do
    ActiveRecord::Base.establish_connection if defined?(ActiveRecord::Base)
  end

  ::Rake.application = ::Rake::Application.new
  ::Rake.application.init
  ::Rake.application.load_rakefile
  ::Rake.application[:environment].invoke
ensure
  $stdout = STDOUT
end
task_names() click to toggle source
# File lib/rails/sh/rake.rb, line 39
def task_names
  ::Rake.application.tasks.map{|t| t.name}
end