Class: Guard::Passenger

Inherits:
Plugin
  • Object
show all
Defined in:
lib/guard/passenger.rb,
lib/guard/passenger/pinger.rb,
lib/guard/passenger/runner.rb

Defined Under Namespace

Modules: Pinger, Runner

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Passenger

Guard methods =



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/guard/passenger.rb', line 26

def initialize(options = {})
  super

  @standalone   = options[:standalone].nil? ? true : options[:standalone]
  @cli_start    = init_cli(options)
  @cli_stop     = cli_stop
  @notification = options[:notification].nil? ? true : options[:notification]

  @ping = options[:ping].eql?(true) ? '/' : options[:ping]

  @sudo = options[:sudo] || ''
  @sudo = @sudo.eql?(true) ? 'sudo' : @sudo
end

Instance Attribute Details

#cli_startObject (readonly)

Returns the value of attribute cli_start.



12
13
14
# File 'lib/guard/passenger.rb', line 12

def cli_start
  @cli_start
end

#notificationObject (readonly)

Returns the value of attribute notification.



12
13
14
# File 'lib/guard/passenger.rb', line 12

def notification
  @notification
end

#pingObject (readonly)

Returns the value of attribute ping.



12
13
14
# File 'lib/guard/passenger.rb', line 12

def ping
  @ping
end

#runningObject (readonly)

Returns the value of attribute running.



12
13
14
# File 'lib/guard/passenger.rb', line 12

def running
  @running
end

#sudoObject (readonly)

Returns the value of attribute sudo.



12
13
14
# File 'lib/guard/passenger.rb', line 12

def sudo
  @sudo
end

Instance Method Details

#reloadObject

Call with Ctrl-Z signal



60
61
62
# File 'lib/guard/passenger.rb', line 60

def reload
  restart_and_ping
end

#run_on_changes(paths = {}) ⇒ Object

Call on file(s) modifications



65
66
67
# File 'lib/guard/passenger.rb', line 65

def run_on_changes(paths = {})
  restart_and_ping
end

#running?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/guard/passenger.rb', line 18

def running?
  @running
end

#standalone?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/guard/passenger.rb', line 14

def standalone?
  @standalone
end

#startObject

Call once when guard starts



41
42
43
44
45
46
47
48
# File 'lib/guard/passenger.rb', line 41

def start
  UI.info 'Guard::Passenger is running!'
  if standalone?
    running = Runner.start_passenger(cli_start, @sudo)
  else
    true
  end
end

#stopObject

Call with Ctrl-C signal (when Guard quit)



51
52
53
54
55
56
57
# File 'lib/guard/passenger.rb', line 51

def stop
  if standalone? && running?
    UI.info 'Stopping Passenger...'
    Runner.stop_passenger(cli_stop, @sudo)
  end
  true
end