Class: Guard::Rack
- Inherits:
-
Plugin
- Object
- Plugin
- Guard::Rack
- Defined in:
- lib/guard/rack.rb,
lib/guard/rack/command.rb,
lib/guard/rack/custom_process.rb
Defined Under Namespace
Classes: Command, CustomProcess
Constant Summary collapse
- DEFAULT_OPTIONS =
{ port: 9292, host: '0.0.0.0', environment: 'development', start_on_start: true, force_run: false, timeout: 20, debugger: false, config: 'config.ru', cmd: 'rackup' }.freeze
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#runner ⇒ Object
readonly
Returns the value of attribute runner.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Rack
constructor
A new instance of Rack.
- #reload ⇒ Object
- #run_on_changes(_paths) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Rack
Returns a new instance of Rack.
22 23 24 25 26 |
# File 'lib/guard/rack.rb', line 22 def initialize( = {}) super @options = DEFAULT_OPTIONS.merge() @runner = ::Guard::RackRunner.new(@options) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/guard/rack.rb', line 8 def @options end |
#runner ⇒ Object (readonly)
Returns the value of attribute runner.
8 9 10 |
# File 'lib/guard/rack.rb', line 8 def runner @runner end |
Instance Method Details
#reload ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/guard/rack.rb', line 34 def reload UI.info 'Restarting Rack...' Notifier.notify("Rack restarting on port #{[:port]} in #{[:environment]} environment...", title: 'Restarting Rack...', image: :pending) if runner.restart UI.info "Rack restarted, pid #{runner.pid}" Notifier.notify("Rack restarted on port #{[:port]}.", title: 'Rack restarted!', image: :success) else UI.info 'Rack NOT restarted, check your log files.' Notifier.notify('Rack NOT restarted, check your log files.', title: 'Rack NOT restarted!', image: :failed) end end |
#run_on_changes(_paths) ⇒ Object
51 52 53 |
# File 'lib/guard/rack.rb', line 51 def run_on_changes(_paths) reload end |
#start ⇒ Object
28 29 30 31 32 |
# File 'lib/guard/rack.rb', line 28 def start server = [:server] ? "#{[:server]} and " : '' UI.info "Guard::Rack will now restart your app on port #{[:port]} using #{server}#{[:environment]} environment." reload if [:start_on_start] end |
#stop ⇒ Object
46 47 48 49 |
# File 'lib/guard/rack.rb', line 46 def stop Notifier.notify('Until next time...', title: 'Rack shutting down.', image: :pending) runner.stop end |