Module: Lifestream

Defined in:
lib/lifestream.rb,
lib/lifestream/branch.rb,
lib/lifestream/source.rb,
lib/lifestream/stream.rb,
lib/lifestream/channel.rb,
lib/lifestream/request.rb,
lib/lifestream/channel/rss2.rb

Defined Under Namespace

Classes: Branch, Channel, NoConfiguration, Request, Source, Stream

Class Method Summary collapse

Class Method Details

.optionsObject

Provides configurability to Lifestream. There are a number of options available, such as:

  • whiny: Will raise an error if Lifestream cannot process a given feed.

    Defaults to true

  • config: Path to the lifestream.yml file that contains the feeds to download. Defaults to gem location, you will probably want to set this

  • cache: The path that the downloaded feeds should be cached in, defaults to tmp Set cache to false to disable it

  • cache_expiration: The amount of time that the cache is fresh for Defaults to 1 hour



15
16
17
18
19
20
21
22
# File 'lib/lifestream.rb', line 15

def self.options
  @options ||= {
    :config => 'lifestream.yml',
    :whiny  => true,
    :cache  => 'tmp',
    :cache_expiration => (60 * 60 * 1)
  }
end

.run(preload = false) ⇒ Object

Generates a Lifestream::Stream which contains all the channels with their branches parsed from the feeds in the lifestream.yml file, ordered by their published_at date.



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/lifestream.rb', line 27

def self.run(preload = false)
  lifestream = Lifestream::Stream.new
  ensure_configuration_exists
  
  feeds = YAML.load(File.open(options[:config]))
  feeds.each_pair do |name, options|
    klass = Lifestream::Channel.const_get(options['format'])
    channel = klass.new(name, options['url'])
    channel.branches if preload
    lifestream.channels << channel
  end
  lifestream
end