Sha256: 6505d7a8b7477a304eace1af401669b57d6687f37490864a45256289fe970f41
Contents?: true
Size: 1.87 KB
Versions: 1
Compression:
Stored size: 1.87 KB
Contents
require 'pry' require 'pry-doc' require 'pry-git' require 'pry-remote' require 'pry-nav' require 'awesome_print' require 'jazz_hands/hirb_ext' if RUBY_VERSION >= '1.9.3' require 'coolline' require 'coderay' end module JazzHands class Railtie < Rails::Railtie initializer 'jazz_hands.initialize' do |app| silence_warnings do ::IRB = Pry # Replace IRB with Pry completely # Use coolline with CodeRay for syntax highlighting as you type # Only works on >= 1.9.3 because coolline depends on io/console if RUBY_VERSION >= '1.9.3' Pry.config.input = Coolline.new do |c| c.transform_proc = proc do CodeRay.scan(c.line, :ruby).term end c.completion_proc = proc do word = c.completed_word Object.constants.map(&:to_s).select { |w| w.start_with? word } end end end # Use awesome_print for output, but keep pry's pager Pry.config.print = ->(output, value) do pretty = value.ai(indent: 2) Pry::Helpers::BaseHelpers.stagger_output("=> #{pretty}", output) end # Friendlier prompt - nesting levels look like directory paths name = app.class.parent_name.underscore colored_name = Pry::Helpers::Text.blue(name) raquo = Pry::Helpers::Text.red("\u00BB") target_string = ->(object, level) do unless (string = Pry.view_clip(object)) == 'main' "(#{'../' * level}#{string})" else '' end end Pry.config.prompt = [ ->(object, level, _) do "#{colored_name}#{target_string.(object, level)} #{raquo} " end, ->(object, level, _) do "#{' ' * (name.size + target_string.(object, level).size)} #{raquo} " end ] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jazz_hands-0.0.5 | lib/jazz_hands/railtie.rb |