Class: CommitCommentTools::ReportNormlizer

Inherits:
Object
  • Object
show all
Defined in:
lib/commit-comment-tools/report-normalizer.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeReportNormlizer

Returns a new instance of ReportNormlizer.



28
29
30
# File 'lib/commit-comment-tools/report-normalizer.rb', line 28

def initialize
  @person_reports = {}
end

Class Method Details

.normalize(parsed_reports) ⇒ Object



23
24
25
# File 'lib/commit-comment-tools/report-normalizer.rb', line 23

def normalize(parsed_reports)
  new.normalize(parsed_reports)
end

Instance Method Details

#normalize(parsed_reports) ⇒ Object



32
33
34
35
36
37
# File 'lib/commit-comment-tools/report-normalizer.rb', line 32

def normalize(parsed_reports)
  parsed_reports.each do |person, daily_report|
    normalize_daily_report(person, daily_report)
  end
  @person_reports
end

#normalize_daily_report(person, daily_report) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/commit-comment-tools/report-normalizer.rb', line 39

def normalize_daily_report(person, daily_report)
  @person_reports[person] = {}

  daily_report.each do |date, report|
    normalized_date = normalize_date(date)
    @person_reports[person][normalized_date] = normalize_report(report)
  end
  @person_reports
end

#normalize_date(date) ⇒ Object



49
50
51
# File 'lib/commit-comment-tools/report-normalizer.rb', line 49

def normalize_date(date)
  Date.parse(date).strftime("%Y-%m-%d")
end

#normalize_report(report) ⇒ Object



53
54
55
56
# File 'lib/commit-comment-tools/report-normalizer.rb', line 53

def normalize_report(report)
  report[:read_ratio] = report[:read_ratio].to_i
  report
end