Class: SeeingIsBelieving::Binary
- Inherits:
-
Object
- Object
- SeeingIsBelieving::Binary
- Defined in:
- lib/seeing_is_believing/binary.rb,
lib/seeing_is_believing/binary/align_file.rb,
lib/seeing_is_believing/binary/align_line.rb,
lib/seeing_is_believing/binary/clean_body.rb,
lib/seeing_is_believing/binary/parse_args.rb,
lib/seeing_is_believing/binary/align_chunk.rb,
lib/seeing_is_believing/binary/comment_lines.rb,
lib/seeing_is_believing/binary/add_annotations.rb,
lib/seeing_is_believing/binary/rewrite_comments.rb,
lib/seeing_is_believing/binary/comment_formatter.rb,
lib/seeing_is_believing/binary/commentable_lines.rb
Defined Under Namespace
Modules: RewriteComments Classes: AddAnnotations, AlignChunk, AlignFile, AlignLine, CleanBody, CommentFormatter, CommentLines, CommentableLines, ParseArgs
Constant Summary collapse
- SUCCESS_STATUS =
0
- DISPLAYABLE_ERROR_STATUS =
e.g. there was an error, but the output is legit (we can display exceptions)
1
- NONDISPLAYABLE_ERROR_STATUS =
e.g. an error like incorrect invocation or syntax that can’t be displayed in the input program
2
- VALUE_MARKER =
"# => "
- EXCEPTION_MARKER =
"# ~> "
- STDOUT_MARKER =
"# >> "
- STDERR_MARKER =
"# !> "
- VALUE_REGEX =
/\A#\s*=>/
- EXCEPTION_REGEX =
/\A#\s*~>/
- STDOUT_REGEX =
/\A#\s*>>/
- STDERR_REGEX =
/\A#\s*!>/
Instance Attribute Summary collapse
-
#argv ⇒ Object
Returns the value of attribute argv.
-
#stderr ⇒ Object
Returns the value of attribute stderr.
-
#stdin ⇒ Object
Returns the value of attribute stdin.
-
#stdout ⇒ Object
Returns the value of attribute stdout.
-
#timeout_error ⇒ Object
Returns the value of attribute timeout_error.
-
#unexpected_exception ⇒ Object
Returns the value of attribute unexpected_exception.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(argv, stdin, stdout, stderr) ⇒ Binary
constructor
A new instance of Binary.
Constructor Details
#initialize(argv, stdin, stdout, stderr) ⇒ Binary
Returns a new instance of Binary.
28 29 30 31 32 33 |
# File 'lib/seeing_is_believing/binary.rb', line 28 def initialize(argv, stdin, stdout, stderr) self.argv = argv self.stdin = stdin self.stdout = stdout self.stderr = stderr end |
Instance Attribute Details
#argv ⇒ Object
Returns the value of attribute argv.
26 27 28 |
# File 'lib/seeing_is_believing/binary.rb', line 26 def argv @argv end |
#stderr ⇒ Object
Returns the value of attribute stderr.
26 27 28 |
# File 'lib/seeing_is_believing/binary.rb', line 26 def stderr @stderr end |
#stdin ⇒ Object
Returns the value of attribute stdin.
26 27 28 |
# File 'lib/seeing_is_believing/binary.rb', line 26 def stdin @stdin end |
#stdout ⇒ Object
Returns the value of attribute stdout.
26 27 28 |
# File 'lib/seeing_is_believing/binary.rb', line 26 def stdout @stdout end |
#timeout_error ⇒ Object
Returns the value of attribute timeout_error.
26 27 28 |
# File 'lib/seeing_is_believing/binary.rb', line 26 def timeout_error @timeout_error end |
#unexpected_exception ⇒ Object
Returns the value of attribute unexpected_exception.
26 27 28 |
# File 'lib/seeing_is_believing/binary.rb', line 26 def unexpected_exception @unexpected_exception end |
Instance Method Details
#call ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/seeing_is_believing/binary.rb', line 35 def call @exitstatus ||= begin parse_flags if flags_have_errors? then print_errors ; NONDISPLAYABLE_ERROR_STATUS elsif should_print_help? then print_help ; SUCCESS_STATUS elsif should_print_version? then print_version ; SUCCESS_STATUS elsif has_filename? && file_dne? then print_file_dne ; NONDISPLAYABLE_ERROR_STATUS elsif should_clean? then print_cleaned_program ; SUCCESS_STATUS elsif invalid_syntax? then print_syntax_error ; NONDISPLAYABLE_ERROR_STATUS elsif (evaluate_program; program_timedout?) then print_timeout_error ; NONDISPLAYABLE_ERROR_STATUS elsif something_blew_up? then print_unexpected_error ; NONDISPLAYABLE_ERROR_STATUS elsif output_as_json? then print_result_as_json ; SUCCESS_STATUS else print_program ; program_exit_status end end end |