Sha256: 94f12d174f2da9522bea3175fcf6684dbdb0cf495ca85ad6bbadc0e6ae350ae1

Contents?: true

Size: 790 Bytes

Versions: 2

Compression:

Stored size: 790 Bytes

Contents

module Smoke
  module Source # :nodoc:
    module Feed # :nodoc:
      Smoke.register(Smoke::Source::Feed)
      
      def feed(name, &block)
        Feed.new(name, &block)
      end
      
      # Feed can take multiple rss or atom feeds and munge them up together.
      # 
      # Usage:
      #   Smoke.feed(:ruby) do
      #     url "domain.tld/rss"
      #     url "site.tld/atom"
      #   end
      class Feed < Origin
        attr_reader :requests
        
        def url(feed_uri)
          (@feeds ||= [] ) << feed_uri
        end
        
        protected
        def dispatch
          @requests = @feeds.map{|f| Smoke::Request.new(f, :raw_response) }
          self.items = @requests.map{|r| ::SimpleRSS.parse(r.body).items }.flatten
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
benschwarz-smoke-0.2.3 lib/smoke/source/feed.rb
benschwarz-smoke-0.2.4 lib/smoke/source/feed.rb