module Rails::Sh::Forkable
Public Instance Methods
_invoke()
click to toggle source
# File lib/rails/sh/forkable.rb, line 30 def _invoke raise NotImplementedError end
after_fork(&block)
click to toggle source
# File lib/rails/sh/forkable.rb, line 38 def after_fork(&block) @after_fork = block end
before_fork(&block)
click to toggle source
# File lib/rails/sh/forkable.rb, line 34 def before_fork(&block) @before_fork = block end
invoke(line, options = {})
click to toggle source
# File lib/rails/sh/forkable.rb, line 8 def invoke(line, options = {}) run_before_fork pid = fork do run_after_fork if options[:pager] begin $stdout = StringIO.new _invoke(line) ensure output = $stdout.string lesspipe output $stdout = STDOUT end else _invoke(line) end end Process.waitpid(pid) end
run_after_fork(&block)
click to toggle source
# File lib/rails/sh/forkable.rb, line 46 def run_after_fork(&block) @after_fork.call if @after_fork end
run_before_fork(&block)
click to toggle source
# File lib/rails/sh/forkable.rb, line 42 def run_before_fork(&block) @before_fork.call if @before_fork end