Class: Guard::Jobs::PryWrapper

Inherits:
Base
  • Object
show all
Defined in:
lib/guard/jobs/pry_wrapper.rb

Constant Summary collapse

GUARD_RC =

The default Ruby script to configure Guard Pry if the option `:guard_rc` is not defined.

"~/.guardrc"
HISTORY_FILE =

The default Guard Pry history file if the option `:history_file` is not defined.

"~/.guard_history"
SHORTCUTS =

List of shortcuts for each interactor command

{
  help: "h",
  all: "a",
  reload: "r",
  change: "c",
  show: "s",
  scope: "o",
  notification: "n",
  pause: "p",
  exit: "e",
  quit: "q"
}

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ PryWrapper

Returns a new instance of PryWrapper


63
64
65
66
67
68
69
# File 'lib/guard/jobs/pry_wrapper.rb', line 63

def initialize(options)
  @mutex = Mutex.new
  @thread = nil
  @terminal_settings = TerminalSettings.new

  _setup(options)
end

Instance Method Details

#backgroundObject


84
85
86
# File 'lib/guard/jobs/pry_wrapper.rb', line 84

def background
  _kill_pry
end

#foregroundObject


71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/guard/jobs/pry_wrapper.rb', line 71

def foreground
  UI.debug "Start interactor"
  @terminal_settings.save

  _switch_to_pry
  # TODO: rename :stopped to continue
  _killed? ? :stopped : :exit
ensure
  UI.reset_line
  UI.debug "Interactor was stopped or killed"
  @terminal_settings.restore
end

#handle_interruptObject


88
89
90
91
92
# File 'lib/guard/jobs/pry_wrapper.rb', line 88

def handle_interrupt
  thread = @thread
  fail Interrupt unless thread
  thread.raise Interrupt
end