lib/supergood/client.rb in supergood-0.1.3 vs lib/supergood/client.rb in supergood-0.1.4
- old
+ new
@@ -27,10 +27,11 @@
@base_url = ENV['SUPERGOOD_BASE_URL'] || DEFAULT_SUPERGOOD_BASE_URL
@api = Supergood::Api.new(supergood_client_id, supergood_client_secret, @base_url)
@config = Supergood::Utils.make_config(config)
+ @allowed_domains = @config[:allowedDomains]
@ignored_domains = @config[:ignoredDomains]
@keys_to_hash = @config[:keysToHash]
@logger = Supergood::Logger.new(@api, @config, @api.header_options)
@api.set_logger(@logger)
@@ -57,10 +58,11 @@
@api
end
def flush_cache(force = false)
# If there's notthing in the response cache, and we're not forcing a flush, then return
+
if @response_cache.empty? && !force
return
elsif force && @response_cache.empty? && @request_cache.empty?
return
end
@@ -176,13 +178,16 @@
def ignored?(domain)
base_domain = URI.parse(@base_url).hostname
if domain == base_domain
return true
+ elsif @allowed_domains.any?
+ @allowed_domains.all? do |allowed_domain|
+ !domain.include? allowed_domain
+ end
else
@ignored_domains.any? do |ignored_domain|
- pattern = URI.parse(ignored_domain).hostname
- domain =~ pattern
+ domain.include? ignored_domain
end
end
end
end
end