Module: Rails::Sh::Rake

Extended by:
Forkable
Defined in:
lib/rails/sh/rake.rb

Class Method Summary collapse

Methods included from Forkable

_invoke, after_fork, before_fork, invoke, run_after_fork, run_before_fork

Methods included from Helpers

#lesspipe

Class Method Details

._invoke(line) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# 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

.initObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 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_namesObject



39
40
41
# File 'lib/rails/sh/rake.rb', line 39

def task_names
  ::Rake.application.tasks.map{|t| t.name}
end