Class: Guard::Interactor

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/guard/interactor.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(no_interaction = false) ⇒ Interactor

Initializes the interactor. This configures Pry and creates some custom commands and aliases for Guard.


9
10
11
12
13
14
15
16
17
18
# File 'lib/guard/interactor.rb', line 9

def initialize(no_interaction = false)
  @interactive = !no_interaction && self.class.enabled?

  # TODO: only require the one used
  require "guard/jobs/sleep"
  require "guard/jobs/pry_wrapper"

  job_klass = interactive? ? Jobs::PryWrapper : Jobs::Sleep
  @idle_job = job_klass.new(self.class.options)
end

Class Attribute Details

.enabled=(value) ⇒ Object

TODO: handle switching interactors during runtime?


46
47
48
# File 'lib/guard/interactor.rb', line 46

def enabled=(value)
  @enabled = value
end

.optionsObject


31
32
33
# File 'lib/guard/interactor.rb', line 31

def options
  @options ||= {}
end

Class Method Details

.enabled?Boolean Also known as: enabled

TODO: allow custom user idle jobs, e.g. [:pry, :sleep, :exit, …]

Returns:

  • (Boolean)

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

def enabled?
  @enabled || @enabled.nil?
end

Instance Method Details

#interactive?Boolean

Returns:

  • (Boolean)

20
21
22
# File 'lib/guard/interactor.rb', line 20

def interactive?
  @interactive
end