Merge branch 'pathawks-rubocop/misc'

* pathawks-rubocop/misc:
  Fix Page#relative_path so that it consistently does NOT have the prepending slash (previously inconsistent)
  Rubocop cleanup for lib/jekyll/layout.rb
  Rubocop cleanup for lib/jekyll/plugin_manager.rb
  Rubocop cleanup for lib/jekyll/page.rb
This commit is contained in:
Parker Moore 2016-05-25 17:57:52 -07:00
commit 34d172007b
No known key found for this signature in database
GPG Key ID: 193CDEBA72063C58
5 changed files with 25 additions and 22 deletions

View File

@ -18,11 +18,8 @@ AllCops:
- lib/jekyll/entry_filter.rb
- lib/jekyll/filters.rb
- lib/jekyll/frontmatter_defaults.rb
- lib/jekyll/layout.rb
- lib/jekyll/liquid_renderer/table.rb
- lib/jekyll/liquid_renderer.rb
- lib/jekyll/page.rb
- lib/jekyll/plugin_manager.rb
- lib/jekyll/reader.rb
- lib/jekyll/readers/layout_reader.rb
- lib/jekyll/readers/page_reader.rb

View File

@ -58,7 +58,9 @@ module Jekyll
# Returns a String path which represents the relative path
# from the site source to this layout
def relative_path
@relative_path ||= Pathname.new(path).relative_path_from(Pathname.new(@base_dir)).to_s
@relative_path ||= Pathname.new(path).relative_path_from(
Pathname.new(@base_dir)
).to_s
end
end
end

View File

@ -9,7 +9,7 @@ module Jekyll
alias_method :extname, :ext
FORWARD_SLASH = '/'.freeze
FORWARD_SLASH = "/".freeze
# Attributes for Liquid templates
ATTRIBUTES_FOR_LIQUID = %w(
@ -18,7 +18,7 @@ module Jekyll
name
path
url
)
).freeze
# A set of extensions that are considered HTML or HTML-like so we
# should not alter them, this includes .xhtml through XHTM5.
@ -27,7 +27,7 @@ module Jekyll
.html
.xhtml
.htm
)
).freeze
# Initialize a new Page.
#
@ -71,7 +71,7 @@ module Jekyll
#
# Returns the String permalink or nil if none has been set.
def permalink
data.nil? ? nil : data['permalink']
data.nil? ? nil : data["permalink"]
end
# The template of the permalink.
@ -92,9 +92,9 @@ module Jekyll
# Returns the String url.
def url
@url ||= URL.new({
:template => template,
:template => template,
:placeholders => url_placeholders,
:permalink => permalink
:permalink => permalink
}).to_s
end
@ -135,12 +135,12 @@ module Jekyll
#
# Returns the path to the source file
def path
data.fetch('path') { relative_path.sub(/\A\//, '') }
data.fetch("path") { relative_path }
end
# The path to the page source file, relative to the site source
def relative_path
File.join(*[@dir, @name].map(&:to_s).reject(&:empty?))
File.join(*[@dir, @name].map(&:to_s).reject(&:empty?)).sub(%r{\A\/}, "")
end
# Obtain destination path.
@ -167,7 +167,7 @@ module Jekyll
# Returns the Boolean of whether this Page is an index file or not.
def index?
basename == 'index'
basename == "index"
end
def trigger_hooks(hook_name, *args)

View File

@ -24,7 +24,9 @@ module Jekyll
#
# Returns nothing.
def require_gems
Jekyll::External.require_with_graceful_fail(site.gems.select { |gem| plugin_allowed?(gem) })
Jekyll::External.require_with_graceful_fail(
site.gems.select { |gem| plugin_allowed?(gem) }
)
end
def self.require_from_bundler
@ -33,7 +35,8 @@ module Jekyll
Bundler.setup
required_gems = Bundler.require(:jekyll_plugins)
Jekyll.logger.debug("PluginManager:", "Required #{required_gems.map(&:name).join(', ')}")
message = "Required #{required_gems.map(&:name).join(", ")}"
Jekyll.logger.debug("PluginManager:", message)
ENV["JEKYLL_NO_BUNDLER_REQUIRE"] = "true"
true
@ -57,7 +60,7 @@ module Jekyll
# Returns an array of strings, each string being the name of a gem name
# that is allowed to be used.
def whitelist
@whitelist ||= Array[site.config['whitelist']].flatten
@whitelist ||= Array[site.config["whitelist"]].flatten
end
# Require all .rb files if safe mode is off
@ -76,16 +79,17 @@ module Jekyll
#
# Returns an Array of plugin search paths
def plugins_path
if site.config['plugins_dir'].eql? Jekyll::Configuration::DEFAULTS['plugins_dir']
[site.in_source_dir(site.config['plugins_dir'])]
if site.config["plugins_dir"].eql? Jekyll::Configuration::DEFAULTS["plugins_dir"]
[site.in_source_dir(site.config["plugins_dir"])]
else
Array(site.config['plugins_dir']).map { |d| File.expand_path(d) }
Array(site.config["plugins_dir"]).map { |d| File.expand_path(d) }
end
end
def deprecation_checks
pagination_included = (site.config['gems'] || []).include?('jekyll-paginate') || defined?(Jekyll::Paginate)
if site.config['paginate'] && !pagination_included
pagination_included = (site.config["gems"] || []).include?("jekyll-paginate") ||
defined?(Jekyll::Paginate)
if site.config["paginate"] && !pagination_included
Jekyll::Deprecator.deprecation_message "You appear to have pagination " \
"turned on, but you haven't included the `jekyll-paginate` gem. " \
"Ensure you have `gems: [jekyll-paginate]` in your configuration file."

View File

@ -15,7 +15,7 @@ class TestFrontMatterDefaults < JekyllUnitTest
}]
})
@site.process
@affected = @site.pages.find { |page| page.relative_path == "/contacts/bar.html" }
@affected = @site.pages.find { |page| page.relative_path == "contacts/bar.html" }
@not_affected = @site.pages.find { |page| page.relative_path == "about.html" }
end