Class: Planet

Inherits:
Object
  • Object
show all
Defined in:
lib/planet.rb,
lib/planet/blog.rb,
lib/planet/version.rb,
lib/planet/parsers/base_parser.rb

Defined Under Namespace

Modules: Version Classes: Blog, Importer, Parsers, Post

Constant Summary collapse

VERSION =
Version.to_s

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_file_path) ⇒ Planet

Returns a new instance of Planet.



10
11
12
13
14
15
# 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

Instance Attribute Details

#blogsObject

Returns the value of attribute blogs.



8
9
10
# File 'lib/planet.rb', line 8

def blogs
  @blogs
end

#configObject

Returns the value of attribute config.



8
9
10
# File 'lib/planet.rb', line 8

def config
  @config
end

#whitelisted_tagsObject

Returns the value of attribute whitelisted_tags.



8
9
10
# File 'lib/planet.rb', line 8

def whitelisted_tags
  @whitelisted_tags
end

Instance Method Details

#aggregateObject



21
22
23
24
25
26
# File 'lib/planet.rb', line 21

def aggregate
  self.blogs.each do |blog|
    puts "=> Parsing #{ blog.feed }"
    blog.fetch
  end
end

#postsObject



17
18
19
# File 'lib/planet.rb', line 17

def posts
  self.blogs.map { |b| b.posts }.flatten
end

#write_postsObject



28
29
30
# File 'lib/planet.rb', line 28

def write_posts
  Importer.import(self)
end