Module: Html2rss
- Defined in:
- lib/html2rss.rb,
lib/html2rss/item.rb,
lib/html2rss/utils.rb,
lib/html2rss/config.rb,
lib/html2rss/version.rb,
lib/html2rss/feed_builder.rb,
lib/html2rss/item_extractors.rb,
lib/html2rss/item_extractors/href.rb,
lib/html2rss/item_extractors/html.rb,
lib/html2rss/item_extractors/text.rb,
lib/html2rss/item_extractors/static.rb,
lib/html2rss/attribute_post_processors.rb,
lib/html2rss/item_extractors/attribute.rb,
lib/html2rss/item_extractors/current_time.rb,
lib/html2rss/attribute_post_processors/template.rb,
lib/html2rss/attribute_post_processors/parse_uri.rb,
lib/html2rss/attribute_post_processors/substring.rb,
lib/html2rss/attribute_post_processors/parse_time.rb,
lib/html2rss/attribute_post_processors/sanitize_html.rb,
lib/html2rss/attribute_post_processors/html_to_markdown.rb
Defined Under Namespace
Modules: AttributePostProcessors, ItemExtractors, Utils Classes: Config, FeedBuilder, Item
Constant Summary collapse
- VERSION =
'0.4.1'.freeze
Class Method Summary collapse
-
.feed(config) ⇒ RSS:Rss
Returns a RSS object which is generated from the provided config.
-
.feed_from_yaml_config(file, name) ⇒ RSS:Rss
Returns a RSS object which is generated from the provided file.
Class Method Details
.feed(config) ⇒ RSS:Rss
Returns a RSS object which is generated from the provided config.
`config`: can be a Hash or an instance of Html2rss::Config.
Example:
feed = Html2rss.feed(
channel: { name: 'StackOverflow: Hot Network Questions', url: 'https://stackoverflow.com' },
selectors: {
items: { selector: '#hot-network-questions > ul > li' },
title: { selector: 'a' },
link: { selector: 'a', extractor: 'href' }
}
)
# => #<RSS::Rss:0x00007fb2f48d14a0 ...>
48 49 50 51 52 53 |
# File 'lib/html2rss.rb', line 48 def self.feed(config) config = Config.new(config) unless config.is_a?(Config) feed = FeedBuilder.new config feed.rss end |
.feed_from_yaml_config(file, name) ⇒ RSS:Rss
Returns a RSS object which is generated from the provided file.
`file_path`: a File object of a YAML file `name`: the of the feed
Example:
feed = Html2rss.feed_from_yaml_config(File.join(['spec', 'config.test.yml']), 'nuxt-releases')
# => #<RSS::Rss:0x00007fb2f6331228
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/html2rss.rb', line 19 def self.feed_from_yaml_config(file, name) # rubocop:disable Security/YAMLLoad yaml = YAML.load(File.open(file)) # rubocop:enable Security/YAMLLoad feed_config = yaml['feeds'][name] global_config = yaml.reject { |key| key == 'feeds' } config = Config.new(feed_config, global_config) feed(config) end |