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:
parent
504c9a34ad
commit
a4adeb446b
|
@ -74,6 +74,20 @@ module Jekyll
|
||||||
end
|
end
|
||||||
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
|
# Read all the files in <source>/<dir>/_drafts and create a new Post
|
||||||
# object with each one.
|
# object with each one.
|
||||||
#
|
#
|
||||||
|
|
|
@ -146,7 +146,7 @@ module Jekyll
|
||||||
base = reader.in_source_dir(dir)
|
base = reader.in_source_dir(dir)
|
||||||
entries = Dir.chdir(base) { reader.filter_entries(Dir.entries('.'), base) }
|
entries = Dir.chdir(base) { reader.filter_entries(Dir.entries('.'), base) }
|
||||||
|
|
||||||
read_posts(dir)
|
reader.read_posts(dir)
|
||||||
reader.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
|
||||||
|
@ -168,20 +168,6 @@ module Jekyll
|
||||||
static_files.sort_by!(&:relative_path)
|
static_files.sort_by!(&:relative_path)
|
||||||
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 = 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
|
# Read in all collections specified in the configuration
|
||||||
#
|
#
|
||||||
# Returns nothing.
|
# Returns nothing.
|
||||||
|
|
|
@ -189,7 +189,7 @@ class TestSite < JekyllUnitTest
|
||||||
end
|
end
|
||||||
|
|
||||||
should "read posts" do
|
should "read posts" do
|
||||||
@site.read_posts('')
|
@site.reader.read_posts('')
|
||||||
posts = Dir[source_dir('_posts', '**', '*')]
|
posts = Dir[source_dir('_posts', '**', '*')]
|
||||||
posts.delete_if { |post| File.directory?(post) && !Post.valid?(post) }
|
posts.delete_if { |post| File.directory?(post) && !Post.valid?(post) }
|
||||||
assert_equal posts.size - @num_invalid_posts, @site.posts.size
|
assert_equal posts.size - @num_invalid_posts, @site.posts.size
|
||||||
|
|
|
@ -13,7 +13,7 @@ class TestTags < JekyllUnitTest
|
||||||
site = Site.new(Jekyll.configuration)
|
site = Site.new(Jekyll.configuration)
|
||||||
|
|
||||||
if override['read_posts']
|
if override['read_posts']
|
||||||
site.read_posts('')
|
site.reader.read_posts('')
|
||||||
end
|
end
|
||||||
|
|
||||||
info = { :filters => [Jekyll::Filters], :registers => { :site => site } }
|
info = { :filters => [Jekyll::Filters], :registers => { :site => site } }
|
||||||
|
|
Loading…
Reference in New Issue