module Jekyll::Incremental
– @note we replace theirs in-place. @example bundle exec jekyll b –incremental A replacement of Jekyll's Regenerator
. That does a
few things a bit differently, most things.
–
Constants
- CACHE_KEY
- FORCE_KEYS
- VERSION
Public Instance Methods
add(path, forced: false)
click to toggle source
– seen_before address a logical race that happens
incide of Jekyll. Dependencies are added before dependents, which is not good at all.
–
# File lib/jekyll-incremental.rb, line 113 def add(path, forced: false) return metadata[path] if metadata.key?(path) metadata[path] = { seen_before: false, dynamic: !File.exist?(site.in_source_dir(path)), last_modified: file_mtime_of(path), dependencies: Set.new, forced: forced, } end
add_dependency(path, dependency)
click to toggle source
–
# File lib/jekyll-incremental.rb, line 125 def add_dependency(path, dependency) add(path).fetch(:dependencies) << dependency end
cache()
– They are one in the same now, there is no reason to
have something that is different as we will eventually write it anyways. Seems redundant.
–
Alias for: metadata
clear()
click to toggle source
–
# File lib/jekyll-incremental.rb, line 151 def clear @metadata = nil Jekyll.cache.delete(CACHE_KEY) metadata end
dependencies_modified?(path)
click to toggle source
–
# File lib/jekyll-incremental.rb, line 89 def dependencies_modified?(path) path[:dependencies].map { |v| modified?(v) } .include?(true) end
disabled?()
click to toggle source
# File lib/jekyll-incremental.rb, line 19 def disabled? !site.incremental? || (site.config.key?("incremental") && !site.config["incremental"]) end
existing_file_modified?(doc)
– They are one in the same now, there is no reason to
have something that is different as we will eventually call this anyways.
–
Alias for: modified?
file_mtime_of(path)
click to toggle source
–
# File lib/jekyll-incremental.rb, line 104 def file_mtime_of(path) File.exist?(path) ? File.mtime(path) : Time.now end
force(path)
click to toggle source
–
# File lib/jekyll-incremental.rb, line 130 def force(path) add(path, { force: true, }) end
forced_by_data?(doc)
click to toggle source
–
# File lib/jekyll-incremental.rb, line 65 def forced_by_data?(doc) doc.data.values_at(FORCE_KEYS) .include?(true) end
metadata()
click to toggle source
–
# File lib/jekyll-incremental.rb, line 137 def metadata @metadata ||= Jekyll.cache.fetch(CACHE_KEY) do {} end end
Also aliased as: cache
metadata_file()
click to toggle source
–
# File lib/jekyll-incremental.rb, line 180 def metadata_file site.in_source_dir(".jekyll-metadata") end
modified?(doc)
click to toggle source
– rubocop:disable Metrics/PerceivedComplexity rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/LineLength rubocop:disable Metrics/AbcSize –
# File lib/jekyll-incremental.rb, line 76 def modified?(doc) return true if metadata[doc.path]&.[](:forced) return true unless File.exist?(site.in_dest_dir(doc.path)) modified, hash = file_mtime_of(doc.path), metadata[doc.path] return modified > hash[:last_modified] if hash && !hash[:dynamic] && hash[:seen_before] return hash[:seen_before] = true if hash && !hash[:seen_before] return dependencies_modified?(hash) if hash add(doc.path).update(seen_before: true) true end
Also aliased as: existing_file_modified?, source_modified_or_dest_missing?
regenerate?(doc)
click to toggle source
– {
<Filename> => { last_modified => Time.now, forced => true|false dependencies => [ <FileName> ] }
} – Determines if a file should be regenerated or not,
this is determined by a few key things, such as whether you force it by metadata inside of your file, or whether the file has been modified.
–
# File lib/jekyll-incremental.rb, line 40 def regenerate?(doc) out = false unless doc.write? out = true if doc.respond_to?(:asset_file?) && doc.asset_file? out = true if forced_by_data?(doc) out = modified?(doc) # -- # Make sure they know. # -- Jekyll.logger.debug "Incremental" do "#{out} for #{doc.path}" end out end
regenerate_page?(doc)
– They are one in the same now, there is no reason to
have something that is different. These still exist for people who manually call this stuff.
–
Alias for: regenerate?
write_metadata()
click to toggle source
– Write the metadata into the Jekyll
cache. @return [nil] –
# File lib/jekyll-incremental.rb, line 161 def write_metadata unless disabled? Jekyll.cache.write(CACHE_KEY, cache) end end