Class: Guard::Rails
- Inherits:
-
Guard
- Object
- Guard
- Guard::Rails
- Defined in:
- lib/guard/rails.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :CLI => nil, :daemon => false, :debugger => false, :environment => 'development', :force_runs => false, :pid_file => nil, # construct the filename based on options[:environment] on runtime :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(watchers = [], 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(watchers = [], options = {}) ⇒ Rails
Returns a new instance of Rails.
29 30 31 32 33 34 |
# File 'lib/guard/rails.rb', line 29 def initialize(watchers = [], = {}) super @options = DEFAULT_OPTIONS.merge() @runner = RailsRunner.new(@options) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/guard/rails.rb', line 12 def @options end |
#runner ⇒ Object (readonly)
Returns the value of attribute runner.
12 13 14 |
# File 'lib/guard/rails.rb', line 12 def runner @runner end |
Instance Method Details
#reload(action = "restart") ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/guard/rails.rb', line 42 def reload(action = "restart") action_cap = action.capitalize UI.info "#{action_cap}ing Rails..." Notifier.notify("Rails #{action}ing on port #{[:port]} in #{[:environment]} environment...", :title => "#{action_cap}ing Rails...", :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
60 61 62 |
# File 'lib/guard/rails.rb', line 60 def run_on_changes(paths) reload end |
#start ⇒ Object
36 37 38 39 40 |
# File 'lib/guard/rails.rb', line 36 def start server = [:server] ? "#{[:server]} and " : "" UI.info "Guard::Rails will now restart your app on port #{[:port]} using #{server}#{[:environment]} environment." reload("start") if [:start_on_start] end |
#stop ⇒ Object
55 56 57 58 |
# File 'lib/guard/rails.rb', line 55 def stop Notifier.notify("Until next time...", :title => "Rails shutting down.", :image => :pending) runner.stop end |