public
Description: A 'planet' like feed aggregator using feedparser and erubis
Clone URL: git://github.com/technicalpickles/feedbarn.git
Added a farmer for gathering feeds.
Thu Feb 21 18:44:08 -0800 2008
commit  5088bdbc704883cdcf8ec19e33b56c729ffb2e02
tree    7440a768aaac4697105fee66fed6d6caed2c9c6e
parent  cebbdcbc729c9618fedd6a163a7b13a1e1fe1860
...
1
2
3
 
4
 
5
6
7
8
9
 
 
 
 
 
 
 
 
 
10
...
1
2
 
3
4
5
6
 
7
 
8
9
10
11
12
13
14
15
16
17
18
0
@@ -1,8 +1,16 @@
0
 #!/usr/bin/env ruby
0
 
0
-require File.dirname(__FILE__) + '/../lib/feedbarn/barn.rb'
0
+$:.unshift File.dirname(__FILE__) + '/../lib'
0
 
0
+require 'feedbarn'
0
 
0
-barn = FeedBarn::Barn.new('My barn', [])
0
 
0
-puts barn.name
0
\ No newline at end of file
0
+farmer = FeedBarn::Farmer.new
0
+feeds = farmer.gather
0
+barn = FeedBarn::Barn.new('My barn', feeds)
0
+
0
+puts barn.name
0
+
0
+barn.entries.each do |entry|
0
+ puts entry.title
0
+end
0
\ No newline at end of file
...
 
 
0
...
1
2
3
0
@@ -0,0 +1,2 @@
0
+require 'feedbarn/barn'
0
+require 'feedbarn/farmer'
0
\ No newline at end of file
...
6
7
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
10
11
...
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
0
@@ -6,5 +6,32 @@ module FeedBarn
0
       self.name = name
0
       self.feeds = feeds
0
     end
0
+
0
+ def entries
0
+ if @entries.nil?
0
+ collect_entries!
0
+ sort_entries!
0
+ end
0
+ @entries
0
+ end
0
+
0
+ private
0
+
0
+ def sort_entries!
0
+ @entries.sort! do |a, b|
0
+ unless a.date_published.nil? or b.date_published.nil?
0
+ a.date_published <=> b.date_published
0
+ else
0
+ a.title <=> b.title
0
+ end
0
+ end
0
+ end
0
+
0
+ def collect_entries!
0
+ @entries = []
0
+ feeds.each do |feed|
0
+ @entries += feed.entries
0
+ end
0
+ end
0
   end
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.