Class: Pipeline::Reporters

Inherits:
Object
  • Object
show all
Defined in:
lib/pipeline/reporters.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = { }) ⇒ Reporters

No need to use this directly.



21
22
# File 'lib/pipeline/reporters.rb', line 21

def initialize options = { }
end

Class Method Details

.add(klass) ⇒ Object

Add a task. This will call klass.new when running tests



5
6
7
# File 'lib/pipeline/reporters.rb', line 5

def self.add klass
  @reporters << klass unless @reporters.include? klass
end

.initialize_reporters(reporters_directory = "") ⇒ Object



13
14
15
16
17
18
# File 'lib/pipeline/reporters.rb', line 13

def self.initialize_reporters reporters_directory = ""
  #Load all files in task_directory
  Dir.glob(File.join(reporters_directory, "*.rb")).sort.each do |f|
    require f
  end
end

.reportersObject



9
10
11
# File 'lib/pipeline/reporters.rb', line 9

def self.reporters
  @reporters
end

.run_report(tracker) ⇒ Object

Run all the tasks on the given Tracker. Returns a new instance of tasks with the results.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/pipeline/reporters.rb', line 26

def self.run_report(tracker)
  @reporters.each do |c|
    reporter = c.new()
    if tracker.options[:output_format].first == reporter.format
      begin
        output = reporter.run_report(tracker)
        if tracker.options[:output_file]
          file = File.open(tracker.options[:output_file], 'w'){ |f| f.write(output)}
        else
          Pipeline.notify output unless tracker.options[:quiet]
        end
      rescue => e
        Pipeline.error e.message
        tracker.error e
      end
    end
  end
end