Class: Lolcommits::CLI::ProcessRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/lolcommits/cli/process_runner.rb

Overview

Helper class for forking lolcommits process to the background (or not).

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ ProcessRunner

Initializes a new process runner.



8
9
10
# File 'lib/lolcommits/cli/process_runner.rb', line 8

def initialize(config)
  @configuration = config
end

Instance Method Details

#fork_me?(please) { ... } ⇒ Boolean

Forks the lolcommits process if requested.

Writes the PID of the lolcommits process to the filesystem when backgrounded, for monitoring purposes.

Yields:

  • the main event loop for lolcommits



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/lolcommits/cli/process_runner.rb', line 19

def fork_me?(please, &block)
  if please
    $stdout.sync = true
    write_pid fork {
      yield block
      delete_pid
    }
  else
    yield block
  end
end