lib/html2rss/feed_builder.rb in html2rss-0.0.1 vs lib/html2rss/feed_builder.rb in html2rss-0.1.0
- old
+ new
@@ -20,24 +20,26 @@
end
private
def add_channel_to_maker(maker)
- [:language, :author, :title, :description, :link, :ttl].each do |attribute_name|
+ %i[language author title description link ttl].each do |attribute_name|
maker.channel.send("#{attribute_name}=".to_sym, config.send(attribute_name))
end
maker.channel.generator = "html2rss V. #{::Html2rss::VERSION}"
maker.channel.lastBuildDate = Time.now.to_s
end
def feed_items
- Item.from_url config.url, config
+ @feed_items ||= Item.from_url config.url, config
end
def add_item_to_items(feed_item, items)
+ return unless feed_item.valid?
+
items.new_item do |rss_item|
- config.attribute_names.each do |attribute_name|
+ feed_item.available_attributes.each do |attribute_name|
rss_item.send("#{attribute_name}=".to_sym, feed_item.send(attribute_name))
rss_item.guid.content = Digest::SHA1.hexdigest(feed_item.title)
end
end