PageRenderTime 12ms CodeModel.GetById 11ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/README.rdoc

http://github.com/alloy/dietrb
Unknown | 109 lines | 82 code | 27 blank | 0 comment | 0 complexity | 2d492debff59636997043b098ce43c55 MD5 | raw file
  1IMPORTANT! THIS REPO HAS BEEN MOVED TO http://svn.macosforge.org/repository/ruby/DietRB/trunk
  2AND IS AVAILABLE AS A GIT MIRROR ON http://github.com/MacRuby/DietRB.
  3
  4= IRB on a diet, for MacRuby / Ruby 1.9
  5
  6The goal is to have a small and cleaned up version of IRB. Trimmed down to only
  7do the stuff I, and most people I know, actually use.
  8
  9Trimming down the core code is done mainly by using Ripper, which comes with
 10Ruby 1.9, instead of shipping it's own parser etc.
 11
 12There's still lots to be done, but the ‘basic functionality’ as is now, should
 13not grow too much more. For now my things to-do are .irbrc support, completion,
 14and investigate what else people really really need. After that it's time to
 15polish.
 16
 17= Important notice
 18
 19Since on Ruby 1.9 *all* latest gems are pushed onto the load path by default,
 20installing the DietRB gem would break the existing IRB binary. Therefor, with
 21the DietRB gem is installed, it will hijack the `irb' bin file.
 22
 23The original IRB will still work when you uninstall the DietRB gem, though.
 24
 25== Extensions
 26
 27* irb/ext/colorize.rb, adds support for colorizing the prompt and result. The
 28  code was based upon Wirble's implementation, so your custom Wirble themes
 29  should still work.
 30  
 31  Configure it with:
 32  
 33  * IRB.formatter.color_scheme = scheme, where scheme can be: :dark_background,
 34    :light_background, or :fresh. Defaults to :dark_background.
 35  
 36  * IRB.formatter.colors returns the hash of current token-type to color
 37    mappings.
 38
 39* irb/ext/completion.rb, adds, as the name implies, autocompletion for
 40  constants, variables, methods, etc.
 41
 42* irb/ext/history.rb, stores/loads the history in and from the history file,
 43  which is located at ~/.irb_history.
 44  
 45  It provides the following API:
 46  
 47  * Kernel#history(N), or Kernel#h, will show N number of the most recent history
 48    entries. Defaults to 50.
 49  
 50  * Kernel#history!(entry_or_range), or Kernel#h!, will execute the specified
 51    history entry, or entries if a range is given.
 52  
 53  * Kernel#clear_history! will clear the history and the history file.
 54
 55== Differences
 56
 57* Dietrb will try to warn about syntax errors as soon as a line is entered and
 58  only reset the buffer to the previous line. This means that you don't need to
 59  loose any previous work:
 60  
 61  IRB:
 62  
 63    irb(main):001:0> class A
 64    irb(main):002:1>   def foo
 65    irb(main):003:2>     } p :ok
 66    irb(main):004:1>   end
 67    SyntaxError: compile error
 68    (irb):3: syntax error, unexpected '}'
 69        } p :ok
 70         ^
 71    (irb):4: syntax error, unexpected $end, expecting kEND
 72    	from (irb):4
 73    	from :0
 74    irb(main):005:0> A.new.foo
 75    NameError: uninitialized constant A
 76    	from (irb):5
 77    	from :0
 78  
 79  Dietrb:
 80  
 81    irb(main):001:0> class A
 82    irb(main):002:1>   def foo
 83    irb(main):003:2>     } p :ok
 84    SyntaxError: compile error
 85    (irb):3: syntax error, unexpected '}'
 86    irb(main):004:2>     p :ok
 87    irb(main):005:2>   end
 88    irb(main):006:1> end
 89    => nil
 90    irb(main):007:0> A.new.foo
 91    :ok
 92    => :ok
 93
 94== Play
 95
 96Normal usage:
 97
 98  irb(main):001:0> class A
 99  irb(main):002:1>   def foo
100  irb(main):003:2>     :ok
101  irb(main):004:2>   end
102  irb(main):005:1> end
103  => nil
104  irb(main):006:0> irb A.new
105  irb(#<#<Class:…>::A:…>):001:0> foo
106  => :ok
107  irb(#<#<Class:…>::A:…>):002:0> quit
108  => nil
109  irb(main):007:0> quit