Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
PlanetPostImporter runs a block after initializing Planet.
I think this way is easier to move to other projects, rather than allowing the executable to override the importer.
- Loading branch information
Federico Bana
committed
Dec 13, 2012
1 parent
db6ffd2
commit 1ea4d60
Showing
3 changed files
with
40 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
class PostImporter | ||
class PlanetPostImporter | ||
|
||
def self.import(planet) | ||
posts_dir = planet.config.fetch('posts_directory', 'source/_posts/') | ||
FileUtils.mkdir_p(posts_dir) | ||
puts "=> Writing #{ planet.posts.size } posts to the #{ posts_dir } directory." | ||
def self.import(config) | ||
|
||
planet.posts.each do |post| | ||
file_name = posts_dir + post.file_name | ||
planet = Planet.new(config) | ||
|
||
planet.aggregate | ||
|
||
yield(planet) | ||
|
||
File.open(file_name + '.markdown', "w+") { |f| f.write(post.to_s) } | ||
end | ||
end | ||
|
||
end |