dietrb

IRB on a diet, for MacRuby / Ruby 1.9

OTHER License

Downloads
79.4K
Stars
62
Committers
2

IMPORTANT! THIS REPO HAS BEEN MOVED TO http://svn.macosforge.org/repository/ruby/DietRB/trunk AND IS AVAILABLE AS A GIT MIRROR ON http://github.com/MacRuby/DietRB.

= IRB on a diet, for MacRuby / Ruby 1.9

The goal is to have a small and cleaned up version of IRB. Trimmed down to only do the stuff I, and most people I know, actually use.

Trimming down the core code is done mainly by using Ripper, which comes with Ruby 1.9, instead of shipping it's own parser etc.

There's still lots to be done, but the ‘basic functionality’ as is now, should not grow too much more. For now my things to-do are .irbrc support, completion, and investigate what else people really really need. After that it's time to polish.

= Important notice

Since on Ruby 1.9 all latest gems are pushed onto the load path by default, installing the DietRB gem would break the existing IRB binary. Therefor, with the DietRB gem is installed, it will hijack the `irb' bin file.

The original IRB will still work when you uninstall the DietRB gem, though.

== Extensions

  • irb/ext/colorize.rb, adds support for colorizing the prompt and result. The code was based upon Wirble's implementation, so your custom Wirble themes should still work.

    Configure it with:

    • IRB.formatter.color_scheme = scheme, where scheme can be: :dark_background, :light_background, or :fresh. Defaults to :dark_background.

    • IRB.formatter.colors returns the hash of current token-type to color mappings.

  • irb/ext/completion.rb, adds, as the name implies, autocompletion for constants, variables, methods, etc.

  • irb/ext/history.rb, stores/loads the history in and from the history file, which is located at ~/.irb_history.

    It provides the following API:

    • Kernel#history(N), or Kernel#h, will show N number of the most recent history entries. Defaults to 50.

    • Kernel#history!(entry_or_range), or Kernel#h!, will execute the specified history entry, or entries if a range is given.

    • Kernel#clear_history! will clear the history and the history file.

== Differences

  • Dietrb will try to warn about syntax errors as soon as a line is entered and only reset the buffer to the previous line. This means that you don't need to loose any previous work:

    IRB:

    irb(main):001:0> class A irb(main):002:1> def foo irb(main):003:2> } p :ok irb(main):004:1> end SyntaxError: compile error (irb):3: syntax error, unexpected '}' } p :ok ^ (irb):4: syntax error, unexpected $end, expecting kEND from (irb):4 from :0 irb(main):005:0> A.new.foo NameError: uninitialized constant A from (irb):5 from :0

    Dietrb:

    irb(main):001:0> class A irb(main):002:1> def foo irb(main):003:2> } p :ok SyntaxError: compile error (irb):3: syntax error, unexpected '}' irb(main):004:2> p :ok irb(main):005:2> end irb(main):006:1> end => nil irb(main):007:0> A.new.foo :ok => :ok

== Play

Normal usage:

irb(main):001:0> class A irb(main):002:1> def foo irb(main):003:2> :ok irb(main):004:2> end irb(main):005:1> end => nil irb(main):006:0> irb A.new irb(#<#Class:…::A:…>):001:0> foo => :ok irb(#<#Class:…::A:…>):002:0> quit => nil irb(main):007:0> quit