Sha256: 90554796fb04d278b877f88d18304af52fbad0b4522e106f3e9a78eda88a457f

Contents?: true

Size: 645 Bytes

Versions: 10

Compression:

Stored size: 645 Bytes

Contents

# frozen_string_literal: true

module Coverband
  class RackServerCheck
    def self.running?
      new(Kernel.caller_locations).running?
    end

    def initialize(stack)
      @stack = stack
    end

    def running?
      rack_server? || rails_server?
    end

    def rack_server?
      @stack.any? { |line| line.path.include?("lib/rack/") }
    end

    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
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
coverband-6.1.4 lib/coverband/integrations/rack_server_check.rb
coverband-6.1.3 lib/coverband/integrations/rack_server_check.rb
coverband-6.1.2 lib/coverband/integrations/rack_server_check.rb
coverband-6.1.2.rc.1 lib/coverband/integrations/rack_server_check.rb
coverband-6.1.1 lib/coverband/integrations/rack_server_check.rb
coverband-6.1.0 lib/coverband/integrations/rack_server_check.rb
coverband-6.0.3.rc.4 lib/coverband/integrations/rack_server_check.rb
coverband-6.0.3.rc.3 lib/coverband/integrations/rack_server_check.rb
coverband-6.0.3.rc.2 lib/coverband/integrations/rack_server_check.rb
coverband-6.0.3.rc.1 lib/coverband/integrations/rack_server_check.rb