public
Description: A 'planet' like feed aggregator using feedparser and erubis
Clone URL: git://github.com/technicalpickles/feedbarn.git
New 'barns' directory to put barn configs in. Farmer now loads all 
blueprints for barns at initialization time.
Fri Feb 22 10:00:01 -0800 2008
commit  b179b1d07fae3d21cc1712e6181092063f5dc59a
tree    a725d43ff66fb4da0e1cc738f85cd8d9341221ac
parent  95c6df75533abc53a8dab4d894ff86590811aa2d
...
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
...
38
39
40
 
41
42
43
44
45
46
47
 
 
 
 
 
 
 
 
48
49
50
51
...
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
...
40
41
42
43
44
45
46
47
48
 
 
49
50
51
52
53
54
55
56
57
58
59
60
0
@@ -8,28 +8,30 @@ module FeedBarn
0
   class Farmer
0
     CONFIG = 'config/feeds.yaml'
0
     
0
- attr_accessor :config, :barns
0
+ attr_accessor :config, :barns, :blueprints
0
     
0
     def initialize()
0
       self.config = YAML.load_file('config/settings.yml')
0
       self.barns = {}
0
+
0
+ self.blueprints = {}
0
+ Dir.glob('config/barns/*.yml').each do |config_path|
0
+ barn_name = yank_barn_name_from config_path
0
+ self.blueprints[barn_name] = load_blueprint_from config_path
0
+ end
0
     end
0
     
0
- def feed_urls
0
- self.config['feeds'].collect { |feed|
0
- feed['url']
0
- }
0
- end
0
-
0
+ # Builds out a barn
0
     def build barn_name
0
- barn_config = load_config_for barn_name
0
- barns[barn_config['title']] = Barn.new(barn_name, barn_config)
0
+ blueprint = blueprints[barn_name]
0
+ barns[blueprint['title']] = Barn.new(barn_name, blueprint)
0
     end
0
     
0
+ # Populates a barn with feeds
0
     def fill barn
0
       barn.feeds = []
0
 
0
- load_config_for(barn.name)['feeds'].each do |feed_config|
0
+ blueprints[barn.name]['feeds'].each do |feed_config|
0
         url = feed_config['url']
0
         downloaded_feed = FeedNormalizer::FeedNormalizer.parse(open(url))
0
         barn.feeds << Feed.new(downloaded_feed, feed_config)
0
@@ -38,13 +40,20 @@ module FeedBarn
0
       barn.feeds
0
     end
0
     
0
+ # Gets a showcase ready
0
     def prepare_showcase barn
0
       FeedBarn::Showcase.new(barn)
0
     end
0
     
0
     private
0
- def load_config_for barn_name
0
- YAML.load_file("config/#{barn_name}.yml")
0
+
0
+ # Loads a config a particular barn
0
+ def load_blueprint_from barn_yml
0
+ YAML.load_file(barn_yml)
0
+ end
0
+
0
+ def yank_barn_name_from filename
0
+ File.basename(filename).gsub(/\.yml$/,'')
0
     end
0
   end
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.