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.
-
#download_size_limit ⇒ Object
Returns the value of attribute download_size_limit.
-
#encoding ⇒ Object
Returns the value of attribute encoding.
-
#favicon_size ⇒ Object
Returns the value of attribute favicon_size.
-
#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.
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 67 68 69 70 71 |
# File 'lib/link_thumbnailer/configuration.rb', line 40 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' } @download_size_limit = 10 * 1024 * 1024 @encoding = 'utf-8' end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
27 28 29 |
# File 'lib/link_thumbnailer/configuration.rb', line 27 def attributes @attributes end |
#blacklist_urls ⇒ Object
Returns the value of attribute blacklist_urls.
27 28 29 |
# File 'lib/link_thumbnailer/configuration.rb', line 27 def blacklist_urls @blacklist_urls end |
#description_min_length ⇒ Object
Returns the value of attribute description_min_length.
27 28 29 |
# File 'lib/link_thumbnailer/configuration.rb', line 27 def description_min_length @description_min_length end |
#download_size_limit ⇒ Object
Returns the value of attribute download_size_limit.
27 28 29 |
# File 'lib/link_thumbnailer/configuration.rb', line 27 def download_size_limit @download_size_limit end |
#encoding ⇒ Object
Returns the value of attribute encoding.
27 28 29 |
# File 'lib/link_thumbnailer/configuration.rb', line 27 def encoding @encoding end |
#favicon_size ⇒ Object
Returns the value of attribute favicon_size.
27 28 29 |
# File 'lib/link_thumbnailer/configuration.rb', line 27 def favicon_size @favicon_size end |
#graders ⇒ Object
Returns the value of attribute graders.
27 28 29 |
# File 'lib/link_thumbnailer/configuration.rb', line 27 def graders @graders end |
#http_open_timeout ⇒ Object Also known as: http_timeout
Returns the value of attribute http_open_timeout.
27 28 29 |
# File 'lib/link_thumbnailer/configuration.rb', line 27 def http_open_timeout @http_open_timeout end |
#http_override_headers ⇒ Object
Returns the value of attribute http_override_headers.
27 28 29 |
# File 'lib/link_thumbnailer/configuration.rb', line 27 def http_override_headers @http_override_headers end |
#http_read_timeout ⇒ Object
Returns the value of attribute http_read_timeout.
27 28 29 |
# File 'lib/link_thumbnailer/configuration.rb', line 27 def http_read_timeout @http_read_timeout end |
#image_limit ⇒ Object
Returns the value of attribute image_limit.
27 28 29 |
# File 'lib/link_thumbnailer/configuration.rb', line 27 def image_limit @image_limit end |
#image_stats ⇒ Object
Returns the value of attribute image_stats.
27 28 29 |
# File 'lib/link_thumbnailer/configuration.rb', line 27 def image_stats @image_stats end |
#max_concurrency ⇒ Object
Returns the value of attribute max_concurrency.
27 28 29 |
# File 'lib/link_thumbnailer/configuration.rb', line 27 def max_concurrency @max_concurrency end |
#negative_regex ⇒ Object
Returns the value of attribute negative_regex.
27 28 29 |
# File 'lib/link_thumbnailer/configuration.rb', line 27 def negative_regex @negative_regex end |
#positive_regex ⇒ Object
Returns the value of attribute positive_regex.
27 28 29 |
# File 'lib/link_thumbnailer/configuration.rb', line 27 def positive_regex @positive_regex end |
#raise_on_invalid_format ⇒ Object
Returns the value of attribute raise_on_invalid_format.
27 28 29 |
# File 'lib/link_thumbnailer/configuration.rb', line 27 def raise_on_invalid_format @raise_on_invalid_format end |
#redirect_limit ⇒ Object
Returns the value of attribute redirect_limit.
27 28 29 |
# File 'lib/link_thumbnailer/configuration.rb', line 27 def redirect_limit @redirect_limit end |
#scrapers ⇒ Object
Returns the value of attribute scrapers.
27 28 29 |
# File 'lib/link_thumbnailer/configuration.rb', line 27 def scrapers @scrapers end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
27 28 29 |
# File 'lib/link_thumbnailer/configuration.rb', line 27 def user_agent @user_agent end |
#verify_ssl ⇒ Object
Returns the value of attribute verify_ssl.
27 28 29 |
# File 'lib/link_thumbnailer/configuration.rb', line 27 def verify_ssl @verify_ssl end |