Extracted `read_content` from site.rb into reader.rb

- Extracted
 - Updated References
 - Ran Tests

Signed-off-by: Martin Jorn Rogalla <martin@martinrogalla.com>
This commit is contained in:
Martin Jorn Rogalla 2015-03-04 20:11:27 +01:00
parent 537235c38b
commit 67a2369854
2 changed files with 10 additions and 10 deletions

View File

@ -74,6 +74,14 @@ module Jekyll
end end
end end
def read_content(dir, magic_dir, klass)
get_entries(dir, magic_dir).map do |entry|
klass.new(site, site.source, dir, entry) if klass.valid?(entry)
end.reject do |entry|
entry.nil?
end
end
# Read and parse all yaml files under <source>/<dir> # Read and parse all yaml files under <source>/<dir>
# #
# Returns nothing # Returns nothing

View File

@ -175,7 +175,7 @@ module Jekyll
# #
# Returns nothing. # Returns nothing.
def read_posts(dir) def read_posts(dir)
posts = read_content(dir, '_posts', Post) posts = reader.read_content(dir, '_posts', Post)
posts.each do |post| posts.each do |post|
aggregate_post_info(post) if publisher.publish?(post) aggregate_post_info(post) if publisher.publish?(post)
@ -189,7 +189,7 @@ module Jekyll
# #
# Returns nothing. # Returns nothing.
def read_drafts(dir) def read_drafts(dir)
drafts = read_content(dir, '_drafts', Draft) drafts = reader.read_content(dir, '_drafts', Draft)
drafts.each do |draft| drafts.each do |draft|
if draft.published? if draft.published?
@ -198,14 +198,6 @@ module Jekyll
end end
end end
def read_content(dir, magic_dir, klass)
reader.get_entries(dir, magic_dir).map do |entry|
klass.new(self, source, dir, entry) if klass.valid?(entry)
end.reject do |entry|
entry.nil?
end
end
# Read in all collections specified in the configuration # Read in all collections specified in the configuration
# #
# Returns nothing. # Returns nothing.