2015-12-16 00:07:31 -05:00
|
|
|
# frozen_string_literal: false
|
2018-11-05 02:01:49 -05:00
|
|
|
require_relative "../2.0"
|
2004-10-31 09:14:21 -05:00
|
|
|
|
2018-11-05 02:01:49 -05:00
|
|
|
require_relative "0.9"
|
2004-10-31 09:14:21 -05:00
|
|
|
|
|
|
|
module RSS
|
|
|
|
module Maker
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2004-10-31 09:14:21 -05:00
|
|
|
class RSS20 < RSS09
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2007-03-17 06:13:25 -04:00
|
|
|
def initialize(feed_version="2.0")
|
2004-10-31 09:14:21 -05:00
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
class Channel < RSS09::Channel
|
|
|
|
|
2007-03-17 06:13:25 -04:00
|
|
|
private
|
2004-11-28 01:53:41 -05:00
|
|
|
def required_variable_names
|
2007-08-04 23:03:05 -04:00
|
|
|
%w(link)
|
2004-11-28 01:53:41 -05:00
|
|
|
end
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2004-11-19 03:25:25 -05:00
|
|
|
class SkipDays < RSS09::Channel::SkipDays
|
|
|
|
class Day < RSS09::Channel::SkipDays::Day
|
|
|
|
end
|
2004-10-31 09:14:21 -05:00
|
|
|
end
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2004-11-19 03:25:25 -05:00
|
|
|
class SkipHours < RSS09::Channel::SkipHours
|
|
|
|
class Hour < RSS09::Channel::SkipHours::Hour
|
|
|
|
end
|
|
|
|
end
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2004-10-31 09:14:21 -05:00
|
|
|
class Cloud < RSS09::Channel::Cloud
|
2007-03-17 06:13:25 -04:00
|
|
|
def to_feed(rss, channel)
|
2004-10-31 09:14:21 -05:00
|
|
|
cloud = Rss::Channel::Cloud.new
|
|
|
|
set = setup_values(cloud)
|
|
|
|
if set
|
2004-11-19 03:25:25 -05:00
|
|
|
channel.cloud = cloud
|
2007-03-17 06:13:25 -04:00
|
|
|
set_parent(cloud, channel)
|
|
|
|
setup_other_elements(rss, cloud)
|
2004-10-31 09:14:21 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2007-03-17 06:13:25 -04:00
|
|
|
private
|
|
|
|
def required_variable_names
|
|
|
|
%w(domain port path registerProcedure protocol)
|
2004-10-31 09:14:21 -05:00
|
|
|
end
|
|
|
|
end
|
2004-11-19 03:25:25 -05:00
|
|
|
|
|
|
|
class Categories < RSS09::Channel::Categories
|
2007-03-17 06:13:25 -04:00
|
|
|
def to_feed(rss, channel)
|
2004-11-19 03:25:25 -05:00
|
|
|
@categories.each do |category|
|
2007-03-17 06:13:25 -04:00
|
|
|
category.to_feed(rss, channel)
|
2004-11-19 03:25:25 -05:00
|
|
|
end
|
|
|
|
end
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2004-11-19 03:25:25 -05:00
|
|
|
class Category < RSS09::Channel::Categories::Category
|
2007-03-17 06:13:25 -04:00
|
|
|
def to_feed(rss, channel)
|
2004-11-19 03:25:25 -05:00
|
|
|
category = Rss::Channel::Category.new
|
|
|
|
set = setup_values(category)
|
|
|
|
if set
|
2004-12-04 04:53:01 -05:00
|
|
|
channel.categories << category
|
2007-03-17 06:13:25 -04:00
|
|
|
set_parent(category, channel)
|
|
|
|
setup_other_elements(rss, category)
|
2004-11-19 03:25:25 -05:00
|
|
|
end
|
|
|
|
end
|
2007-03-17 06:13:25 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
def required_variable_names
|
|
|
|
%w(content)
|
2004-11-19 03:25:25 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2007-03-17 06:13:25 -04:00
|
|
|
|
|
|
|
class Generator < GeneratorBase
|
|
|
|
def to_feed(rss, channel)
|
|
|
|
channel.generator = content
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def required_variable_names
|
|
|
|
%w(content)
|
|
|
|
end
|
|
|
|
end
|
2004-10-31 09:14:21 -05:00
|
|
|
end
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2004-10-31 09:14:21 -05:00
|
|
|
class Image < RSS09::Image
|
2007-03-17 06:13:25 -04:00
|
|
|
private
|
|
|
|
def required_element?
|
|
|
|
false
|
|
|
|
end
|
2004-10-31 09:14:21 -05:00
|
|
|
end
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2004-10-31 09:14:21 -05:00
|
|
|
class Items < RSS09::Items
|
|
|
|
class Item < RSS09::Items::Item
|
|
|
|
private
|
2007-03-17 06:13:25 -04:00
|
|
|
def required_variable_names
|
2008-02-11 03:24:18 -05:00
|
|
|
[]
|
|
|
|
end
|
|
|
|
|
|
|
|
def not_set_required_variables
|
|
|
|
vars = super
|
|
|
|
if !title {|t| t.have_required_values?} and
|
|
|
|
!description {|d| d.have_required_values?}
|
|
|
|
vars << "title or description"
|
|
|
|
end
|
|
|
|
vars
|
2007-03-17 06:13:25 -04:00
|
|
|
end
|
|
|
|
|
2004-10-31 09:14:21 -05:00
|
|
|
def variables
|
|
|
|
super + ["pubDate"]
|
|
|
|
end
|
|
|
|
|
|
|
|
class Guid < RSS09::Items::Item::Guid
|
2007-03-17 06:13:25 -04:00
|
|
|
def to_feed(rss, item)
|
2004-10-31 09:14:21 -05:00
|
|
|
guid = Rss::Channel::Item::Guid.new
|
|
|
|
set = setup_values(guid)
|
|
|
|
if set
|
|
|
|
item.guid = guid
|
2007-03-17 06:13:25 -04:00
|
|
|
set_parent(guid, item)
|
|
|
|
setup_other_elements(rss, guid)
|
2004-10-31 09:14:21 -05:00
|
|
|
end
|
|
|
|
end
|
2007-03-17 06:13:25 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
def required_variable_names
|
|
|
|
%w(content)
|
2004-10-31 09:14:21 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Enclosure < RSS09::Items::Item::Enclosure
|
2007-03-17 06:13:25 -04:00
|
|
|
def to_feed(rss, item)
|
2004-10-31 09:14:21 -05:00
|
|
|
enclosure = Rss::Channel::Item::Enclosure.new
|
|
|
|
set = setup_values(enclosure)
|
|
|
|
if set
|
|
|
|
item.enclosure = enclosure
|
2007-03-17 06:13:25 -04:00
|
|
|
set_parent(enclosure, item)
|
|
|
|
setup_other_elements(rss, enclosure)
|
2004-10-31 09:14:21 -05:00
|
|
|
end
|
|
|
|
end
|
2007-03-17 06:13:25 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
def required_variable_names
|
|
|
|
%w(url length type)
|
2004-10-31 09:14:21 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Source < RSS09::Items::Item::Source
|
2007-03-17 06:13:25 -04:00
|
|
|
def to_feed(rss, item)
|
2004-10-31 09:14:21 -05:00
|
|
|
source = Rss::Channel::Item::Source.new
|
|
|
|
set = setup_values(source)
|
|
|
|
if set
|
|
|
|
item.source = source
|
2007-03-17 06:13:25 -04:00
|
|
|
set_parent(source, item)
|
|
|
|
setup_other_elements(rss, source)
|
2004-10-31 09:14:21 -05:00
|
|
|
end
|
|
|
|
end
|
2007-03-17 06:13:25 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
def required_variable_names
|
|
|
|
%w(url content)
|
|
|
|
end
|
|
|
|
|
|
|
|
class Links < RSS09::Items::Item::Source::Links
|
|
|
|
def to_feed(rss, source)
|
|
|
|
return if @links.empty?
|
|
|
|
@links.first.to_feed(rss, source)
|
|
|
|
end
|
|
|
|
|
|
|
|
class Link < RSS09::Items::Item::Source::Links::Link
|
|
|
|
def to_feed(rss, source)
|
|
|
|
source.url = href
|
|
|
|
end
|
|
|
|
end
|
2004-10-31 09:14:21 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2004-11-19 03:25:25 -05:00
|
|
|
class Categories < RSS09::Items::Item::Categories
|
2007-03-17 06:13:25 -04:00
|
|
|
def to_feed(rss, item)
|
2004-11-19 03:25:25 -05:00
|
|
|
@categories.each do |category|
|
2007-03-17 06:13:25 -04:00
|
|
|
category.to_feed(rss, item)
|
2004-10-31 09:14:21 -05:00
|
|
|
end
|
|
|
|
end
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2004-11-19 03:25:25 -05:00
|
|
|
class Category < RSS09::Items::Item::Categories::Category
|
2007-03-17 06:13:25 -04:00
|
|
|
def to_feed(rss, item)
|
2004-11-19 03:25:25 -05:00
|
|
|
category = Rss::Channel::Item::Category.new
|
|
|
|
set = setup_values(category)
|
|
|
|
if set
|
2004-12-04 04:53:01 -05:00
|
|
|
item.categories << category
|
2007-03-17 06:13:25 -04:00
|
|
|
set_parent(category, item)
|
2004-11-19 03:25:25 -05:00
|
|
|
setup_other_elements(rss)
|
|
|
|
end
|
|
|
|
end
|
2007-03-17 06:13:25 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
def required_variable_names
|
|
|
|
%w(content)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Authors < RSS09::Items::Item::Authors
|
|
|
|
def to_feed(rss, item)
|
|
|
|
return if @authors.empty?
|
|
|
|
@authors.first.to_feed(rss, item)
|
|
|
|
end
|
|
|
|
|
|
|
|
class Author < RSS09::Items::Item::Authors::Author
|
|
|
|
def to_feed(rss, item)
|
|
|
|
item.author = name
|
2004-11-19 03:25:25 -05:00
|
|
|
end
|
2004-10-31 09:14:21 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2004-10-31 09:14:21 -05:00
|
|
|
class Textinput < RSS09::Textinput
|
|
|
|
end
|
|
|
|
end
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2008-02-11 03:24:18 -05:00
|
|
|
add_maker("2.0", "2.0", RSS20)
|
|
|
|
add_maker("rss2.0", "2.0", RSS20)
|
2004-10-31 09:14:21 -05:00
|
|
|
end
|
|
|
|
end
|