Module: Debbie
- Defined in:
- lib/debbie.rb,
lib/debbie/railtie.rb,
lib/debbie/version.rb
Defined Under Namespace
Classes: Railtie
Constant Summary collapse
- VERSION =
'2.0.0'
Class Method Summary collapse
-
.enable_syntax_highlighting_as_you_type! ⇒ Object
(also: enable_syntax_highlighting_as_you_type)
Enable syntax highlighting as you type in the Rails console via coolline and coderay (MRI 1.9.3+ only).
Class Method Details
.enable_syntax_highlighting_as_you_type! ⇒ Object Also known as: enable_syntax_highlighting_as_you_type
Enable syntax highlighting as you type in the Rails console via coolline and coderay (MRI 1.9.3+ only). Disabled by default as it’s a bit buggy.
Call from a Rails initializer:
Debbie.enable_syntax_highlighting_as_you_type!
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/debbie.rb', line 40 def enable_syntax_highlighting_as_you_type! raise 'Syntax highlighting only supported on 1.9.3+' unless RUBY_VERSION >= '1.9.3' # Use coolline with CodeRay for syntax highlighting as you type. # Only works on >= 1.9.3 because coolline depends on io/console. require 'coolline' require 'coderay' 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 |