Use External instead of Deprecator for requiring gracefully
This commit is contained in:
parent
8c19a6f430
commit
c576d23908
|
@ -29,12 +29,6 @@ require 'liquid'
|
||||||
require 'kramdown'
|
require 'kramdown'
|
||||||
require 'colorator'
|
require 'colorator'
|
||||||
|
|
||||||
# Conditional optimizations
|
|
||||||
begin
|
|
||||||
require 'liquid-c'
|
|
||||||
rescue LoadError
|
|
||||||
end
|
|
||||||
|
|
||||||
SafeYAML::OPTIONS[:suppress_warnings] = true
|
SafeYAML::OPTIONS[:suppress_warnings] = true
|
||||||
Liquid::Template.error_mode = :strict
|
Liquid::Template.error_mode = :strict
|
||||||
|
|
||||||
|
@ -51,6 +45,7 @@ module Jekyll
|
||||||
autoload :EntryFilter, 'jekyll/entry_filter'
|
autoload :EntryFilter, 'jekyll/entry_filter'
|
||||||
autoload :Errors, 'jekyll/errors'
|
autoload :Errors, 'jekyll/errors'
|
||||||
autoload :Excerpt, 'jekyll/excerpt'
|
autoload :Excerpt, 'jekyll/excerpt'
|
||||||
|
autoload :External, 'jekyll/external'
|
||||||
autoload :Filters, 'jekyll/filters'
|
autoload :Filters, 'jekyll/filters'
|
||||||
autoload :FrontmatterDefaults, 'jekyll/frontmatter_defaults'
|
autoload :FrontmatterDefaults, 'jekyll/frontmatter_defaults'
|
||||||
autoload :Layout, 'jekyll/layout'
|
autoload :Layout, 'jekyll/layout'
|
||||||
|
@ -162,6 +157,9 @@ module Jekyll
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Conditional optimizations
|
||||||
|
Jekyll::External.require_if_present('liquid-c')
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -172,7 +170,7 @@ require_all 'jekyll/generators'
|
||||||
require_all 'jekyll/tags'
|
require_all 'jekyll/tags'
|
||||||
|
|
||||||
# Eventually remove these for 3.0 as non-core
|
# Eventually remove these for 3.0 as non-core
|
||||||
Jekyll::Deprecator.gracefully_require(%w[
|
Jekyll::External.require_with_graceful_fail(%w[
|
||||||
toml
|
toml
|
||||||
jekyll-paginate
|
jekyll-paginate
|
||||||
jekyll-gist
|
jekyll-gist
|
||||||
|
|
|
@ -66,7 +66,7 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns nothing.
|
# Returns nothing.
|
||||||
def watch(site, options)
|
def watch(site, options)
|
||||||
Deprecator.gracefully_require 'jekyll-watch'
|
External.require_with_graceful_fail 'jekyll-watch'
|
||||||
Jekyll::Watcher.watch(options)
|
Jekyll::Watcher.watch(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ module Jekyll
|
||||||
class Markdown
|
class Markdown
|
||||||
class RDiscountParser
|
class RDiscountParser
|
||||||
def initialize(config)
|
def initialize(config)
|
||||||
Jekyll::Deprecator.gracefully_require "rdiscount"
|
Jekyll::External.require_with_graceful_fail "rdiscount"
|
||||||
@config = config
|
@config = config
|
||||||
@rdiscount_extensions = @config['rdiscount']['extensions'].map { |e| e.to_sym }
|
@rdiscount_extensions = @config['rdiscount']['extensions'].map { |e| e.to_sym }
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,7 @@ module Jekyll
|
||||||
module WithPygments
|
module WithPygments
|
||||||
include CommonMethods
|
include CommonMethods
|
||||||
def block_code(code, lang)
|
def block_code(code, lang)
|
||||||
Jekyll::Deprecator.gracefully_require("pygments")
|
Jekyll::External.require_with_graceful_fail("pygments")
|
||||||
lang = lang && lang.split.first || "text"
|
lang = lang && lang.split.first || "text"
|
||||||
add_code_tags(
|
add_code_tags(
|
||||||
Pygments.highlight(code, :lexer => lang, :options => { :encoding => 'utf-8' }),
|
Pygments.highlight(code, :lexer => lang, :options => { :encoding => 'utf-8' }),
|
||||||
|
@ -55,7 +55,7 @@ module Jekyll
|
||||||
|
|
||||||
|
|
||||||
def initialize(config)
|
def initialize(config)
|
||||||
Deprecator.gracefully_require("redcarpet")
|
External.require_with_graceful_fail("redcarpet")
|
||||||
@config = config
|
@config = config
|
||||||
@redcarpet_extensions = {}
|
@redcarpet_extensions = {}
|
||||||
@config['redcarpet']['extensions'].each { |e| @redcarpet_extensions[e.to_sym] = true }
|
@config['redcarpet']['extensions'].each { |e| @redcarpet_extensions[e.to_sym] = true }
|
||||||
|
@ -71,7 +71,7 @@ module Jekyll
|
||||||
end
|
end
|
||||||
when "rouge"
|
when "rouge"
|
||||||
Class.new(Redcarpet::Render::HTML) do
|
Class.new(Redcarpet::Render::HTML) do
|
||||||
Jekyll::Deprecator.gracefully_require(%w[
|
Jekyll::External.require_with_graceful_fail(%w[
|
||||||
rouge
|
rouge
|
||||||
rouge/plugins/redcarpet
|
rouge/plugins/redcarpet
|
||||||
])
|
])
|
||||||
|
|
|
@ -40,22 +40,5 @@ module Jekyll
|
||||||
Jekyll.logger.warn "Defaults:", "Please update your front-matter defaults to use 'type: #{current}'."
|
Jekyll.logger.warn "Defaults:", "Please update your front-matter defaults to use 'type: #{current}'."
|
||||||
end
|
end
|
||||||
|
|
||||||
def gracefully_require(gem_name)
|
|
||||||
Array(gem_name).each do |name|
|
|
||||||
begin
|
|
||||||
require name
|
|
||||||
rescue LoadError => e
|
|
||||||
Jekyll.logger.error "Dependency Error:", <<-MSG
|
|
||||||
Yikes! It looks like you don't have #{name} or one of its dependencies installed.
|
|
||||||
In order to use Jekyll as currently configured, you'll need to install this gem.
|
|
||||||
|
|
||||||
The full error message from Ruby is: '#{e.message}'
|
|
||||||
|
|
||||||
If you run into trouble, you can find helpful resources at http://jekyllrb.com/help/!
|
|
||||||
MSG
|
|
||||||
raise Errors::MissingDependencyException.new(name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue