Class: Snuffle::Formatters::Html
- Inherits:
-
Object
- Object
- Snuffle::Formatters::Html
show all
- Includes:
- Base
- Defined in:
- lib/snuffle/formatters/html.rb
Instance Method Summary
collapse
Methods included from Base
#columns, #export, #filename, included, #initialize, #output_path, #path_to_results
Instance Method Details
#content ⇒ Object
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/snuffle/formatters/html.rb', line 18
def content
Haml::Engine.new(output_template).render(
Object.new, {
summary: summary,
source_lines: preprocessed,
date: Time.now.strftime("%Y/%m/%d"),
time: Time.now.strftime("%l:%M %P")
}
)
end
|
#file_extension ⇒ Object
41
42
43
|
# File 'lib/snuffle/formatters/html.rb', line 41
def file_extension
".htm"
end
|
10
11
12
|
# File 'lib/snuffle/formatters/html.rb', line 10
def formatter
Rouge::Formatters::HTML.new(css_class: 'highlight', line_numbers: true)
end
|
#lexer ⇒ Object
14
15
16
|
# File 'lib/snuffle/formatters/html.rb', line 14
def lexer
lexer = Rouge::Lexers::Ruby.new
end
|
#output_template ⇒ Object
29
30
31
|
# File 'lib/snuffle/formatters/html.rb', line 29
def output_template
File.read(File.dirname(__FILE__) + "/templates/output.html.haml")
end
|
#preprocessed ⇒ Object
33
34
35
|
# File 'lib/snuffle/formatters/html.rb', line 33
def preprocessed
formatter.format(lexer.lex(source))
end
|
#root_path ⇒ Object
37
38
39
|
# File 'lib/snuffle/formatters/html.rb', line 37
def root_path
"doc/snuffle/source"
end
|