Class: Taeval::Reporter

Inherits:
Object
  • Object
show all
Includes:
FileHelper
Defined in:
lib/taeval/reporter.rb

Instance Method Summary collapse

Methods included from FileHelper

#create, #exist?, #flatten_include!, #open, #path_of

Constructor Details

#initialize(conf_h) ⇒ Reporter

Returns a new instance of Reporter.



9
10
11
12
# File 'lib/taeval/reporter.rb', line 9

def initialize(conf_h)
  @path    = path_of(conf_h.dig('report', 'path'))
  @records = {}
end

Instance Method Details

#add(data) ⇒ Object



14
15
16
17
18
# File 'lib/taeval/reporter.rb', line 14

def add(data)
  @records[data[:repo]] = {} if !@records.has_key?(data[:repo])
  @records[data[:repo]][data[:runner]] = [] if !@records[data[:repo]].has_key?(data[:runner])
  @records[data[:repo]][data[:runner]] << data[:msg]
end

#saveObject



20
21
22
23
24
25
# File 'lib/taeval/reporter.rb', line 20

def save
  p "Reporter#save..."
  File.open(@path,'w') do |f|
    f.write(@records.to_json)
  end
end