Giter VIP home page Giter VIP logo

jazz_hands's Introduction

Jazz Hands Bitdeli Badge

Spending hours in the rails console? Spruce it up and show off those hard-working hands!

jazz_hands is an opinionated set of console-related gems and a bit of glue:

  • Pry for a powerful shell alternative to IRB.
  • Awesome Print for stylish pretty print.
  • Hirb for tabular collection output.
  • Pry Rails for additional commands (show-routes, show-models, show-middleware) in the Rails console.
  • Pry Doc to browse Ruby source, including C, directly from the console.
  • Pry Git to teach the console about git. Diffs, blames, and commits on methods and classes, not just files.
  • Pry Remote to connect remotely to a Pry console.
  • Pry Debugger to turn the console into a simple debugger.
  • Pry Stack Explorer to navigate the call stack and frames.
  • Coolline and Coderay for syntax highlighting as you type. Optional. MRI 1.9.3/2.0.0 only

Usage

Ruby 1.9.2+, Rails 3 or 4 only. Add to your project Gemfile:

group :development, :test do
  gem 'jazz_hands'
end

That's it. Run rails console as usual.

Hirb isn't enabled by default. To use, run Hirb.enable in the console.

Ruby compiled against a proper readline library, ideally GNU readline, is recommended. Alternatively, gem install rb-readline for an acceptible backup. Using ruby compiled against a libedit wrapper (primarily OS X) will work but is not recommended.

Options

Change the following options by creating an initializer in your Rails project Example config/initializers/jazz_hands.rb:

if defined?(JazzHands)
  JazzHands.colored_prompt = false
  JazzHands.enable_syntax_highlighting_as_you_type!
end

colored_prompt

Color the console prompt? Defaults to true when the current ruby is compiled against GNU readline or rb-readline, which don't have issues counting characters in colored prompts. false for libedit.

Note: Pry.color = false trumps this setting and disables all console coloring.

prompt_separator

Separator string between the application name and line input. Defaults to » for GNU readline or libedit. Defaults to > for rb-readline which fails on mixed encodings.

Syntax highlighting

Syntax highlighting as you type via Coolline and Coderay is disabled by default due to slightly buggy behavior. To enable, add JazzHands.enable_syntax_highlighting_as_you_type! to the initializer. Only works with MRI 1.9.3 or 2.0.0.

Contributing

Patches and bug reports are welcome. Just send a pull request or file an issue. Project changelog.

jazz_hands's People

Contributors

caseylang avatar nixme avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jazz_hands's Issues

Problem with dependencies in Rails 4.0.1

Hi,

I'm trying to get jazz_hands working on a Rails 4.0.1 project, but am getting this error:

Installing debugger (1.6.2)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/Users/benlewis/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb

*** extconf.rb failed ***

...

An error occurred while installing debugger (1.6.2), and Bundler cannot continue.
Make sure that gem install debugger -v '1.6.2' succeeds before bundling.

No colours when running with spring

When rails console is initialized with spring binstubs there are no colours.
With bin/rails like that:

#!/usr/bin/env ruby
# begin
#   load File.expand_path("../spring", __FILE__)
# rescue LoadError
# end
APP_PATH = File.expand_path('../../config/application',  __FILE__)
require_relative '../config/boot'
require 'rails/commands'

running bin/rails console I get:
1

With bin/rails like that:

#!/usr/bin/env ruby
begin
  load File.expand_path("../spring", __FILE__)
rescue LoadError
end
APP_PATH = File.expand_path('../../config/application',  __FILE__)
require_relative '../config/boot'
require 'rails/commands'

running bin/rails console I get:
2

Colored prompt and extra symbols

In default rails console without any extra settings prompt contains extra symbols, but only when displaying result of the command (when typing command current prompt is ok)
2013-01-21_22-40-39

JRuby compatible mode

Could you please create a JRuby compatible mode?

By default, c extension is disabled in JRuby and possibly not supported in the future.

Now one of the dependencies, pry-stack_explorer, requires binding_of_caller which has c extension.

Thanks.

Support for pry 0.10.0

pry version 0.10.0 has been released.

It would be nice to have jazz_hands support it.

In my case, especially because guard 2.2 now depends on pry 0.10.0 and I am really not able to have them both running together.

$ bundle install
Fetching git://github.com/nixme/jazz_hands.git
Fetching gem metadata from https://rubygems.org/.........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Bundler could not find compatible versions for gem "pry":
  In snapshot (Gemfile.lock):
    pry (0.10.0)

  In Gemfile:
    jazz_hands (>= 0) ruby depends on
      pry (~> 0.9.12) ruby

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.

Line editing and history broken in some terminals

I've switched to using jazz_hands on Ruby 1.9.3 on Ubuntu 12. Default install, no customisations.

When I start a rails console everything looks correct. Output is awesome.

However, when I start typing, about 2/3 of the way across the screen the text suddenly wraps and overwrites the line in place - typically how an app would look when it doesn't understand the terminal setting. This happens before the terminal width is reached. Once this has happened the user is typing blind as the placement of characters is unpredictable.

Another way to trigger it is to use the command history and try to edit a previous line.

I've fiddled with terminal settings, sizes etc but have seen no major differences. It is repeatable on all the Ubuntu machines here. It happens on bash, zsh etc.

On a Debian box, it's less severe,. but the line wraps and overwrites itself.

On an OS X box, it's similar to Debian. Line wrapping is broken and repeated use of history moves the prompt across the screen unpredictably.

JSON

Hi :) Does Jazz Hand provide a way to nicely display JSON data?

Evaluate line by line with pry?

Hey there

I have a lot of biiiig Capybara request specs:

it 'does something' do
  visit some_path

  do_something
  do_another_thing
  do_something_again
  do_do_do

  expect(page).to have_selector 'bla'
end

When one of it fails, it's often useful to use driver: :chrome to see what happens visually and set a binding.pry somewhere in the beginning:

it 'does something', driver: :chrome do
  visit some_path

  binding.pry
  do_something
  do_another_thing
  do_something_again
  do_do_do

  expect(page).to have_selector 'bla'
end

Now I'd like to see step by step what Capybara is doing, so I intuitively want to use s or n. But instead of executing line by line, it always jumps into some Capybara methods which I'm actually not interested in. I searched a lot and I found different gems claiming to do something like that, but none seems to do the job as I need it.

So I wanted to ask you (because you seem to know many pry gems in and out): is there a solution for my need? Or is it simply not possible?

Thank you.

Ruby 2 support

Have you considered byebug and pry-byebug for ruby 2 support? Would you accept a pull request in that direction?

uninitialized constant Pry::Prompt (NameError)

Hello, getting the following error:

.rvm/gems/ruby-2.2.3/gems/pry-rails-0.3.5/lib/pry-rails/prompt.rb:36:in `module:PryRails': uninitialized constant Pry::Prompt (NameError)

Which apparantely has something to do with the version of pry

Would you by chance have any solutions regarding this?

GIT
  remote: git://github.com/nixme/jazz_hands.git
  revision: 5e4b48f145883ecb14b55bf04eacc28ac9662676
  branch: bring-your-own-debugger
  specs:
    jazz_hands (0.5.2)
      awesome_print (~> 1.2)
      coolline (>= 0.4.2)
      hirb (~> 0.7.1)
      pry (~> 0.9.12)
      pry-doc (~> 0.4.6)
      pry-git (~> 0.2.3)
      pry-rails (~> 0.3.2)
      pry-remote (>= 0.1.7)
      pry-stack_explorer (~> 0.4.9)
      railties (>= 3.0, < 5.0)

Using jazz_hands outside of rails

Being as non of the gems included in jazz_hands are rails specific, it would be good to use it outside of rails. Maybe a wrapper around binding.pry would do the trick.

Include awesome_print 1.2.0 html fixes

awesome_print 1.2.0 introduced some important html formatting fixes for ActionView. Without these fixes, output is hard to read.

michaeldv/awesome_print@ba7ff0f

Please include 1.2.0. Thanks!

It's also nice to loosen up the dependencies a bit to allow for automatic upgrades. At least for the non-C extension gems.

Incompatible with Ruby 2.1.2

Just switched a project over too ruby 2.1.2, and it seems jazz_hands's dependencies kill the bundle.

Using debugger-ruby_core_source 1.3.4

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /Users/me/.rvm/rubies/ruby-2.1.2/bin/ruby extconf.rb 
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
  --with-opt-dir
  --with-opt-include
  --without-opt-include=${opt-dir}/include
  --with-opt-lib
  --without-opt-lib=${opt-dir}/lib
  --with-make-prog
  --without-make-prog
  --srcdir=.
  --curdir
  --ruby=/Users/me/.rvm/rubies/ruby-2.1.2/bin/ruby
/Users/me/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/fileutils.rb:1573:in `stat': No such file or directory @ rb_file_s_stat - ./212/ruby_debug.h (Errno::ENOENT)
  from /Users/me/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/fileutils.rb:1573:in `block in fu_each_src_dest'
  from /Users/me/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/fileutils.rb:1587:in `fu_each_src_dest0'
  from /Users/me/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/fileutils.rb:1571:in `fu_each_src_dest'
  from /Users/me/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/fileutils.rb:399:in `cp'
  from extconf.rb:83:in `block in <main>'
  from extconf.rb:82:in `each'
  from extconf.rb:82:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /Users/me/.rvm/gems/ruby-2.1.2@redsteel-site/gems/debugger-1.6.6 for inspection.
Results logged to /Users/me/.rvm/gems/ruby-2.1.2@redsteel-site/extensions/x86_64-darwin-13/2.1.0/debugger-1.6.6/gem_make.out
An error occurred while installing debugger (1.6.6), and Bundler cannot continue.
Make sure that `gem install debugger -v '1.6.6'` succeeds before bundling.

wired <kbd style="color:white"> in pry console

I'm not sure if I missed something.

$ rails c
Loading development environment (Rails 4.1.1)
[1] blogApp >  p [ {test: false}, true ]
[{:test=>false}, true]
=> [
  <kbd style="color:white">[0] </kbd>{
    :test<kbd style="color:slategray"> =&gt; </kbd><kbd style="color:red">false</kbd>
  },
  <kbd style="color:white">[1] </kbd><kbd style="color:green">true</kbd>
]

You can't see it, but the first line [1] is colored correctly whereas the rest all has the same color.

One line in config/application.rb might be related.

AwesomePrint.defaults = {html: true}

I also tried html: false and without that line. Both without success. I'd like to have this true by default. But this option shouldn't make a difference for the pry console imho.

This is my Gemfile

#[...]
  gem 'jazz_hands', github: 'nixme/jazz_hands', branch: 'bring-your-own-debugger'
#[...]

Activity

Is this project dead?

  • The last release was 1 year ago
  • There are opened pull requests and people willing to improve/use it

We need at least to update the dependencies over here and fix the debugger thing.
I can create a pull request to update the dependencies only and another to remove any dependency on debuggers as mentioned here.

cc/ @nixme

Unicode symbols issue

When i try to type anything in rails console i got this error

Error: incompatible character encodings: ASCII-8BIT and UTF-8
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/rb-readline-0.4.2/lib/rbreadline.rb:3138:in `[]='
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/rb-readline-0.4.2/lib/rbreadline.rb:3138:in `rl_redisplay'
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/rb-readline-0.4.2/lib/rbreadline.rb:3898:in `readline_internal_setup'
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/rb-readline-0.4.2/lib/rbreadline.rb:4742:in `readline_internal'
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/rb-readline-0.4.2/lib/rbreadline.rb:4765:in `readline'
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/rb-readline-0.4.2/lib/readline.rb:40:in `readline'
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:600:in `block in readline'
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:544:in `handle_read_errors'
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:589:in `readline'
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:369:in `retrieve_line'
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:304:in `block in r'
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:301:in `loop'
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:301:in `r'
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:271:in `re'
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:251:in `rep'
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:231:in `block (3 levels) in repl'
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:230:in `loop'
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:230:in `block (2 levels) in repl'
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:229:in `catch'
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:229:in `block in repl'
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:228:in `catch'
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_instance.rb:228:in `repl'
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/pry-0.9.10/lib/pry/pry_class.rb:154:in `start'
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/pry-debugger-0.2.0/lib/pry-debugger/pry_ext.rb:19:in `start'
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/commands/console.rb:47:in `start'
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/commands/console.rb:8:in `start'
/Users/yanis/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/commands.rb:41:in `<top (required)>'
script/rails:6:in `require'
script/rails:6:in `<main>'
FATAL: Pry failed to get user input using `Readline`.
To fix this you may be able to pass input and output file descriptors to pry directly. e.g.
  Pry.config.input = STDIN
  Pry.config.output = STDOUT
  binding.pry

Cannot use gem

Hi,

I would like to have tried the gem but:

Bundler could not find compatible versions for gem "railties":
  In Gemfile:
    jazz_hands (>= 0) ruby depends on
      railties (~> 3.0) ruby

    sass-rails (~> 4.0.0) ruby depends on
      railties (4.0.0)

Bundler could not find compatible versions for gem "coderay":
  In Gemfile:
    jazz_hands (>= 0) ruby depends on
      coderay (~> 0.9.8) ruby

    better_errors (>= 0) ruby depends on
      coderay (1.1.0)

Any idea about how to fix those?

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.