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.

Parameters:



12
13
14
# File 'lib/lolcommits/cli/process_runner.rb', line 12

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.

Parameters:

  • please (Boolean)

    whether or not to fork lolcommits process

Yields:

  • the main event loop for lolcommits

Returns:

  • (Boolean)


23
24
25
26
27
28
29
30
31
32
33
# File 'lib/lolcommits/cli/process_runner.rb', line 23

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