lib/html2rss.rb in html2rss-0.12.0 vs lib/html2rss.rb in html2rss-0.13.0

- old
+ new

@@ -4,15 +4,26 @@ loader = Zeitwerk::Loader.for_gem loader.setup require 'yaml' +require 'logger' ## # The Html2rss namespace. module Html2rss ## + # The logger instance. + Log = Logger.new($stdout) + + Log.level = ENV.fetch('LOG_LEVEL', :warn).upcase.to_sym + + Log.formatter = proc do |severity, datetime, _progname, msg| + "#{datetime} [#{severity}] #{msg}\n" + end + + ## # The Html2rss::Error base class. class Error < StandardError; end ## # Key for the feeds configuration in the YAML file. @@ -87,9 +98,19 @@ global_config.merge!(yaml.reject { |key| key == CONFIG_KEY_FEEDS }) feeds[feed_name] else yaml end + end + + ## + # Scrapes the provided URL and returns an RSS object. + # No need for a "feed config". + # + # @param url [String] the URL to automatically source the feed from + # @return [RSS::Rss] + def self.auto_source(url) + Html2rss::AutoSource.new(url).build end private_class_method :load_yaml, :find_feed_config end