diff --git a/lib/jekyll/configuration.rb b/lib/jekyll/configuration.rb index 24c96e0f..4bc41682 100644 --- a/lib/jekyll/configuration.rb +++ b/lib/jekyll/configuration.rb @@ -16,7 +16,7 @@ module Jekyll 'safe' => false, 'show_drafts' => nil, - 'limit_posts' => nil, + 'limit_posts' => 0, 'lsi' => false, 'future' => true, # remove and make true just default 'pygments' => true, # remove and make true just default diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 7a4e15f0..107b0951 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -28,7 +28,7 @@ module Jekyll self.future = config['future'] self.show_drafts = config['show_drafts'] # given as String if it is came from CLI option - self.limit_posts = config['limit_posts'].nil? ? nil : config["limit_posts"].to_i + self.limit_posts = config['limit_posts'].to_i self.keep_files = config['keep_files'] self.reset @@ -63,8 +63,8 @@ module Jekyll self.categories = Hash.new { |hash, key| hash[key] = [] } self.tags = Hash.new { |hash, key| hash[key] = [] } - if !self.limit_posts.nil? && self.limit_posts < 1 - raise ArgumentError, "Limit posts must be nil or >= 1" + if self.limit_posts < 0 + raise ArgumentError, "Limit posts must be nil or >= 0" end end @@ -149,7 +149,7 @@ module Jekyll self.posts.sort! # limit the posts if :limit_posts option is set - if limit_posts + unless limit_posts.zero? limit = self.posts.length < limit_posts ? self.posts.length : limit_posts self.posts = self.posts[-limit, limit] end diff --git a/test/test_generated_site.rb b/test/test_generated_site.rb index bb6a6eb0..4d12867f 100644 --- a/test/test_generated_site.rb +++ b/test/test_generated_site.rb @@ -58,11 +58,11 @@ class TestGeneratedSite < Test::Unit::TestCase assert_equal 5, @site.posts.size end - should "ensure limit posts is 1 or more" do + should "ensure limit posts is 0 or more" do assert_raise ArgumentError do clear_dest stub(Jekyll).configuration do - Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir, 'limit_posts' => 0}) + Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir, 'limit_posts' => -1}) end @site = Site.new(Jekyll.configuration)