2015-12-16 00:07:31 -05:00
|
|
|
# frozen_string_literal: false
|
2018-11-02 13:52:33 -04:00
|
|
|
require_relative "rss"
|
2004-10-31 19:43:47 -05:00
|
|
|
|
|
|
|
module RSS
|
2013-04-26 01:36:51 -04:00
|
|
|
##
|
|
|
|
#
|
|
|
|
# Provides a set of builders for various RSS objects
|
|
|
|
#
|
|
|
|
# * Feeds
|
|
|
|
# * RSS 0.91
|
|
|
|
# * RSS 1.0
|
|
|
|
# * RSS 2.0
|
|
|
|
# * Atom 1.0
|
|
|
|
#
|
|
|
|
# * Elements
|
|
|
|
# * Atom::Entry
|
|
|
|
|
2004-10-31 19:43:47 -05:00
|
|
|
module Maker
|
2013-04-26 01:36:51 -04:00
|
|
|
|
|
|
|
# Collection of supported makers
|
2004-10-31 19:43:47 -05:00
|
|
|
MAKERS = {}
|
2007-03-17 06:13:25 -04:00
|
|
|
|
2004-10-31 19:43:47 -05:00
|
|
|
class << self
|
2013-04-26 08:21:45 -04:00
|
|
|
# Builder for an RSS object
|
|
|
|
# Creates an object of the type passed in +args+
|
|
|
|
#
|
|
|
|
# Executes the +block+ to populate elements of the created RSS object
|
2004-11-19 03:25:25 -05:00
|
|
|
def make(version, &block)
|
2008-12-11 07:06:26 -05:00
|
|
|
self[version].make(&block)
|
2004-10-31 19:43:47 -05:00
|
|
|
end
|
|
|
|
|
2013-04-26 01:36:51 -04:00
|
|
|
# Returns the maker for the +version+
|
2008-12-10 07:34:09 -05:00
|
|
|
def [](version)
|
|
|
|
maker_info = maker(version)
|
|
|
|
raise UnsupportedMakerVersionError.new(version) if maker_info.nil?
|
2008-12-11 07:06:26 -05:00
|
|
|
maker_info[:maker]
|
2004-10-31 19:43:47 -05:00
|
|
|
end
|
|
|
|
|
2013-04-26 01:36:51 -04:00
|
|
|
# Adds a maker to the set of supported makers
|
2008-02-11 03:24:18 -05:00
|
|
|
def add_maker(version, normalized_version, maker)
|
|
|
|
MAKERS[version] = {:maker => maker, :version => normalized_version}
|
2004-10-31 19:43:47 -05:00
|
|
|
end
|
|
|
|
|
2013-04-26 01:36:51 -04:00
|
|
|
# Returns collection of supported maker versions
|
2007-03-17 06:13:25 -04:00
|
|
|
def versions
|
|
|
|
MAKERS.keys.uniq.sort
|
|
|
|
end
|
|
|
|
|
2013-04-26 01:36:51 -04:00
|
|
|
# Returns collection of supported makers
|
2007-03-17 06:13:25 -04:00
|
|
|
def makers
|
2013-04-26 01:36:51 -04:00
|
|
|
MAKERS.values.collect { |info| info[:maker] }.uniq
|
2004-10-31 19:43:47 -05:00
|
|
|
end
|
2008-12-10 07:34:09 -05:00
|
|
|
|
2013-04-26 01:36:51 -04:00
|
|
|
# Returns true if the version is supported
|
2009-05-16 05:22:55 -04:00
|
|
|
def supported?(version)
|
|
|
|
versions.include?(version)
|
|
|
|
end
|
|
|
|
|
2008-12-10 07:34:09 -05:00
|
|
|
private
|
|
|
|
# Can I remove this method?
|
|
|
|
def maker(version)
|
|
|
|
MAKERS[version]
|
|
|
|
end
|
2004-10-31 19:43:47 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2004-11-19 03:25:25 -05:00
|
|
|
|
2018-11-05 02:01:49 -05:00
|
|
|
require_relative "maker/1.0"
|
|
|
|
require_relative "maker/2.0"
|
2018-11-02 13:52:33 -04:00
|
|
|
require_relative "maker/feed"
|
|
|
|
require_relative "maker/entry"
|
|
|
|
require_relative "maker/content"
|
|
|
|
require_relative "maker/dublincore"
|
|
|
|
require_relative "maker/slash"
|
|
|
|
require_relative "maker/syndication"
|
|
|
|
require_relative "maker/taxonomy"
|
|
|
|
require_relative "maker/trackback"
|
|
|
|
require_relative "maker/image"
|
|
|
|
require_relative "maker/itunes"
|