class Guard::Puma
Constants
- DEFAULT_OPTIONS
Attributes
options[R]
runner[R]
Public Class Methods
default_env()
click to toggle source
# File lib/guard/puma.rb, line 9 def self.default_env ENV.fetch('RACK_ENV', 'development') end
new(options = {})
click to toggle source
Calls superclass method
# File lib/guard/puma.rb, line 25 def initialize(options = {}) super @options = DEFAULT_OPTIONS.merge(options) @options[:port] = nil if @options.key?(:config) @runner = ::Guard::PumaRunner.new(@options) @last_restarted = Time.now end
Public Instance Methods
reload()
click to toggle source
# File lib/guard/puma.rb, line 42 def reload return if (Time.now - @last_restarted) < options[:restart_timeout] @last_restarted = Time.now Compat::UI.info "Restarting Puma..." if options[:notifications].include?(:restarting) Compat::UI.notify( "Puma restarting#{port_text} in #{options[:environment]} environment...", title: "Restarting Puma...", image: :pending ) end if runner.restart Compat::UI.info "Puma restarted" if options[:notifications].include?(:restarted) Compat::UI.notify( "Puma restarted#{port_text}.", title: "Puma restarted!", image: :success ) end else Compat::UI.info "Puma NOT restarted, check your log files." if options[:notifications].include?(:not_restarted) Compat::UI.notify( "Puma NOT restarted, check your log files.", title: "Puma NOT restarted!", image: :failed ) end end end
run_on_changes(paths)
click to toggle source
# File lib/guard/puma.rb, line 82 def run_on_changes(paths) reload end
start()
click to toggle source
# File lib/guard/puma.rb, line 33 def start return unless options[:start_on_start] server = options[:server] ? "#{options[:server]} and " : "" Compat::UI.info( "Puma starting#{port_text} in #{server}#{options[:environment]} environment." ) runner.start end
stop()
click to toggle source
# File lib/guard/puma.rb, line 71 def stop return unless options[:start_on_start] if options[:notifications].include?(:stopped) Compat::UI.notify( "Until next time...", title: "Puma shutting down.", image: :pending ) end runner.halt end
Private Instance Methods
port_text()
click to toggle source
# File lib/guard/puma.rb, line 88 def port_text " on port #{options[:port]}" if options[:port] end