Sha256: 9d5e5a43d0d6e84499602c4b9e5ccf96bd95381596ddb7d08870b9125866c6ea
Contents?: true
Size: 1.73 KB
Versions: 3
Compression:
Stored size: 1.73 KB
Contents
module Html2rss ## # The Config class abstracts from the config data structure and # provides default values. class Config def initialize(feed_config, global_config = {}) @global_config = Utils::IndifferentAccessHash.new global_config @feed_config = Utils::IndifferentAccessHash.new feed_config @channel_config = Utils::IndifferentAccessHash.new @feed_config.fetch('channel', {}) end def author channel_config.fetch 'author', 'html2rss' end def ttl channel_config.fetch 'ttl', 3600 end def title channel_config.fetch 'title', 'html2rss generated title' end def language channel_config.fetch 'language', 'en' end def description channel_config.fetch 'description', 'A description of my html2rss feed.' end def url channel_config.dig 'url' end alias link url def time_zone channel_config.fetch 'time_zone', 'UTC' end def json? channel_config.fetch 'json', false end def headers global_config.fetch('headers', {}).merge(channel_config.fetch('headers', {})) end def attribute_options(name) feed_config.dig('selectors').fetch(name, {}).merge('channel' => channel_config) end def attribute?(name) attribute_names.include?(name.to_s) end def categories feed_config.dig('selectors').fetch('categories', []).map(&:to_sym) end def selector(name) feed_config.dig('selectors', name, 'selector') end def attribute_names @attribute_names ||= feed_config.fetch('selectors', {}).keys.map(&:to_s).tap do |attrs| attrs.delete('items') end end private attr_reader :feed_config, :channel_config, :global_config end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
html2rss-0.8.0 | lib/html2rss/config.rb |
html2rss-0.7.0 | lib/html2rss/config.rb |
html2rss-0.6.0 | lib/html2rss/config.rb |