Module: UrlReader

Extended by:
ActiveSupport::Concern
Includes:
UrlFixer
Defined in:
lib/url_reader.rb

Defined Under Namespace

Modules: UrlFixer Classes: BaseError, CannotResolveEncodingError, FileCache, ReadError

Constant Summary collapse

REQUEST_TIMEOUT =
10
REQUEST_OPEN_TIMEOUT =
10

Instance Method Summary collapse

Methods included from UrlFixer

#fixed_url

Instance Method Details

#read_url(url, options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/url_reader.rb', line 13

def read_url(url, options = {})
  if defined?(Rails) && Rails.env.development?
    if ENV['READ_URL_CACHE_NOT_USE'] != 'true'
      ckey = cache_key(url, options)
      res = cache.read_entry(ckey)
      res || read_url_core_with_cache_write(url, options, ckey)
    else
      read_url_core_with_cache_write(url, options)
    end
  else
    read_url_core(url, options)
  end
end