Permalink
Browse files

Add support for autoloading reporter plugins.

  • Loading branch information...
1 parent f42e63c commit 462dd62f52c3ada1c242cdb6243eaf17e6f0e8e0 @trans trans committed Apr 14, 2012
Showing with 19 additions and 3 deletions.
  1. +10 −2 lib/tapout/cli.rb
  2. +9 −1 lib/tapout/reporters/abstract.rb
View
@@ -29,11 +29,19 @@ def self.cli(*argv)
self.config.minimal = val
end
- opt.on('--no-color', 'Supress ANSI color codes') do
+ opt.on('--no-color', 'suppress ANSI color codes') do
$ansi = false
end
- opt.on('--debug', 'Run with $DEBUG flag on') do |fmt|
+ opt.on('--require', '-r FEATURE', 'require feature') do |feature|
+ require feature
+ end
+
+ #opt.on('--plugin', '-p NAME', 'Require plugin feature (tapout-<name>)') do |name|
+ # require "tapout-#{name}"
+ #end
+
+ opt.on('--debug', 'run with $DEBUG flag on') do |fmt|
$DEBUG = true
end
@@ -19,7 +19,15 @@ def self.index
def self.factory(name)
list = index.keys.abbrev
rptr = index[list[name || DEAFULT_REPORTER]]
- raise ArgumentError, "Unrecognized reporter -- #{name.inspect}" unless rptr
+ unless rptr
+ begin
+ require "tapout-#{name}"
+ list = index.keys.abbrev
+ rptr = index[list[name || DEAFULT_REPORTER]]
+ rescue LoadError
+ end
+ raise ArgumentError, "Unrecognized reporter -- #{name.inspect}" unless rptr
+ end
rptr
end

0 comments on commit 462dd62

Please sign in to comment.