Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add support for custom reporters. (Ryan Sandridge) [major]

  • Loading branch information...
commit 9a65ccac67edd39cb76f6ea98681c5f6a7432421 1 parent fa3a688
@trans trans authored
Showing with 20 additions and 23 deletions.
  1. +9 −0 README.md
  2. +11 −23 lib/turn/configuration.rb
View
9 README.md
@@ -119,6 +119,15 @@ Also, you can use following environment variables to adjust settings:
backtrace Number of backtrace lines to display. Default: set from ENV or nil
ansi Force colorize output (requires 'ansi' gem).
+Finally, you can include your own custom Reporter type (aka format). Turn will search for reporters in the `.turn/reporters/`
+directory of your local project and then in your user home directory. So for example, if you specified the following:
+
+ Turn.config.format = :cool
+
+Then Turn will look first for `./.turn/reporters/cool_reporter.rb`, then `~/.turn/reporters/cool_reporter.rb`.
+
+See source code for examples of how to write your own reporters.
+
## REQUIREMENTS:
View
34 lib/turn/configuration.rb
@@ -180,30 +180,18 @@ def suite_name
# Select reporter based on output mode.
def reporter
@reporter ||= (
- opts = reporter_options
- case format
- when :marshal
- require 'turn/reporters/marshal_reporter'
- Turn::MarshalReporter.new($stdout, opts)
- when :progress
- require 'turn/reporters/progress_reporter'
- Turn::ProgressReporter.new($stdout, opts)
- when :dotted, :dot
- require 'turn/reporters/dot_reporter'
- Turn::DotReporter.new($stdout, opts)
- when :outline
- require 'turn/reporters/outline_reporter'
- Turn::OutlineReporter.new($stdout, opts)
- when :cue
- require 'turn/reporters/cue_reporter'
- Turn::CueReporter.new($stdout, opts)
- when :pretty
- require 'turn/reporters/pretty_reporter'
- Turn::PrettyReporter.new($stdout, opts)
- else
- require 'turn/reporters/pretty_reporter'
- Turn::PrettyReporter.new($stdout, opts)
+ rpt_format = format || :pretty
+ class_name = rpt_format.to_s.capitalize + "Reporter"
+
+ path = "turn/reporters/#{rpt_format}_reporter"
+ [$HOME, DIR.pwd].each do |dir|
+ file = File.join(dir, ".turn", "reporters", "#{rpt_format}_reporter.rb")
+ path = file if File.exist?(file)
end
+
+ require path
+
+ Turn.const_get(class_name).new($stdout, reporter_opts)
)
end
Please sign in to comment.
Something went wrong with that request. Please try again.