Class: SeeingIsBelieving

Inherits:
Object
  • Object
show all
Defined in:
lib/seeing_is_believing.rb,
lib/seeing_is_believing/line.rb,
lib/seeing_is_believing/error.rb,
lib/seeing_is_believing/binary.rb,
lib/seeing_is_believing/result.rb,
lib/seeing_is_believing/version.rb,
lib/seeing_is_believing/debugger.rb,
lib/seeing_is_believing/has_exception.rb,
lib/seeing_is_believing/parser_helpers.rb,
lib/seeing_is_believing/hard_core_ensure.rb,
lib/seeing_is_believing/wrap_expressions.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,
lib/seeing_is_believing/evaluate_by_moving_files.rb

Overview

comprehensive list of syntaxes that can come up github.com/whitequark/parser/blob/master/doc/AST_FORMAT.md

Defined Under Namespace

Modules: HasException, ParserHelpers Classes: Binary, BugInSib, Debugger, EvaluateByMovingFiles, HardCoreEnsure, Line, RecordedException, Result, TempFileAlreadyExists, WrapExpressions

Constant Summary collapse

BLANK_REGEX =
/\A\s*\Z/
SeeingIsBelievingError =

all our errors will inherit from this so that a user can catch any error generated by this lib

Class.new StandardError
VERSION =
'2.0.1'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(program, options = {}) ⇒ SeeingIsBelieving

Returns a new instance of SeeingIsBelieving.



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/seeing_is_believing.rb', line 19

def initialize(program, options={})
  @program            = program
  @matrix_filename    = options[:matrix_filename]
  @filename           = options[:filename]
  @stdin              = to_stream options.fetch(:stdin, '')
  @require            = options.fetch :require, []
  @load_path          = options.fetch :load_path, []
  @encoding           = options.fetch :encoding, nil
  @timeout            = options[:timeout]
  @debugger           = options.fetch :debugger, Debugger.new(stream: nil)
  @ruby_executable    = options.fetch :ruby_executable, 'ruby'
  @number_of_captures = options.fetch :number_of_captures, Float::INFINITY
end

Class Method Details

.call(*args) ⇒ Object



15
16
17
# File 'lib/seeing_is_believing.rb', line 15

def self.call(*args)
  new(*args).call
end

Instance Method Details

#callObject



33
34
35
36
37
38
39
40
41
# File 'lib/seeing_is_believing.rb', line 33

def call
  @memoized_result ||= begin
    new_program = program_that_will_record_expressions
    debugger.context("TRANSLATED PROGRAM") { new_program }
    result = result_for new_program
    debugger.context("RESULT") { result.inspect }
    result
  end
end