Permalink
Browse files

Separating add and add_directory methods in Auto::Plugins, require! a…

…nd require_all! in Auto::Runner
  • Loading branch information...
1 parent c058c95 commit 6962109e560e1d97a85537fdc280e3c60b9cf262 @winton committed Nov 16, 2009
Showing with 21 additions and 11 deletions.
  1. +6 −1 lib/auto/plugins.rb
  2. +13 −8 lib/auto/runner.rb
  3. +1 −1 spec/auto/plugins_spec.rb
  4. +1 −1 spec/auto/runner_spec.rb
View
@@ -14,8 +14,13 @@ class Plugins
class <<self
- # Add a directory to the plugin load paths.
+ # Add a plugin base directory
def add(path)
+ Runner.require! Plugin.new(path)
+ end
+
+ # Add a directory to the plugin load paths.
+ def add_directory(path)
@@directories = [] if $testing
@@directories << path
@@directories.uniq!
View
@@ -21,15 +21,20 @@ def run(path_or_task=nil, &block)
class <<self
- def require!
+ def require!(plugin=nil)
+ require_all! and return unless plugin
+ if plugin.library
+ require plugin.library
+ end
+ begin
+ include eval(plugin.module)
+ rescue
+ end
+ end
+
+ def require_all!
Plugins.plugins.each do |plugin|
- if plugin.library
- require plugin.library
- end
- begin
- include eval(plugin.module)
- rescue
- end
+ require! plugin
end
end
end
@@ -4,7 +4,7 @@ module Auto
describe Auto::Plugins do
before(:all) do
- Plugins.add @fixtures = "#{SPEC}/plugins"
+ Plugins.add_directory @fixtures = "#{SPEC}/plugins"
@libraries = Plugins.libraries
@modules = Plugins.modules
@tasks = Plugins.tasks
View
@@ -4,7 +4,7 @@ module Auto
describe Auto::Runner do
before(:all) do
- Plugins.add @fixtures = "#{SPEC}/plugins"
+ Plugins.add_directory @fixtures = "#{SPEC}/plugins"
@runner = Runner.new
end

0 comments on commit 6962109

Please sign in to comment.