From 482986e3467457ced56c814ce91fd04f387551ac Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Fri, 26 Apr 2013 20:21:17 +0200 Subject: [PATCH] Refactored setting of Post.published flag --- lib/jekyll/post.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 1ebb7f94..4e337e96 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -41,18 +41,11 @@ module Jekyll self.process(name) self.read_yaml(@base, name) - # If we've added a date and time to the YAML, use that instead of the - # filename date. Means we'll sort correctly. if self.data.has_key?('date') - # ensure Time via to_s and reparse self.date = Time.parse(self.data["date"].to_s) end - if self.data.has_key?('published') && self.data['published'] == false - self.published = false - else - self.published = true - end + self.published = self.is_published self.tags = self.data.pluralized_array("tag", "tags") @@ -64,6 +57,14 @@ module Jekyll self.categories.flatten! end + def is_published + if self.data.has_key?('published') && self.data['published'] == false + false + else + true + end + end + # Get the full path to the directory containing the post files def containing_dir(source, dir) return File.join(source, dir, '_posts')