lib/onebox.rb in onebox-1.1.0 vs lib/onebox.rb in onebox-1.2.0
- old
+ new
@@ -5,32 +5,40 @@
require "opengraph_parser"
require "hexpress"
require "hexpress/web"
require "ostruct"
require "moneta"
+require "cgi"
-require_relative "onebox/version"
-require_relative "onebox/preview"
-require_relative "onebox/matcher"
-require_relative "onebox/engine"
-require_relative "onebox/view"
-
module Onebox
DEFAULTS = {
cache: Moneta.new(:Memory, expires: true, serializer: :json),
- timeout: 10
+ timeout: 10,
+ load_paths: [File.join(Gem::Specification.find_by_name("onebox").gem_dir, "templates")]
}
- @@defaults = DEFAULTS
+ @@options = DEFAULTS
- def self.preview(url, options = Onebox.defaults)
+ def self.preview(url, options = Onebox.options)
Preview.new(url, options)
end
- def self.defaults
- OpenStruct.new(@@defaults)
+ def self.options
+ OpenStruct.new(@@options)
end
- def self.defaults=(options)
- @@defaults = DEFAULTS.merge(options)
+ def self.has_matcher?(url)
+ result = Matcher.new(url).oneboxed
+ !!result
end
+
+ def self.options=(options)
+ @@options = DEFAULTS.merge(options)
+ end
end
+
+require_relative "onebox/version"
+require_relative "onebox/preview"
+require_relative "onebox/matcher"
+require_relative "onebox/engine"
+require_relative "onebox/layout"
+require_relative "onebox/view"