Class: Orb::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/orb/runner.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, source_location) ⇒ Runner

Returns a new instance of Runner.



11
12
13
14
15
16
# File 'lib/orb/runner.rb', line 11

def initialize(context, source_location)
  @context = context
  @test_buffer = TestBuffer.new(*parse_source_location(source_location))
  setup_pry
  Orb::Runner.current = self
end

Class Attribute Details

.currentObject

Returns the value of attribute current.



8
9
10
# File 'lib/orb/runner.rb', line 8

def current
  @current
end

Instance Attribute Details

#source_fileObject (readonly)

Returns the value of attribute source_file.



5
6
7
# File 'lib/orb/runner.rb', line 5

def source_file
  @source_file
end

#source_lineObject (readonly)

Returns the value of attribute source_line.



5
6
7
# File 'lib/orb/runner.rb', line 5

def source_line
  @source_line
end

#test_bufferObject (readonly)

Returns the value of attribute test_buffer.



5
6
7
# File 'lib/orb/runner.rb', line 5

def test_buffer
  @test_buffer
end

Instance Method Details

#parse_source_location(source_location) ⇒ Object



18
19
20
21
# File 'lib/orb/runner.rb', line 18

def parse_source_location(source_location)
  source_location.scan(/(.*):(\d)+:.*/)
  [$1, $2.to_i]
end

#runObject



36
37
38
# File 'lib/orb/runner.rb', line 36

def run
  @pry.repl(@context)
end

#setup_pryObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/orb/runner.rb', line 23

def setup_pry
  Pry.instance_eval do
    if initial_session?
      load_rc       if Pry.config.should_load_rc
      # load_plugins  if Pry.config.plugins.enabled
      load_requires if Pry.config.should_load_requires
      load_history  if Pry.config.history.should_load
    end
  end
  @pry = Pry.new
  @pry.instance_variable_set("@orb_test_buffer", @test_buffer)
end