PHP 8.2.31
Preview: taxonomy.rb Size: 3.11 KB
//proc/thread-self/root/opt/alt/ruby21/lib64/ruby/2.1.0/rss/maker/taxonomy.rb

require 'rss/taxonomy'
require 'rss/maker/1.0'
require 'rss/maker/dublincore'

module RSS
  module Maker
    module TaxonomyTopicsModel
      def self.append_features(klass)
        super

        klass.def_classed_element("#{RSS::TAXO_PREFIX}_topics",
                                  "TaxonomyTopics")
      end

      def self.install_taxo_topics(klass)
        klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
          class TaxonomyTopics < TaxonomyTopicsBase
            def to_feed(feed, current)
              if current.respond_to?(:taxo_topics)
                topics = current.class::TaxonomyTopics.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 TaxonomyTopicsBase < Base
        attr_reader :resources
        def_array_element("resource")
        remove_method :new_resource
      end
    end

    module TaxonomyTopicModel
      def self.append_features(klass)
        super

        class_name = "TaxonomyTopics"
        klass.def_classed_elements("#{TAXO_PREFIX}_topic", "value", class_name)
      end

      def self.install_taxo_topic(klass)
        klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
          class TaxonomyTopics < TaxonomyTopicsBase
            class TaxonomyTopic < TaxonomyTopicBase
              DublinCoreModel.install_dublin_core(self)
              TaxonomyTopicsModel.install_taxo_topics(self)

              def to_feed(feed, current)
                if current.respond_to?(:taxo_topics)
                  topic = current.class::TaxonomyTopic.new(value)
                  topic.taxo_link = value
                  taxo_topics.to_feed(feed, topic) if taxo_topics
                  current.taxo_topics << topic
                  setup_other_elements(feed, topic)
                end
              end
            end
          end
EOC
      end

      class TaxonomyTopicsBase < Base
        def_array_element("topic", nil, "TaxonomyTopic")
        alias_method(:new_taxo_topic, :new_topic) # For backward compatibility

        class TaxonomyTopicBase < Base
          include DublinCoreModel
          include TaxonomyTopicsModel

          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 TaxonomyTopicModel
    end

    class ChannelBase
      include TaxonomyTopicsModel
    end

    class ItemsBase
      class ItemBase
        include TaxonomyTopicsModel
      end
    end

    makers.each do |maker|
      maker.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
        TaxonomyTopicModel.install_taxo_topic(self)

        class Channel
          TaxonomyTopicsModel.install_taxo_topics(self)
        end

        class Items
          class Item
            TaxonomyTopicsModel.install_taxo_topics(self)
          end
        end
      EOC
    end
  end
end

Directory Contents

Dirs: 0 × Files: 15

Name Size Perms Modified Actions
11.79 KB lrw-r--r-- 2010-11-08 20:59:01
Edit Download
10.01 KB lrw-r--r-- 2010-11-08 20:59:01
Edit Download
5.68 KB lrw-r--r-- 2009-10-02 10:45:39
Edit Download
4.50 KB lrw-r--r-- 2007-11-16 01:30:29
Edit Download
24.05 KB lrw-r--r-- 2012-11-16 16:55:29
Edit Download
384 B lrw-r--r-- 2009-10-02 10:45:39
Edit Download
3.74 KB lrw-r--r-- 2010-11-08 20:59:01
Edit Download
4.71 KB lrw-r--r-- 2011-11-05 07:37:47
Edit Download
12.48 KB lrw-r--r-- 2009-05-16 09:08:58
Edit Download
2.86 KB lrw-r--r-- 2011-05-19 00:07:25
Edit Download
7.26 KB lrw-r--r-- 2008-06-29 08:34:40
Edit Download
735 B lrw-r--r-- 2007-11-16 01:30:29
Edit Download
349 B lrw-r--r-- 2009-10-02 10:45:39
Edit Download
3.11 KB lrw-r--r-- 2009-10-02 10:45:39
Edit Download
1.57 KB lrw-r--r-- 2009-10-02 10:45:39
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).