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

- old
+ new

@@ -41,11 +41,11 @@ # @param name [String, Symbol, nil] Name of the feed in the YAML file. # @param global_config [Hash] Global options (e.g., HTTP headers). # @param params [Hash] Dynamic parameters for the feed configuration. # @return [RSS::Rss] RSS object generated from the configuration. def self.feed_from_yaml_config(file, name = nil, global_config: {}, params: {}) - yaml = load_yaml(file) + yaml = YAML.safe_load_file(file, symbolize_names: true) feeds = yaml[CONFIG_KEY_FEEDS] || {} feed_config = find_feed_config(yaml, feeds, name, global_config) feed(Config.new(feed_config, global_config, params)) @@ -72,19 +72,10 @@ config = Config.new(config) unless config.is_a?(Config) RssBuilder.build(config) end ## - # Loads and parses the YAML file. - # - # @param file [String] Path to the YAML file. - # @return [Hash] Parsed YAML content. - def self.load_yaml(file) - YAML.safe_load_file(file, symbolize_names: true) - end - - ## # Builds the feed configuration based on the provided parameters. # # @param yaml [Hash] Parsed YAML content. # @param feeds [Hash] Feeds from the YAML content. # @param feed_name [String, Symbol, nil] Name of the feed in the YAML file. @@ -107,10 +98,14 @@ # 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 + url = Addressable::URI.parse(url) + + response = Html2rss::Utils.request_url(url) + + Html2rss::AutoSource.new(url, body: response.body, headers: response.headers).build end - private_class_method :load_yaml, :find_feed_config + private_class_method :find_feed_config end