Class: StaticRails::RackServerCheck
- Inherits:
-
Object
- Object
- StaticRails::RackServerCheck
- Defined in:
- lib/static-rails/rack_server_check.rb
Overview
Shamelessly ripped out of @danmeyer’s Coverband: github.com/danmayer/coverband/blob/master/lib/coverband/integrations/rack_server_check.rb#L14
Copyright © 2010-2018 Dan Mayer
Distributed under the MIT License
Details:
https://github.com/danmayer/coverband/blob/master/LICENSE.txt
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(stack) ⇒ RackServerCheck
constructor
A new instance of RackServerCheck.
- #rack_server? ⇒ Boolean
- #rails_server? ⇒ Boolean
- #running? ⇒ Boolean
Constructor Details
#initialize(stack) ⇒ RackServerCheck
Returns a new instance of RackServerCheck.
15 16 17 |
# File 'lib/static-rails/rack_server_check.rb', line 15 def initialize(stack) @stack = stack end |
Class Method Details
.running? ⇒ Boolean
11 12 13 |
# File 'lib/static-rails/rack_server_check.rb', line 11 def self.running? new(Kernel.caller_locations).running? end |
Instance Method Details
#rack_server? ⇒ Boolean
23 24 25 |
# File 'lib/static-rails/rack_server_check.rb', line 23 def rack_server? @stack.any? { |line| line.path.include?("lib/rack/") } end |
#rails_server? ⇒ Boolean
27 28 29 30 31 32 33 34 |
# File 'lib/static-rails/rack_server_check.rb', line 27 def rails_server? @stack.any? do |location| ( (location.path.include?("rails/commands/commands_tasks.rb") && location.label == "server") || (location.path.include?("rails/commands/server/server_command.rb") && location.label == "perform") ) end end |
#running? ⇒ Boolean
19 20 21 |
# File 'lib/static-rails/rack_server_check.rb', line 19 def running? rack_server? || rails_server? end |