Sha256: b66dc115e8144250822780404dfa0741fd4122ca7ab8b590415ec6f8265d3a40

Contents?: true

Size: 1.4 KB

Versions: 45

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

require "openssl"
require "open-uri"
require "multi_json"
require "nokogiri"
require "mustache"
require "ostruct"
require "cgi"
require "net/http"
require "digest"
require "sanitize"
require_relative "onebox/sanitize_config"

module Onebox
  DEFAULTS = {
    connect_timeout: 5,
    timeout: 10,
    max_download_kb: (10 * 1024), # 10MB
    load_paths: [File.join(Gem::Specification.find_by_name("onebox").gem_dir, "templates")],
    allowed_ports: [80, 443],
    allowed_schemes: ["http", "https"],
    sanitize_config: Sanitize::Config::ONEBOX,
    redirect_limit: 5
  }

  @@options = DEFAULTS

  def self.preview(url, options = Onebox.options)
    # onebox does not have native caching
    unless Onebox::Helpers.blank?(options[:cache])
      warn "Onebox no longer has inbuilt caching so `cache` option will be ignored."
    end

    Preview.new(url, options)
  end

  def self.check(url, options = Onebox.options)
    StatusCheck.new(url, options)
  end

  def self.options
    OpenStruct.new(@@options)
  end

  def self.has_matcher?(url)
    !!Matcher.new(url).oneboxed
  end

  def self.options=(options)
    @@options = DEFAULTS.merge(options)
  end
end

require_relative "onebox/version"
require_relative "onebox/preview"
require_relative "onebox/status_check"
require_relative "onebox/matcher"
require_relative "onebox/engine"
require_relative "onebox/layout"
require_relative "onebox/view"

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
onebox-2.2.19 lib/onebox.rb
onebox-2.2.18 lib/onebox.rb
onebox-2.2.17 lib/onebox.rb
onebox-2.2.16 lib/onebox.rb
onebox-2.2.15 lib/onebox.rb
onebox-2.2.14 lib/onebox.rb
onebox-2.2.13 lib/onebox.rb
onebox-2.2.12 lib/onebox.rb
onebox-2.2.11 lib/onebox.rb
onebox-2.2.10 lib/onebox.rb
onebox-2.2.9 lib/onebox.rb
onebox-2.2.8 lib/onebox.rb
onebox-2.2.6 lib/onebox.rb
onebox-2.2.4 lib/onebox.rb
onebox-2.2.2 lib/onebox.rb
onebox-2.2.1 lib/onebox.rb
onebox-2.2.0 lib/onebox.rb
onebox-2.1.9 lib/onebox.rb
onebox-2.1.8 lib/onebox.rb
onebox-2.1.7 lib/onebox.rb