Class: SeeingIsBelieving::Result
- Inherits:
-
Object
- Object
- SeeingIsBelieving::Result
- Includes:
- Enumerable
- Defined in:
- lib/seeing_is_believing/result.rb
Defined Under Namespace
Classes: RecordedException
Instance Attribute Summary collapse
-
#exception ⇒ Object
(also: #has_exception?)
Returns the value of attribute exception.
-
#exitstatus ⇒ Object
Returns the value of attribute exitstatus.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#max_line_captures ⇒ Object
Returns the value of attribute max_line_captures.
-
#num_lines ⇒ Object
Returns the value of attribute num_lines.
-
#ruby_version ⇒ Object
Returns the value of attribute ruby_version.
-
#sib_version ⇒ Object
Returns the value of attribute sib_version.
-
#stderr ⇒ Object
Returns the value of attribute stderr.
-
#stdout ⇒ Object
Returns the value of attribute stdout.
-
#timeout_seconds ⇒ Object
Returns the value of attribute timeout_seconds.
Instance Method Summary collapse
- #[](line_number, type = :inspect) ⇒ Object
- #as_json ⇒ Object
- #each(&block) ⇒ Object
- #has_stderr? ⇒ Boolean
- #has_stdout? ⇒ Boolean
-
#initialize ⇒ Result
constructor
A new instance of Result.
- #record_exception(line_number, exception_class, exception_message, exception_backtrace) ⇒ Object
- #record_result(type, line_number, value) ⇒ Object
- #timeout? ⇒ Boolean
Constructor Details
#initialize ⇒ Result
Returns a new instance of Result.
8 9 10 11 |
# File 'lib/seeing_is_believing/result.rb', line 8 def initialize self.stdout = '' self.stderr = '' end |
Instance Attribute Details
#exception ⇒ Object Also known as: has_exception?
Returns the value of attribute exception.
6 7 8 |
# File 'lib/seeing_is_believing/result.rb', line 6 def exception @exception end |
#exitstatus ⇒ Object
Returns the value of attribute exitstatus.
6 7 8 |
# File 'lib/seeing_is_believing/result.rb', line 6 def exitstatus @exitstatus end |
#filename ⇒ Object
Returns the value of attribute filename.
6 7 8 |
# File 'lib/seeing_is_believing/result.rb', line 6 def filename @filename end |
#max_line_captures ⇒ Object
Returns the value of attribute max_line_captures.
6 7 8 |
# File 'lib/seeing_is_believing/result.rb', line 6 def max_line_captures @max_line_captures end |
#num_lines ⇒ Object
Returns the value of attribute num_lines.
6 7 8 |
# File 'lib/seeing_is_believing/result.rb', line 6 def num_lines @num_lines end |
#ruby_version ⇒ Object
Returns the value of attribute ruby_version.
6 7 8 |
# File 'lib/seeing_is_believing/result.rb', line 6 def ruby_version @ruby_version end |
#sib_version ⇒ Object
Returns the value of attribute sib_version.
6 7 8 |
# File 'lib/seeing_is_believing/result.rb', line 6 def sib_version @sib_version end |
#stderr ⇒ Object
Returns the value of attribute stderr.
6 7 8 |
# File 'lib/seeing_is_believing/result.rb', line 6 def stderr @stderr end |
#stdout ⇒ Object
Returns the value of attribute stdout.
6 7 8 |
# File 'lib/seeing_is_believing/result.rb', line 6 def stdout @stdout end |
#timeout_seconds ⇒ Object
Returns the value of attribute timeout_seconds.
6 7 8 |
# File 'lib/seeing_is_believing/result.rb', line 6 def timeout_seconds @timeout_seconds end |
Instance Method Details
#[](line_number, type = :inspect) ⇒ Object
36 37 38 |
# File 'lib/seeing_is_believing/result.rb', line 36 def [](line_number, type=:inspect) results_for(line_number, type) end |
#as_json ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/seeing_is_believing/result.rb', line 49 def as_json ex = has_exception? && { line_number_in_this_file: exception.line_number, class_name: exception.class_name, message: exception., backtrace: exception.backtrace, } { stdout: stdout, stderr: stderr, exitstatus: exitstatus, exception: ex, lines: each.with_object(Hash.new) .with_index(1) { |(result, hash), line_number| hash[line_number] = result }, } end |
#each(&block) ⇒ Object
40 41 42 43 |
# File 'lib/seeing_is_believing/result.rb', line 40 def each(&block) return to_enum :each unless block (1..num_lines).each { |line_number| block.call self[line_number] } end |
#has_stderr? ⇒ Boolean
19 20 21 |
# File 'lib/seeing_is_believing/result.rb', line 19 def has_stderr? stderr && !stderr.empty? end |
#has_stdout? ⇒ Boolean
15 16 17 |
# File 'lib/seeing_is_believing/result.rb', line 15 def has_stdout? stdout && !stdout.empty? end |
#record_exception(line_number, exception_class, exception_message, exception_backtrace) ⇒ Object
32 33 34 |
# File 'lib/seeing_is_believing/result.rb', line 32 def record_exception(line_number, exception_class, , exception_backtrace) self.exception = RecordedException.new line_number, exception_class, , exception_backtrace end |
#record_result(type, line_number, value) ⇒ Object
27 28 29 30 |
# File 'lib/seeing_is_believing/result.rb', line 27 def record_result(type, line_number, value) results_for(line_number, type) << value value end |
#timeout? ⇒ Boolean
23 24 25 |
# File 'lib/seeing_is_believing/result.rb', line 23 def timeout? !!timeout_seconds end |