Module: SeeingIsBelieving::Binary::AnnotateEndOfFile
- Extended by:
- AnnotateEndOfFile
- Included in:
- AnnotateEndOfFile
- Defined in:
- lib/seeing_is_believing/binary/annotate_end_of_file.rb
Instance Method Summary collapse
- #add_stdout_stderr_and_exceptions_to(new_body, results, options) ⇒ Object
- #exception_output_for(results, options) ⇒ Object
- #stderr_ouptut_for(results, options) ⇒ Object
- #stdout_ouptut_for(results, options) ⇒ Object
Instance Method Details
#add_stdout_stderr_and_exceptions_to(new_body, results, options) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/seeing_is_believing/binary/annotate_end_of_file.rb', line 9 def add_stdout_stderr_and_exceptions_to(new_body, results, ) output = stdout_ouptut_for(results, ) << stderr_ouptut_for(results, ) << exception_output_for(results, ) code = Code.new(new_body) code.rewriter.insert_after code.body_range, output new_body.replace code.rewriter.process end |
#exception_output_for(results, options) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/seeing_is_believing/binary/annotate_end_of_file.rb', line 37 def exception_output_for(results, ) return '' unless results.has_exception? exception_marker = [:markers][:exception][:prefix] output = "" results.exceptions.each do |exception| output << "\n" output << FormatComment.new(0, exception_marker, exception.class_name, ).call << "\n" exception..each_line do |line| output << FormatComment.new(0, exception_marker, line.chomp, ).call << "\n" end output << exception_marker.sub(/\s+$/, '') << "\n" exception.backtrace.each do |line| output << FormatComment.new(0, exception_marker, line.chomp, ).call << "\n" end end output end |
#stderr_ouptut_for(results, options) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/seeing_is_believing/binary/annotate_end_of_file.rb', line 28 def stderr_ouptut_for(results, ) return '' unless results.has_stderr? output = "\n" results.stderr.each_line do |line| output << FormatComment.call(0, [:markers][:stderr][:prefix], line.chomp, ) << "\n" end output end |
#stdout_ouptut_for(results, options) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/seeing_is_believing/binary/annotate_end_of_file.rb', line 19 def stdout_ouptut_for(results, ) return '' unless results.has_stdout? output = "\n" results.stdout.each_line do |line| output << FormatComment.call(0, [:markers][:stdout][:prefix], line.chomp, ) << "\n" end output end |