rubocop: refactor modified? method
This commit is contained in:
parent
d13112dbdc
commit
0b169f7739
|
@ -90,7 +90,14 @@ module Jekyll
|
||||||
return cache[path]
|
return cache[path]
|
||||||
end
|
end
|
||||||
|
|
||||||
check_path_exists(path)
|
if metadata[path]
|
||||||
|
# If we have seen this file before,
|
||||||
|
# check if it or one of its dependencies has been modified
|
||||||
|
existing_file_modified?(path)
|
||||||
|
else
|
||||||
|
# If we have not seen this file before, add it to the metadata and regenerate it
|
||||||
|
add(path)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add a dependency of a path
|
# Add a dependency of a path
|
||||||
|
@ -170,25 +177,23 @@ module Jekyll
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Private: Check path that exists in metadata
|
|
||||||
#
|
|
||||||
# Returns Boolean
|
|
||||||
private
|
private
|
||||||
def check_path_exists(path)
|
def existing_file_modified?(path)
|
||||||
data = metadata[path]
|
# If one of this file dependencies have been modified,
|
||||||
if data
|
# set the regeneration bit for both the dependency and the file to true
|
||||||
data["deps"].each do |dependency|
|
metadata[path]["deps"].each do |dependency|
|
||||||
if modified?(dependency)
|
if modified?(dependency)
|
||||||
return cache[dependency] = cache[path] = true
|
return cache[dependency] = cache[path] = true
|
||||||
end
|
|
||||||
end
|
|
||||||
if File.exist?(path) && data["mtime"].eql?(File.mtime(path))
|
|
||||||
return cache[path] = false
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Path does not exist in metadata, add it
|
if File.exist?(path) && metadata[path]["mtime"].eql?(File.mtime(path))
|
||||||
add(path)
|
# If this file has not been modified, set the regeneration bit to false
|
||||||
|
cache[path] = false
|
||||||
|
else
|
||||||
|
# If it has been modified, set it to true
|
||||||
|
add(path)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue