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: backported from trunk. (2005-11-16 - now)

* lib/rss/taxonomy.rb: changed class or module prefix to
  Taxonomy from Taxo.
* lib/rss/maker/taxonomy.rb: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kou 2006-06-17 00:28:36 +00:00
parent 4a396a8b7a
commit 76b8215877
3 changed files with 63 additions and 34 deletions

View file

@ -25,6 +25,35 @@ Sat Jun 17 09:03:47 2006 Kouhei Sutou <kou@cozmixng.org>
* lib/rss/taxonomy.rb: fixed <taxo:topic> #to_s bug. * lib/rss/taxonomy.rb: fixed <taxo:topic> #to_s bug.
* test/rss/test_taxonomy.rb: added a #to_s test. * test/rss/test_taxonomy.rb: added a #to_s test.
* lib/rss/maker/taxonomy.rb: implemented taxonomy module for RSS
Maker.
* lib/rss/taxonomy.rb: supported RSS Maker.
* lib/rss/maker.rb: added taxonomy module support.
* lib/rss/rss.rb: adjusted to other element API.
* lib/rss/1.0.rb: adjusted to other element API but backward
compatibility is reserved.
* lib/rss/0.9.rb: ditto.
* test/rss/test_maker_taxo.rb: added test case for taxonomy module
for RSS Maker.
* test/rss/test_setup_maker_1.0.rb: added tests for taxo:topic.
* test/rss/test_setup_maker_1.0.rb: added backward compatibility
test.
* test/rss/test_setup_maker_0.9.rb: ditto.
* test/rss/test_setup_maker_2.0.rb: ditto.
* test/rss/rss-testcase.rb: added convenience method for setting
up taxo:topic.
* test/rss/rss-assertions.rb: added assertion for taxo:topic.
* sample/rss/blend.rb: followed new API.
* lib/rss/taxonomy.rb: changed class or module prefix to
Taxonomy from Taxo.
* lib/rss/maker/taxonomy.rb: ditto.
Sat Jun 17 02:01:00 2006 Tanaka Akira <akr@m17n.org> Sat Jun 17 02:01:00 2006 Tanaka Akira <akr@m17n.org>
* lib/pp.rb (Kernel#pretty_inspect): defined for pretty printed * lib/pp.rb (Kernel#pretty_inspect): defined for pretty printed

View file

@ -4,7 +4,7 @@ require 'rss/maker/dublincore'
module RSS module RSS
module Maker module Maker
module TaxoTopicsModel module TaxonomyTopicsModel
def self.append_features(klass) def self.append_features(klass)
super super
@ -13,7 +13,7 @@ module RSS
klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1) klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
attr_reader :taxo_topics attr_reader :taxo_topics
def make_taxo_topics def make_taxo_topics
self.class::TaxoTopics.new(@maker) self.class::TaxonomyTopics.new(@maker)
end end
def setup_taxo_topics(rss, current) def setup_taxo_topics(rss, current)
@ -24,10 +24,10 @@ EOC
def self.install_taxo_topics(klass) def self.install_taxo_topics(klass)
klass.module_eval(<<-EOC, *Utils.get_file_and_line_from_caller(1)) klass.module_eval(<<-EOC, *Utils.get_file_and_line_from_caller(1))
class TaxoTopics < TaxoTopicsBase class TaxonomyTopics < TaxonomyTopicsBase
def to_rss(rss, current) def to_rss(rss, current)
if current.respond_to?(:taxo_topics) if current.respond_to?(:taxo_topics)
topics = current.class::TaxoTopics.new topics = current.class::TaxonomyTopics.new
bag = topics.Bag bag = topics.Bag
@resources.each do |resource| @resources.each do |resource|
bag.lis << RDF::Bag::Li.new(resource) bag.lis << RDF::Bag::Li.new(resource)
@ -39,7 +39,7 @@ EOC
EOC EOC
end end
class TaxoTopicsBase class TaxonomyTopicsBase
include Base include Base
attr_reader :resources attr_reader :resources
@ -47,7 +47,7 @@ EOC
end end
end end
module TaxoTopicModel module TaxonomyTopicModel
def self.append_features(klass) def self.append_features(klass)
super super
@ -56,7 +56,7 @@ EOC
klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1) klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
attr_reader :taxo_topics attr_reader :taxo_topics
def make_taxo_topics def make_taxo_topics
self.class::TaxoTopics.new(@maker) self.class::TaxonomyTopics.new(@maker)
end end
def setup_taxo_topics(rss, current) def setup_taxo_topics(rss, current)
@ -68,7 +68,7 @@ EOC
end end
def taxo_topic=(new_value) def taxo_topic=(new_value)
@taxo_topic[0] = self.class::TaxoTopic.new(self) @taxo_topic[0] = self.class::TaxonomyTopic.new(self)
@taxo_topic[0].value = new_value @taxo_topic[0].value = new_value
end end
EOC EOC
@ -76,14 +76,14 @@ EOC
def self.install_taxo_topic(klass) def self.install_taxo_topic(klass)
klass.module_eval(<<-EOC, *Utils.get_file_and_line_from_caller(1)) klass.module_eval(<<-EOC, *Utils.get_file_and_line_from_caller(1))
class TaxoTopics < TaxoTopicsBase class TaxonomyTopics < TaxonomyTopicsBase
class TaxoTopic < TaxoTopicBase class TaxonomyTopic < TaxonomyTopicBase
DublinCoreModel.install_dublin_core(self) DublinCoreModel.install_dublin_core(self)
TaxoTopicsModel.install_taxo_topics(self) TaxonomyTopicsModel.install_taxo_topics(self)
def to_rss(rss, current) def to_rss(rss, current)
if current.respond_to?(:taxo_topics) if current.respond_to?(:taxo_topics)
topic = current.class::TaxoTopic.new(value) topic = current.class::TaxonomyTopic.new(value)
topic.taxo_link = value topic.taxo_link = value
taxo_topics.to_rss(rss, topic) if taxo_topics taxo_topics.to_rss(rss, topic) if taxo_topics
current.taxo_topics << topic current.taxo_topics << topic
@ -99,13 +99,13 @@ EOC
EOC EOC
end end
class TaxoTopicsBase class TaxonomyTopicsBase
include Base include Base
def_array_element("taxo_topics") def_array_element("taxo_topics")
def new_taxo_topic def new_taxo_topic
taxo_topic = self.class::TaxoTopic.new(self) taxo_topic = self.class::TaxonomyTopic.new(self)
@taxo_topics << taxo_topic @taxo_topics << taxo_topic
taxo_topic taxo_topic
end end
@ -116,10 +116,10 @@ EOC
end end
end end
class TaxoTopicBase class TaxonomyTopicBase
include Base include Base
include DublinCoreModel include DublinCoreModel
include TaxoTopicsModel include TaxonomyTopicsModel
attr_accessor :value attr_accessor :value
add_need_initialize_variable("value") add_need_initialize_variable("value")
@ -134,43 +134,43 @@ EOC
end end
class RSSBase class RSSBase
include TaxoTopicModel include TaxonomyTopicModel
end end
class ChannelBase class ChannelBase
include TaxoTopicsModel include TaxonomyTopicsModel
end end
class ItemsBase class ItemsBase
class ItemBase class ItemBase
include TaxoTopicsModel include TaxonomyTopicsModel
end end
end end
class RSS10 class RSS10
TaxoTopicModel.install_taxo_topic(self) TaxonomyTopicModel.install_taxo_topic(self)
class Channel class Channel
TaxoTopicsModel.install_taxo_topics(self) TaxonomyTopicsModel.install_taxo_topics(self)
end end
class Items class Items
class Item class Item
TaxoTopicsModel.install_taxo_topics(self) TaxonomyTopicsModel.install_taxo_topics(self)
end end
end end
end end
class RSS09 class RSS09
TaxoTopicModel.install_taxo_topic(self) TaxonomyTopicModel.install_taxo_topic(self)
class Channel class Channel
TaxoTopicsModel.install_taxo_topics(self) TaxonomyTopicsModel.install_taxo_topics(self)
end end
class Items class Items
class Item class Item
TaxoTopicsModel.install_taxo_topics(self) TaxonomyTopicsModel.install_taxo_topics(self)
end end
end end
end end

View file

@ -18,11 +18,11 @@ module RSS
%w(topic topics).each do |name| %w(topic topics).each do |name|
class_name = Utils.to_class_name(name) class_name = Utils.to_class_name(name)
BaseListener.install_class_name(TAXO_URI, name, "Taxo#{class_name}") BaseListener.install_class_name(TAXO_URI, name, "Taxonomy#{class_name}")
TAXO_ELEMENTS << "#{TAXO_PREFIX}_#{name}" TAXO_ELEMENTS << "#{TAXO_PREFIX}_#{name}"
end end
module TaxoTopicsModel module TaxonomyTopicsModel
extend BaseModel extend BaseModel
def self.append_features(klass) def self.append_features(klass)
@ -47,7 +47,7 @@ module RSS
end end
end end
class TaxoTopics < Element class TaxonomyTopics < Element
include RSS10 include RSS10
Bag = ::RSS::RDF::Bag Bag = ::RSS::RDF::Bag
@ -117,7 +117,7 @@ module RSS
end end
end end
module TaxoTopicModel module TaxonomyTopicModel
extend BaseModel extend BaseModel
def self.append_features(klass) def self.append_features(klass)
@ -134,11 +134,11 @@ module RSS
end end
end end
class TaxoTopic < Element class TaxonomyTopic < Element
include RSS10 include RSS10
include DublinCoreModel include DublinCoreModel
include TaxoTopicsModel include TaxonomyTopicsModel
class << self class << self
def required_prefix def required_prefix
@ -212,10 +212,10 @@ module RSS
end end
class RDF class RDF
include TaxoTopicModel include TaxonomyTopicModel
class Channel class Channel
include TaxoTopicsModel include TaxonomyTopicsModel
end end
class Item; include TaxoTopicsModel; end class Item; include TaxonomyTopicsModel; end
end end
end end