class Planet
Constants
- VERSION
Attributes
blogs[RW]
config[RW]
Public Class Methods
new(config_file_path)
click to toggle source
# File lib/planet.rb, line 10 def initialize(config_file_path) config_file = read_config_file(config_file_path) self.config = config_file[:planet] self.blogs = config_file[:blogs] self.whitelisted_tags = self.config['whitelisted_tags'] end
Public Instance Methods
aggregate()
click to toggle source
# File lib/planet.rb, line 21 def aggregate self.blogs.each do |blog| puts "=> Parsing #{ blog.feed }" blog.fetch end end
posts()
click to toggle source
# File lib/planet.rb, line 17 def posts self.blogs.map { |b| b.posts }.flatten end
write_posts()
click to toggle source
# File lib/planet.rb, line 28 def write_posts Importer.import(self) end
Private Instance Methods
read_config_file(config_file_path)
click to toggle source
# File lib/planet.rb, line 34 def read_config_file(config_file_path) config = YAML.load_file(config_file_path) planet = config.fetch('planet', {}) blogs = config.fetch('blogs', []).map do |blog| Blog.new( feed: blog['feed'], url: blog['url'], author: blog['author'], image: blog['image'], posts: [], planet: self, twitter: blog['twitter'], categories: blog['categories'], tags: blog['tags'] ) end { planet: planet, blogs: blogs } end