Class: ConfluenceStepOutputter
- Inherits:
-
Object
- Object
- ConfluenceStepOutputter
- Defined in:
- lib/confluence_step_outputter.rb
Instance Method Summary collapse
- #close ⇒ Object
- #end_all ⇒ Object
- #end_directory ⇒ Object
- #footer ⇒ Object
- #header ⇒ Object
-
#initialize(file) ⇒ ConfluenceStepOutputter
constructor
A new instance of ConfluenceStepOutputter.
- #start_all ⇒ Object
- #start_directory(dir) ⇒ Object
- #step(step) ⇒ Object
Constructor Details
#initialize(file) ⇒ ConfluenceStepOutputter
Returns a new instance of ConfluenceStepOutputter.
7 8 9 10 |
# File 'lib/confluence_step_outputter.rb', line 7 def initialize(file) @file = File.open(file, 'w') @previous_type = '' end |
Instance Method Details
#close ⇒ Object
21 22 23 |
# File 'lib/confluence_step_outputter.rb', line 21 def close @file.close end |
#end_all ⇒ Object
41 42 43 |
# File 'lib/confluence_step_outputter.rb', line 41 def end_all # No-op end |
#end_directory ⇒ Object
31 32 33 |
# File 'lib/confluence_step_outputter.rb', line 31 def end_directory # No-op end |
#footer ⇒ Object
16 17 18 19 |
# File 'lib/confluence_step_outputter.rb', line 16 def @file.puts %(<p> </p>) @file.puts %(<p><em>Documentation generated #{Time.now}</em></p>) end |
#header ⇒ Object
12 13 14 |
# File 'lib/confluence_step_outputter.rb', line 12 def header # No-op end |
#start_all ⇒ Object
35 36 37 38 39 |
# File 'lib/confluence_step_outputter.rb', line 35 def start_all @file.puts %(<p> </p>) @file.puts '<h2>All definitions alphabetically</h2>' @previous_type = '' end |
#start_directory(dir) ⇒ Object
25 26 27 28 29 |
# File 'lib/confluence_step_outputter.rb', line 25 def start_directory(dir) @file.puts %(<p> </p>) @file.puts "<h2>#{dir}</h2>" @previous_type = '' end |
#step(step) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/confluence_step_outputter.rb', line 45 def step(step) if @previous_type != step[:type] @file.puts %(<h3>#{step[:type]} definitions</h3>) @previous_type = step[:type] end @file.puts %(<ac:macro ac:name="expand">) @file.puts %( <ac:parameter ac:name="title">#{CGI.escapeHTML(step[:name])}</ac:parameter>) @file.puts %( <ac:rich-text-body>) # TODO: Add link to source repo or Jenkins workspace # <p><a href=".../#{CGI.escapeHTML(step[:filename])}" style="color: #888;">#{CGI.escapeHTML(step[:filename])}:#{step[:line_number]}</a></p> @file.puts %( <p style="color: #888;">#{CGI.escapeHTML(step[:filename])}:#{step[:line_number]}</p>) @file.puts %( <pre style="background-color: #ddd; padding-top: 1.2em;">) step[:code].each do |line| @file.puts %( #{CGI.escapeHTML(line)}) end @file.puts %( </pre>) @file.puts %( </ac:rich-text-body>) @file.puts %(</ac:macro>) end |