Sha256: 0cea5ce5e9792eef312e9b211359b0bbb0123e66e5684c7008ba1e11e782f49b
Contents?: true
Size: 960 Bytes
Versions: 2
Compression:
Stored size: 960 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 host.docker.internal ) 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 localhost_ignored? (LOCALHOST_ALIASES & ignore_hosts.to_a).any? end def ignore_hosts(*hosts) ignored_hosts.merge(hosts) end def unignore_hosts(*hosts) ignored_hosts.subtract(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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vcr-6.3.1 | lib/vcr/request_ignorer.rb |
vcr-6.3.0 | lib/vcr/request_ignorer.rb |