Class: Onebox::Preview
- Inherits:
-
Object
- Object
- Onebox::Preview
- Defined in:
- lib/onebox/preview.rb
Defined Under Namespace
Classes: InvalidURI
Constant Summary collapse
- WEB_EXCEPTIONS =
[ client_exception, OpenURI::HTTPError, Timeout::Error, Net::HTTPError, Errno::ECONNREFUSED, ]
Instance Method Summary collapse
- #data ⇒ Object
- #errors ⇒ Object
-
#initialize(url, options = Onebox.options) ⇒ Preview
constructor
A new instance of Preview.
- #options ⇒ Object
- #placeholder_html ⇒ Object
- #to_s ⇒ Object
- #verified_data ⇒ Object
Constructor Details
#initialize(url, options = Onebox.options) ⇒ Preview
Returns a new instance of Preview.
16 17 18 19 20 21 22 23 24 |
# File 'lib/onebox/preview.rb', line 16 def initialize(url, = Onebox.) @url = url @options = .dup allowed_origins = @options[:allowed_iframe_origins] || Onebox::Engine.all_iframe_origins @options[:allowed_iframe_regexes] = Engine.origins_to_regexes(allowed_origins) @engine_class = Matcher.new(@url, @options).oneboxed end |
Instance Method Details
#data ⇒ Object
45 46 47 48 |
# File 'lib/onebox/preview.rb', line 45 def data return {} unless engine engine.data end |
#errors ⇒ Object
40 41 42 43 |
# File 'lib/onebox/preview.rb', line 40 def errors return {} unless engine engine.errors end |
#options ⇒ Object
55 56 57 |
# File 'lib/onebox/preview.rb', line 55 def OpenStruct.new(@options) end |
#placeholder_html ⇒ Object
33 34 35 36 37 38 |
# File 'lib/onebox/preview.rb', line 33 def placeholder_html return "" unless engine sanitize process_html engine.placeholder_html rescue *WEB_EXCEPTIONS "" end |
#to_s ⇒ Object
26 27 28 29 30 31 |
# File 'lib/onebox/preview.rb', line 26 def to_s return "" unless engine sanitize process_html engine_html rescue *WEB_EXCEPTIONS "" end |
#verified_data ⇒ Object
50 51 52 53 |
# File 'lib/onebox/preview.rb', line 50 def verified_data return {} unless engine engine.verified_data end |