# frozen_string_literal: false
require_relative "parser"
# RSS has three different versions. This module contains support for version
# 1.0[http://web.resource.org/rss/1.0/]
# Producing our own RSS feeds is easy as well. Let's make a very basic feed:
# rss = RSS::Maker.make("1.0") do |maker|
# maker.channel.language = "en"
# maker.channel.author = "matz"
# maker.channel.about = "About my feed."
# maker.channel.updated = Time.now.to_s
# maker.channel.link = "http://www.ruby-lang.org/en/feeds/news.rss"
# maker.channel.title = "Example Feed"
# maker.channel.description = "A longer description of my feed."
# maker.items.new_item do |item|
# item.link = "http://www.ruby-lang.org/en/news/2010/12/25/ruby-1-9-2-p136-is-released/"
# item.title = "Ruby 1.9.2-p136 is released"
# item.updated = Time.now.to_s
# As you can see, this is a very Builder-like DSL. This code will spit out an
# RSS 1.0 feed with one item. If we needed a second item, we'd make another
# block with maker.items.new_item and build a second one.
def self.append_features(klass)
klass.install_must_call_validator('', ::RSS::URI)
URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
install_ns('', ::RSS::URI)
["item", "+", :children],
].each do |tag, occurs, type|
__send__("install_have_#{type}_element", tag, ::RSS::URI, occurs)
alias_method(:rss_version, :feed_version)
def initialize(version=nil, encoding=nil, standalone=nil)
super('1.0', version, encoding, standalone)
tag_name_with_prefix(PREFIX)
["resource", [URI, ""], true]
].each do |name, uri, required|
install_get_attribute(name, uri, required)
if Utils.element_initialize_arguments?(args)
tag_name_with_prefix(PREFIX)
install_have_children_element("li", URI, "*")
install_must_call_validator('rdf', ::RSS::RDF::URI)
if Utils.element_initialize_arguments?(args)
tag_name_with_prefix(PREFIX)
install_have_children_element("li", URI, "*")
install_must_call_validator('rdf', URI)
if Utils.element_initialize_arguments?(args)
tag_name_with_prefix(PREFIX)
].each do |name, uri, required|
install_get_attribute(name, uri, required, nil, nil,
['description', nil, :text],
['image', '?', :have_child],
['items', nil, :have_child],
['textinput', '?', :have_child],
].each do |tag, occurs, type|
__send__("install_#{type}_element", tag, ::RSS::URI, occurs)
if Utils.element_initialize_arguments?(args)
def setup_maker_attributes(channel)
].each do |name, uri, required|
install_get_attribute(name, uri, required, nil, nil,
if Utils.element_initialize_arguments?(args)
class Textinput < Element
].each do |name, uri, required|
install_get_attribute(name, uri, required, nil, nil,
if Utils.element_initialize_arguments?(args)
install_have_child_element("Seq", URI, nil)
install_must_call_validator('rdf', URI)
if Utils.element_initialize_arguments?(args)
].each do |name, uri, required|
install_get_attribute(name, uri, required, nil, nil,
%w(title url link).each do |name|
install_text_element(name, ::RSS::URI, nil)
if Utils.element_initialize_arguments?(args)
].each do |name, uri, required|
install_get_attribute(name, uri, required, nil, nil,
install_text_element(tag, ::RSS::URI, occurs)
if Utils.element_initialize_arguments?(args)
if items.respond_to?("items")
# For backward compatibility
class Textinput < Element
].each do |name, uri, required|
install_get_attribute(name, uri, required, nil, nil,
%w(title description name link).each do |name|
install_text_element(name, ::RSS::URI, nil)
if Utils.element_initialize_arguments?(args)
RSS10::ELEMENTS.each do |name|
BaseListener.install_get_text_element(URI, name, name)
def initial_start_RDF(tag_name, prefix, attrs, ns)
check_ns(tag_name, prefix, ns, RDF::URI, false)
@rss = RDF.new(@version, @encoding, @standalone)
@rss.do_validate = @do_validate
@rss.xml_stylesheets = @xml_stylesheets
pr = Proc.new do |text, tags|
@rss.validate_for_stream(tags, @ignore_unknown_element) if @do_validate