Class: SeeingIsBelieving::Binary::AddAnnotations
- Inherits:
-
Object
- Object
- SeeingIsBelieving::Binary::AddAnnotations
- Includes:
- HasException
- Defined in:
- lib/seeing_is_believing/binary/add_annotations.rb
Constant Summary collapse
- RESULT_PREFIX =
'# =>'
- EXCEPTION_PREFIX =
'# ~>'
- STDOUT_PREFIX =
'# >>'
- STDERR_PREFIX =
'# !>'
Instance Attribute Summary collapse
-
#file_result ⇒ Object
Returns the value of attribute file_result.
Attributes included from HasException
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(body, options = {}) ⇒ AddAnnotations
constructor
A new instance of AddAnnotations.
- #new_body ⇒ Object
Constructor Details
#initialize(body, options = {}) ⇒ AddAnnotations
Returns a new instance of AddAnnotations.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/seeing_is_believing/binary/add_annotations.rb', line 42 def initialize(body, ={}) cleaned_body = RemovePreviousAnnotations.call body self. = self.body = (xmpfilter_style ? body : cleaned_body) self.file_result = SeeingIsBelieving.call body(), filename: ([:as] || [:filename]), require: [:require], load_path: [:load_path], encoding: [:encoding], stdin: [:stdin], timeout: [:timeout], debugger: debugger self.alignment_strategy = [:alignment_strategy].new cleaned_body, start_line, end_line end |
Instance Attribute Details
#file_result ⇒ Object
Returns the value of attribute file_result.
41 42 43 |
# File 'lib/seeing_is_believing/binary/add_annotations.rb', line 41 def file_result @file_result end |
Class Method Details
.method_from_options(*args) ⇒ Object
29 30 31 |
# File 'lib/seeing_is_believing/binary/add_annotations.rb', line 29 def self.(*args) define_method(args.first) { .fetch *args } end |
Instance Method Details
#call ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/seeing_is_believing/binary/add_annotations.rb', line 61 def call @printed_program ||= begin # can we put the call to chomp into the line_queue initialization code? line_queue.until { |line, line_number| SyntaxAnalyzer.begins_data_segment?(line.chomp) } .each { |line, line_number| add_line line, line_number } add_stdout add_stderr add_exception add_remaining_lines if debugger.enabled? debugger.context("RESULT") { new_body }.to_s else new_body end end end |
#new_body ⇒ Object
57 58 59 |
# File 'lib/seeing_is_believing/binary/add_annotations.rb', line 57 def new_body @new_body ||= '' end |