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 'colorator'
|
||||
|
||||
# Conditional optimizations
|
||||
begin
|
||||
require 'liquid-c'
|
||||
rescue LoadError
|
||||
end
|
||||
|
||||
SafeYAML::OPTIONS[:suppress_warnings] = true
|
||||
Liquid::Template.error_mode = :strict
|
||||
|
||||
|
@ -51,6 +45,7 @@ module Jekyll
|
|||
autoload :EntryFilter, 'jekyll/entry_filter'
|
||||
autoload :Errors, 'jekyll/errors'
|
||||
autoload :Excerpt, 'jekyll/excerpt'
|
||||
autoload :External, 'jekyll/external'
|
||||
autoload :Filters, 'jekyll/filters'
|
||||
autoload :FrontmatterDefaults, 'jekyll/frontmatter_defaults'
|
||||
autoload :Layout, 'jekyll/layout'
|
||||
|
@ -162,6 +157,9 @@ module Jekyll
|
|||
end
|
||||
end
|
||||
|
||||
# Conditional optimizations
|
||||
Jekyll::External.require_if_present('liquid-c')
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -172,7 +170,7 @@ require_all 'jekyll/generators'
|
|||
require_all 'jekyll/tags'
|
||||
|
||||
# Eventually remove these for 3.0 as non-core
|
||||
Jekyll::Deprecator.gracefully_require(%w[
|
||||
Jekyll::External.require_with_graceful_fail(%w[
|
||||
toml
|
||||
jekyll-paginate
|
||||
jekyll-gist
|
||||
|
|
|
@ -66,7 +66,7 @@ module Jekyll
|
|||
#
|
||||
# Returns nothing.
|
||||
def watch(site, options)
|
||||
Deprecator.gracefully_require 'jekyll-watch'
|
||||
External.require_with_graceful_fail 'jekyll-watch'
|
||||
Jekyll::Watcher.watch(options)
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ module Jekyll
|
|||
class Markdown
|
||||
class RDiscountParser
|
||||
def initialize(config)
|
||||
Jekyll::Deprecator.gracefully_require "rdiscount"
|
||||
Jekyll::External.require_with_graceful_fail "rdiscount"
|
||||
@config = config
|
||||
@rdiscount_extensions = @config['rdiscount']['extensions'].map { |e| e.to_sym }
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ module Jekyll
|
|||
module WithPygments
|
||||
include CommonMethods
|
||||
def block_code(code, lang)
|
||||
Jekyll::Deprecator.gracefully_require("pygments")
|
||||
Jekyll::External.require_with_graceful_fail("pygments")
|
||||
lang = lang && lang.split.first || "text"
|
||||
add_code_tags(
|
||||
Pygments.highlight(code, :lexer => lang, :options => { :encoding => 'utf-8' }),
|
||||
|
@ -55,7 +55,7 @@ module Jekyll
|
|||
|
||||
|
||||
def initialize(config)
|
||||
Deprecator.gracefully_require("redcarpet")
|
||||
External.require_with_graceful_fail("redcarpet")
|
||||
@config = config
|
||||
@redcarpet_extensions = {}
|
||||
@config['redcarpet']['extensions'].each { |e| @redcarpet_extensions[e.to_sym] = true }
|
||||
|
@ -71,7 +71,7 @@ module Jekyll
|
|||
end
|
||||
when "rouge"
|
||||
Class.new(Redcarpet::Render::HTML) do
|
||||
Jekyll::Deprecator.gracefully_require(%w[
|
||||
Jekyll::External.require_with_graceful_fail(%w[
|
||||
rouge
|
||||
rouge/plugins/redcarpet
|
||||
])
|
||||
|
|
|
@ -40,22 +40,5 @@ module Jekyll
|
|||
Jekyll.logger.warn "Defaults:", "Please update your front-matter defaults to use 'type: #{current}'."
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue