Class: SourceMonitor::Configuration::FaviconsSettings

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

Constant Summary collapse

DEFAULT_FETCH_TIMEOUT =

seconds

5
DEFAULT_MAX_DOWNLOAD_SIZE =

1 MB

1 * 1024 * 1024
DEFAULT_RETRY_COOLDOWN_DAYS =
7
DEFAULT_ALLOWED_CONTENT_TYPES =
%w[
  image/x-icon
  image/vnd.microsoft.icon
  image/png
  image/jpeg
  image/gif
  image/svg+xml
  image/webp
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFaviconsSettings

Returns a new instance of FaviconsSettings.



25
26
27
# File 'lib/source_monitor/configuration/favicons_settings.rb', line 25

def initialize
  reset!
end

Instance Attribute Details

#allowed_content_typesObject

Returns the value of attribute allowed_content_types.



6
7
8
# File 'lib/source_monitor/configuration/favicons_settings.rb', line 6

def allowed_content_types
  @allowed_content_types
end

#enabledObject

Returns the value of attribute enabled.



6
7
8
# File 'lib/source_monitor/configuration/favicons_settings.rb', line 6

def enabled
  @enabled
end

#fetch_timeoutObject

Returns the value of attribute fetch_timeout.



6
7
8
# File 'lib/source_monitor/configuration/favicons_settings.rb', line 6

def fetch_timeout
  @fetch_timeout
end

#max_download_sizeObject

Returns the value of attribute max_download_size.



6
7
8
# File 'lib/source_monitor/configuration/favicons_settings.rb', line 6

def max_download_size
  @max_download_size
end

#retry_cooldown_daysObject

Returns the value of attribute retry_cooldown_days.



6
7
8
# File 'lib/source_monitor/configuration/favicons_settings.rb', line 6

def retry_cooldown_days
  @retry_cooldown_days
end

Instance Method Details

#enabled?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/source_monitor/configuration/favicons_settings.rb', line 37

def enabled?
  !!enabled && !!defined?(ActiveStorage)
end

#reset!Object



29
30
31
32
33
34
35
# File 'lib/source_monitor/configuration/favicons_settings.rb', line 29

def reset!
  @enabled = true
  @fetch_timeout = DEFAULT_FETCH_TIMEOUT
  @max_download_size = DEFAULT_MAX_DOWNLOAD_SIZE
  @retry_cooldown_days = DEFAULT_RETRY_COOLDOWN_DAYS
  @allowed_content_types = DEFAULT_ALLOWED_CONTENT_TYPES.dup
end