Sha256: df4d440c64ae7f41077be0ce8535a5baf548a0e0337108125f32d98614cece90

Contents?: true

Size: 551 Bytes

Versions: 2

Compression:

Stored size: 551 Bytes

Contents

require 'uri'
require 'set'

module VCR
  class RequestIgnorer
    LOCALHOST_ALIASES = %w( localhost 127.0.0.1 0.0.0.0 )

    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)
      ignored_hosts.include?(URI(request.uri).host)
    end

  private

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vcr-2.0.0.beta2 lib/vcr/request_ignorer.rb
vcr-2.0.0.beta1 lib/vcr/request_ignorer.rb