1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/rss, test/rss:

- supported Atom.
  - bumped version 0.1.6 to 0.1.7.
* sample/rss/convert.rb: added new sample.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kou 2007-03-17 10:13:25 +00:00
parent 53cbab0484
commit 966a25465a
71 changed files with 10254 additions and 3045 deletions

View file

@ -12,7 +12,7 @@ module RSS
%w(link).each do |name|
full_name = "#{TAXO_PREFIX}_#{name}"
BaseListener.install_get_text_element(TAXO_URI, name, "#{full_name}=")
BaseListener.install_get_text_element(TAXO_URI, name, full_name)
TAXO_ELEMENTS << "#{TAXO_PREFIX}_#{name}"
end
@ -28,22 +28,10 @@ module RSS
def self.append_features(klass)
super
var_name = "#{TAXO_PREFIX}_topics"
klass.install_have_child_element(var_name)
end
def taxo_validate(tags)
found_topics = false
tags.each do |tag|
if tag == "topics"
if found_topics
raise TooMuchTagError.new(tag, tag_name)
else
found_topics = true
end
else
raise UnknownTagError.new(tag, TAXO_URI)
end
klass.install_must_call_validator(TAXO_PREFIX, TAXO_URI)
%w(topics).each do |name|
klass.install_have_child_element(name, TAXO_URI, "?",
"#{TAXO_PREFIX}_#{name}")
end
end
@ -64,13 +52,17 @@ module RSS
@tag_name = "topics"
install_have_child_element("Bag")
install_must_call_validator('rdf', ::RSS::RDF::URI)
install_have_child_element("Bag", RDF::URI, nil)
install_must_call_validator('rdf', RDF::URI)
def initialize(bag=Bag.new)
super()
@Bag = bag
def initialize(*args)
if Utils.element_initialize_arguments?(args)
super
else
super()
self.Bag = args[0]
end
self.Bag ||= Bag.new
end
def full_name
@ -80,15 +72,6 @@ module RSS
def maker_target(target)
target.taxo_topics
end
def to_s(need_convert=true, indent=calc_indent)
rv = tag(indent) do |next_indent|
[
Bag_element(need_convert, next_indent),
other_element(need_convert, next_indent),
]
end
end
def resources
if @Bag
@ -99,21 +82,6 @@ module RSS
[]
end
end
private
def children
[@Bag]
end
def _tags
rv = []
rv << [::RSS::RDF::URI, 'Bag'] unless @Bag.nil?
rv
end
def rdf_validate(tags)
_validate(tags, [["Bag", nil]])
end
end
end
@ -123,15 +91,7 @@ module RSS
def self.append_features(klass)
super
var_name = "#{TAXO_PREFIX}_topic"
klass.install_have_children_element(var_name)
end
def taxo_validate(tags)
tags.each do |tag|
if tag != "topic"
raise UnknownTagError.new(tag, TAXO_URI)
end
end
klass.install_have_children_element("topic", TAXO_URI, "*", var_name)
end
class TaxonomyTopic < Element
@ -152,62 +112,26 @@ module RSS
@tag_name = "topic"
install_get_attribute("about", ::RSS::RDF::URI, true)
install_text_element("#{TAXO_PREFIX}_link")
install_get_attribute("about", ::RSS::RDF::URI, true, nil, nil,
"#{RDF::PREFIX}:about")
install_text_element("link", TAXO_URI, "?", "#{TAXO_PREFIX}_link")
def initialize(about=nil)
super()
@about = about
def initialize(*args)
if Utils.element_initialize_arguments?(args)
super
else
super()
self.about = args[0]
end
end
def full_name
tag_name_with_prefix(TAXO_PREFIX)
end
def to_s(need_convert=true, indent=calc_indent)
rv = tag(indent) do |next_indent|
[
other_element(need_convert, next_indent),
]
end
end
def taxo_validate(tags)
elements = %w(link topics)
counter = {}
tags.each do |tag|
if elements.include?(tag)
counter[tag] ||= 0
counter[tag] += 1
raise TooMuchTagError.new(tag, tag_name) if counter[tag] > 1
else
raise UnknownTagError.new(tag, TAXO_URI)
end
end
end
def maker_target(target)
target.new_taxo_topic
end
private
def children
[@taxo_link, @taxo_topics]
end
def _attrs
[
["#{RDF::PREFIX}:about", true, "about"]
]
end
def _tags
rv = []
rv << [TAXO_URI, "link"] unless @taxo_link.nil?
rv << [TAXO_URI, "topics"] unless @taxo_topics.nil?
rv
end
end
end