Class: LinkThumbnailer::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/link_thumbnailer/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLinkThumbnailer::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

#attributesObject

Returns the value of attribute attributes.



27
28
29
# File 'lib/link_thumbnailer/configuration.rb', line 27

def attributes
  @attributes
end

#blacklist_urlsObject

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_lengthObject

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_limitObject

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

#encodingObject

Returns the value of attribute encoding.



27
28
29
# File 'lib/link_thumbnailer/configuration.rb', line 27

def encoding
  @encoding
end

#favicon_sizeObject

Returns the value of attribute favicon_size.



27
28
29
# File 'lib/link_thumbnailer/configuration.rb', line 27

def favicon_size
  @favicon_size
end

#gradersObject

Returns the value of attribute graders.



27
28
29
# File 'lib/link_thumbnailer/configuration.rb', line 27

def graders
  @graders
end

#http_open_timeoutObject 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_headersObject

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_timeoutObject

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_limitObject

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_statsObject

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_concurrencyObject

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_regexObject

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_regexObject

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_formatObject

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_limitObject

Returns the value of attribute redirect_limit.



27
28
29
# File 'lib/link_thumbnailer/configuration.rb', line 27

def redirect_limit
  @redirect_limit
end

#scrapersObject

Returns the value of attribute scrapers.



27
28
29
# File 'lib/link_thumbnailer/configuration.rb', line 27

def scrapers
  @scrapers
end

#user_agentObject

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_sslObject

Returns the value of attribute verify_ssl.



27
28
29
# File 'lib/link_thumbnailer/configuration.rb', line 27

def verify_ssl
  @verify_ssl
end