module RichUrls

Constants

DEFAULT_TIMEOUT

Public Class Methods

browser() click to toggle source
# File lib/richurls.rb, line 26
def self.browser
  @browser || PatronBrowser.new
end
browser=(browser) click to toggle source
# File lib/richurls.rb, line 17
def self.browser=(browser)
  unless browser.is_a? Browser
    raise ArgumentError,
          'browser needs to be of a RichUrls::Browser type'
  end

  @browser ||= browser
end
cache() click to toggle source
# File lib/richurls.rb, line 13
def self.cache
  @cache || Cache::None.new
end
cache=(wrapper) click to toggle source
# File lib/richurls.rb, line 30
def self.cache=(wrapper)
  unless wrapper.is_a? Cache::Wrapper
    raise ArgumentError,
          'caching wrapper needs to be an instance of Cache::Wrapper'
  end

  @cache ||= wrapper
end
enrich(url, filter: [], cache_time: nil) click to toggle source
# File lib/richurls.rb, line 47
def self.enrich(url, filter: [], cache_time: nil)
  unless URI::DEFAULT_PARSER.make_regexp.match?(url)
    raise MalformedURLError, "this url is malformed: #{url}"
  end

  UrlFetcher.fetch(url, filter, browser: browser, cache_time: cache_time)
end
headers() click to toggle source
# File lib/richurls.rb, line 43
def self.headers
  @headers || {}
end
headers=(headers) click to toggle source
# File lib/richurls.rb, line 39
def self.headers=(headers)
  @headers ||= headers
end