/README.rdoc

http://github.com/alloy/dietrb · Unknown · 109 lines · 82 code · 27 blank · 0 comment · 0 complexity · 2d492debff59636997043b098ce43c55 MD5 · raw file

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