Skip to content
Browse files

#1 put the risk report in a temporary location in a cross-platform way.

  • Loading branch information...
1 parent 1bf67f1 commit 39997930590b843f0bc49bba681b8e78423befa7 @robertgreiner committed Jan 20, 2012
View
5 lib/tipster/files/file.rb
@@ -1,5 +1,10 @@
+require 'tmpdir'
+
class File
def self.root(file)
expand_path('../../../', dirname(__FILE__)) << '/' << file
end
+ def self.temp(file)
+ expand_path File.expand_path Dir.tmpdir << '/' << file
+ end
end
View
1 lib/tipster/heuristics/code_churn_heuristic.rb
@@ -20,7 +20,6 @@ def process(file)
end
def churn_ratio(file)
-
total_lines = FileInfo.new(file.file_name).line_count
churned_lines = file.lines_modified
churned_lines.to_f / total_lines.to_f
View
7 lib/tipster/reports/html_report.rb
@@ -2,10 +2,12 @@
require 'launchy'
require_relative '../presenters/code_ratio_presenter'
require_relative '../presenters/code_churn_presenter'
+require_relative '../files/file'
class HtmlReport
def initialize(commit_id = nil)
+ @risk_report = File.temp 'risk_report.html'
generate html commit_id
end
@@ -20,11 +22,12 @@ def html(commit_id)
end
def generate(source)
- File.open('risk_report.html', 'w') {|f| f.write(source) }
+ File.open(@risk_report, 'w') {|f| f.write(source) }
end
def display_in_browser
- Launchy.open('risk_report.html')
+ puts @risk_report
+ Launchy.open('file:///' << @risk_report)
end
def file_details(change_list)

0 comments on commit 3999793

Please sign in to comment.
Something went wrong with that request. Please try again.