Class: Virb::Pry

Inherits:
Object
  • Object
show all
Defined in:
lib/virb/pry.rb

Defined Under Namespace

Classes: Fifo, Output

Class Method Summary collapse

Class Method Details

.startObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/virb/pry.rb', line 49

def self.start
  `rm -rf .virb`
  `mkdir -p .virb`
  unless File.exist?('.virb/fifo')
    `mkfifo .virb/fifo`
  end
  `touch .virb/session`

  pgid = Process.getpgid(Process.pid())

  pid = fork do
    ENV['TERM'] = 'dumb'
    require 'pry'

    out = Virb::Pry::Output.new
    $stdout = out
    $stderr = out

    ::Pry.cli = true
    ::Pry.color = false
    ::Pry.config.pager = false
    ::Pry.config.print = ::Pry::SIMPLE_PRINT
    ::Pry.config.auto_indent = false # turns off ansi control escape sequences
    input = Fifo.new
    ::Pry.input = input
    ::Pry.config.output = out
    ::Pry.start(TOPLEVEL_BINDING.eval('self'))
  end

  args = ARGV.dup
  vimscript = File.join(File.dirname(__FILE__), '..', 'virb.vim')
  exec("vim -S #{vimscript} #{args.join(' ')} && rm -rf .virb && kill 0")
end