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.

if ENV["XDG_CONFIG_HOME"] && File.exist?(ENV["XDG_CONFIG_HOME"] + "/guard/guardrc")
  ENV["XDG_CONFIG_HOME"] + "/guard/guardrc"
else
  "~/.guardrc"
end
HISTORY_FILE =

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

if ENV["XDG_DATA_HOME"] && File.exist?(ENV["XDG_DATA_HOME"] + "/guard/history")
  ENV["XDG_DATA_HOME"] + "/guard/history"
else
  "~/.guard_history"
end
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.


73
74
75
76
77
78
79
# File 'lib/guard/jobs/pry_wrapper.rb', line 73

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

  _setup(options)
end

Instance Method Details

#backgroundObject


94
95
96
# File 'lib/guard/jobs/pry_wrapper.rb', line 94

def background
  _kill_pry
end

#foregroundObject


81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/guard/jobs/pry_wrapper.rb', line 81

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


98
99
100
101
102
# File 'lib/guard/jobs/pry_wrapper.rb', line 98

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