Giter Club home page Giter Club logo

better_errors-pry's Introduction

Gem Version Build Status Codacy Badge

BetterErrors::Pry

Better Errors is a gem that provides a very useful error page for Ruby web/API applications. This gem adds Pry support to Better Errors.

This gem is intended to allow us to extract Pry support from the BetterErrors project itself. Through at least v2.4.0, Pry support is included in the project directly. Including this gem will replace the built-in support, and it is functionally the same at this time.

Why the separate gem for Pry support?

BetterErrors supports a very large number of possible configurations. It supports Rails and non-Rails, with binding_of_caller and without, and all of the major versions of the Ruby interpreter.

All of these combinations should be tested. Currently BetterErrors has 14 different test gemfiles, each running on 6 different versions of Ruby. And these are not comprehensive.

Because the BetterErrors gem needs to support each of these configurations, it can't specify any of its optional dependencies' required versions. This makes BetterErrors difficult to maintain, and difficult for application maintainers to keep it and its dependencies up-to-date.

(For example, for several years, the newer version of binding_of_caller did not work correctly, so applications that used BetterErrors were given instructions to lock binding_of_caller to a specific version. This is because BetterErrors could not specify the binding_of_caller version in its own gemspec, since it is optional. Once the issue was fixed, application maintainers had no way to know that it was possible to remove the fixed version.)

The solution is to extract optional functionality that depends on additional gems from the BetterErrors project, and place it in a project like this one.

Installation

Add this to your application's Gemfile, in the development group, just like better_errors:

group :development do
  gem 'better_errors'
  gem 'better_errors-pry'
end

You need to activate pry in the application (for example, in config/environments/development.rb):

BetterErrors.use_pry!

It's important to keep this in the development group. See Better Errors for more information.

Usage

See Better Errors to get started.

When you see the Better Errors console, you can issue Pry-specific commands, such as ls and cd.

Development

After checking out the repo, run bundle install to install the basic dependencies.

You can run the tests with the most recent versions of Pry and Better Errors by running bundle exec rake.

To run the tests against the other sets of dependencies, though, you will need to use Appraisal. Run appraisal install to run install the dependencies for each of the possible combinations.

Then you can run appraisal rake to run all tests, or appraisal pry_0.09 rake (for example) to only run the specs with Pry 0.09.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

On CI, the specs are run against each major release of Ruby in addition to each Appraisal gemfile.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

The gem is available as open source under the terms of the MIT License.

better_errors-pry's People

Contributors

robindaugherty avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

better_errors-pry's Issues

Doesn't seem to work

I wish I had a better message to report than "it doesn't work", but there's no feedback or error message.

  • I added the gem to the Gemfile as specified (in development) in the correct order
  • I double checked that I'm running in development,
  • updated the binding_of_caller and better_errors gems because they were a little out of date,
  • stopped spring,
  • stopped the server,
  • tried straight puma,
  • tried rails s,
  • reset the terminal,
  • reset the computer

... nothing. When better_errors loads, I still have the regular old boring non-Pry console.

Is there some kind of other installation or initializer that needs to be set up that isn't mentioned in the Readme?

Show the current Pry prompt before console is used

Currently, the console prompt is always ">>". Would be great to show the current Pry prompt instead, which depends on the currently-selected frame. For example, [1] pry(#<HomeController>):1>.

This will require a change to the Better Errors error page.
It seems like the easiest way to get this will be to have Better Errors call do_eval when the frame is changed.

An alternative would be to have the REPL instantiated for every frame as the page is being built.
This doesn't seem like it would be efficient.

Compatibility with better_errors 2.5

Not sure if it really doesn't work or if it's just a miss in the Gemfile. Fixing the latter should be trivial.

In snapshot (Gemfile.lock):
    better_errors (= 2.5.0)

  In Gemfile:
    better_errors

    better_errors-pry was resolved to 1.0.2, which depends on
      better_errors (>= 2.3.0, ~> 2.3.0)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.