Sha256: 7ffb7a05429c776b65139e68ab83b25af68b25a1fba0455568a4ec880f83309f
Contents?: true
Size: 769 Bytes
Versions: 11
Compression:
Stored size: 769 Bytes
Contents
require 'uri' 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| ignored_hosts.include?(URI(request.uri).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
11 entries across 11 versions & 1 rubygems