Class: Guard::Passenger

Inherits:
Guard
  • 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(watchers = [], options = {}) ⇒ Passenger

Guard methods =



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

def initialize(watchers = [], 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.



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

def cli_start
  @cli_start
end

#notificationObject (readonly)

Returns the value of attribute notification.



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

def notification
  @notification
end

#pingObject (readonly)

Returns the value of attribute ping.



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

def ping
  @ping
end

#runningObject (readonly)

Returns the value of attribute running.



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

def running
  @running
end

#sudoObject (readonly)

Returns the value of attribute sudo.



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

def sudo
  @sudo
end

Instance Method Details

#reloadObject

Call with Ctrl-Z signal



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

def reload
  restart_and_ping
end

#run_on_changes(paths = {}) ⇒ Object

Call on file(s) modifications



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

def run_on_changes(paths = {})
  restart_and_ping
end

#running?Boolean

Returns:

  • (Boolean)


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

def running?
  @running
end

#standalone?Boolean

Returns:

  • (Boolean)


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

def standalone?
  @standalone
end

#startObject

Call once when guard starts



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

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)



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

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