File tree Expand file tree Collapse file tree 2 files changed +41
-3
lines changed
Expand file tree Collapse file tree 2 files changed +41
-3
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,17 @@ def initialize(config)
1818 self . safe = config [ 'safe' ]
1919 self . source = File . expand_path ( config [ 'source' ] )
2020 self . dest = File . expand_path ( config [ 'destination' ] )
21- self . plugins = File . expand_path ( config [ 'plugins' ] )
21+ self . plugins = if config [ 'plugins' ] . respond_to? ( 'each' )
22+ # If plugins is an array, process it.
23+ Array ( config [ 'plugins' ] ) . map { |d | File . expand_path ( d ) }
24+ else
25+ if config [ 'plugins' ] . nil?
26+ [ ]
27+ else
28+ # Otherwise process a single entry as an array.
29+ [ File . expand_path ( config [ 'plugins' ] ) ]
30+ end
31+ end
2232 self . lsi = config [ 'lsi' ]
2333 self . pygments = config [ 'pygments' ]
2434 self . permalink_style = config [ 'permalink' ] . to_sym
@@ -73,8 +83,10 @@ def setup
7383 # If safe mode is off, load in any Ruby files under the plugins
7484 # directory.
7585 unless self . safe
76- Dir [ File . join ( self . plugins , "**/*.rb" ) ] . each do |f |
77- require f
86+ self . plugins . each do |plugins |
87+ Dir [ File . join ( plugins , "**/*.rb" ) ] . each do |f |
88+ require f
89+ end
7890 end
7991 end
8092
Original file line number Diff line number Diff line change 11require 'helper'
22
33class TestSite < Test ::Unit ::TestCase
4+ context "configuring sites" do
5+ should "have an array for plugins by default" do
6+ site = Site . new ( Jekyll ::DEFAULTS )
7+ assert_equal [ File . join ( Dir . pwd , '_plugins' ) ] , site . plugins
8+ end
9+
10+ should "have an array for plugins if passed as a string" do
11+ site = Site . new ( Jekyll ::DEFAULTS . merge ( { 'plugins' => '/tmp/plugins' } ) )
12+ assert_equal [ '/tmp/plugins' ] , site . plugins
13+ end
14+
15+ should "have an array for plugins if passed as an array" do
16+ site = Site . new ( Jekyll ::DEFAULTS . merge ( { 'plugins' => [ '/tmp/plugins' , '/tmp/otherplugins' ] } ) )
17+ assert_equal [ '/tmp/plugins' , '/tmp/otherplugins' ] , site . plugins
18+ end
19+
20+ should "have an empty array for plugins if nothing is passed" do
21+ site = Site . new ( Jekyll ::DEFAULTS . merge ( { 'plugins' => [ ] } ) )
22+ assert_equal [ ] , site . plugins
23+ end
24+
25+ should "have an empty array for plugins if nil is passed" do
26+ site = Site . new ( Jekyll ::DEFAULTS . merge ( { 'plugins' => nil } ) )
27+ assert_equal [ ] , site . plugins
28+ end
29+ end
430 context "creating sites" do
531 setup do
632 stub ( Jekyll ) . configuration do
You can’t perform that action at this time.
0 commit comments