Merge branch 'PluginsAsArray' of https://github.com/simensen/jekyll into simensen-PluginsAsArray
This commit is contained in:
commit
02366ae5ff
|
@ -18,7 +18,17 @@ module Jekyll
|
||||||
self.safe = config['safe']
|
self.safe = config['safe']
|
||||||
self.source = File.expand_path(config['source'])
|
self.source = File.expand_path(config['source'])
|
||||||
self.dest = File.expand_path(config['destination'])
|
self.dest = File.expand_path(config['destination'])
|
||||||
self.plugins = File.expand_path(config['plugins'])
|
self.plugins = if config['plugins'].respond_to?('each')
|
||||||
|
# If plugins is an array, process it.
|
||||||
|
Array(config['plugins']).map { |d| File.expand_path(d) }
|
||||||
|
else
|
||||||
|
if config['plugins'].nil?
|
||||||
|
[]
|
||||||
|
else
|
||||||
|
# Otherwise process a single entry as an array.
|
||||||
|
[File.expand_path(config['plugins'])]
|
||||||
|
end
|
||||||
|
end
|
||||||
self.lsi = config['lsi']
|
self.lsi = config['lsi']
|
||||||
self.pygments = config['pygments']
|
self.pygments = config['pygments']
|
||||||
self.permalink_style = config['permalink'].to_sym
|
self.permalink_style = config['permalink'].to_sym
|
||||||
|
@ -73,10 +83,12 @@ module Jekyll
|
||||||
# If safe mode is off, load in any Ruby files under the plugins
|
# If safe mode is off, load in any Ruby files under the plugins
|
||||||
# directory.
|
# directory.
|
||||||
unless self.safe
|
unless self.safe
|
||||||
Dir[File.join(self.plugins, "**/*.rb")].each do |f|
|
self.plugins.each do |plugins|
|
||||||
|
Dir[File.join(plugins, "**/*.rb")].each do |f|
|
||||||
require f
|
require f
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
self.converters = Jekyll::Converter.subclasses.select do |c|
|
self.converters = Jekyll::Converter.subclasses.select do |c|
|
||||||
!self.safe || c.safe
|
!self.safe || c.safe
|
||||||
|
|
|
@ -1,6 +1,32 @@
|
||||||
require 'helper'
|
require 'helper'
|
||||||
|
|
||||||
class TestSite < Test::Unit::TestCase
|
class TestSite < Test::Unit::TestCase
|
||||||
|
context "configuring sites" do
|
||||||
|
should "have an array for plugins by default" do
|
||||||
|
site = Site.new(Jekyll::DEFAULTS)
|
||||||
|
assert_equal [File.join(Dir.pwd, '_plugins')], site.plugins
|
||||||
|
end
|
||||||
|
|
||||||
|
should "have an array for plugins if passed as a string" do
|
||||||
|
site = Site.new(Jekyll::DEFAULTS.merge({'plugins' => '/tmp/plugins'}))
|
||||||
|
assert_equal ['/tmp/plugins'], site.plugins
|
||||||
|
end
|
||||||
|
|
||||||
|
should "have an array for plugins if passed as an array" do
|
||||||
|
site = Site.new(Jekyll::DEFAULTS.merge({'plugins' => ['/tmp/plugins', '/tmp/otherplugins']}))
|
||||||
|
assert_equal ['/tmp/plugins', '/tmp/otherplugins'], site.plugins
|
||||||
|
end
|
||||||
|
|
||||||
|
should "have an empty array for plugins if nothing is passed" do
|
||||||
|
site = Site.new(Jekyll::DEFAULTS.merge({'plugins' => []}))
|
||||||
|
assert_equal [], site.plugins
|
||||||
|
end
|
||||||
|
|
||||||
|
should "have an empty array for plugins if nil is passed" do
|
||||||
|
site = Site.new(Jekyll::DEFAULTS.merge({'plugins' => nil}))
|
||||||
|
assert_equal [], site.plugins
|
||||||
|
end
|
||||||
|
end
|
||||||
context "creating sites" do
|
context "creating sites" do
|
||||||
setup do
|
setup do
|
||||||
stub(Jekyll).configuration do
|
stub(Jekyll).configuration do
|
||||||
|
|
Loading…
Reference in New Issue