Merge pull request #4537 from Crunch09/fix-warnings

Merge pull request 4537
This commit is contained in:
jekyllbot 2016-03-31 18:37:32 -07:00
commit 6ee728efcb
13 changed files with 33 additions and 25 deletions

View File

@ -149,7 +149,7 @@ module Jekyll
Jekyll.logger.info "Configuration file:", file
next_config
rescue SystemCallError
if @default_config_file
if @default_config_file ||= nil
Jekyll.logger.warn "Configuration file:", "none"
{}
else

View File

@ -8,7 +8,9 @@ module Jekyll
#
# Returns the String prefix.
def self.highlighter_prefix(highlighter_prefix = nil)
@highlighter_prefix = highlighter_prefix if highlighter_prefix
if !defined?(@highlighter_prefix) || !highlighter_prefix.nil?
@highlighter_prefix = highlighter_prefix
end
@highlighter_prefix
end
@ -20,7 +22,9 @@ module Jekyll
#
# Returns the String suffix.
def self.highlighter_suffix(highlighter_suffix = nil)
@highlighter_suffix = highlighter_suffix if highlighter_suffix
if !defined?(@highlighter_suffix) || !highlighter_suffix.nil?
@highlighter_suffix = highlighter_suffix
end
@highlighter_suffix
end

View File

@ -6,7 +6,7 @@ module Jekyll
safe true
def setup
return if @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"]

View File

@ -18,6 +18,7 @@ module Jekyll
Jekyll::External.require_with_graceful_fail "kramdown"
@main_fallback_highlighter = config["highlighter"] || "rouge"
@config = config["kramdown"] || {}
@highlighter = nil
setup
end

View File

@ -94,8 +94,8 @@ module Jekyll
return true if !scope.key?('path') || scope['path'].empty?
scope_path = Pathname.new(scope['path'])
Pathname.new(sanitize_path(path)).ascend do |path|
if path.to_s == scope_path.to_s
Pathname.new(sanitize_path(path)).ascend do |ascended_path|
if ascended_path.to_s == scope_path.to_s
return true
end
end

View File

@ -60,7 +60,7 @@ module Jekyll
#
# Returns the safety Boolean.
def self.safe(safe = nil)
if safe
if !defined?(@safe) || !safe.nil?
@safe = safe
end
@safe || false

View File

@ -1,6 +1,8 @@
module Jekyll
class Regenerator
attr_reader :site, :metadata, :cache
attr_accessor :disabled
private :disabled, :disabled=
def initialize(site)
@site = site
@ -115,7 +117,7 @@ module Jekyll
#
# Returns nothing.
def add_dependency(path, dependency)
return if metadata[path].nil? || @disabled
return if metadata[path].nil? || disabled
unless metadata[path]["deps"].include? dependency
metadata[path]["deps"] << dependency
@ -144,8 +146,8 @@ module Jekyll
#
# Returns a Boolean (true for disabled, false for enabled).
def disabled?
@disabled = !site.incremental? if @disabled.nil?
@disabled
self.disabled = !site.incremental? if disabled.nil?
disabled
end
private

View File

@ -37,7 +37,7 @@ class TestConvertible < JekyllUnitTest
out = capture_stderr do
@convertible.read_yaml(@base, 'exploit_front_matter.erb')
end
refute_match /undefined class\/module DoesNotExist/, out
refute_match(/undefined class\/module DoesNotExist/, out)
end
should "not parse if there is encoding error in file" do

View File

@ -158,7 +158,7 @@ class TestFilters < JekyllUnitTest
end
should "format a time with xmlschema" do
assert_match /2014-05-10T00:10:07/, @filter.date_to_xmlschema(@time_as_numeric)
assert_match(/2014-05-10T00:10:07/, @filter.date_to_xmlschema(@time_as_numeric))
end
should "format a time according to RFC-822" do

View File

@ -91,7 +91,7 @@ class TestNewCommand < JekyllUnitTest
should 'force created folder' do
capture_stdout { Jekyll::Commands::New.process(@args) }
output = capture_stdout { Jekyll::Commands::New.process(@args, '--force') }
assert_match /New jekyll site installed in/, output
assert_match(/New jekyll site installed in/, output)
end
end

View File

@ -232,13 +232,13 @@ class TestSite < JekyllUnitTest
context 'error handling' do
should "raise if destination is included in source" do
assert_raises Jekyll::Errors::FatalException do
site = Site.new(site_configuration('destination' => source_dir))
Site.new(site_configuration('destination' => source_dir))
end
end
should "raise if destination is source" do
assert_raises Jekyll::Errors::FatalException do
site = Site.new(site_configuration('destination' => File.join(source_dir, "..")))
Site.new(site_configuration('destination' => File.join(source_dir, "..")))
end
end
end
@ -520,7 +520,6 @@ class TestSite < JekyllUnitTest
contacts_html = @site.pages.find { |p| p.name == "contacts.html" }
@site.process
source = @site.in_source_dir(contacts_html.path)
dest = File.expand_path(contacts_html.destination(@site.dest))
mtime1 = File.stat(dest).mtime.to_i # first run must generate dest file

View File

@ -149,7 +149,7 @@ CONTENT
end
should "not cause a markdown error" do
refute_match /markdown\-html\-error/, @result
refute_match(/markdown\-html\-error/, @result)
end
should "render markdown with pygments" do
@ -442,7 +442,7 @@ CONTENT
end
should "not cause an error" do
refute_match /markdown\-html\-error/, @result
refute_match(/markdown\-html\-error/, @result)
end
should "have the url to the \"complex\" post from 2008-11-21" do
@ -466,7 +466,7 @@ CONTENT
end
should "not cause an error" do
refute_match /markdown\-html\-error/, @result
refute_match(/markdown\-html\-error/, @result)
end
should "have the url to the \"complex\" post from 2008-11-21" do
@ -600,7 +600,8 @@ title: Include symlink
CONTENT
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true, 'safe' => true })
end
refute_match /SYMLINK TEST/, @result
@result ||= ''
refute_match(/SYMLINK TEST/, @result)
end
should "not expose the existence of symlinked files" do
@ -615,7 +616,7 @@ title: Include symlink
CONTENT
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true, 'safe' => true })
end
assert_match /should exist and should not be a symlink/, ex.message
assert_match(/should exist and should not be a symlink/, ex.message)
end
end
@ -877,7 +878,8 @@ title: Include symlink
CONTENT
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true, 'safe' => true })
end
refute_match /SYMLINK TEST/, @result
@result ||= ''
refute_match(/SYMLINK TEST/, @result)
end
should "not expose the existence of symlinked files" do
@ -892,7 +894,7 @@ title: Include symlink
CONTENT
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true, 'safe' => true })
end
assert_match /should exist and should not be a symlink/, ex.message
assert_match(/should exist and should not be a symlink/, ex.message)
end
end
end

View File

@ -63,12 +63,12 @@ class TestURL < JekyllUnitTest
},
})
site.read
doc = site.collections["methods"].docs.find do |doc|
matching_doc = site.collections["methods"].docs.find do |doc|
doc.relative_path == "_methods/escape-+ #%20[].md"
end
assert_equal '/methods/escape-+-20/escape-20.html', URL.new(
:template => '/methods/:title/:name:output_ext',
:placeholders => doc.url_placeholders
:placeholders => matching_doc.url_placeholders
).to_s
end