Class: Tracing::HtmlAppender
- Inherits:
-
FileAppender
- Object
- BaseAppender
- FileAppender
- Tracing::HtmlAppender
- Defined in:
- lib/appenders/types/html_appender.rb
Instance Attribute Summary collapse
-
#html_output ⇒ Object
Returns the value of attribute html_output.
-
#to_file ⇒ Object
Returns the value of attribute to_file.
Attributes inherited from BaseAppender
Attributes included from FilterUse
Attributes included from Filter::ExecUse
Attributes included from Filter::Registration
Instance Method Summary collapse
-
#allow_append(txt, context) ⇒ Object
perform append perform append.
- #create_initial_file(file) ⇒ Object
- #html_begin ⇒ Object
- #html_end ⇒ Object
-
#initialize(init_options = nil) ⇒ HtmlAppender
constructor
A new instance of HtmlAppender.
-
#not_allow_append(lines, context) ⇒ Object
silently ignore.
- #write_wrap_file(file) ⇒ Object
Methods inherited from FileAppender
#file_path, #insert_into_file, #is_old_file?, #write_file
Methods included from DefaultPath
Methods inherited from BaseAppender
create_template, #handle, register_templates, #time_limit
Methods included from Filter::Registration
#_register_filters, #create_filters, #register_filters, #unregister_filters
Constructor Details
#initialize(init_options = nil) ⇒ HtmlAppender
Returns a new instance of HtmlAppender.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/appenders/types/html_appender.rb', line 5 def initialize( = nil) @tracer = Tracing::HtmlTemplate.new super() @html_output = html_begin return if ! # write to file @to_file = [:to_file] # override default path for class @default_path = [:default_path] if @to_file write_wrap_file(to_file) else html_output << html_begin << html_end end end |
Instance Attribute Details
#html_output ⇒ Object
Returns the value of attribute html_output.
3 4 5 |
# File 'lib/appenders/types/html_appender.rb', line 3 def html_output @html_output end |
#to_file ⇒ Object
Returns the value of attribute to_file.
3 4 5 |
# File 'lib/appenders/types/html_appender.rb', line 3 def to_file @to_file end |
Instance Method Details
#allow_append(txt, context) ⇒ Object
perform append perform append
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/appenders/types/html_appender.rb', line 58 def allow_append(txt, context) # check if BEGIN or END if txt.include?('BEGIN') txt = tracer.handle_before_call(context) elsif txt.include?('END') txt = tracer.handle_after_call(context) end if to_file insert_into_file(to_file, txt, html_end) else # insert into string html_output = txt[0..-html_end.length] + txt + html_end end end |
#create_initial_file(file) ⇒ Object
32 33 34 |
# File 'lib/appenders/types/html_appender.rb', line 32 def create_initial_file(file) write_wrap_file(file) end |
#html_begin ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/appenders/types/html_appender.rb', line 36 def html_begin %q{<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Tracing :: abc</title> <link rel="stylesheet" href="tracing.css" type="text/css" media="screen" title="tracing" charset="utf-8"> <script type="text/javascript" src="jquery-1.3.2.min.js"></script> <script type="text/javascript" src="tracing.js"></script> </head> <body>} end |
#html_end ⇒ Object
49 50 51 52 53 54 |
# File 'lib/appenders/types/html_appender.rb', line 49 def html_end %q{ </body> </html> } end |
#not_allow_append(lines, context) ⇒ Object
silently ignore
75 76 |
# File 'lib/appenders/types/html_appender.rb', line 75 def not_allow_append(lines, context) end |
#write_wrap_file(file) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/appenders/types/html_appender.rb', line 24 def write_wrap_file(file) file = file_path(file) File.open(file, "w") do |file| file.puts html_begin file.puts html_end end end |