Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename gem, flip stack (2012) #8

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ script:
rvm:
- 1.9.2
- 1.9.3
- 2.0.0
- 2.1.5
- 2.2.0

notifications:
irc: "irc.freenode.org#pry"
recipients:
- jrmair@gmail.com
- chris@ill-logic.com

branches:
only:
Expand Down
Empty file modified CHANGELOG
100755 → 100644
Empty file.
8 changes: 6 additions & 2 deletions LICENSE
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
License
-------

(The MIT License)
The MIT License

Copyright (c) 2011 John Mair (banisterfiend)
Copyright (c) 2015 Barry Allard (steakknife)

Copyright (c) 2014 Chris Gahan (epitron)

Copyright (c) 2011 John Mair (banister)

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
144 changes: 12 additions & 132 deletions README.md
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,145 +1,25 @@
pry-stack_explorer
pry-stack
===========

(C) John Mair (banisterfiend) 2011
A Pry plugin to navigate the stack.

_Walk the stack in a Pry session_
This gem is almost exactly the same as [pry-stack_explorer](http://github.com/pry/pry-stack_explorer), with three exceptions:

pry-stack_explorer is a plugin for the [Pry](http://pry.github.com)
REPL that enables the user to navigate the call-stack.
* Its name is shorter
* "up" and "down" actually move the stack pointer in those directions
* You can type "stack" instead of "show-stack"
* It has a fresh pine scent

From the point a Pry session is started, the user can move up the stack
through parent frames, examine state, and even evaluate code.

Unlike `ruby-debug`, pry-stack_explorer incurs no runtime cost and
enables navigation right up the call-stack to the birth of the
program.

pry-stack_explorer is currently designed to work on **Rubinius and MRI
Ruby 1.9.2+ (including 1.9.3)**. Support for other Ruby versions and
implementations is planned for the future.

The `up`, `down`, `frame` and `show-stack` commands are provided. See
Pry's in-session help for more information on any of these commands.

**How to use:**

After installing `pry-stack_explorer`, just start Pry as normal (typically via a `binding.pry`), the stack_explorer plugin will be detected and used automatically.

* Install the [gem](https://rubygems.org/gems/pry-stack_explorer): `gem install pry-stack_explorer`
* Read the [documentation](http://rdoc.info/github/banister/pry-stack_explorer/master/file/README.md)
* See the [source code](http://github.com/pry/pry-stack_explorer)
* See the [wiki](https://github.com/pry/pry-stack_explorer/wiki) for in-depth usage information.

Example: Moving around between frames
--------

```
[8] pry(J)> show-stack

Showing all accessible frames in stack:
--
=> #0 [method] c <Object#c()>
#1 [block] block in b <Object#b()>
#2 [method] b <Object#b()>
#3 [method] alphabet <Object#alphabet(y)>
#4 [class] <class:J>
#5 [block] block in <main>
#6 [eval] <main>
#7 [top] <main>
[9] pry(J)> frame 3

Frame number: 3/7
Frame type: method

From: /Users/john/ruby/projects/pry-stack_explorer/examples/example.rb @ line 10 in Object#alphabet:

5:
6: require 'pry-stack_explorer'
7:
8: def alphabet(y)
9: x = 20
=> 10: b
11: end
12:
13: def b
14: x = 30
15: proc {
[10] pry(J)> x
=> 20
```

Example: Modifying state in a caller
-------

```
Frame number: 0/3
Frame type: method

From: /Users/john/ruby/projects/pry-stack_explorer/examples/example2.rb @ line 15 in Object#beta:

10: beta
11: puts x
12: end
13:
14: def beta
=> 15: binding.pry
16: end
17:
18: alpha
[1] pry(main)> show-stack

Showing all accessible frames in stack:
--
=> #0 [method] beta <Object#beta()>
#1 [method] alpha <Object#alpha()>
#2 [eval] <main>
#3 [top] <main>
[2] pry(main)> up

Frame number: 1/3
Frame type: method

From: /Users/john/ruby/projects/pry-stack_explorer/examples/example2.rb @ line 10 in Object#alpha:

5:
6:
7:
8: def alpha
9: x = "hello"
=> 10: beta
11: puts x
12: end
13:
14: def beta
15: binding.pry
[3] pry(main)> x = "goodbye"
=> "goodbye"
[4] pry(main)> ^D

OUTPUT: goodbye
```

Output from above is `goodbye` as we changed the `x` local inside the `alpha` (caller) stack frame.

Limitations
-------------------------

* First release, so may have teething problems.
* Limited to Rubinius, and MRI 1.9.2+ at this stage.

Contact
License
-------

Problems or questions contact me at [github](http://github.com/banister)
The MIT License

Copyright (c) 2015 Barry Allard ([steakknife](http://github.com/steakknife))

License
-------

(The MIT License)
Copyright (c) 2014 Chris Gahan ([epitron](http://github.com/epitron))

Copyright (c) 2011 John Mair (banisterfiend)
Copyright (c) 2011 John Mair ([banisterfiend](http://github.com/banister))

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
114 changes: 16 additions & 98 deletions Rakefile
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,112 +1,30 @@
$:.unshift 'lib'
gem_version = File.read("VERSION").strip
gem_name = "pry-stack"

dlext = RbConfig::CONFIG['DLEXT']
direc = File.dirname(__FILE__)

PROJECT_NAME = "pry-stack_explorer"

require 'rake/clean'
require 'rubygems/package_task'
require "#{PROJECT_NAME}/version"

CLOBBER.include("**/*~", "**/*#*", "**/*.log")
CLEAN.include("**/*#*", "**/*#*.*", "**/*_flymake*.*", "**/*_flymake",
"**/*.rbc", "**/.#*.*")

def apply_spec_defaults(s)
s.name = PROJECT_NAME
s.summary = "Walk the stack in a Pry session"
s.version = PryStackExplorer::VERSION
s.date = Time.now.strftime '%Y-%m-%d'
s.author = "John Mair (banisterfiend)"
s.email = '[email protected]'
s.description = s.summary
s.require_path = 'lib'
s.add_dependency("binding_of_caller",">= 0.7")
s.add_dependency("pry",">=0.9.11")
s.add_development_dependency("bacon","~>1.1.0")
s.add_development_dependency('rake', '~> 0.9')
s.homepage = "https://github.com/pry/pry-stack_explorer"
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- test/*`.split("\n")
end

desc "run pry with plugin enabled"
task :pry do
exec("pry -rubygems -I#{direc}/lib/ -r #{direc}/lib/#{PROJECT_NAME}")
end

desc "Run example"
task :example do
sh "ruby -rubygems -I#{direc}/lib/ #{direc}/examples/example.rb "
desc "Build the gem"
task :build do
system "gem build #{gem_name}.gemspec"
end

desc "Run example2"
task :example2 do
sh "ruby -I#{direc}/lib/ #{direc}/examples/example2.rb "
end

desc "Run example3"
task :example3 do
sh "ruby -I#{direc}/lib/ #{direc}/examples/example3.rb "

desc "Build and push the gem to rubygems.org"
task :release => :build do
system "gem push #{gem_name}-#{gem_version}.gem"
end

desc "Show version"
task :version do
puts "PryStackExplorer version: #{PryStackExplorer::VERSION}"
desc "Build and install the gem"
task :install => :build do
system "gem install #{gem_name}-#{gem_version}.gem"
end

desc "run tests"
task :default => :test

desc "run tests"
desc "Run bacon tests"
task :test do
sh "bacon -Itest -rubygems -a -q"
end

desc "generate gemspec"
task :gemspec => "ruby:gemspec"

namespace :ruby do
spec = Gem::Specification.new do |s|
apply_spec_defaults(s)
s.platform = Gem::Platform::RUBY
end

Gem::PackageTask.new(spec) do |pkg|
pkg.need_zip = false
pkg.need_tar = false
end

desc "Generate gemspec file"
task :gemspec do
File.open("#{spec.name}.gemspec", "w") do |f|
f << spec.to_ruby
end
end
end

desc "build all platform gems at once"
task :gems => [:clean, :rmgems, :gemspec, "ruby:gem"]

desc "remove all platform gems"
task :rmgems => ["ruby:clobber_package"]

desc "reinstall gem"
task :reinstall => :gems do
sh "gem uninstall pry-stack_explorer" rescue nil
sh "gem install -l #{direc}/pkg/#{PROJECT_NAME}-#{PryStackExplorer::VERSION}.gem"
end

task :install => :reinstall

desc "build and push latest gems"
task :pushgems => :gems do
chdir("#{File.dirname(__FILE__)}/pkg") do
Dir["*.gem"].each do |gemfile|
sh "gem push #{gemfile}"
end
end
desc "Load this checked out git repo in pry"
task :pry do
system "pry --gem"
end

task :pushgem => :pushgems
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.5.0
4 changes: 2 additions & 2 deletions examples/example.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
unless Object.const_defined? :PryStackExplorer
unless Object.const_defined? :PryStack
$:.unshift File.expand_path '../../lib', __FILE__
require 'pry'
end

require 'pry-stack_explorer'
require 'pry-stack'

def alphabet(y)
x = 20
Expand Down
4 changes: 2 additions & 2 deletions examples/example2.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
unless Object.const_defined? :PryStackExplorer
unless Object.const_defined? :PryStack
$:.unshift File.expand_path '../../lib', __FILE__
require 'pry'
end

require 'pry-stack_explorer'
require 'pry-stack'

def alpha
x = "hello"
Expand Down
4 changes: 2 additions & 2 deletions examples/example3.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
unless Object.const_defined? :PryStackExplorer
unless Object.const_defined? :PryStack
$:.unshift File.expand_path '../../lib', __FILE__
require 'pry'
end

require 'pry-stack_explorer'
require 'pry-stack'

def b
x = 30
Expand Down
Loading