Class: Barthes::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/barthes/reporter.rb,
lib/barthes/reporter/default.rb,
lib/barthes/reporter/junit_xml.rb

Defined Under Namespace

Classes: Default, JunitXml

Instance Method Summary collapse

Constructor Details

#initializeReporter

Returns a new instance of Reporter.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/barthes/reporter.rb', line 7

def initialize
	@reporters = []
	if Barthes::Config[:reporters]
		Barthes::Config[:reporters].each do |reporter|
			if reporter.match(/^(.+)(\{.*\})$/)
				klass_name, json_string = $1, $2
				opts = JSON.parse(json_string)	
				klass = klass_name.constantize
				@reporters << klass.new(opts)
			else
				klass = reporter.constantize
				@reporters << klass.new
			end
		end
	else
		@reporters = [Reporter::Default.new]
	end
end

Instance Method Details

#report(event, *args, &block) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/barthes/reporter.rb', line 26

def report(event, *args, &block)
	@reporters.each do |r|
		m = :"before_#{event.to_s}"
		r.send(m, *args) if r.respond_to?(m)
	end
	
	result = yield

	@reporters.each do |r|
		m = :"after_#{event.to_s}"
		r.send(m, *args) if r.respond_to?(m)
	end
end