Class: Guard::Rails
- Inherits:
-
Plugin
- Object
- Plugin
- Guard::Rails
- Defined in:
- lib/guard/rails.rb,
lib/guard/rails/runner.rb
Defined Under Namespace
Classes: Runner
Constant Summary collapse
- DEFAULT_OPTIONS =
{ CLI: nil, daemon: false, debugger: false, environment: 'development', force_run: false, pid_file: nil, # construct the filename based on options[:environment] on runtime host: "localhost", port: 3000, server: nil, # specified by rails start_on_start: true, timeout: 30, zeus_plan: 'server', zeus: false, }
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 = {}) ⇒ Rails
constructor
A new instance of Rails.
- #reload(action = "restart") ⇒ Object
- #run_on_changes(paths) ⇒ Object (also: #run_on_change)
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Rails
Returns a new instance of Rails.
25 26 27 28 29 30 |
# File 'lib/guard/rails.rb', line 25 def initialize( = {}) super @options = DEFAULT_OPTIONS.merge() @runner = Runner.new(@options) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/guard/rails.rb', line 7 def @options end |
#runner ⇒ Object (readonly)
Returns the value of attribute runner.
7 8 9 |
# File 'lib/guard/rails.rb', line 7 def runner @runner end |
Instance Method Details
#reload(action = "restart") ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/guard/rails.rb', line 37 def reload(action = "restart") title = "#{action.capitalize}ing Rails..." UI.info title Notifier.notify("Rails #{action}ing on port #{[:port]} in #{[:environment]}...", title: title, image: :pending) if runner.restart UI.info "Rails #{action}ed, pid #{runner.pid}" Notifier.notify("Rails #{action}ed on port #{[:port]}.", title: "Rails #{action}ed!", image: :success) else UI.info "Rails NOT #{action}ed, check your log files." Notifier.notify("Rails NOT #{action}ed, check your log files.", title: "Rails NOT #{action}ed!", image: :failed) end end |
#run_on_changes(paths) ⇒ Object Also known as: run_on_change
55 56 57 |
# File 'lib/guard/rails.rb', line 55 def run_on_changes(paths) reload end |
#start ⇒ Object
32 33 34 35 |
# File 'lib/guard/rails.rb', line 32 def start UI.info "[Guard::Rails] will start #{[:server] || "the default web server"} on port #{[:port]} in #{[:environment]}." reload("start") if [:start_on_start] end |
#stop ⇒ Object
50 51 52 53 |
# File 'lib/guard/rails.rb', line 50 def stop Notifier.notify("Until next time...", title: "Rails shutting down.", image: :pending) runner.stop end |