Implement more suggestions
This commit is contained in:
parent
dc30114605
commit
8a257aca6b
|
@ -58,8 +58,7 @@ module Jekyll
|
||||||
c.option 'unpublished', '--unpublished', 'Render posts that were marked as unpublished'
|
c.option 'unpublished', '--unpublished', 'Render posts that were marked as unpublished'
|
||||||
c.option 'quiet', '-q', '--quiet', 'Silence output.'
|
c.option 'quiet', '-q', '--quiet', 'Silence output.'
|
||||||
c.option 'verbose', '-V', '--verbose', 'Print verbose output.'
|
c.option 'verbose', '-V', '--verbose', 'Print verbose output.'
|
||||||
c.option 'full_rebuild', '-f', '--full-rebuild', 'Clean the site before rebuilding.'
|
c.option 'full_rebuild', '-f', '--full-rebuild', 'Disable incremental rebuild.'
|
||||||
c.option 'no_metadata', '--no-metadata', 'Disable incremental regeneration.'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,10 +5,6 @@ module Jekyll
|
||||||
def initialize(site)
|
def initialize(site)
|
||||||
@site = site
|
@site = site
|
||||||
|
|
||||||
# Configuration options
|
|
||||||
@full_rebuild = site.config['full_rebuild']
|
|
||||||
@disabled = site.config['no_metadata']
|
|
||||||
|
|
||||||
# Read metadata from file
|
# Read metadata from file
|
||||||
read_metadata
|
read_metadata
|
||||||
|
|
||||||
|
@ -48,7 +44,7 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns a boolean.
|
# Returns a boolean.
|
||||||
def regenerate?(path, add = true)
|
def regenerate?(path, add = true)
|
||||||
return true if @disabled
|
return true if disabled?
|
||||||
|
|
||||||
# Check for path in cache
|
# Check for path in cache
|
||||||
if cache.has_key? path
|
if cache.has_key? path
|
||||||
|
@ -56,7 +52,8 @@ module Jekyll
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check path that exists in metadata
|
# Check path that exists in metadata
|
||||||
if data = metadata[path]
|
data = metadata[path]
|
||||||
|
if data
|
||||||
data["deps"].each do |dependency|
|
data["deps"].each do |dependency|
|
||||||
if regenerate?(dependency)
|
if regenerate?(dependency)
|
||||||
return cache[dependency] = cache[path] = true
|
return cache[dependency] = cache[path] = true
|
||||||
|
@ -99,6 +96,14 @@ module Jekyll
|
||||||
site.in_source_dir('.jekyll-metadata')
|
site.in_source_dir('.jekyll-metadata')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Check if metadata has been disabled
|
||||||
|
#
|
||||||
|
# Returns a Boolean (true for disabled, false for enabled).
|
||||||
|
def disabled?
|
||||||
|
@disabled = site.config['full_rebuild'] if @disabled.nil?
|
||||||
|
@disabled
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Read metadata from the metadata file, if no file is found,
|
# Read metadata from the metadata file, if no file is found,
|
||||||
|
@ -106,7 +111,7 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns the read metadata.
|
# Returns the read metadata.
|
||||||
def read_metadata
|
def read_metadata
|
||||||
@metadata = if !(@full_rebuild || @disabled) && File.file?(metadata_file)
|
@metadata = if !disabled? && File.file?(metadata_file)
|
||||||
SafeYAML.load(File.read(metadata_file))
|
SafeYAML.load(File.read(metadata_file))
|
||||||
else
|
else
|
||||||
{}
|
{}
|
||||||
|
|
|
@ -319,7 +319,7 @@ module Jekyll
|
||||||
each_site_file { |item|
|
each_site_file { |item|
|
||||||
item.write(dest) if item.regenerate?
|
item.write(dest) if item.regenerate?
|
||||||
}
|
}
|
||||||
metadata.write unless config['no_metadata']
|
metadata.write unless config['full_rebuild']
|
||||||
end
|
end
|
||||||
|
|
||||||
# Construct a Hash of Posts indexed by the specified Post attribute.
|
# Construct a Hash of Posts indexed by the specified Post attribute.
|
||||||
|
|
Loading…
Reference in New Issue