From a28f54a59fac7ac59e3189dec400637cd573bd1d Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Sun, 9 Sep 2018 18:14:46 -0400 Subject: [PATCH] Bump Rubocop to v0.59.0 (#7237) Merge pull request 7237 --- .rubocop.yml | 5 +++-- Gemfile | 2 +- lib/jekyll/cache.rb | 8 ++++++++ lib/jekyll/cleaner.rb | 1 + lib/jekyll/collection.rb | 4 ++++ lib/jekyll/command.rb | 1 + lib/jekyll/commands/doctor.rb | 7 +++++++ lib/jekyll/commands/serve.rb | 1 + lib/jekyll/configuration.rb | 1 + lib/jekyll/converters/markdown.rb | 1 + lib/jekyll/convertible.rb | 1 + lib/jekyll/document.rb | 2 ++ lib/jekyll/drops/document_drop.rb | 1 + lib/jekyll/drops/drop.rb | 1 + lib/jekyll/drops/site_drop.rb | 1 + lib/jekyll/entry_filter.rb | 1 + lib/jekyll/excerpt.rb | 1 + lib/jekyll/external.rb | 1 + lib/jekyll/filters.rb | 10 ++++++++++ lib/jekyll/filters/date_filters.rb | 4 ++++ lib/jekyll/filters/url_filters.rb | 6 ++++++ lib/jekyll/frontmatter_defaults.rb | 2 ++ lib/jekyll/hooks.rb | 1 + lib/jekyll/log_adapter.rb | 1 + lib/jekyll/plugin_manager.rb | 2 ++ lib/jekyll/reader.rb | 2 ++ lib/jekyll/readers/layout_reader.rb | 1 + lib/jekyll/readers/post_reader.rb | 1 + lib/jekyll/readers/theme_assets_reader.rb | 1 + lib/jekyll/regenerator.rb | 1 + lib/jekyll/renderer.rb | 9 +++++---- lib/jekyll/site.rb | 2 ++ lib/jekyll/static_file.rb | 1 + lib/jekyll/stevenson.rb | 1 + lib/jekyll/tags/post_url.rb | 1 + lib/jekyll/theme.rb | 1 + lib/jekyll/url.rb | 1 + lib/jekyll/utils.rb | 3 +++ lib/jekyll/utils/platforms.rb | 13 ++++++------- test/test_regenerator.rb | 1 + 40 files changed, 91 insertions(+), 14 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 63094135..745a1232 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -88,9 +88,10 @@ Naming/HeredocDelimiterNaming: - test/**/*.rb Naming/MemoizedInstanceVariableName: Exclude: - - lib/jekyll/page_without_a_file.rb - - lib/jekyll/drops/unified_payload_drop.rb + - lib/jekyll/convertible.rb - lib/jekyll/drops/site_drop.rb + - lib/jekyll/drops/unified_payload_drop.rb + - lib/jekyll/page_without_a_file.rb Naming/UncommunicativeMethodParamName: AllowedNames: - _ diff --git a/Gemfile b/Gemfile index 34e9be49..88d0f4d7 100644 --- a/Gemfile +++ b/Gemfile @@ -25,7 +25,7 @@ group :test do gem "nokogiri", "~> 1.7" gem "rspec" gem "rspec-mocks" - gem "rubocop", "~> 0.57.2" + gem "rubocop", "~> 0.59.0" gem "test-dependency-theme", :path => File.expand_path("test/fixtures/test-dependency-theme", __dir__) gem "test-theme", :path => File.expand_path("test/fixtures/test-theme", __dir__) diff --git a/lib/jekyll/cache.rb b/lib/jekyll/cache.rb index ae5138e0..abf3610c 100644 --- a/lib/jekyll/cache.rb +++ b/lib/jekyll/cache.rb @@ -43,6 +43,7 @@ module Jekyll # Returns cached value def [](key) return @cache[key] if @cache.key?(key) + path = path_to(hash(key)) if @@disk_cache_enabled && File.file?(path) && File.readable?(path) @cache[key] = load(path) @@ -57,6 +58,7 @@ module Jekyll def []=(key, value) @cache[key] = value return unless @@disk_cache_enabled + path = path_to(hash(key)) dump(path, value) end @@ -78,6 +80,7 @@ module Jekyll def delete(key) @cache.delete(key) return unless @@disk_cache_enabled + path = path_to(hash(key)) File.delete(path) end @@ -91,6 +94,7 @@ module Jekyll # Otherwise, it might be cached on disk # but we should not consider the disk cache if it is disabled return false unless @@disk_cache_enabled + path = path_to(hash(key)) File.file?(path) && File.readable?(path) end @@ -103,6 +107,7 @@ module Jekyll config = config.inspect cache = Jekyll::Cache.new "Jekyll::Cache" return if cache.key?("config") && cache["config"] == config + clear cache = Jekyll::Cache.new "Jekyll::Cache" cache["config"] = config @@ -116,6 +121,7 @@ module Jekyll def path_to(hash = nil) @base_dir ||= File.join(@@base_dir, @name) return @base_dir if hash.nil? + File.join(@base_dir, hash[0..1], hash[2..-1]).freeze end @@ -145,6 +151,7 @@ module Jekyll # rubocop:disable Security/MarshalLoad def load(path) raise unless @@disk_cache_enabled + cached_file = File.open(path, "rb") value = Marshal.load(cached_file) cached_file.close @@ -158,6 +165,7 @@ module Jekyll # Returns nothing. def dump(path, value) return unless @@disk_cache_enabled + dir = File.dirname(path) FileUtils.mkdir_p(dir) File.open(path, "wb") do |cached_file| diff --git a/lib/jekyll/cleaner.rb b/lib/jekyll/cleaner.rb index 36d28a9b..2ad0f17a 100644 --- a/lib/jekyll/cleaner.rb +++ b/lib/jekyll/cleaner.rb @@ -45,6 +45,7 @@ module Jekyll Utils.safe_glob(site.in_dest_dir, ["**", "*"], File::FNM_DOTMATCH).each do |file| next if file =~ HIDDEN_FILE_REGEX || file =~ regex || dirs.include?(file) + files << file end diff --git a/lib/jekyll/collection.rb b/lib/jekyll/collection.rb index e4af6a3a..1ead17b3 100644 --- a/lib/jekyll/collection.rb +++ b/lib/jekyll/collection.rb @@ -58,6 +58,7 @@ module Jekyll filtered_entries.each do |file_path| full_path = collection_dir(file_path) next if File.directory?(full_path) + if Utils.has_yaml_header? full_path read_document(full_path) else @@ -73,6 +74,7 @@ module Jekyll # relative to the collection's directory def entries return [] unless exists? + @entries ||= Utils.safe_glob(collection_dir, ["**", "*"], File::FNM_DOTMATCH).map do |entry| entry["#{collection_dir}/"] = "" @@ -86,6 +88,7 @@ module Jekyll # Returns a list of filtered entry paths. def filtered_entries return [] unless exists? + @filtered_entries ||= Dir.chdir(directory) do entry_filter.filter(entries).reject do |f| @@ -124,6 +127,7 @@ module Jekyll # is stored on the filesystem. def collection_dir(*files) return directory if files.empty? + site.in_source_dir(container, relative_directory, *files) end diff --git a/lib/jekyll/command.rb b/lib/jekyll/command.rb index d81ccef5..9918c890 100644 --- a/lib/jekyll/command.rb +++ b/lib/jekyll/command.rb @@ -40,6 +40,7 @@ module Jekyll # Returns a full Jekyll configuration def configuration_from_options(options) return options if options.is_a?(Jekyll::Configuration) + Jekyll.configuration(options) end diff --git a/lib/jekyll/commands/doctor.rb b/lib/jekyll/commands/doctor.rb index 4cc196cd..1cfc5f23 100644 --- a/lib/jekyll/commands/doctor.rb +++ b/lib/jekyll/commands/doctor.rb @@ -45,8 +45,10 @@ module Jekyll def properly_gathered_posts?(site) return true if site.config["collections_dir"].empty? + posts_at_root = site.in_source_dir("_posts") return true unless File.directory?(posts_at_root) + Jekyll.logger.warn "Warning:", "Detected '_posts' directory outside custom `collections_dir`!" Jekyll.logger.warn "", @@ -70,6 +72,7 @@ module Jekyll urls = collect_urls(urls, site.posts.docs, site.dest) urls.each do |url, paths| next unless paths.size > 1 + conflicting_urls = true Jekyll.logger.warn "Conflict:", "The URL '#{url}' is the destination" \ " for the following pages: #{paths.join(", ")}" @@ -79,6 +82,7 @@ module Jekyll def fsnotify_buggy?(_site) return true unless Utils::Platforms.osx? + if Dir.pwd != `pwd`.strip Jekyll.logger.error " " + <<-STR.strip.gsub(%r!\n\s+!, "\n ") We have detected that there might be trouble using fsevent on your @@ -98,6 +102,7 @@ module Jekyll urls = case_insensitive_urls(site.pages + site.docs_to_write, site.dest) urls.each_value do |real_urls| next unless real_urls.uniq.size > 1 + urls_only_differ_by_case = true Jekyll.logger.warn "Warning:", "The following URLs only differ" \ " by case. On a case-insensitive file system one of the URLs" \ @@ -138,6 +143,7 @@ module Jekyll def url_exists?(url) return true unless url.nil? || url.empty? + Jekyll.logger.warn "Warning:", "You didn't set an URL in the config file, "\ "you may encounter problems with some plugins." false @@ -156,6 +162,7 @@ module Jekyll def url_absolute(url) return true if Addressable::URI.parse(url).absolute? + Jekyll.logger.warn "Warning:", "Your site URL does not seem to be absolute, "\ "check the value of `url` in your config file." false diff --git a/lib/jekyll/commands/serve.rb b/lib/jekyll/commands/serve.rb index 4c9d5dfc..6db46168 100644 --- a/lib/jekyll/commands/serve.rb +++ b/lib/jekyll/commands/serve.rb @@ -261,6 +261,7 @@ module Jekyll return system "start", address if Utils::Platforms.windows? return system "xdg-open", address if Utils::Platforms.linux? return system "open", address if Utils::Platforms.osx? + Jekyll.logger.error "Refusing to launch browser; " \ "Platform launcher unknown." end diff --git a/lib/jekyll/configuration.rb b/lib/jekyll/configuration.rb index 804686e6..67eafb22 100644 --- a/lib/jekyll/configuration.rb +++ b/lib/jekyll/configuration.rb @@ -196,6 +196,7 @@ module Jekyll begin files.each do |config_file| next if config_file.nil? || config_file.empty? + new_config = read_config_file(config_file) configuration = Utils.deep_merge_hashes(configuration, new_config) end diff --git a/lib/jekyll/converters/markdown.rb b/lib/jekyll/converters/markdown.rb index 67b10409..ed3a554a 100644 --- a/lib/jekyll/converters/markdown.rb +++ b/lib/jekyll/converters/markdown.rb @@ -9,6 +9,7 @@ module Jekyll def setup return if @setup ||= false + unless (@parser = get_processor) Jekyll.logger.error "Invalid Markdown processor given:", @config["markdown"] Jekyll.logger.info "", "Custom processors are not loaded in safe mode" if @config["safe"] diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb index 85532ba9..863fa4eb 100644 --- a/lib/jekyll/convertible.rb +++ b/lib/jekyll/convertible.rb @@ -161,6 +161,7 @@ module Jekyll # Returns true if the file has Liquid Tags or Variables, false otherwise. def render_with_liquid? return false if data["render_with_liquid"] == false + Jekyll::Utils.has_liquid_construct?(content) end diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index 8b6e54e3..5179b44d 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -160,6 +160,7 @@ module Jekyll # true otherwise. def render_with_liquid? return false if data["render_with_liquid"] == false + !(coffeescript_file? || yaml_file? || !Utils.has_liquid_construct?(content)) end @@ -304,6 +305,7 @@ module Jekyll # equal or greater than the other doc's path. See String#<=> for more details. def <=>(other) return nil unless other.respond_to?(:data) + cmp = data["date"] <=> other.data["date"] cmp = path <=> other.path if cmp.nil? || cmp.zero? cmp diff --git a/lib/jekyll/drops/document_drop.rb b/lib/jekyll/drops/document_drop.rb index 9c19ec91..ee54344f 100644 --- a/lib/jekyll/drops/document_drop.rb +++ b/lib/jekyll/drops/document_drop.rb @@ -26,6 +26,7 @@ module Jekyll def <=>(other) return nil unless other.is_a? DocumentDrop + cmp = self["date"] <=> other["date"] cmp = self["path"] <=> other["path"] if cmp.nil? || cmp.zero? cmp diff --git a/lib/jekyll/drops/drop.rb b/lib/jekyll/drops/drop.rb index 208b266b..315817fe 100644 --- a/lib/jekyll/drops/drop.rb +++ b/lib/jekyll/drops/drop.rb @@ -101,6 +101,7 @@ module Jekyll def key?(key) return false if key.nil? return true if self.class.mutable? && @mutations.key?(key) + respond_to?(key) || fallback_data.key?(key) end diff --git a/lib/jekyll/drops/site_drop.rb b/lib/jekyll/drops/site_drop.rb index 3ec2dc51..9cbff240 100644 --- a/lib/jekyll/drops/site_drop.rb +++ b/lib/jekyll/drops/site_drop.rb @@ -44,6 +44,7 @@ module Jekyll # We should remove this in 4.0 and switch to `{{ post.related_posts }}`. def related_posts return nil unless @current_document.is_a?(Jekyll::Document) + @current_document.related_posts end attr_writer :current_document diff --git a/lib/jekyll/entry_filter.rb b/lib/jekyll/entry_filter.rb index 91d7961c..95f95c2a 100644 --- a/lib/jekyll/entry_filter.rb +++ b/lib/jekyll/entry_filter.rb @@ -35,6 +35,7 @@ module Jekyll next true if symlink?(e) # Do not reject this entry if it is included. next false if included?(e) + # Reject this entry if it is special, a backup file, or excluded. special?(e) || backup?(e) || excluded?(e) end diff --git a/lib/jekyll/excerpt.rb b/lib/jekyll/excerpt.rb index 8eea0e2e..87f25ebb 100644 --- a/lib/jekyll/excerpt.rb +++ b/lib/jekyll/excerpt.rb @@ -90,6 +90,7 @@ module Jekyll def render_with_liquid? return false if data["render_with_liquid"] == false + !(coffeescript_file? || yaml_file? || !Utils.has_liquid_construct?(content)) end diff --git a/lib/jekyll/external.rb b/lib/jekyll/external.rb index 15b30a5f..f2831719 100644 --- a/lib/jekyll/external.rb +++ b/lib/jekyll/external.rb @@ -42,6 +42,7 @@ module Jekyll # RubyGems. def version_constraint(gem_name) return "= #{Jekyll::VERSION}" if gem_name.to_s.eql?("jekyll-docs") + "> 0" end diff --git a/lib/jekyll/filters.rb b/lib/jekyll/filters.rb index ed8c3163..62cd0f65 100644 --- a/lib/jekyll/filters.rb +++ b/lib/jekyll/filters.rb @@ -169,6 +169,7 @@ module Jekyll def where(input, property, value) return input if property.nil? || value.nil? return input unless input.respond_to?(:select) + input = input.values if input.is_a?(Hash) input_id = input.hash @@ -195,6 +196,7 @@ module Jekyll # Returns the filtered array of objects def where_exp(input, variable, expression) return input unless input.respond_to?(:select) + input = input.values if input.is_a?(Hash) # FIXME condition = parse_condition(expression) @@ -214,6 +216,7 @@ module Jekyll def to_integer(input) return 1 if input == true return 0 if input == false + input.to_i end @@ -226,6 +229,7 @@ module Jekyll # Returns the filtered array of objects def sort(input, property = nil, nils = "first") raise ArgumentError, "Cannot sort a null object." if input.nil? + if property.nil? input.sort else @@ -244,6 +248,7 @@ module Jekyll def pop(array, num = 1) return array unless array.is_a?(Array) + num = Liquid::Utils.to_integer(num) new_ary = array.dup new_ary.pop(num) @@ -252,6 +257,7 @@ module Jekyll def push(array, input) return array unless array.is_a?(Array) + new_ary = array.dup new_ary.push(input) new_ary @@ -259,6 +265,7 @@ module Jekyll def shift(array, num = 1) return array unless array.is_a?(Array) + num = Liquid::Utils.to_integer(num) new_ary = array.dup new_ary.shift(num) @@ -267,6 +274,7 @@ module Jekyll def unshift(array, input) return array unless array.is_a?(Array) + new_ary = array.dup new_ary.unshift(input) new_ary @@ -274,6 +282,7 @@ module Jekyll def sample(input, num = 1) return input unless input.respond_to?(:sample) + num = Liquid::Utils.to_integer(num) rescue 1 if num == 1 input.sample @@ -330,6 +339,7 @@ module Jekyll def parse_sort_input(property) number_like = %r!\A\s*-?(?:\d+\.?\d*|\.\d+)\s*\Z! return property.to_f if property =~ number_like + property end diff --git a/lib/jekyll/filters/date_filters.rb b/lib/jekyll/filters/date_filters.rb index d804a1db..966b49b8 100644 --- a/lib/jekyll/filters/date_filters.rb +++ b/lib/jekyll/filters/date_filters.rb @@ -45,6 +45,7 @@ module Jekyll # Returns the formatted String. def date_to_xmlschema(date) return date if date.to_s.empty? + time(date).xmlschema end @@ -60,6 +61,7 @@ module Jekyll # Returns the formatted String. def date_to_rfc822(date) return date if date.to_s.empty? + time(date).rfc822 end @@ -72,11 +74,13 @@ module Jekyll # Returns a stringified date or the empty input. def stringify_date(date, month_type, type = nil, style = nil) return date if date.to_s.empty? + time = time(date) if type == "ordinal" day = time.day ordinal_day = "#{day}#{ordinal(day)}" return time.strftime("#{month_type} #{ordinal_day}, %Y") if style == "US" + return time.strftime("#{ordinal_day} #{month_type} %Y") end time.strftime("%d #{month_type} %Y") diff --git a/lib/jekyll/filters/url_filters.rb b/lib/jekyll/filters/url_filters.rb index 55835167..777502d0 100644 --- a/lib/jekyll/filters/url_filters.rb +++ b/lib/jekyll/filters/url_filters.rb @@ -10,10 +10,13 @@ module Jekyll # Returns the absolute URL as a String. def absolute_url(input) return if input.nil? + input = input.url if input.respond_to?(:url) return input if Addressable::URI.parse(input.to_s).absolute? + site = @context.registers[:site] return relative_url(input) if site.config["url"].nil? + Addressable::URI.parse( site.config["url"].to_s + relative_url(input) ).normalize.to_s @@ -27,6 +30,7 @@ module Jekyll # Returns a URL relative to the domain root as a String. def relative_url(input) return if input.nil? + input = input.url if input.respond_to?(:url) return input if Addressable::URI.parse(input.to_s).absolute? @@ -43,6 +47,7 @@ module Jekyll # Returns a URL with the trailing `/index.html` removed def strip_index(input) return if input.nil? || input.to_s.empty? + input.sub(%r!/index\.html?$!, "/") end @@ -55,6 +60,7 @@ module Jekyll def ensure_leading_slash(input) return input if input.nil? || input.empty? || input.start_with?("/") + "/#{input}" end end diff --git a/lib/jekyll/frontmatter_defaults.rb b/lib/jekyll/frontmatter_defaults.rb index 95c46900..708a6e2d 100644 --- a/lib/jekyll/frontmatter_defaults.rb +++ b/lib/jekyll/frontmatter_defaults.rb @@ -36,6 +36,7 @@ module Jekyll def ensure_time!(set) return set unless set.key?("values") && set["values"].key?("date") return set if set["values"]["date"].is_a?(Time) + set["values"]["date"] = Utils.parse_date( set["values"]["date"], "An invalid date format was found in a front-matter default set: #{set}" @@ -132,6 +133,7 @@ module Jekyll collections_dir = @site.config["collections_dir"] slashed_coll_dir = "#{collections_dir}/" return path if collections_dir.empty? || !path.to_s.start_with?(slashed_coll_dir) + path.sub(slashed_coll_dir, "") end diff --git a/lib/jekyll/hooks.rb b/lib/jekyll/hooks.rb index 23b2776b..a6fbc743 100644 --- a/lib/jekyll/hooks.rb +++ b/lib/jekyll/hooks.rb @@ -60,6 +60,7 @@ module Jekyll # Ensure the priority is a Fixnum def self.priority_value(priority) return priority if priority.is_a?(Integer) + PRIORITY_MAP[priority] || DEFAULT_PRIORITY end diff --git a/lib/jekyll/log_adapter.rb b/lib/jekyll/log_adapter.rb index b7154911..6ddfa4ad 100644 --- a/lib/jekyll/log_adapter.rb +++ b/lib/jekyll/log_adapter.rb @@ -144,6 +144,7 @@ module Jekyll # the appropriate writer method, e.g. writer.info. def write(level_of_message, topic, message = nil, &block) return false unless write_message?(level_of_message) + writer.public_send(level_of_message, message(topic, message, &block)) end end diff --git a/lib/jekyll/plugin_manager.rb b/lib/jekyll/plugin_manager.rb index f53d187a..d7785338 100644 --- a/lib/jekyll/plugin_manager.rb +++ b/lib/jekyll/plugin_manager.rb @@ -37,8 +37,10 @@ module Jekyll # Returns false only if no dependencies have been specified, otherwise nothing. def require_theme_deps return false unless site.theme.runtime_dependencies + site.theme.runtime_dependencies.each do |dep| next if dep.name == "jekyll" + External.require_with_graceful_fail(dep.name) if plugin_allowed?(dep.name) end end diff --git a/lib/jekyll/reader.rb b/lib/jekyll/reader.rb index 78a76e97..eeb71749 100644 --- a/lib/jekyll/reader.rb +++ b/lib/jekyll/reader.rb @@ -61,6 +61,7 @@ module Jekyll # Returns nothing. def retrieve_posts(dir) return if outside_configured_directory?(dir) + site.posts.docs.concat(post_reader.read_posts(dir)) site.posts.docs.concat(post_reader.read_drafts(dir)) if site.show_drafts end @@ -124,6 +125,7 @@ module Jekyll def get_entries(dir, subfolder) base = site.in_source_dir(dir, subfolder) return [] unless File.exist?(base) + entries = Dir.chdir(base) { filter_entries(Dir["**/*"], base) } entries.delete_if { |e| File.directory?(site.in_source_dir(base, e)) } end diff --git a/lib/jekyll/readers/layout_reader.rb b/lib/jekyll/readers/layout_reader.rb index f1dbe599..85ebd011 100644 --- a/lib/jekyll/readers/layout_reader.rb +++ b/lib/jekyll/readers/layout_reader.rb @@ -54,6 +54,7 @@ module Jekyll def within(directory) return unless File.exist?(directory) + Dir.chdir(directory) { yield } end diff --git a/lib/jekyll/readers/post_reader.rb b/lib/jekyll/readers/post_reader.rb index 050bd930..a82f9d8e 100644 --- a/lib/jekyll/readers/post_reader.rb +++ b/lib/jekyll/readers/post_reader.rb @@ -61,6 +61,7 @@ module Jekyll def read_content(dir, magic_dir, matcher) @site.reader.get_entries(dir, magic_dir).map do |entry| next unless entry =~ matcher + path = @site.in_source_dir(File.join(dir, magic_dir, entry)) Document.new(path, :site => @site, diff --git a/lib/jekyll/readers/theme_assets_reader.rb b/lib/jekyll/readers/theme_assets_reader.rb index afccf813..8b62c9d3 100644 --- a/lib/jekyll/readers/theme_assets_reader.rb +++ b/lib/jekyll/readers/theme_assets_reader.rb @@ -12,6 +12,7 @@ module Jekyll Find.find(site.theme.assets_path) do |path| next if File.directory?(path) + if File.symlink?(path) Jekyll.logger.warn "Theme reader:", "Ignored symlinked asset: #{path}" else diff --git a/lib/jekyll/regenerator.rb b/lib/jekyll/regenerator.rb index 444b7884..88c6a819 100644 --- a/lib/jekyll/regenerator.rb +++ b/lib/jekyll/regenerator.rb @@ -21,6 +21,7 @@ module Jekyll # Returns a boolean. def regenerate?(document) return true if disabled + case document when Page regenerate_page?(document) diff --git a/lib/jekyll/renderer.rb b/lib/jekyll/renderer.rb index 030b9a3c..1b463b9c 100644 --- a/lib/jekyll/renderer.rb +++ b/lib/jekyll/renderer.rb @@ -158,10 +158,10 @@ module Jekyll output = render_layout(output, layout, info) add_regenerator_dependencies(layout) - if (layout = site.layouts[layout.data["layout"]]) - break if used.include?(layout) - used << layout - end + next unless (layout = site.layouts[layout.data["layout"]]) + break if used.include?(layout) + + used << layout end output end @@ -202,6 +202,7 @@ module Jekyll def add_regenerator_dependencies(layout) return unless document.write? + site.regenerator.add_dependency( site.in_source_dir(document.path), layout.path diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 530e2b23..b0bbd481 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -377,6 +377,7 @@ module Jekyll # Returns a path which is prefixed with the theme root directory. def in_theme_dir(*paths) return nil unless theme + paths.reduce(theme.root) do |base, path| Jekyll.sanitized_path(base, path) end @@ -474,6 +475,7 @@ module Jekyll def render_regenerated(document, payload) return unless regenerator.regenerate?(document) + document.output = Jekyll::Renderer.new(self, document, payload).run document.trigger_hooks(:post_render) end diff --git a/lib/jekyll/static_file.rb b/lib/jekyll/static_file.rb index 01c950d8..a07d9e4b 100644 --- a/lib/jekyll/static_file.rb +++ b/lib/jekyll/static_file.rb @@ -98,6 +98,7 @@ module Jekyll dest_path = destination(dest) return false if File.exist?(dest_path) && !modified? + self.class.mtimes[path] = mtime FileUtils.mkdir_p(File.dirname(dest_path)) diff --git a/lib/jekyll/stevenson.rb b/lib/jekyll/stevenson.rb index 1d27bcd8..4cfc7fbb 100644 --- a/lib/jekyll/stevenson.rb +++ b/lib/jekyll/stevenson.rb @@ -17,6 +17,7 @@ module Jekyll @logdev = logdevice(severity) return true if @logdev.nil? || severity < @level + progname ||= @progname if message.nil? if block_given? diff --git a/lib/jekyll/tags/post_url.rb b/lib/jekyll/tags/post_url.rb index b12d8d0a..cf44eeed 100644 --- a/lib/jekyll/tags/post_url.rb +++ b/lib/jekyll/tags/post_url.rb @@ -83,6 +83,7 @@ module Jekyll site.posts.docs.each do |p| next unless @post.deprecated_equality p + Jekyll::Deprecator.deprecation_message "A call to "\ "'{% post_url #{@post.name} %}' did not match " \ "a post using the new matching method of checking name " \ diff --git a/lib/jekyll/theme.rb b/lib/jekyll/theme.rb index e6490108..134a86d8 100644 --- a/lib/jekyll/theme.rb +++ b/lib/jekyll/theme.rb @@ -40,6 +40,7 @@ module Jekyll def configure_sass return unless sass_path + External.require_with_graceful_fail("sass") unless defined?(Sass) Sass.load_paths << sass_path end diff --git a/lib/jekyll/url.rb b/lib/jekyll/url.rb index 39c0b3cd..a32ec898 100644 --- a/lib/jekyll/url.rb +++ b/lib/jekyll/url.rb @@ -68,6 +68,7 @@ module Jekyll def generate_url_from_hash(template) @placeholders.inject(template) do |result, token| break result if result.index(":").nil? + if token.last.nil? # Remove leading "/" to avoid generating urls with `//` result.gsub("/:#{token.first}", "") diff --git a/lib/jekyll/utils.rb b/lib/jekyll/utils.rb index f52a62ff..1444058b 100644 --- a/lib/jekyll/utils.rb +++ b/lib/jekyll/utils.rb @@ -152,6 +152,7 @@ module Jekyll # Returns true is the string contains sequences of `{%` or `{{` def has_liquid_construct?(content) return false if content.nil? || content.empty? + content.include?("{%") || content.include?("{{") end # rubocop: enable PredicateName @@ -292,8 +293,10 @@ module Jekyll # Returns matched pathes def safe_glob(dir, patterns, flags = 0) return [] unless Dir.exist?(dir) + pattern = File.join(Array(patterns)) return [dir] if pattern.empty? + Dir.chdir(dir) do Dir.glob(pattern, flags).map { |f| File.join(dir, f) } end diff --git a/lib/jekyll/utils/platforms.rb b/lib/jekyll/utils/platforms.rb index e0e2e331..710ca20a 100644 --- a/lib/jekyll/utils/platforms.rb +++ b/lib/jekyll/utils/platforms.rb @@ -70,13 +70,12 @@ module Jekyll private def proc_version - @proc_version ||= begin - Pathutil.new( - "/proc/version" - ).read - rescue Errno::ENOENT - nil - end + @proc_version ||= + begin + Pathutil.new("/proc/version").read + rescue Errno::ENOENT + nil + end end end end diff --git a/test/test_regenerator.rb b/test/test_regenerator.rb index 39b28baa..b86156d1 100644 --- a/test/test_regenerator.rb +++ b/test/test_regenerator.rb @@ -42,6 +42,7 @@ class TestRegenerator < JekyllUnitTest # because regenerate? checks if the destination exists [@page, @post, @document, @asset_file].each do |item| next unless item.respond_to?(:destination) + dest = item.destination(@site.dest) FileUtils.mkdir_p(File.dirname(dest)) FileUtils.touch(dest)