Commit 226e41fb authored by Coraline Ehmke's avatar Coraline Ehmke

Output code to HTML view

parent 2a81bafe
......@@ -15,7 +15,7 @@ module Snuffle
summaries = []
file_list(path).each do |path_to_file|
summary = Snuffle::SourceFile.new(path_to_file: path_to_file).summary
report(summary)
report(summary, summary.source)
summaries << summary
end
create_html_index(summaries)
......@@ -36,10 +36,10 @@ module Snuffle
end
end
def report(summary)
def report(summary, source)
text_report(summary)
cvs_report(summary)
html_report(summary)
html_report(summary, source)
end
def create_html_index(summaries)
......@@ -53,10 +53,10 @@ module Snuffle
results_files << Snuffle::Formatters::Csv.new(summary).export
end
def html_report(summary)
def html_report(summary, source)
return unless options['format'] == 'html'
return unless summary.object_candidates.count > 0
results_files << Snuffle::Formatters::Html.new(summary).export
results_files << Snuffle::Formatters::Html.new(summary, source).export
end
def text_report(summary)
......
......@@ -6,10 +6,12 @@ module Snuffle
def self.included(klass)
klass.send(:attr_accessor, :summary)
klass.send(:attr_accessor, :source)
end
def initialize(summary)
def initialize(summary, source="")
self.summary = summary
self.source = source
end
def content
......
......@@ -30,6 +30,10 @@ module Snuffle
File.read(File.dirname(__FILE__) + "/templates/output.html.haml")
end
def preprocessed
formatter.format(lexer.lex(source))
end
def root_path
"doc/snuffle/source"
end
......
......@@ -32,7 +32,7 @@ module Snuffle
end_pos += line.size
self.lines_of_code << LineOfCode.new(index: index, range: (start_pos..end_pos))
line
end.join("\r\n")
end.join
end
def summary
......@@ -41,7 +41,8 @@ module Snuffle
source: self.source,
class_name: class_name,
path_to_file: self.path_to_file,
object_candidates: object_candidates
object_candidates: object_candidates,
source: self.source
)
end
......
......@@ -2,7 +2,12 @@ module Snuffle
class Summary
include PoroPlus
attr_accessor :class_name, :path_to_file, :object_candidates
attr_accessor :class_name, :path_to_file, :object_candidates, :source
def class_filename
self.class_name.downcase.gsub(' ', '_')
end
end
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment