Module: Duvet
- Defined in:
- lib/duvet.rb,
lib/duvet/cov.rb,
lib/duvet/covs.rb,
lib/duvet/version.rb
Defined Under Namespace
Constant Summary collapse
- DEFAULTS =
{:dir => 'cov', :style => 'rcov'}
- TEMPLATE_PATH =
Pathname.new(__FILE__).dirname + '..' + 'templates'
- TEMPLATE_HASH =
{ 'time' => Time.now, 'version' => VERSION, 'name' => 'duvet' }
- VERSION =
'0.3.3'
Instance Attribute Summary collapse
-
#opts ⇒ Object
Returns the value of attribute opts.
Class Method Summary collapse
-
.at_exit ⇒ Object
Proc to call when exiting.
-
.result ⇒ Object
Get result.
-
.running? ⇒ Boolean
Whether coverage is running.
-
.start(opts = {}) ⇒ Object
Start tracking.
-
.write ⇒ Object
Write results.
Instance Attribute Details
#opts ⇒ Object
Returns the value of attribute opts.
19 20 21 |
# File 'lib/duvet.rb', line 19 def opts @opts end |
Class Method Details
.at_exit ⇒ Object
TODO:
Allow user to override block used
Proc to call when exiting
64 65 66 |
# File 'lib/duvet.rb', line 64 def self.at_exit Proc.new { self.write } end |
.result ⇒ Object
Get result
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/duvet.rb', line 40 def self.result cov = Coverage.result if running? if @opts[:filter] filtered = {} @opts[:filter] = /#{@opts[:filter]}/ unless @opts[:filter].is_a?(Regexp) cov.each do |k, v| if @opts[:filter] =~ k filtered[k] = v end end cov = filtered end @result ||= Duvet::Covs.new(cov) ensure @running = false end |
.running? ⇒ Boolean
Returns whether coverage is running.
69 70 71 |
# File 'lib/duvet.rb', line 69 def self.running? @running end |
.start(opts = {}) ⇒ Object
Start tracking
32 33 34 35 36 37 |
# File 'lib/duvet.rb', line 32 def self.start(opts={}) @opts = DEFAULTS.merge(opts) Coverage.start @running = true end |
.write ⇒ Object
Write results
58 59 60 |
# File 'lib/duvet.rb', line 58 def self.write self.result.write(Pathname.new(@opts[:dir])) if running? end |