Extracted `read_posts` 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:22:37 +01:00
parent 504c9a34ad
commit a4adeb446b
4 changed files with 17 additions and 17 deletions

View File

@ -74,6 +74,20 @@ module Jekyll
end
end
# Read all the files in <source>/<dir>/_posts and create a new Post
# object with each one.
#
# dir - The String relative path of the directory to read.
#
# Returns nothing.
def read_posts(dir)
posts = read_content(dir, '_posts', Post)
posts.each do |post|
aggregate_post_info(post) if site.publisher.publish?(post)
end
end
# Read all the files in <source>/<dir>/_drafts and create a new Post
# object with each one.
#

View File

@ -146,7 +146,7 @@ module Jekyll
base = reader.in_source_dir(dir)
entries = Dir.chdir(base) { reader.filter_entries(Dir.entries('.'), base) }
read_posts(dir)
reader.read_posts(dir)
reader.read_drafts(dir) if show_drafts
posts.sort!
limit_posts! if limit_posts > 0 # limit the posts if :limit_posts option is set
@ -168,20 +168,6 @@ module Jekyll
static_files.sort_by!(&:relative_path)
end
# Read all the files in <source>/<dir>/_posts and create a new Post
# object with each one.
#
# dir - The String relative path of the directory to read.
#
# Returns nothing.
def read_posts(dir)
posts = reader.read_content(dir, '_posts', Post)
posts.each do |post|
reader.aggregate_post_info(post) if publisher.publish?(post)
end
end
# Read in all collections specified in the configuration
#
# Returns nothing.

View File

@ -189,7 +189,7 @@ class TestSite < JekyllUnitTest
end
should "read posts" do
@site.read_posts('')
@site.reader.read_posts('')
posts = Dir[source_dir('_posts', '**', '*')]
posts.delete_if { |post| File.directory?(post) && !Post.valid?(post) }
assert_equal posts.size - @num_invalid_posts, @site.posts.size

View File

@ -13,7 +13,7 @@ class TestTags < JekyllUnitTest
site = Site.new(Jekyll.configuration)
if override['read_posts']
site.read_posts('')
site.reader.read_posts('')
end
info = { :filters => [Jekyll::Filters], :registers => { :site => site } }