Rubocop: lib/jekyll/readers/post_reader.rb

This commit is contained in:
Pat Hawks 2016-05-26 00:10:31 -05:00
parent 615a9ee9ac
commit 0696e6c169
1 changed files with 6 additions and 5 deletions

View File

@ -12,7 +12,7 @@ module Jekyll
# #
# Returns nothing. # Returns nothing.
def read_drafts(dir) def read_drafts(dir)
read_publishable(dir, '_drafts', Document::DATELESS_FILENAME_MATCHER) read_publishable(dir, "_drafts", Document::DATELESS_FILENAME_MATCHER)
end end
# Read all the files in <source>/<dir>/_posts and create a new Document # Read all the files in <source>/<dir>/_posts and create a new Document
@ -22,7 +22,7 @@ module Jekyll
# #
# Returns nothing. # Returns nothing.
def read_posts(dir) def read_posts(dir)
read_publishable(dir, '_posts', Document::DATE_FILENAME_MATCHER) read_publishable(dir, "_posts", Document::DATE_FILENAME_MATCHER)
end end
# Read all the files in <source>/<dir>/<magic_dir> and create a new # Read all the files in <source>/<dir>/<magic_dir> and create a new
@ -32,9 +32,10 @@ module Jekyll
# #
# Returns nothing. # Returns nothing.
def read_publishable(dir, magic_dir, matcher) def read_publishable(dir, magic_dir, matcher)
read_content(dir, magic_dir, matcher).tap do |docs| documents = read_content(dir, magic_dir, matcher).tap do |docs|
docs.each(&:read) docs.each(&:read)
end.select do |doc| end
documents.select do |doc|
site.publisher.publish?(doc).tap do |will_publish| site.publisher.publish?(doc).tap do |will_publish|
if !will_publish && site.publisher.hidden_in_the_future?(doc) if !will_publish && site.publisher.hidden_in_the_future?(doc)
Jekyll.logger.debug "Skipping:", "#{doc.relative_path} has a future date" Jekyll.logger.debug "Skipping:", "#{doc.relative_path} has a future date"
@ -57,7 +58,7 @@ module Jekyll
next unless entry =~ matcher next unless entry =~ matcher
path = @site.in_source_dir(File.join(dir, magic_dir, entry)) path = @site.in_source_dir(File.join(dir, magic_dir, entry))
Document.new(path, { Document.new(path, {
:site => @site, :site => @site,
:collection => @site.posts :collection => @site.posts
}) })
end.reject(&:nil?) end.reject(&:nil?)