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 Jekyll.logger.info "Configuration file:", file
next_config next_config
rescue SystemCallError rescue SystemCallError
if @default_config_file if @default_config_file ||= nil
Jekyll.logger.warn "Configuration file:", "none" Jekyll.logger.warn "Configuration file:", "none"
{} {}
else else

View File

@ -8,7 +8,9 @@ module Jekyll
# #
# Returns the String prefix. # Returns the String prefix.
def self.highlighter_prefix(highlighter_prefix = nil) 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 @highlighter_prefix
end end
@ -20,7 +22,9 @@ module Jekyll
# #
# Returns the String suffix. # Returns the String suffix.
def self.highlighter_suffix(highlighter_suffix = nil) 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 @highlighter_suffix
end end

View File

@ -6,7 +6,7 @@ module Jekyll
safe true safe true
def setup def setup
return if @setup return if @setup ||= false
unless (@parser = get_processor) unless (@parser = get_processor)
Jekyll.logger.error "Invalid Markdown processor given:", @config["markdown"] Jekyll.logger.error "Invalid Markdown processor given:", @config["markdown"]
Jekyll.logger.info "", "Custom processors are not loaded in safe mode" if @config["safe"] 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" Jekyll::External.require_with_graceful_fail "kramdown"
@main_fallback_highlighter = config["highlighter"] || "rouge" @main_fallback_highlighter = config["highlighter"] || "rouge"
@config = config["kramdown"] || {} @config = config["kramdown"] || {}
@highlighter = nil
setup setup
end end

View File

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

View File

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

View File

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

View File

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

View File

@ -158,7 +158,7 @@ class TestFilters < JekyllUnitTest
end end
should "format a time with xmlschema" do 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 end
should "format a time according to RFC-822" do should "format a time according to RFC-822" do

View File

@ -91,7 +91,7 @@ class TestNewCommand < JekyllUnitTest
should 'force created folder' do should 'force created folder' do
capture_stdout { Jekyll::Commands::New.process(@args) } capture_stdout { Jekyll::Commands::New.process(@args) }
output = capture_stdout { Jekyll::Commands::New.process(@args, '--force') } 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
end end

View File

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

View File

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

View File

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