Implement @mattr-'s suggestions
This commit is contained in:
parent
fe6bfc6f1b
commit
ac03af3229
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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" }
|
||||
|
|
|
@ -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" }
|
||||
|
|
Loading…
Reference in New Issue