Wirble 0.1.1: Irb Enhancements for the Masses

Paul D. wrote:

I looked into highlighting the input in Irb, too. It’s a lot more work,
but it might be doable. At a minimum, I’d need to write, borrow, or
steal a full-blown Ruby lexer. I’d probably need a more terminal-
friendly replacement for readlines (probably curses).

You can use the lexer built into irb. I forget how it’s
done, but I did it two years ago. :wink:

Hal

Paul D. wrote:

Hi All,

I just released version 0.1.1 of Wirble. Wirble is a small collection
of enhancements Irb, packaged in an easy-to-use format. Wirble includes
tab-completion, persistent history, built-in ri support, and syntax
highlighting for Irb results.

Nice! I think you should do auto indent too.

IRB.conf[:AUTO_INDENT]=true

I got colors to work on my XP box by installing win32_console.

http://raa.ruby-lang.org/project/win32_console/

after that I just added:
require ‘win32/console/ansi’

On Windows:

C:>ruby --version
ruby 1.8.4 (2006-04-14) [i386-mswin32]

I get the followin:

Object.ri ‘object_id’
c:/ruby/lib/ruby/gems/1.8/gems/wirble-0.1.2/./wirble.rb:88:in
initialize': No such file or directory - /c/.irb_history (Errno::ENOENT) from c:/ruby/lib/ruby/gems/1.8/gems/wirble-0.1.2/./wirble.rb:88:insave_history’
from
c:/ruby/lib/ruby/gems/1.8/gems/wirble-0.1.2/./wirble.rb:113:in
initialize' from c:/ruby/lib/ruby/1.8/irb/ruby-lex.rb:253 c:/ruby/lib/ruby/gems/1.8/gems/wirble-0.1.2/./wirble.rb:88:ininitialize’: No such file or directory - /c/.irb_history
(Errno::ENOENT)
from
c:/ruby/lib/ruby/gems/1.8/gems/wirble-0.1.2/./wirble.rb:88:in
save_history' from c:/ruby/lib/ruby/gems/1.8/gems/wirble-0.1.2/./wirble.rb:113:ininitialize’
from c:/ruby/lib/ruby/1.8/irb/ruby-lex.rb:253


“Nothing will ever be attempted, if all
possible objections must first be
overcome.” - Samuel Johnson

“Luck is what happens when
preparation meets opportunity.” - Seneca

or even better

gem in -y win32console

On 9/8/06, Gordon T. [email protected] wrote:

When I tried it on Windows XP, I get this wierd error:

–/LSm8UPTCLHL4o89
Content-Type: application/pgp-signature
Content-Disposition: inline;
filename=“signature.asc”
Content-Description: Digital signature
X-Google-AttachSize: 190


“Nothing will ever be attempted, if all
possible objections must first be
overcome.” - Samuel Johnson

“Luck is what happens when
preparation meets opportunity.” - Seneca

On Sep 8, 2006, at 8:01 PM, Hal F. wrote:

Paul D. wrote:

I looked into highlighting the input in Irb, too. It’s a lot more
work,
but it might be doable. At a minimum, I’d need to write, borrow, or
steal a full-blown Ruby lexer. I’d probably need a more terminal-
friendly replacement for readlines (probably curses).

You can use the lexer built into irb. I forget how it’s
done, but I did it two years ago. :wink:

You certainly can steal irb’s lexer. Here’s an example from some code
I’ve been kicking around for a while, so you can see how it works:

(This code understands a very minimal set of ruby and turns it into a
sort of Sexpr)

require ‘irb/ruby-lex’
module RubyMerge
class ParseSkeleton
def initialize(io)
@io = io
end

 def skeleton
   lexer = RubyLex.new
   stack = []
   results = []
   lexer.set_input( @io )
   while current = lexer.token
     case current
     when RubyLex::TkDEF, RubyLex::TkMODULE
       if stack.empty?
         results << current.name.to_sym
         ident = nil
         1 while ( ident = lexer.token ).kind_of? RubyLex::TkSPACE
         results << ident.name
       else
         if results.last.kind_of? Array
           results.last << current.name.to_sym
           ident = nil
           1 while ( ident = lexer.token ).kind_of? RubyLex::TkSPACE
           results.last << ident.name
         else
           results << []
           results.last << current.name.to_sym
           ident = nil
           1 while ( ident = lexer.token ).kind_of? RubyLex::TkSPACE
           results.last << ident.name
         end
       end
       stack.push current
     when RubyLex::TkEND
       stack.pop
     end
   end
   results
 end

end
end

On 8 Sep 2006, at 19:04, Paul D. wrote:

http://pablotron.org/files/wirble-0.1.2.tar.gz.asc
http://pablotron.org/files/gems/wirble-0.1.2.gem
http://pablotron.org/files/gems/wirble-0.1.2.gem.asc

Am I doing this wrong? …

benjohn # sudo gem instal wirble --source http://pablotron.org/
files/gems/wirble-0.1.2.gem
ERROR: While executing gem … (Gem::RemoteSourceException)
HTTP Response 404
benjohn #

Thanks,
Benjohn

Hi,

I have been using win32console (with Ruby 1.8.2 and 1.8.4) and I had
some errors with the ansi.rb file:

-there’s a name conflict with IO: I corrected that with
class AnsiIO < IO

-there’s an error “private method sub! called” in _PrintString, and I
corrected that with s = t.dup.to_s (line 88)

After doing that, I suppressed the warnings by adding a -W0 option in my
irb.bat file and finally got colors with irb!

I hope this can help someone having the same troubles as me (or is there
something that I missed?).

Eric.


Eric T.
LTG - Product Manager
LEIRIOS
tel: 33(0)6.61.48.57.65/33(0)3.81.88.62.02
e-mail: [email protected]
blog: http://etorreborre.blogspot.com

----- Message d’origine ----
De : Tom J. [email protected]
Ã? : ruby-talk ML [email protected]
Envoyé le : Samedi, 9 Septembre 2006, 2h46mn 50s
Objet : Re: Re : [ANN] Wirble 0.1.1: Irb Enhancements for the Masses

or even better

gem in -y win32console

On 9/8/06, Gordon T. [email protected] wrote:

When I tried it on Windows XP, I get this wierd error:

–/LSm8UPTCLHL4o89
Content-Type: application/pgp-signature
Content-Disposition: inline;
filename=“signature.asc”
Content-Description: Digital signature
X-Google-AttachSize: 190


“Nothing will ever be attempted, if all
possible objections must first be
overcome.” - Samuel Johnson

“Luck is what happens when
preparation meets opportunity.” - Seneca