diff --git a/lib/jekyll/cleaner.rb b/lib/jekyll/cleaner.rb index e7ee44a0..00191db7 100644 --- a/lib/jekyll/cleaner.rb +++ b/lib/jekyll/cleaner.rb @@ -13,7 +13,7 @@ module Jekyll # Cleans up the site's destination directory def cleanup! FileUtils.rm_rf(obsolete_files) - FileUtils.rm_rf(metadata_file) if @site.config["clean"] + FileUtils.rm_rf(metadata_file) if @site.config["full_rebuild"] end private diff --git a/lib/jekyll/command.rb b/lib/jekyll/command.rb index d463d235..423c3202 100644 --- a/lib/jekyll/command.rb +++ b/lib/jekyll/command.rb @@ -58,7 +58,7 @@ module Jekyll c.option 'unpublished', '--unpublished', 'Render posts that were marked as unpublished' c.option 'quiet', '-q', '--quiet', 'Silence output.' c.option 'verbose', '-V', '--verbose', 'Print verbose output.' - c.option 'clean', '-c', '--clean', 'Clean the site before rebuilding.' + c.option 'full_rebuild', '-f', '--full-rebuild', 'Clean the site before rebuilding.' end end diff --git a/lib/jekyll/configuration.rb b/lib/jekyll/configuration.rb index 24e96898..7f1148a6 100644 --- a/lib/jekyll/configuration.rb +++ b/lib/jekyll/configuration.rb @@ -17,7 +17,7 @@ module Jekyll # Handling Reading 'safe' => false, 'include' => ['.htaccess'], - 'exclude' => ['.jekyll-metadata'], + 'exclude' => [], 'keep_files' => ['.git','.svn'], 'encoding' => 'utf-8', 'markdown_ext' => 'markdown,mkdown,mkdn,mkd,md', diff --git a/lib/jekyll/metadata.rb b/lib/jekyll/metadata.rb index 275ee9da..2012afc6 100644 --- a/lib/jekyll/metadata.rb +++ b/lib/jekyll/metadata.rb @@ -7,9 +7,8 @@ module Jekyll def initialize(site) @site = site - # Initialize metadata store by reading YAML file, - # or an empty hash if file does not exist - @metadata = (File.file?(metadata_file) && !(site.config['clean'])) ? SafeYAML.load(File.read(metadata_file)) : {} + # Read metadata from file + read_metadata # Initialize cache to an empty hash @cache = {} @@ -92,5 +91,15 @@ module Jekyll def metadata_file Jekyll.sanitized_path(site.source, '.jekyll-metadata') end + + private + + # Read metadata from the metadata file, if no file is found, + # initialize with an empty hash + # + # Returns the read metadata. + def read_metadata + @metadata = (File.file?(metadata_file) && !(site.config['full_rebuild'])) ? SafeYAML.load(File.read(metadata_file)) : {} + end end end diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index f00e24c9..738cae0e 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -294,7 +294,7 @@ module Jekyll collections.each do |label, collection| collection.docs.each do |document| document.output = Jekyll::Renderer.new(self, document).run if ( - @metadata.regenerate?(document.path, document.write?) || + metadata.regenerate?(document.path, document.write?) || document.data['regenerate'] ) end @@ -303,7 +303,7 @@ module Jekyll payload = site_payload [posts, pages].flatten.each do |page_or_post| page_or_post.render(layouts, payload) if ( - @metadata.regenerate?(Jekyll.sanitized_path(source, page_or_post.relative_path)) || + metadata.regenerate?(Jekyll.sanitized_path(source, page_or_post.relative_path)) || page_or_post.data['regenerate'] ) end @@ -324,11 +324,11 @@ module Jekyll def write each_site_file { |item| item.write(dest) if ( - @metadata.regenerate?(Jekyll.sanitized_path(source, item.path)) || + metadata.regenerate?(Jekyll.sanitized_path(source, item.path)) || (item.respond_to?(:data) && item.data['regenerate']) ) } - @metadata.write + metadata.write end # Construct a Hash of Posts indexed by the specified Post attribute. diff --git a/test/test_document.rb b/test/test_document.rb index cf6c2cbf..2ff688ba 100644 --- a/test/test_document.rb +++ b/test/test_document.rb @@ -247,7 +247,7 @@ class TestDocument < Test::Unit::TestCase }, "source" => source_dir, "destination" => dest_dir, - "clean" => true + "full_rebuild" => true })) @site.process @document = @site.collections["slides"].files.find { |doc| doc.relative_path == "_slides/octojekyll.png" } diff --git a/test/test_site.rb b/test/test_site.rb index 2fd6ad36..a6ef5af8 100644 --- a/test/test_site.rb +++ b/test/test_site.rb @@ -331,7 +331,7 @@ class TestSite < Test::Unit::TestCase end bad_processor = "Custom::Markdown" - s = Site.new(site_configuration('markdown' => bad_processor, 'clean' => true)) + s = Site.new(site_configuration('markdown' => bad_processor, 'full_rebuild' => true)) assert_raise Jekyll::Errors::FatalException do s.process end @@ -351,7 +351,7 @@ class TestSite < Test::Unit::TestCase should 'throw FatalException at process time' do bad_processor = 'not a processor name' - s = Site.new(site_configuration('markdown' => bad_processor, 'clean' => true)) + s = Site.new(site_configuration('markdown' => bad_processor, 'full_rebuild' => true)) assert_raise Jekyll::Errors::FatalException do s.process end @@ -422,7 +422,7 @@ class TestSite < Test::Unit::TestCase context "manipulating the Jekyll environment" do setup do @site = Site.new(site_configuration({ - "clean" => true + 'full_rebuild' => true })) @site.process @page = @site.pages.find { |p| p.name == "environment.html" } @@ -436,7 +436,7 @@ class TestSite < Test::Unit::TestCase setup do ENV["JEKYLL_ENV"] = "production" @site = Site.new(site_configuration({ - "clean" => true + 'full_rebuild' => true })) @site.process @page = @site.pages.find { |p| p.name == "environment.html" }