Extracted `read_drafts` 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:19:39 +01:00
parent 29169aa858
commit 504c9a34ad
2 changed files with 17 additions and 17 deletions

View File

@ -74,6 +74,22 @@ module Jekyll
end end
end end
# Read all the files in <source>/<dir>/_drafts and create a new Post
# object with each one.
#
# dir - The String relative path of the directory to read.
#
# Returns nothing.
def read_drafts(dir)
drafts = read_content(dir, '_drafts', Draft)
drafts.each do |draft|
if draft.published?
aggregate_post_info(draft)
end
end
end
def read_content(dir, magic_dir, klass) def read_content(dir, magic_dir, klass)
get_entries(dir, magic_dir).map do |entry| get_entries(dir, magic_dir).map do |entry|
klass.new(site, site.source, dir, entry) if klass.valid?(entry) klass.new(site, site.source, dir, entry) if klass.valid?(entry)

View File

@ -147,7 +147,7 @@ module Jekyll
entries = Dir.chdir(base) { reader.filter_entries(Dir.entries('.'), base) } entries = Dir.chdir(base) { reader.filter_entries(Dir.entries('.'), base) }
read_posts(dir) read_posts(dir)
read_drafts(dir) if show_drafts reader.read_drafts(dir) if show_drafts
posts.sort! posts.sort!
limit_posts! if limit_posts > 0 # limit the posts if :limit_posts option is set limit_posts! if limit_posts > 0 # limit the posts if :limit_posts option is set
@ -182,22 +182,6 @@ module Jekyll
end end
end end
# Read all the files in <source>/<dir>/_drafts and create a new Post
# object with each one.
#
# dir - The String relative path of the directory to read.
#
# Returns nothing.
def read_drafts(dir)
drafts = reader.read_content(dir, '_drafts', Draft)
drafts.each do |draft|
if draft.published?
reader.aggregate_post_info(draft)
end
end
end
# Read in all collections specified in the configuration # Read in all collections specified in the configuration
# #
# Returns nothing. # Returns nothing.