mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									f988ceb53b
								
							
						
					
					
						commit
						4ef7ec62ca
					
				
					 14 changed files with 585 additions and 21 deletions
				
			
		
							
								
								
									
										27
									
								
								ChangeLog
									
										
									
									
									
								
							
							
						
						
									
										27
									
								
								ChangeLog
									
										
									
									
									
								
							| 
						 | 
					@ -1,3 +1,30 @@
 | 
				
			||||||
 | 
					Wed Nov 23 18:21:11 2005  Kouhei Sutou  <kou@cozmixng.org>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						* 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.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Wed Nov 23 17:42:24 2005  Kouhei Sutou  <kou@cozmixng.org>
 | 
					Wed Nov 23 17:42:24 2005  Kouhei Sutou  <kou@cozmixng.org>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	* lib/rss/rss.rb: fixed a indentation bug.
 | 
						* lib/rss/rss.rb: fixed a indentation bug.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -472,8 +472,12 @@ module RSS
 | 
				
			||||||
          rv
 | 
					          rv
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        def maker_target(maker)
 | 
					        def maker_target(items)
 | 
				
			||||||
          maker.items.new_item
 | 
					          if items.respond_to?("items")
 | 
				
			||||||
 | 
					            # For backward compatibility
 | 
				
			||||||
 | 
					            items = items.items
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					          items.new_item
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        def setup_maker_element(item)
 | 
					        def setup_maker_element(item)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -170,6 +170,12 @@ module RSS
 | 
				
			||||||
        tag_name_with_prefix(PREFIX)
 | 
					        tag_name_with_prefix(PREFIX)
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
 | 
					      def setup_maker(target)
 | 
				
			||||||
 | 
					        lis.each do |li|
 | 
				
			||||||
 | 
					          target << li.resource
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
      private
 | 
					      private
 | 
				
			||||||
      def children
 | 
					      def children
 | 
				
			||||||
        @li
 | 
					        @li
 | 
				
			||||||
| 
						 | 
					@ -224,6 +230,12 @@ module RSS
 | 
				
			||||||
        tag_name_with_prefix(PREFIX)
 | 
					        tag_name_with_prefix(PREFIX)
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
 | 
					      def setup_maker(target)
 | 
				
			||||||
 | 
					        lis.each do |li|
 | 
				
			||||||
 | 
					          target << li.resource
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
      private
 | 
					      private
 | 
				
			||||||
      def children
 | 
					      def children
 | 
				
			||||||
        @li
 | 
					        @li
 | 
				
			||||||
| 
						 | 
					@ -600,8 +612,12 @@ module RSS
 | 
				
			||||||
        ]
 | 
					        ]
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      def maker_target(maker)
 | 
					      def maker_target(items)
 | 
				
			||||||
        maker.items.new_item
 | 
					        if items.respond_to?("items")
 | 
				
			||||||
 | 
					          # For backward compatibility
 | 
				
			||||||
 | 
					          items = items.items
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					        items.new_item
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,5 +32,6 @@ require "rss/maker/2.0"
 | 
				
			||||||
require "rss/maker/content"
 | 
					require "rss/maker/content"
 | 
				
			||||||
require "rss/maker/dublincore"
 | 
					require "rss/maker/dublincore"
 | 
				
			||||||
require "rss/maker/syndication"
 | 
					require "rss/maker/syndication"
 | 
				
			||||||
 | 
					require "rss/maker/taxonomy"
 | 
				
			||||||
require "rss/maker/trackback"
 | 
					require "rss/maker/trackback"
 | 
				
			||||||
require "rss/maker/image"
 | 
					require "rss/maker/image"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										178
									
								
								lib/rss/maker/taxonomy.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										178
									
								
								lib/rss/maker/taxonomy.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,178 @@
 | 
				
			||||||
 | 
					require 'rss/taxonomy'
 | 
				
			||||||
 | 
					require 'rss/maker/1.0'
 | 
				
			||||||
 | 
					require 'rss/maker/dublincore'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					module RSS
 | 
				
			||||||
 | 
					  module Maker
 | 
				
			||||||
 | 
					    module TaxoTopicsModel
 | 
				
			||||||
 | 
					      def self.append_features(klass)
 | 
				
			||||||
 | 
					        super
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        klass.add_need_initialize_variable("taxo_topics", "make_taxo_topics")
 | 
				
			||||||
 | 
					        klass.add_other_element("taxo_topics")
 | 
				
			||||||
 | 
					        klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
 | 
				
			||||||
 | 
					          attr_reader :taxo_topics
 | 
				
			||||||
 | 
					          def make_taxo_topics
 | 
				
			||||||
 | 
					            self.class::TaxoTopics.new(@maker)
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					          def setup_taxo_topics(rss, current)
 | 
				
			||||||
 | 
					            @taxo_topics.to_rss(rss, current)
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					EOC
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      def self.install_taxo_topics(klass)
 | 
				
			||||||
 | 
					        klass.module_eval(<<-EOC, *Utils.get_file_and_line_from_caller(1))
 | 
				
			||||||
 | 
					          class TaxoTopics < TaxoTopicsBase
 | 
				
			||||||
 | 
					            def to_rss(rss, current)
 | 
				
			||||||
 | 
					              if current.respond_to?(:taxo_topics)
 | 
				
			||||||
 | 
					                topics = current.class::TaxoTopics.new
 | 
				
			||||||
 | 
					                bag = topics.Bag
 | 
				
			||||||
 | 
					                @resources.each do |resource|
 | 
				
			||||||
 | 
					                  bag.lis << RDF::Bag::Li.new(resource)
 | 
				
			||||||
 | 
					                end
 | 
				
			||||||
 | 
					                current.taxo_topics = topics
 | 
				
			||||||
 | 
					              end
 | 
				
			||||||
 | 
					            end
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					EOC
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      class TaxoTopicsBase
 | 
				
			||||||
 | 
					        include Base
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        attr_reader :resources
 | 
				
			||||||
 | 
					        def_array_element("resources")
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    module TaxoTopicModel
 | 
				
			||||||
 | 
					      def self.append_features(klass)
 | 
				
			||||||
 | 
					        super
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        klass.add_need_initialize_variable("taxo_topics", "make_taxo_topics")
 | 
				
			||||||
 | 
					        klass.add_other_element("taxo_topics")
 | 
				
			||||||
 | 
					        klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
 | 
				
			||||||
 | 
					          attr_reader :taxo_topics
 | 
				
			||||||
 | 
					          def make_taxo_topics
 | 
				
			||||||
 | 
					            self.class::TaxoTopics.new(@maker)
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					          def setup_taxo_topics(rss, current)
 | 
				
			||||||
 | 
					            @taxo_topics.to_rss(rss, current)
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          def taxo_topic
 | 
				
			||||||
 | 
					            @taxo_topics[0] and @taxo_topics[0].value
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					          def taxo_topic=(new_value)
 | 
				
			||||||
 | 
					            @taxo_topic[0] = self.class::TaxoTopic.new(self)
 | 
				
			||||||
 | 
					            @taxo_topic[0].value = new_value
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					EOC
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      def self.install_taxo_topic(klass)
 | 
				
			||||||
 | 
					        klass.module_eval(<<-EOC, *Utils.get_file_and_line_from_caller(1))
 | 
				
			||||||
 | 
					          class TaxoTopics < TaxoTopicsBase
 | 
				
			||||||
 | 
					            class TaxoTopic < TaxoTopicBase
 | 
				
			||||||
 | 
					              DublinCoreModel.install_dublin_core(self)
 | 
				
			||||||
 | 
					              TaxoTopicsModel.install_taxo_topics(self)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					              def to_rss(rss, current)
 | 
				
			||||||
 | 
					                if current.respond_to?(:taxo_topics)
 | 
				
			||||||
 | 
					                  topic = current.class::TaxoTopic.new(value)
 | 
				
			||||||
 | 
					                  topic.taxo_link = value
 | 
				
			||||||
 | 
					                  taxo_topics.to_rss(rss, topic) if taxo_topics
 | 
				
			||||||
 | 
					                  current.taxo_topics << topic
 | 
				
			||||||
 | 
					                  setup_other_elements(rss)
 | 
				
			||||||
 | 
					                end
 | 
				
			||||||
 | 
					              end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					              def current_element(rss)
 | 
				
			||||||
 | 
					                super.taxo_topics.last
 | 
				
			||||||
 | 
					              end
 | 
				
			||||||
 | 
					            end
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					EOC
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      class TaxoTopicsBase
 | 
				
			||||||
 | 
					        include Base
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        def_array_element("taxo_topics")
 | 
				
			||||||
 | 
					                            
 | 
				
			||||||
 | 
					        def new_taxo_topic
 | 
				
			||||||
 | 
					          taxo_topic = self.class::TaxoTopic.new(self)
 | 
				
			||||||
 | 
					          @taxo_topics << taxo_topic
 | 
				
			||||||
 | 
					          taxo_topic
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        def to_rss(rss, current)
 | 
				
			||||||
 | 
					          @taxo_topics.each do |taxo_topic|
 | 
				
			||||||
 | 
					            taxo_topic.to_rss(rss, current)
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        class TaxoTopicBase
 | 
				
			||||||
 | 
					          include Base
 | 
				
			||||||
 | 
					          include DublinCoreModel
 | 
				
			||||||
 | 
					          include TaxoTopicsModel
 | 
				
			||||||
 | 
					          
 | 
				
			||||||
 | 
					          attr_accessor :value
 | 
				
			||||||
 | 
					          add_need_initialize_variable("value")
 | 
				
			||||||
 | 
					          alias_method(:taxo_link, :value)
 | 
				
			||||||
 | 
					          alias_method(:taxo_link=, :value=)
 | 
				
			||||||
 | 
					          
 | 
				
			||||||
 | 
					          def have_required_values?
 | 
				
			||||||
 | 
					            @value
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    class RSSBase
 | 
				
			||||||
 | 
					      include TaxoTopicModel
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    class ChannelBase
 | 
				
			||||||
 | 
					      include TaxoTopicsModel
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    class ItemsBase
 | 
				
			||||||
 | 
					      class ItemBase
 | 
				
			||||||
 | 
					        include TaxoTopicsModel
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    class RSS10
 | 
				
			||||||
 | 
					      TaxoTopicModel.install_taxo_topic(self)
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      class Channel
 | 
				
			||||||
 | 
					        TaxoTopicsModel.install_taxo_topics(self)
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      class Items
 | 
				
			||||||
 | 
					        class Item
 | 
				
			||||||
 | 
					          TaxoTopicsModel.install_taxo_topics(self)
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    class RSS09
 | 
				
			||||||
 | 
					      TaxoTopicModel.install_taxo_topic(self)
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      class Channel
 | 
				
			||||||
 | 
					        TaxoTopicsModel.install_taxo_topics(self)
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      class Items
 | 
				
			||||||
 | 
					        class Item
 | 
				
			||||||
 | 
					          TaxoTopicsModel.install_taxo_topics(self)
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
| 
						 | 
					@ -655,7 +655,6 @@ EOC
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def setup_maker_elements(parent)
 | 
					    def setup_maker_elements(parent)
 | 
				
			||||||
      self.class.have_children_elements.each do |name, plural_name|
 | 
					      self.class.have_children_elements.each do |name, plural_name|
 | 
				
			||||||
        real_name = name.sub(/^[^_]+_/, '')
 | 
					 | 
				
			||||||
        if parent.respond_to?(plural_name)
 | 
					        if parent.respond_to?(plural_name)
 | 
				
			||||||
          target = parent.__send__(plural_name)
 | 
					          target = parent.__send__(plural_name)
 | 
				
			||||||
          __send__(plural_name).each do |elem|
 | 
					          __send__(plural_name).each do |elem|
 | 
				
			||||||
| 
						 | 
					@ -894,9 +893,7 @@ EOC
 | 
				
			||||||
      channel.setup_maker(maker) if channel
 | 
					      channel.setup_maker(maker) if channel
 | 
				
			||||||
      image.setup_maker(maker) if image
 | 
					      image.setup_maker(maker) if image
 | 
				
			||||||
      textinput.setup_maker(maker) if textinput
 | 
					      textinput.setup_maker(maker) if textinput
 | 
				
			||||||
      items.each do |item|
 | 
					      super(maker)
 | 
				
			||||||
        item.setup_maker(maker)
 | 
					 | 
				
			||||||
      end
 | 
					 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -77,6 +77,10 @@ module RSS
 | 
				
			||||||
        tag_name_with_prefix(TAXO_PREFIX)
 | 
					        tag_name_with_prefix(TAXO_PREFIX)
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      def maker_target(target)
 | 
				
			||||||
 | 
					        target.taxo_topics
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      def to_s(need_convert=true, indent=calc_indent)
 | 
					      def to_s(need_convert=true, indent=calc_indent)
 | 
				
			||||||
        rv = tag(indent) do |next_indent|
 | 
					        rv = tag(indent) do |next_indent|
 | 
				
			||||||
          [
 | 
					          [
 | 
				
			||||||
| 
						 | 
					@ -183,6 +187,10 @@ module RSS
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      def maker_target(target)
 | 
				
			||||||
 | 
					        target.new_taxo_topic
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      private
 | 
					      private
 | 
				
			||||||
      def children
 | 
					      def children
 | 
				
			||||||
        [@taxo_link, @taxo_topics]
 | 
					        [@taxo_link, @taxo_topics]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -61,7 +61,7 @@ rss = RSS::Maker.make("1.0") do |maker|
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  feeds.each do |feed|
 | 
					  feeds.each do |feed|
 | 
				
			||||||
    feed.items.each do |item|
 | 
					    feed.items.each do |item|
 | 
				
			||||||
      item.setup_maker(maker)
 | 
					      item.setup_maker(maker.items)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
  maker.items.do_sort = true
 | 
					  maker.items.do_sort = true
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -435,6 +435,25 @@ module RSS
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def assert_taxo_topic(topics, target)
 | 
				
			||||||
 | 
					      _wrap_assertion do
 | 
				
			||||||
 | 
					        topics.each_with_index do |topic, i|
 | 
				
			||||||
 | 
					          taxo_topic = target.taxo_topics[i]
 | 
				
			||||||
 | 
					          topic.each do |name, value|
 | 
				
			||||||
 | 
					            case name
 | 
				
			||||||
 | 
					            when :link
 | 
				
			||||||
 | 
					              assert_equal(value, taxo_topic.about)
 | 
				
			||||||
 | 
					              assert_equal(value, taxo_topic.taxo_link)
 | 
				
			||||||
 | 
					            when :topics
 | 
				
			||||||
 | 
					              assert_equal(value, taxo_topic.taxo_topics.resources)
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					              assert_equal(value, taxo_topic.__send__("dc_#{name}"))
 | 
				
			||||||
 | 
					            end
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def assert_attributes(attrs, names, target)
 | 
					    def assert_attributes(attrs, names, target)
 | 
				
			||||||
      _wrap_assertion do
 | 
					      _wrap_assertion do
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -248,5 +248,24 @@ EOC
 | 
				
			||||||
      item.link = link
 | 
					      item.link = link
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    def setup_taxo_topic(target, topics)
 | 
				
			||||||
 | 
					      topics.each do |topic|
 | 
				
			||||||
 | 
					        taxo_topic = target.taxo_topics.new_taxo_topic
 | 
				
			||||||
 | 
					        topic.each do |name, value|
 | 
				
			||||||
 | 
					          case name
 | 
				
			||||||
 | 
					          when :link
 | 
				
			||||||
 | 
					            taxo_topic.taxo_link = value
 | 
				
			||||||
 | 
					          when :topics
 | 
				
			||||||
 | 
					            value.each do |t|
 | 
				
			||||||
 | 
					              taxo_topic.taxo_topics << t
 | 
				
			||||||
 | 
					            end
 | 
				
			||||||
 | 
					          else
 | 
				
			||||||
 | 
					            dc_elems = taxo_topic.__send__("dc_#{name}s")
 | 
				
			||||||
 | 
					            dc_elem = dc_elems.__send__("new_#{name}")
 | 
				
			||||||
 | 
					            dc_elem.value = value
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										79
									
								
								test/rss/test_maker_taxo.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								test/rss/test_maker_taxo.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,79 @@
 | 
				
			||||||
 | 
					require "rss-testcase"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					require "rss/maker"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					module RSS
 | 
				
			||||||
 | 
					  class TestMakerTaxonomy < TestCase
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def setup
 | 
				
			||||||
 | 
					      @uri = "http://purl.org/rss/1.0/modules/taxonomy/"
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      @resources = [
 | 
				
			||||||
 | 
					        "http://meerkat.oreillynet.com/?c=cat23",
 | 
				
			||||||
 | 
					        "http://meerkat.oreillynet.com/?c=47",
 | 
				
			||||||
 | 
					        "http://dmoz.org/Computers/Data_Formats/Markup_Languages/XML/",
 | 
				
			||||||
 | 
					      ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      @topics = [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          :link => "http://meerkat.oreillynet.com/?c=cat23",
 | 
				
			||||||
 | 
					          :title => "Data: XML",
 | 
				
			||||||
 | 
					          :description => "A Meerkat channel",
 | 
				
			||||||
 | 
					         },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          :link => "http://dmoz.org/Computers/Data_Formats/Markup_Languages/XML/",
 | 
				
			||||||
 | 
					          :title => "XML",
 | 
				
			||||||
 | 
					          :subject => "XML",
 | 
				
			||||||
 | 
					          :description => "DMOZ category",
 | 
				
			||||||
 | 
					          :topics => [
 | 
				
			||||||
 | 
					            "http://meerkat.oreillynet.com/?c=cat23",
 | 
				
			||||||
 | 
					            "http://dmoz.org/Computers/Data_Formats/Markup_Languages/SGML/",
 | 
				
			||||||
 | 
					            "http://dmoz.org/Computers/Programming/Internet/",
 | 
				
			||||||
 | 
					          ]
 | 
				
			||||||
 | 
					         },
 | 
				
			||||||
 | 
					       ]
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_rss10
 | 
				
			||||||
 | 
					      rss = RSS::Maker.make("1.0") do |maker|
 | 
				
			||||||
 | 
					        setup_dummy_channel(maker)
 | 
				
			||||||
 | 
					        set_topics(maker.channel)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        setup_dummy_item(maker)
 | 
				
			||||||
 | 
					        set_topics(maker.items.last)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        setup_taxo_topic(maker, @topics)
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					      assert_equal(@resources, rss.channel.taxo_topics.resources)
 | 
				
			||||||
 | 
					      assert_equal(@resources, rss.items.last.taxo_topics.resources)
 | 
				
			||||||
 | 
					      assert_taxo_topic(@topics, rss)
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def _test_date
 | 
				
			||||||
 | 
					      t1 = Time.iso8601("2000-01-01T12:00:05+00:00")
 | 
				
			||||||
 | 
					      t2 = Time.iso8601("2005-01-01T12:00:05+00:00")
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      rss = RSS::Maker.make("1.0") do |maker|
 | 
				
			||||||
 | 
					        setup_dummy_channel(maker)
 | 
				
			||||||
 | 
					        maker.channel.date = t1
 | 
				
			||||||
 | 
					        date = maker.channel.dc_dates.new_date
 | 
				
			||||||
 | 
					        date.value = t2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        setup_dummy_item(maker)
 | 
				
			||||||
 | 
					        item = maker.items.last
 | 
				
			||||||
 | 
					        item.date = t2
 | 
				
			||||||
 | 
					        date = item.dc_dates.new_date
 | 
				
			||||||
 | 
					        date.value = t1
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					      assert_equal([t1, t2], rss.channel.dc_dates.collect{|x| x.value})
 | 
				
			||||||
 | 
					      assert_equal([t2, t1], rss.items.last.dc_dates.collect{|x| x.value})
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    private
 | 
				
			||||||
 | 
					    def set_topics(target, resources=@resources)
 | 
				
			||||||
 | 
					      resources.each do |value|
 | 
				
			||||||
 | 
					        target.taxo_topics << value
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
| 
						 | 
					@ -138,7 +138,7 @@ module RSS
 | 
				
			||||||
      assert_equal(link, textInput.link)
 | 
					      assert_equal(link, textInput.link)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_setup_maker_items
 | 
					    def test_setup_maker_items(for_backward_compatibility=false)
 | 
				
			||||||
      title = "TITLE"
 | 
					      title = "TITLE"
 | 
				
			||||||
      link = "http://hoge.com/"
 | 
					      link = "http://hoge.com/"
 | 
				
			||||||
      description = "text hoge fuga"
 | 
					      description = "text hoge fuga"
 | 
				
			||||||
| 
						 | 
					@ -160,7 +160,11 @@ module RSS
 | 
				
			||||||
        rss.channel.setup_maker(maker)
 | 
					        rss.channel.setup_maker(maker)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        rss.items.each do |item|
 | 
					        rss.items.each do |item|
 | 
				
			||||||
 | 
					          if for_backward_compatibility
 | 
				
			||||||
            item.setup_maker(maker)
 | 
					            item.setup_maker(maker)
 | 
				
			||||||
 | 
					          else
 | 
				
			||||||
 | 
					            item.setup_maker(maker.items)
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
| 
						 | 
					@ -173,6 +177,10 @@ module RSS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_setup_maker_items_backward_compatibility
 | 
				
			||||||
 | 
					      test_setup_maker_items(true)
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    def test_setup_maker
 | 
					    def test_setup_maker
 | 
				
			||||||
      encoding = "EUC-JP"
 | 
					      encoding = "EUC-JP"
 | 
				
			||||||
      standalone = true
 | 
					      standalone = true
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -47,6 +47,25 @@ module RSS
 | 
				
			||||||
          "http://foo.com/trackback/tb.cgi?tb_id=20021010",
 | 
					          "http://foo.com/trackback/tb.cgi?tb_id=20021010",
 | 
				
			||||||
        ],
 | 
					        ],
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      @taxo_topic_elems = [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          :link => "http://meerkat.oreillynet.com/?c=cat23",
 | 
				
			||||||
 | 
					          :title => "Data: XML",
 | 
				
			||||||
 | 
					          :description => "A Meerkat channel",
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          :link => "http://dmoz.org/Computers/Data_Formats/Markup_Languages/XML/",
 | 
				
			||||||
 | 
					          :title => "XML",
 | 
				
			||||||
 | 
					          :subject => "XML",
 | 
				
			||||||
 | 
					          :description => "DMOZ category",
 | 
				
			||||||
 | 
					          :topics => [
 | 
				
			||||||
 | 
					            "http://meerkat.oreillynet.com/?c=cat23",
 | 
				
			||||||
 | 
					            "http://dmoz.org/Computers/Data_Formats/Markup_Languages/SGML/",
 | 
				
			||||||
 | 
					            "http://dmoz.org/Computers/Programming/Internet/",
 | 
				
			||||||
 | 
					          ]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					      ]
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def test_setup_maker_channel
 | 
					    def test_setup_maker_channel
 | 
				
			||||||
| 
						 | 
					@ -164,7 +183,7 @@ module RSS
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_setup_maker_items
 | 
					    def test_setup_maker_items(for_backward_compatibility=false)
 | 
				
			||||||
      title = "TITLE"
 | 
					      title = "TITLE"
 | 
				
			||||||
      link = "http://hoge.com/"
 | 
					      link = "http://hoge.com/"
 | 
				
			||||||
      description = "text hoge fuga"
 | 
					      description = "text hoge fuga"
 | 
				
			||||||
| 
						 | 
					@ -200,7 +219,11 @@ module RSS
 | 
				
			||||||
        rss.channel.setup_maker(maker)
 | 
					        rss.channel.setup_maker(maker)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        rss.items.each do |item|
 | 
					        rss.items.each do |item|
 | 
				
			||||||
 | 
					          if for_backward_compatibility
 | 
				
			||||||
            item.setup_maker(maker)
 | 
					            item.setup_maker(maker)
 | 
				
			||||||
 | 
					          else
 | 
				
			||||||
 | 
					            item.setup_maker(maker.items)
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
| 
						 | 
					@ -231,8 +254,8 @@ module RSS
 | 
				
			||||||
      title = "TITLE"
 | 
					      title = "TITLE"
 | 
				
			||||||
      link = "http://hoge.com/"
 | 
					      link = "http://hoge.com/"
 | 
				
			||||||
      description = "text hoge fuga"
 | 
					      description = "text hoge fuga"
 | 
				
			||||||
      item_size = 5
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      item_size = 5
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
      rss = RSS::Maker.make("1.0") do |maker|
 | 
					      rss = RSS::Maker.make("1.0") do |maker|
 | 
				
			||||||
        setup_dummy_channel(maker)
 | 
					        setup_dummy_channel(maker)
 | 
				
			||||||
| 
						 | 
					@ -243,7 +266,7 @@ module RSS
 | 
				
			||||||
          item.link = "#{link}#{i}"
 | 
					          item.link = "#{link}#{i}"
 | 
				
			||||||
          item.description = "#{description}#{i}"
 | 
					          item.description = "#{description}#{i}"
 | 
				
			||||||
          item.dc_date = Time.now + i * 60
 | 
					          item.dc_date = Time.now + i * 60
 | 
				
			||||||
          item.setup_maker(maker)
 | 
					          item.setup_maker(maker.items)
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
        maker.items.do_sort = false
 | 
					        maker.items.do_sort = false
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
| 
						 | 
					@ -265,7 +288,7 @@ module RSS
 | 
				
			||||||
          item.link = "#{link}#{i}"
 | 
					          item.link = "#{link}#{i}"
 | 
				
			||||||
          item.description = "#{description}#{i}"
 | 
					          item.description = "#{description}#{i}"
 | 
				
			||||||
          item.dc_date = Time.now + i * 60
 | 
					          item.dc_date = Time.now + i * 60
 | 
				
			||||||
          item.setup_maker(maker)
 | 
					          item.setup_maker(maker.items)
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
        maker.items.do_sort = true
 | 
					        maker.items.do_sort = true
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
| 
						 | 
					@ -278,6 +301,10 @@ module RSS
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_setup_maker_items_backward_compatibility
 | 
				
			||||||
 | 
					      test_setup_maker_items(true)
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    def test_setup_maker
 | 
					    def test_setup_maker
 | 
				
			||||||
      encoding = "EUC-JP"
 | 
					      encoding = "EUC-JP"
 | 
				
			||||||
      standalone = true
 | 
					      standalone = true
 | 
				
			||||||
| 
						 | 
					@ -312,8 +339,8 @@ module RSS
 | 
				
			||||||
      assert_equal(encoding, new_rss.encoding)
 | 
					      assert_equal(encoding, new_rss.encoding)
 | 
				
			||||||
      assert_equal(standalone, new_rss.standalone)
 | 
					      assert_equal(standalone, new_rss.standalone)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      xss = rss.xml_stylesheets.first
 | 
					      xss = new_rss.xml_stylesheets.first
 | 
				
			||||||
      assert_equal(1, rss.xml_stylesheets.size)
 | 
					      assert_equal(1, new_rss.xml_stylesheets.size)
 | 
				
			||||||
      assert_equal(href, xss.href)
 | 
					      assert_equal(href, xss.href)
 | 
				
			||||||
      assert_equal(type, xss.type)
 | 
					      assert_equal(type, xss.type)
 | 
				
			||||||
      assert_equal(title, xss.title)
 | 
					      assert_equal(title, xss.title)
 | 
				
			||||||
| 
						 | 
					@ -322,5 +349,178 @@ module RSS
 | 
				
			||||||
      assert_equal(alternate, xss.alternate)
 | 
					      assert_equal(alternate, xss.alternate)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_setup_maker_full
 | 
				
			||||||
 | 
					      encoding = "EUC-JP"
 | 
				
			||||||
 | 
					      standalone = true
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      href = 'a.xsl'
 | 
				
			||||||
 | 
					      type = 'text/xsl'
 | 
				
			||||||
 | 
					      title = 'sample'
 | 
				
			||||||
 | 
					      media = 'printer'
 | 
				
			||||||
 | 
					      charset = 'UTF-8'
 | 
				
			||||||
 | 
					      alternate = 'yes'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      channel_about = "http://hoge.com"
 | 
				
			||||||
 | 
					      channel_title = "fugafuga"
 | 
				
			||||||
 | 
					      channel_link = "http://hoge.com"
 | 
				
			||||||
 | 
					      channel_description = "fugafugafugafuga"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      image_title = "fugafuga"
 | 
				
			||||||
 | 
					      image_url = "http://hoge.com/hoge.png"
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      textinput_title = "fugafuga"
 | 
				
			||||||
 | 
					      textinput_description = "text hoge fuga"
 | 
				
			||||||
 | 
					      textinput_name = "hoge"
 | 
				
			||||||
 | 
					      textinput_link = "http://hoge.com"
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      item_title = "TITLE"
 | 
				
			||||||
 | 
					      item_link = "http://hoge.com/"
 | 
				
			||||||
 | 
					      item_description = "text hoge fuga"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      item_size = 5
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      rss = RSS::Maker.make("1.0") do |maker|
 | 
				
			||||||
 | 
					        maker.encoding = encoding
 | 
				
			||||||
 | 
					        maker.standalone = standalone
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        xss = maker.xml_stylesheets.new_xml_stylesheet
 | 
				
			||||||
 | 
					        xss.href = href
 | 
				
			||||||
 | 
					        xss.type = type
 | 
				
			||||||
 | 
					        xss.title = title
 | 
				
			||||||
 | 
					        xss.media = media
 | 
				
			||||||
 | 
					        xss.charset = charset
 | 
				
			||||||
 | 
					        xss.alternate = alternate
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        maker.channel.about = channel_about
 | 
				
			||||||
 | 
					        maker.channel.title = channel_title
 | 
				
			||||||
 | 
					        maker.channel.link = channel_link
 | 
				
			||||||
 | 
					        maker.channel.description = channel_description
 | 
				
			||||||
 | 
					        @dc_elems.each do |var, value|
 | 
				
			||||||
 | 
					          maker.channel.__send__("dc_#{var}=", value)
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					        @sy_elems.each do |var, value|
 | 
				
			||||||
 | 
					          maker.channel.__send__("sy_#{var}=", value)
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        maker.image.title = image_title
 | 
				
			||||||
 | 
					        maker.image.url = image_url
 | 
				
			||||||
 | 
					        @dc_elems.each do |var, value|
 | 
				
			||||||
 | 
					          maker.image.__send__("dc_#{var}=", value)
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        maker.textinput.link = textinput_link
 | 
				
			||||||
 | 
					        maker.textinput.title = textinput_title
 | 
				
			||||||
 | 
					        maker.textinput.description = textinput_description
 | 
				
			||||||
 | 
					        maker.textinput.name = textinput_name
 | 
				
			||||||
 | 
					        @dc_elems.each do |var, value|
 | 
				
			||||||
 | 
					          maker.textinput.__send__("dc_#{var}=", value)
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        item_size.times do |i|
 | 
				
			||||||
 | 
					          item = maker.items.new_item
 | 
				
			||||||
 | 
					          item.title = "#{item_title}#{i}"
 | 
				
			||||||
 | 
					          item.link = "#{item_link}#{i}"
 | 
				
			||||||
 | 
					          item.description = "#{item_description}#{i}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          @dc_elems.each do |var, value|
 | 
				
			||||||
 | 
					            item.__send__("dc_#{var}=", value)
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					          
 | 
				
			||||||
 | 
					          @content_elems.each do |var, value|
 | 
				
			||||||
 | 
					            item.__send__("content_#{var}=", value)
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          item.trackback_ping = @trackback_elems[:ping]
 | 
				
			||||||
 | 
					          @trackback_elems[:about].each do |value|
 | 
				
			||||||
 | 
					            new_about = item.trackback_abouts.new_about
 | 
				
			||||||
 | 
					            new_about.value = value
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        setup_taxo_topic(maker, @taxo_topic_elems)
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      new_rss = RSS::Maker.make("1.0") do |maker|
 | 
				
			||||||
 | 
					        rss.setup_maker(maker)
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      assert_equal("1.0", new_rss.rss_version)
 | 
				
			||||||
 | 
					      assert_equal(encoding, new_rss.encoding)
 | 
				
			||||||
 | 
					      assert_equal(standalone, new_rss.standalone)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      xss = new_rss.xml_stylesheets.first
 | 
				
			||||||
 | 
					      assert_equal(1, new_rss.xml_stylesheets.size)
 | 
				
			||||||
 | 
					      assert_equal(href, xss.href)
 | 
				
			||||||
 | 
					      assert_equal(type, xss.type)
 | 
				
			||||||
 | 
					      assert_equal(title, xss.title)
 | 
				
			||||||
 | 
					      assert_equal(media, xss.media)
 | 
				
			||||||
 | 
					      assert_equal(charset, xss.charset)
 | 
				
			||||||
 | 
					      assert_equal(alternate, xss.alternate)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      channel = new_rss.channel
 | 
				
			||||||
 | 
					      assert_equal(channel_about, channel.about)
 | 
				
			||||||
 | 
					      assert_equal(channel_title, channel.title)
 | 
				
			||||||
 | 
					      assert_equal(channel_link, channel.link)
 | 
				
			||||||
 | 
					      assert_equal(channel_description, channel.description)
 | 
				
			||||||
 | 
					      item_resources = []
 | 
				
			||||||
 | 
					      item_size.times do |i|
 | 
				
			||||||
 | 
					        item_resources << "#{item_link}#{i}"
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					      assert_equal(item_resources, channel.items.resources)
 | 
				
			||||||
 | 
					      assert_equal(image_url, channel.image.resource)
 | 
				
			||||||
 | 
					      assert_equal(textinput_link, channel.textinput.resource)
 | 
				
			||||||
 | 
					      @dc_elems.each do |var, value|
 | 
				
			||||||
 | 
					        assert_equal(value, channel.__send__("dc_#{var}"))
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					      @sy_elems.each do |var, value|
 | 
				
			||||||
 | 
					        assert_equal(value, channel.__send__("sy_#{var}"))
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      image = new_rss.image
 | 
				
			||||||
 | 
					      assert_equal(image_url, image.about)
 | 
				
			||||||
 | 
					      assert_equal(image_url, new_rss.channel.image.resource)
 | 
				
			||||||
 | 
					      assert_equal(image_title, image.title)
 | 
				
			||||||
 | 
					      assert_equal(channel_link, image.link)
 | 
				
			||||||
 | 
					      assert_equal(image_url, image.url)
 | 
				
			||||||
 | 
					      @dc_elems.each do |var, value|
 | 
				
			||||||
 | 
					        assert_equal(image.__send__("dc_#{var}"), value)
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      textinput = new_rss.textinput
 | 
				
			||||||
 | 
					      assert_equal(textinput_link, textinput.about)
 | 
				
			||||||
 | 
					      assert_equal(textinput_link, new_rss.channel.textinput.resource)
 | 
				
			||||||
 | 
					      assert_equal(textinput_title, textinput.title)
 | 
				
			||||||
 | 
					      assert_equal(textinput_name, textinput.name)
 | 
				
			||||||
 | 
					      assert_equal(textinput_description, textinput.description)
 | 
				
			||||||
 | 
					      assert_equal(textinput_link, textinput.link)
 | 
				
			||||||
 | 
					      @dc_elems.each do |var, value|
 | 
				
			||||||
 | 
					        assert_equal(textinput.__send__("dc_#{var}"), value)
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      assert_equal(item_size, new_rss.items.size)
 | 
				
			||||||
 | 
					      new_rss.items.each_with_index do |item, i|
 | 
				
			||||||
 | 
					        assert_equal("#{item_link}#{i}", item.about)
 | 
				
			||||||
 | 
					        assert_equal("#{item_title}#{i}", item.title)
 | 
				
			||||||
 | 
					        assert_equal("#{item_link}#{i}", item.link)
 | 
				
			||||||
 | 
					        assert_equal("#{item_description}#{i}", item.description)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @dc_elems.each do |var, value|
 | 
				
			||||||
 | 
					          assert_equal(item.__send__("dc_#{var}"), value)
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					        @content_elems.each do |var, value|
 | 
				
			||||||
 | 
					          assert_equal(item.__send__("content_#{var}"), value)
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					        assert_equal(@trackback_elems[:ping], item.trackback_ping)
 | 
				
			||||||
 | 
					        assert_equal(@trackback_elems[:about].size, item.trackback_abouts.size)
 | 
				
			||||||
 | 
					        item.trackback_abouts.each_with_index do |about, i|
 | 
				
			||||||
 | 
					          assert_equal(@trackback_elems[:about][i], about.value)
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      assert_taxo_topic(@taxo_topic_elems, new_rss)
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -162,7 +162,7 @@ module RSS
 | 
				
			||||||
      assert_equal(link, textInput.link)
 | 
					      assert_equal(link, textInput.link)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_setup_maker_items
 | 
					    def test_setup_maker_items(for_backward_compatibility=false)
 | 
				
			||||||
      title = "TITLE"
 | 
					      title = "TITLE"
 | 
				
			||||||
      link = "http://hoge.com/"
 | 
					      link = "http://hoge.com/"
 | 
				
			||||||
      description = "text hoge fuga"
 | 
					      description = "text hoge fuga"
 | 
				
			||||||
| 
						 | 
					@ -217,7 +217,11 @@ module RSS
 | 
				
			||||||
        rss.channel.setup_maker(maker)
 | 
					        rss.channel.setup_maker(maker)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        rss.items.each do |item|
 | 
					        rss.items.each do |item|
 | 
				
			||||||
 | 
					          if for_backward_compatibility
 | 
				
			||||||
            item.setup_maker(maker)
 | 
					            item.setup_maker(maker)
 | 
				
			||||||
 | 
					          else
 | 
				
			||||||
 | 
					            item.setup_maker(maker.items)
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
| 
						 | 
					@ -247,6 +251,10 @@ module RSS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_setup_maker_items_backward_compatibility
 | 
				
			||||||
 | 
					      test_setup_maker_items(true)
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    def test_setup_maker
 | 
					    def test_setup_maker
 | 
				
			||||||
      encoding = "EUC-JP"
 | 
					      encoding = "EUC-JP"
 | 
				
			||||||
      standalone = true
 | 
					      standalone = true
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue