Class: Object

Inherits:
BasicObject
Defined in:
lib/pry-remote-auto.rb

Overview

Example:

require 'pry-remote-auto'

class Foo
  def initialize(x, y)
    binding.remote_pry
  end
end

Foo.new 10, 20

Instance Method Summary collapse

Instance Method Details

#remote_pry_with_auto_launch(*args) ⇒ Object Also known as: remote_pry



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/pry-remote-auto.rb', line 16

def remote_pry_with_auto_launch(*args)
  Thread.start do
    cmd = if defined?(Rails)
      rc = "cd #{Rails.root};"
      rc += "bundle exec " if File.exist?(Rails.root.join('Gemfile'))
      rc
    end

    cmd ||= ""
    cmd += "pry-remote"

    sleep 1
    system 'osascript', '-e', 'tell application "Terminal" to do script "' + cmd + '"'
    system 'osascript', '-e', 'tell application "Terminal" to activate'
  end
  remote_pry_without_auto_launch(*args)
end