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-0.49.98 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-0.49.94 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-0.49.21 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-0.49.15 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-0.49.13 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-0.49.9 vendor/bundle/ruby/2.3.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-0.44.4 vendor/bundle/ruby/2.3.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
dadapush_client-1.0.1 vendor/bundle/ruby/2.3.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-0.30.7 vendor/bundle/ruby/2.3.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
color_me_shop-1.0.0 vendor/bundle/ruby/2.5.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
cloudsmith-api-0.21.4 vendor/bundle/ruby/2.3.0/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
vcr-4.0.0 lib/vcr/request_ignorer.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
logstash-input-salesforce-3.0.0 vendor/jruby/1.9/gems/vcr-3.0.3/lib/vcr/request_ignorer.rb
vcr-3.0.3 lib/vcr/request_ignorer.rb
vcr-3.0.2 lib/vcr/request_ignorer.rb
dwolla_swagger-1.0.6 vendor/bundle/ruby/2.2.0/gems/vcr-2.9.3/lib/vcr/request_ignorer.rb
vcr-3.0.1 lib/vcr/request_ignorer.rb
vcr-3.0.0 lib/vcr/request_ignorer.rb
mustwin-vcr-2.9.3 lib/vcr/request_ignorer.rb