diff --git a/lib/jekyll/reader.rb b/lib/jekyll/reader.rb index 96da74fa..deff185b 100644 --- a/lib/jekyll/reader.rb +++ b/lib/jekyll/reader.rb @@ -74,6 +74,20 @@ module Jekyll end end + # Read all the files in //_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 //_drafts and create a new Post # object with each one. # diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 5b2854d7..3dc5884f 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -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 //_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. diff --git a/test/test_site.rb b/test/test_site.rb index 2e0adbbf..c132bdda 100644 --- a/test/test_site.rb +++ b/test/test_site.rb @@ -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 diff --git a/test/test_tags.rb b/test/test_tags.rb index 4db4ab85..eb998423 100644 --- a/test/test_tags.rb +++ b/test/test_tags.rb @@ -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 } }