Sha256: 2bbd758065787ea491d3415fbfc3d15d6b98164e461dec202656da7f199b8f56

Contents?: true

Size: 870 Bytes

Versions: 1

Compression:

Stored size: 870 Bytes

Contents

require "pry-remote"

# Example:
#
#     require 'pry-remote-auto'
#     
#     class Foo
#       def initialize(x, y)
#         binding.remote_pry
#       end
#     end
#     
#     Foo.new 10, 20
#
class Object
  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
  alias_method :remote_pry_without_auto_launch, :remote_pry
  alias_method :remote_pry, :remote_pry_with_auto_launch
  alias_method :pry_remote, :remote_pry
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pry-remote-auto-1.2.0 lib/pry-remote-auto.rb