Module: Keepgoing

Defined in:
lib/keepgoing.rb,
lib/keepgoing/version.rb

Overview

keepgoing's core, that keeps things going

Constant Summary collapse

VERSION =
"0.3.0"

Class Method Summary collapse

Class Method Details

.clear_screen_on_reload?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/keepgoing.rb', line 39

def self.clear_screen_on_reload?
  %w[1 on true].include?(ENV["CLEAR"])
end

.guardfileObject



29
30
31
32
33
34
35
36
37
# File 'lib/keepgoing.rb', line 29

def self.guardfile
  <<~GUARDFILE
    clearing :#{clear_screen_on_reload? ? "on" : "off"}
    interactor :off
    guard "keepgoing", file: "#{script_file}", clear_screen_on_reload: #{clear_screen_on_reload?} do
      watch("#{script_file}")
    end
  GUARDFILE
end

.script_fileObject



24
25
26
# File 'lib/keepgoing.rb', line 24

def self.script_file
  $PROGRAM_NAME
end

.startObject

The .start method will start up Guard using .guardfile as configuration. This mehtod is idempotent, it will start guard only once on the first call. If guard is already active, it will do nothing.



14
15
16
17
18
19
20
21
# File 'lib/keepgoing.rb', line 14

def self.start
  return if Guard.state

  Guard::UI.level = :warn
  Guard.start(guardfile_contents: guardfile)

  exit
end