BindingDumper
A gem for dumping a whole binding and restoring it later. After restoring you can use pry
to perform delayed debugging.
WARNING this gem is not ready for production yet, please, use it only in development environment.
Installation
Add this line to your application's Gemfile:
gem 'binding_dumper'
And then execute:
$ bundle
Or install it yourself as:
$ gem install binding_dumper
Usage
To dump a binding run
binding.dump
# => "a lot of strange output here, that's fine"
Ideally, you should persist an output somewhere (like in the database). Let's say we have a Rails model called DumpedBinding
with data
field:
StoredBinding.create(data: binding.dump)
Make your server to execute the code above (just put it to any controller's action), go to the console, and run:
b = Binding.load(StoredBinding.last.data)
b.pry
And enjoy!
Blog post about internal parts of the gem
Requirements
- Ruby >= 1.9.3 (see travis.yml for supported versions)
Examples
The simplest one is in the file examples/simple.rb
.
A bit more complex example with Rails environment is in spec/dummy/app/controllers/users_controller.rb
Development
Clone the repo, run bundle install
.
To run all tests using current ruby version, run rspec
or rake
.
To run all tests with ALL supported ruby versions, run bin/multitest
and follow the output.
To run dummy app, run bin/dummy_rails s
(bin/dummy_rails c
for console).
Contributing
- Fork it ( https://github.com/[my-github-username]/binding_dumper/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request