Class: Simplabs::Excellent::Formatters::Html
- Defined in:
- lib/simplabs/excellent/formatters/html.rb
Overview
:nodoc:
Constant Summary collapse
- HEADER_TEMPLATE =
" <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n <html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n <head>\n <title>Excellent result</title>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n <style type=\"text/css\">\n body {\n margin: 0;\n padding: 0;\n background: #fff;\n font-size: 80%;\n font-family: \"Lucida Grande\", Helvetica, sans-serif;\n }\n\n #header {\n background: #ccc;\n color: #000;\n height: 4em;\n }\n\n #header h1 {\n font-size: 1.8em;\n margin: 0px 10px 0px 10px;\n padding: 10px;\n position: absolute;\n }\n\n #results {\n margin: 0px 10px 5px;\n }\n\n dt {\n background: #ccc;\n padding: 5px;\n font-weight: bold;\n margin: 30px 0 0 0;\n }\n\n dd {\n margin: 5px 0px 5px 20px;\n }\n\n dd.warning {\n background: #faf834;\n }\n\n dd.warning span.lineNumber {\n background: #ccc;\n font-weight: bold;\n padding: 3px;\n display: inline-block;\n margin: 0 10px 0 0;\n }\n\n dd.warning span.number {\n width: 30px;\n text-align: right;\n display: inline-block;\n }\n\n #footer {\n margin: 20px 0 20px 0;\n padding: 5px;\n text-align: center;\n }\n\n #footer a {\n color: #000;\n background-color: #ddd;\n text-decoration: none;\n padding: 0 2px 0 2px;\n }\n\n #footer a:active, #footer a:hover {\n color: #fff;\n background-color: #222;\n }\n </style>\n </head>\n <body>\n <div id=\"header\">\n <div id=\"label\">\n <h1>Excellent result</h1>\n </div>\n </div>\n <div id=\"results\">\n"- START_FIlE_TAMPLATE =
" <div class=\"file\">\n <dl>\n <dt>{{filename}}</dt>\n"- END_FIlE_TAMPLATE =
" </dl>\n </div>\n"- WARNING_TEMPLATE =
" <dd class=\"warning\"><span class=\"lineNumber\">Line <span class=\"number\">{{line_number}}</span></span>{{message}}</dd>\n"- FOOTER_TEMPLATE =
" </div>\n <div id=\"footer\">\n <a href=\"http://github.com/simplabs/excellent\" title=\"Excellent at github\">Excellent</a> by <a href=\"http://simplabs.com\" title=\"simplabs\">simplabs</a>\n </div>\n </body>\n </html>\n"
Instance Method Summary collapse
- #end ⇒ Object
- #file(filename) {|_self| ... } ⇒ Object
-
#initialize(stream = $stdout) ⇒ Html
constructor
A new instance of Html.
- #start ⇒ Object
- #warning(warning) ⇒ Object
Constructor Details
#initialize(stream = $stdout) ⇒ Html
Returns a new instance of Html.
11 12 13 |
# File 'lib/simplabs/excellent/formatters/html.rb', line 11 def initialize(stream = $stdout) super end |
Instance Method Details
#end ⇒ Object
29 30 31 |
# File 'lib/simplabs/excellent/formatters/html.rb', line 29 def end @stream.write(FOOTER_TEMPLATE) end |
#file(filename) {|_self| ... } ⇒ Object
19 20 21 22 23 |
# File 'lib/simplabs/excellent/formatters/html.rb', line 19 def file(filename) @stream.write(START_FIlE_TAMPLATE.sub('{{filename}}', filename)) yield self @stream.write(END_FIlE_TAMPLATE) end |
#start ⇒ Object
15 16 17 |
# File 'lib/simplabs/excellent/formatters/html.rb', line 15 def start @stream.write(HEADER_TEMPLATE) end |
#warning(warning) ⇒ Object
25 26 27 |
# File 'lib/simplabs/excellent/formatters/html.rb', line 25 def warning(warning) @stream.write(WARNING_TEMPLATE.sub('{{line_number}}', warning.line_number.to_s).sub('{{message}}', warning.)) end |