Class: Tempo::Views::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/tempo/views/reporter.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.view_recordsObject

Returns the value of attribute view_records.



34
35
36
# File 'lib/tempo/views/reporter.rb', line 34

def view_records
  @view_records
end

Class Method Details

.add_format(*formats) ⇒ Object



36
37
38
39
# File 'lib/tempo/views/reporter.rb', line 36

def add_format(*formats)
  @@formats ||= []
  formats.each {|format| @@formats << format}
end

.add_options(options) ⇒ Object



55
56
57
58
# File 'lib/tempo/views/reporter.rb', line 55

def add_options(options)
  @@options ||= {}
  @@options.merge! options
end

.add_view_record(record) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/tempo/views/reporter.rb', line 60

def add_view_record(record)
  @@view_records ||= []

  if /Views::ViewRecords/.match record.class.name
    @@view_records << record

    # console must be able to return a value
    return console.report record
  else
    raise InvalidViewRecordError
  end
end

.consoleObject

All records are sent directly to the console, so it can decide if action is required immediately based on the type of record



51
52
53
# File 'lib/tempo/views/reporter.rb', line 51

def console
  @@console ||= Formatters::Interactive.new(options)
end

.formatsObject



41
42
43
# File 'lib/tempo/views/reporter.rb', line 41

def formats
  @@formats ||= []
end

.optionsObject



45
46
47
# File 'lib/tempo/views/reporter.rb', line 45

def options
  @@options ||= {}
end

.reportObject



77
78
79
80
81
# File 'lib/tempo/views/reporter.rb', line 77

def report
  # TODO send records to added formatters
  screen_formatter = Formatters::Screen.new(options)
  screen_formatter.format_records view_records
end