Class: MetricFu::Base::Generator
- Inherits:
-
Object
- Object
- MetricFu::Base::Generator
show all
- Defined in:
- lib/metric_fu/base.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(base_dir, options = {}) ⇒ Generator
Returns a new instance of Generator.
16
17
18
|
# File 'lib/metric_fu/base.rb', line 16
def initialize(base_dir, options={})
@base_dir = base_dir
end
|
Class Method Details
.generate_report(base_dir, options = {}) ⇒ Object
20
21
22
|
# File 'lib/metric_fu/base.rb', line 20
def self.generate_report(base_dir, options={})
self.new(base_dir, options).generate_report
end
|
Instance Method Details
#generate_html ⇒ Object
34
35
36
37
|
# File 'lib/metric_fu/base.rb', line 34
def generate_html
analyze
html = ERB.new(File.read(template_file)).result(binding)
end
|
#generate_report ⇒ Object
30
31
32
|
# File 'lib/metric_fu/base.rb', line 30
def generate_report
save_html(generate_html)
end
|
#link_to_filename(name, line = nil) ⇒ Object
43
44
45
46
47
48
49
50
|
# File 'lib/metric_fu/base.rb', line 43
def link_to_filename(name, line = nil)
filename = File.expand_path(name)
if PLATFORM['darwin']
%{<a href="txmt://open/?url=file://#{filename}&line=#{line}">#{name}</a>}
else
%{<a href="file://#{filename}">#{name}</a>}
end
end
|
#save_html(content, file = 'index') ⇒ Object
24
25
26
27
28
|
# File 'lib/metric_fu/base.rb', line 24
def save_html(content, file='index')
open("#{@base_dir}/#{file}.html", "w") do |f|
f.puts content
end
end
|
#template_file ⇒ Object
39
40
41
|
# File 'lib/metric_fu/base.rb', line 39
def template_file
File.join(MetricFu::TEMPLATE_DIR, "#{template_name}.html.erb")
end
|