Skip to content

Commit

Permalink
WIP. HTML results.
Browse files Browse the repository at this point in the history
  • Loading branch information
sharnik committed Nov 15, 2011
1 parent cf461ad commit bb20bf7
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/loris.rb
@@ -1,5 +1,6 @@
require 'rcov'
require 'loris/utils.rb'
require 'loris/result.rb'
require 'loris/base.rb'
require 'loris/report.rb'

Expand Down
3 changes: 3 additions & 0 deletions lib/loris/base.rb
Expand Up @@ -9,6 +9,7 @@ module Loris
accessor :silencers, [/\/gems\//, /\/ruby\//, /\/vendor\//, /\/test\//, /\/spec\//,
__FILE__, File.expand_path('monkeypatching.rb', File.dirname(__FILE__))]
accessor :excluded_paths, ['spec/support', 'spec/factories']
accessor :result

def self.mode
if arguments[:file] && arguments[:line_number]
Expand Down Expand Up @@ -66,6 +67,8 @@ def self.set_attributes(env)

Loris.silencers += Loris.arguments[:add_silencers]
Loris.excluded_paths += Loris.arguments[:add_excluded_paths]

Loris.result = Loris::Result.new
end

# Main method to run Loris: loads tests and runs them.
Expand Down
8 changes: 4 additions & 4 deletions lib/loris/report.rb
Expand Up @@ -31,7 +31,7 @@ def self.puke_out_report
if directory
Dir::mkdir(directory) unless FileTest::directory?(directory)
File.open("#{directory}/index.html", "w") do |f|
f.write report_to_html(result)
f.write report_to_html
end
else
output = ""
Expand All @@ -56,11 +56,11 @@ def self.puke_out_report
end

private
def report_to_html(data)
def self.report_to_html
require "erb"
template_file = File.read('template/index.html.erb')
template_file = File.open(File.expand_path("template/index.html.erb", File.dirname(__FILE__)), "r:UTF-8')
template = ERB.new(template_file, 0, "%<>")
output = template.result(data)
output = template.result( Loris.result.get_binding )
end

def self.condition(test_cases, file, line_number)
Expand Down
13 changes: 13 additions & 0 deletions lib/loris/result.rb
@@ -0,0 +1,13 @@
module Loris
class Result
attr_accessor :dupa

def initialize
@dupa = 'DUPA!'
end

def get_binding
binding()
end
end
end
Expand Up @@ -13,6 +13,7 @@
<body>
<div class='container'>
<h1>Loris results</h1>
<h1><%= @dupa %></h1>
<p> These are results of the coverage tests done by the Loris tool:</p>

<div>
Expand Down

0 comments on commit bb20bf7

Please sign in to comment.