Sha256: 730bb93c8ac8b5143e1c90491d9d08f4b918f9747ff0b52bea8ece6e71e7b8d4

Contents?: true

Size: 777 Bytes

Versions: 71

Compression:

Stored size: 777 Bytes

Contents

require 'set'
require 'vcr/util/hooks'

module VCR
  # @private
  class RequestIgnorer
    include VCR::Hooks

    define_hook :ignore_request

    LOCALHOST_ALIASES = %w( localhost 127.0.0.1 0.0.0.0 )

    def initialize
      ignore_request do |request|
        host = request.parsed_uri.host
        ignored_hosts.include?(host)
      end
    end

    def ignore_localhost=(value)
      if value
        ignore_hosts(*LOCALHOST_ALIASES)
      else
        ignored_hosts.reject! { |h| LOCALHOST_ALIASES.include?(h) }
      end
    end

    def ignore_hosts(*hosts)
      ignored_hosts.merge(hosts)
    end

    def ignore?(request)
      invoke_hook(:ignore_request, request).any?
    end

  private

    def ignored_hosts
      @ignored_hosts ||= Set.new
    end
  end
end

Version data entries

71 entries across 71 versions & 9 rubygems

Version Path
cloudsmith-api-1.42.3 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-1.33.7 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-1.30.0 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-0.57.1 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-0.54.15 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-0.53.79 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-0.53.17 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-0.53.3 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-0.53.1 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-0.52.121 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-0.52.92 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-0.52.79 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-0.52.5 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-0.52.0 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-0.51.93 vendor/bundle/ruby/2.3.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-0.51.38 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-0.51.37 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-0.51.34 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-0.51.22 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-0.49.118 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb