Class: Uncool::Report
- Inherits:
-
Object
- Object
- Uncool::Report
- Defined in:
- lib/uncool/report.rb
Instance Method Summary collapse
- #coverage ⇒ Object
- #display(format = nil) ⇒ Object
- #display_color ⇒ Object
- #display_tap ⇒ Object
-
#initialize(analysis, options = {}) ⇒ Report
constructor
A new instance of Report.
- #options ⇒ Object
- #render ⇒ Object
- #save(logpath) ⇒ Object
Constructor Details
#initialize(analysis, options = {}) ⇒ Report
Returns a new instance of Report.
7 8 9 10 |
# File 'lib/uncool/report.rb', line 7 def initialize(analysis, ={}) @analysis = analysis @options = end |
Instance Method Details
#coverage ⇒ Object
18 19 20 |
# File 'lib/uncool/report.rb', line 18 def coverage @analysis.coverage end |
#display(format = nil) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/uncool/report.rb', line 40 def display(format=nil) case [:format] when 'tap' display_tap else display_color end end |
#display_color ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/uncool/report.rb', line 50 def display_color require 'ansi' puts "\nUnit Coverage" i = 0 coverage.uniq.sort.each do |unit| i += 1 if unit.covered? puts "+ " + unit.to_s.ansi(:green) else puts "- " + unit.to_s.ansi(:red) end end puts end |
#display_tap ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/uncool/report.rb', line 66 def display_tap i = 0 coverage.uniq.sort.each do |unit| i += 1 if unit.covered? puts "ok #{i} - " + unit.to_s else puts "not ok #{i} - " + unit.to_s end end end |
#options ⇒ Object
13 14 15 |
# File 'lib/uncool/report.rb', line 13 def @options end |
#render ⇒ Object
23 24 25 26 27 |
# File 'lib/uncool/report.rb', line 23 def render require 'erb' rhtml = File.read(File.dirname(__FILE__) + '/report.rhtml') ERB.new(rhtml).result(binding) end |
#save(logpath) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/uncool/report.rb', line 30 def save(logpath) require 'fileutils' dir = File.join(logpath, 'uncool') file = File.join(dir, 'index.html') FileUtils.mkdir_p(dir) File.open(file, 'w'){ |w| w << render } $stderr.puts "Saved Uncool report at #{dir}." end |