Class: HtmlReport
Constant Summary
Constants included from Template
Template::COMMIT, Template::HEAD, Template::MAJOR_HEAD, Template::MAJOR_TAIL, Template::MINOR, Template::TAIL
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(stats, title, days) ⇒ HtmlReport
constructor
A new instance of HtmlReport.
Constructor Details
#initialize(stats, title, days) ⇒ HtmlReport
Returns a new instance of HtmlReport.
8 9 10 11 12 |
# File 'lib/html_report.rb', line 8 def initialize(stats, title, days) @stats = stats @title = title @days = days end |
Instance Method Details
#generate ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/html_report.rb', line 14 def generate report = '' from = (Time.now - @days*60*60*24).strftime("%Y.%m.%d") to = Time.now.strftime("%Y.%m.%d") report << Template::HEAD.gsub('%TITLE%', @title).gsub("%FROM%", from).gsub('%TO%', to) for major in @stats.keys.sort report << Template::MAJOR_HEAD.gsub('%MAJOR%', major) sum = 0 for minor, lines in @stats[major].sort report << Template::MINOR.gsub('%MINOR%', minor).gsub('%LINES%', lines.to_s) sum += lines end report << Template::MINOR.gsub('%MINOR%', '.').gsub('%LINES%', sum.to_s) report << Template::MAJOR_TAIL end report << Template::TAIL end |