Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 5 commits
  • 3 files changed
  • 0 commit comments
  • 2 contributors
Showing with 32 additions and 3 deletions.
  1. +1 −0 History.txt
  2. +5 −3 lib/jekyll/site.rb
  3. +26 −0 test/test_site.rb
View
1 History.txt
@@ -4,6 +4,7 @@
* Add --default-mimetype option (#279)
* Allow setting of RedCloth options (#284)
* Add post_url Liquid tag for internal post linking (#369)
+ * Allow multiple plugin dirs to be specified (#438)
* Bug Fixes
* Allow some special characters in highlight names
* URL escape category names in URL generation (#360)
View
8 lib/jekyll/site.rb
@@ -18,7 +18,7 @@ def initialize(config)
self.safe = config['safe']
self.source = File.expand_path(config['source'])
self.dest = File.expand_path(config['destination'])
- self.plugins = File.expand_path(config['plugins'])
+ self.plugins = Array(config['plugins']).map { |d| File.expand_path(d) }
self.lsi = config['lsi']
self.pygments = config['pygments']
self.permalink_style = config['permalink'].to_sym
@@ -73,8 +73,10 @@ def setup
# If safe mode is off, load in any Ruby files under the plugins
# directory.
unless self.safe
- Dir[File.join(self.plugins, "**/*.rb")].each do |f|
- require f
+ self.plugins.each do |plugins|
+ Dir[File.join(plugins, "**/*.rb")].each do |f|
+ require f
+ end
end
end
View
26 test/test_site.rb
@@ -1,6 +1,32 @@
require 'helper'
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
setup do
stub(Jekyll).configuration do

No commit comments for this range

Something went wrong with that request. Please try again.