Class: LinkThumbnailer::Configuration
- Inherits:
-
Object
- Object
- LinkThumbnailer::Configuration
- Defined in:
- lib/link_thumbnailer/configuration.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#blacklist_urls ⇒ Object
Returns the value of attribute blacklist_urls.
-
#description_min_length ⇒ Object
Returns the value of attribute description_min_length.
-
#graders ⇒ Object
Returns the value of attribute graders.
-
#http_open_timeout ⇒ Object
(also: #http_timeout)
Returns the value of attribute http_open_timeout.
-
#http_override_headers ⇒ Object
Returns the value of attribute http_override_headers.
-
#http_read_timeout ⇒ Object
Returns the value of attribute http_read_timeout.
-
#image_limit ⇒ Object
Returns the value of attribute image_limit.
-
#image_stats ⇒ Object
Returns the value of attribute image_stats.
-
#max_concurrency ⇒ Object
Returns the value of attribute max_concurrency.
-
#negative_regex ⇒ Object
Returns the value of attribute negative_regex.
-
#positive_regex ⇒ Object
Returns the value of attribute positive_regex.
-
#raise_on_invalid_format ⇒ Object
Returns the value of attribute raise_on_invalid_format.
-
#redirect_limit ⇒ Object
Returns the value of attribute redirect_limit.
-
#scrapers ⇒ Object
Returns the value of attribute scrapers.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
-
#verify_ssl ⇒ Object
Returns the value of attribute verify_ssl.
Instance Method Summary collapse
-
#initialize ⇒ LinkThumbnailer::Configuration
constructor
Create a new instance.
Constructor Details
#initialize ⇒ LinkThumbnailer::Configuration
Create a new instance.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/link_thumbnailer/configuration.rb', line 37 def initialize @redirect_limit = 3 @user_agent = 'link_thumbnailer' @verify_ssl = true @http_open_timeout = 5 @http_read_timeout = 5 @blacklist_urls = [ %r{^http://ad\.doubleclick\.net/}, %r{^http://b\.scorecardresearch\.com/}, %r{^http://pixel\.quantserve\.com/}, %r{^http://s7\.addthis\.com/} ] @attributes = [:title, :images, :description, :videos, :favicon] @graders = [ ->(description) { ::LinkThumbnailer::Graders::Length.new(description) }, ->(description) { ::LinkThumbnailer::Graders::HtmlAttribute.new(description, :class) }, ->(description) { ::LinkThumbnailer::Graders::HtmlAttribute.new(description, :id) }, ->(description) { ::LinkThumbnailer::Graders::Position.new(description, weigth: 3) }, ->(description) { ::LinkThumbnailer::Graders::LinkDensity.new(description) }, ] @description_min_length = 50 @positive_regex = /article|body|content|entry|hentry|main|page|pagination|post|text|blog|story/i @negative_regex = /combx|comment|com-|contact|foot|footer|footnote|masthead|media|meta|outbrain|promo|related|scroll|shoutbox|sidebar|sponsor|shopping|tags|tool|widget|modal/i @image_limit = 5 @image_stats = true @raise_on_invalid_format = false @max_concurrency = 20 @scrapers = [:opengraph, :default] @http_override_headers = { 'Accept-Encoding' => 'none' } end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
25 26 27 |
# File 'lib/link_thumbnailer/configuration.rb', line 25 def attributes @attributes end |
#blacklist_urls ⇒ Object
Returns the value of attribute blacklist_urls.
25 26 27 |
# File 'lib/link_thumbnailer/configuration.rb', line 25 def blacklist_urls @blacklist_urls end |
#description_min_length ⇒ Object
Returns the value of attribute description_min_length.
25 26 27 |
# File 'lib/link_thumbnailer/configuration.rb', line 25 def description_min_length @description_min_length end |
#graders ⇒ Object
Returns the value of attribute graders.
25 26 27 |
# File 'lib/link_thumbnailer/configuration.rb', line 25 def graders @graders end |
#http_open_timeout ⇒ Object Also known as: http_timeout
Returns the value of attribute http_open_timeout.
25 26 27 |
# File 'lib/link_thumbnailer/configuration.rb', line 25 def http_open_timeout @http_open_timeout end |
#http_override_headers ⇒ Object
Returns the value of attribute http_override_headers.
25 26 27 |
# File 'lib/link_thumbnailer/configuration.rb', line 25 def http_override_headers @http_override_headers end |
#http_read_timeout ⇒ Object
Returns the value of attribute http_read_timeout.
25 26 27 |
# File 'lib/link_thumbnailer/configuration.rb', line 25 def http_read_timeout @http_read_timeout end |
#image_limit ⇒ Object
Returns the value of attribute image_limit.
25 26 27 |
# File 'lib/link_thumbnailer/configuration.rb', line 25 def image_limit @image_limit end |
#image_stats ⇒ Object
Returns the value of attribute image_stats.
25 26 27 |
# File 'lib/link_thumbnailer/configuration.rb', line 25 def image_stats @image_stats end |
#max_concurrency ⇒ Object
Returns the value of attribute max_concurrency.
25 26 27 |
# File 'lib/link_thumbnailer/configuration.rb', line 25 def max_concurrency @max_concurrency end |
#negative_regex ⇒ Object
Returns the value of attribute negative_regex.
25 26 27 |
# File 'lib/link_thumbnailer/configuration.rb', line 25 def negative_regex @negative_regex end |
#positive_regex ⇒ Object
Returns the value of attribute positive_regex.
25 26 27 |
# File 'lib/link_thumbnailer/configuration.rb', line 25 def positive_regex @positive_regex end |
#raise_on_invalid_format ⇒ Object
Returns the value of attribute raise_on_invalid_format.
25 26 27 |
# File 'lib/link_thumbnailer/configuration.rb', line 25 def raise_on_invalid_format @raise_on_invalid_format end |
#redirect_limit ⇒ Object
Returns the value of attribute redirect_limit.
25 26 27 |
# File 'lib/link_thumbnailer/configuration.rb', line 25 def redirect_limit @redirect_limit end |
#scrapers ⇒ Object
Returns the value of attribute scrapers.
25 26 27 |
# File 'lib/link_thumbnailer/configuration.rb', line 25 def scrapers @scrapers end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
25 26 27 |
# File 'lib/link_thumbnailer/configuration.rb', line 25 def user_agent @user_agent end |
#verify_ssl ⇒ Object
Returns the value of attribute verify_ssl.
25 26 27 |
# File 'lib/link_thumbnailer/configuration.rb', line 25 def verify_ssl @verify_ssl end |