Editing in Ruby

Hi all --

I just started reading up on programming in Ruby. I used to program in
VB / VB.NET, and have done some programming in Java, etc etc. In any
case, I am looking over the basic "how to program in Ruby" tutorials on
the web just to get a general idea of how this programming language
works, and I was wondering if there was any editor out there that had
"autocomplete," i.e., one that will automatically give me a list of
functions for the object in question whenever I type in the '.', and
also give me the tooltips once I start a function.
I installed the one-click Ruby installer (I'm running this on WinXP),
and it gave me a copy of SciTE, but it looks like I need to point it to
a text file listing the entire ruby API, and I don't know where to find
that (I've tried Googling for it, but to no avail). I also have
installed RDE, and FreeRide comes with the installer too (but, of
course, FreeRide seems to run on top of Scintilla).
In any case, I was wondering if anyone knew either (a) how to get a
list of all the functions in ruby exported to an API file, or (b) if
there is an editor out there that can help out. Many times when I'm
programming, it's nice to just be able to see what the valid functions
are for the object in question, rather than having to look it up in the
API documentation.

Thanks!
Shreyas

There are things that do that... but why?
Ruby is a very different language than Java and .Net, which sometimes
rely on the IDE too heavily. For Ruby, you don't need autocomplete.
Actually, because Ruby is such a dynamic language, a *good*
autocomplete is virtually impossible to make. My advice: try to use an
editor instead of an IDE or IDE-like environment with autocomplete and
the like. Experiment with Vim or Scite for a while, you might like it.
I did, and I swore by autocomplete for Java before learning Ruby. Just
my $.02!

Jacob

···

On 10/16/05, Shreyas <sravi2k4@gmail.com> wrote:

Hi all --

I just started reading up on programming in Ruby. I used to program in
VB / VB.NET, and have done some programming in Java, etc etc. In any
case, I am looking over the basic "how to program in Ruby" tutorials on
the web just to get a general idea of how this programming language
works, and I was wondering if there was any editor out there that had
"autocomplete," i.e., one that will automatically give me a list of
functions for the object in question whenever I type in the '.', and
also give me the tooltips once I start a function.
I installed the one-click Ruby installer (I'm running this on WinXP),
and it gave me a copy of SciTE, but it looks like I need to point it to
a text file listing the entire ruby API, and I don't know where to find
that (I've tried Googling for it, but to no avail). I also have
installed RDE, and FreeRide comes with the installer too (but, of
course, FreeRide seems to run on top of Scintilla).
In any case, I was wondering if anyone knew either (a) how to get a
list of all the functions in ruby exported to an API file, or (b) if
there is an editor out there that can help out. Many times when I'm
programming, it's nice to just be able to see what the valid functions
are for the object in question, rather than having to look it up in the
API documentation.

Thanks!
Shreyas

I'm a newbie to all things in general but I think the Ruby Development
Tools for Eclipse is the closest thing I know of.

However, as someone noted, it is a dynamic language and so
autocomplete (ctrl+space in Eclipse) leaves much to be desired and is
probably not what you expect.

For Eclipse+Ruby+Rails check out the following:

Setting Up an Eclipse Environment for Ruby and Rails
http://www.napcs.com/howto/railsonwindows.html

Radrails (Eclipse rich client packaged for Rails+Ruby)
http://www.radrails.org/

Radrails Plugin for people already on Eclipse
http://download.radrails.org/update/

Maybe someone has a better setup or solution.

···

2005/10/17, Shreyas <sravi2k4@gmail.com>:

Hi all --

I just started reading up on programming in Ruby. I used to program in
VB / VB.NET, and have done some programming in Java, etc etc. In any
case, I am looking over the basic "how to program in Ruby" tutorials on
the web just to get a general idea of how this programming language
works, and I was wondering if there was any editor out there that had
"autocomplete," i.e., one that will automatically give me a list of
functions for the object in question whenever I type in the '.', and
also give me the tooltips once I start a function.
I installed the one-click Ruby installer (I'm running this on WinXP),
and it gave me a copy of SciTE, but it looks like I need to point it to
a text file listing the entire ruby API, and I don't know where to find
that (I've tried Googling for it, but to no avail). I also have
installed RDE, and FreeRide comes with the installer too (but, of
course, FreeRide seems to run on top of Scintilla).
In any case, I was wondering if anyone knew either (a) how to get a
list of all the functions in ruby exported to an API file, or (b) if
there is an editor out there that can help out. Many times when I'm
programming, it's nice to just be able to see what the valid functions
are for the object in question, rather than having to look it up in the
API documentation.

Thanks!
Shreyas

Shreyas wrote:

In any case, I was wondering if anyone knew either (a) how to get a list of all the functions in ruby exported to an API file, or (b) if there is an editor out there that can help out. Many times when I'm programming, it's nice to just be able to see what the valid
functions are for the object in question, rather than having to look
it up in the API documentation.

Use irb with irb/completion

$ irb
irb(main):001:0> require 'irb/completion'
=> true
irb(main):002:0> f = "Hello, world!"
=> "Hello, world!"
irb(main):003:0> f.downcase
f.downcase f.downcase!
irb(main):003:0> f.downcase

If you hit f.down<tab>, it'll complete to downcase. hit it twice, and
it'll show "f.downcase f.downcase!"

If you want to find other methods, try using f.methods.grep

irb(main):004:0> f.methods.grep /case/
=> ["downcase", "downcase!", "casecmp", "swapcase", "swapcase!",
"upcase", "upcase!"]

f.case<tab> will pull out f.casecmp for you.

This works with any valid object in irb.

irb(main):005:0> i = 1
=> 1
irb(main):006:0> i.methods.grep /case/
=>
irb(main):007:0> i.methods.grep /zero/
=> ["zero?", "nonzero?"]

It's very handy, and I use it a lot, even though I've been rubying for
about 3 years.

Hope that helps you, too!

- Greg

I was wondering if there was any editor out there
that had "autocomplete," i.e., one that will
automatically give me a list of
functions for the object in question whenever I
type in the '.'

The jEdit Ruby Editor Plugin provides method autocompletion for the
Ruby system classes:

I was wondering if anyone knew either
(a) how to get a list of all the functions in
ruby exported to an API file, or
(b) if there is an editor out there that can help
out.
Many times when I'm programming, it's nice to just
be able to see what the valid functions
are for the object in question

The jEdit Ruby Editor Plugin has an integrated documentation panel
that shows you method RDocs as you scroll the autocompletion list. You
can also type search terms into this panel, here's a screenshot:


cheers,
Rob

···

On 10/17/05, Shreyas <sravi2k4@gmail.com> wrote:

and I was wondering if there was any editor out there that
had "autocomplete," i.e., one that will automatically give
me a list of functions for the object in question whenever
I type in the '.'

The Zeus for Windows IDE uses Exuberant Ctags to do it's
class browsing and intellisensing:

   Zeus IDE - Programming environment for Windows developers

The Exuberant Ctags home page lists Ruby as one of the
supported languages:

   Languages Supported by Exuberant Ctags

so in theory Zeus will do intellisensing and class browsing
for the Ruby language.

But for this to work, a minimal amount of configuration will
be needed. For example this link:

   Intellisensing for MFC or wxWidgets - Zeus IDE

Shows how Zeus can be configured to provide intellisensing
for the C# and Mono languages.

Jussi Jumppanen
Author: Zeus for Windows IDE
Note: Zeus is shareware (45 day trial).

Its true that autocomplete is a difficult proposition in a dynamic language.
There is work being done on this, but nothing yet that is any good. Anyway,
don't expect to find usuable autocomplete anywhere in the near future.

I disagree that IDE advice, though. One of the nice things you can get from
the current batch of IDEs is code navigation -- a hierarchical tree that
graphically shows you the modules/classes/methods of the file being edited,
and you can click on one of these to navigate to that element in the code.
This makes it easy to see the structure of the code you are editing.

FreeRIDE has this, so does the RDT plugin for Eclipse (both are free).
Arachno Ruby, while being a commercial product, does this very well.

Curt

···

On 10/16/05, Jacob Quinn Shenker <jqshenker@gmail.com> wrote:

There are things that do that... but why?
Ruby is a very different language than Java and .Net, which sometimes
rely on the IDE too heavily. For Ruby, you don't need autocomplete.
Actually, because Ruby is such a dynamic language, a *good*
autocomplete is virtually impossible to make. My advice: try to use an
editor instead of an IDE or IDE-like environment with autocomplete and
the like. Experiment with Vim or Scite for a while, you might like it.
I did, and I swore by autocomplete for Java before learning Ruby. Just
my $.02!

Jacob

On 10/16/05, Shreyas <sravi2k4@gmail.com> wrote:
> Hi all --
>
> I just started reading up on programming in Ruby. I used to program in
> VB / VB.NET <http://VB.NET>, and have done some programming in Java, etc
etc. In any
> case, I am looking over the basic "how to program in Ruby" tutorials on
> the web just to get a general idea of how this programming language
> works, and I was wondering if there was any editor out there that had
> "autocomplete," i.e., one that will automatically give me a list of
> functions for the object in question whenever I type in the '.', and
> also give me the tooltips once I start a function.
> I installed the one-click Ruby installer (I'm running this on WinXP),
> and it gave me a copy of SciTE, but it looks like I need to point it to
> a text file listing the entire ruby API, and I don't know where to find
> that (I've tried Googling for it, but to no avail). I also have
> installed RDE, and FreeRide comes with the installer too (but, of
> course, FreeRide seems to run on top of Scintilla).
> In any case, I was wondering if anyone knew either (a) how to get a
> list of all the functions in ruby exported to an API file, or (b) if
> there is an editor out there that can help out. Many times when I'm
> programming, it's nice to just be able to see what the valid functions
> are for the object in question, rather than having to look it up in the
> API documentation.
>
> Thanks!
> Shreyas
>
>
>

I agree with Greg.
Add a bit of history capture to your .irbrc script and boom, you've got an
auto-complete, code by exploration environment.
j.

···

On 10/16/05, Greg Millam <ruby-talk@lethalcode.net> wrote:

Shreyas wrote:
> In any case, I was wondering if anyone knew either (a) how to get a
> list of all the functions in ruby exported to an API file, or (b) if
> there is an editor out there that can help out. Many times when I'm
> programming, it's nice to just be able to see what the valid
> functions are for the object in question, rather than having to look
> it up in the API documentation.

Use irb with irb/completion

$ irb
irb(main):001:0> require 'irb/completion'
=> true
irb(main):002:0> f = "Hello, world!"
=> "Hello, world!"
irb(main):003:0> f.downcase
f.downcase f.downcase!
irb(main):003:0> f.downcase

If you hit f.down<tab>, it'll complete to downcase. hit it twice, and
it'll show "f.downcase f.downcase!"

If you want to find other methods, try using f.methods.grep

irb(main):004:0> f.methods.grep /case/
=> ["downcase", "downcase!", "casecmp", "swapcase", "swapcase!",
"upcase", "upcase!"]

f.case<tab> will pull out f.casecmp for you.

This works with any valid object in irb.

irb(main):005:0> i = 1
=> 1
irb(main):006:0> i.methods.grep /case/
=>
irb(main):007:0> i.methods.grep /zero/
=> ["zero?", "nonzero?"]

It's very handy, and I use it a lot, even though I've been rubying for
about 3 years.

Hope that helps you, too!

- Greg

--
"http://ruby-lang.org -- do you ruby?"

Jeff Wood

Curt,
I actually think we agree on this point. Perhaps the point I was
trying to make is that Java and .Net often rely on code generation and
other IDE-powered tricks to speed up development. Ruby doesn't.
However, hierarchical trees and such are great and should definitely
be used!

Jacob

···

On 10/16/05, Curt Hibbs <curt.hibbs@gmail.com> wrote:

Its true that autocomplete is a difficult proposition in a dynamic language.
There is work being done on this, but nothing yet that is any good. Anyway,
don't expect to find usuable autocomplete anywhere in the near future.

I disagree that IDE advice, though. One of the nice things you can get from
the current batch of IDEs is code navigation -- a hierarchical tree that
graphically shows you the modules/classes/methods of the file being edited,
and you can click on one of these to navigate to that element in the code.
This makes it easy to see the structure of the code you are editing.

FreeRIDE has this, so does the RDT plugin for Eclipse (both are free).
Arachno Ruby, while being a commercial product, does this very well.

Curt

On 10/16/05, Jacob Quinn Shenker <jqshenker@gmail.com> wrote:
>
> There are things that do that... but why?
> Ruby is a very different language than Java and .Net, which sometimes
> rely on the IDE too heavily. For Ruby, you don't need autocomplete.
> Actually, because Ruby is such a dynamic language, a *good*
> autocomplete is virtually impossible to make. My advice: try to use an
> editor instead of an IDE or IDE-like environment with autocomplete and
> the like. Experiment with Vim or Scite for a while, you might like it.
> I did, and I swore by autocomplete for Java before learning Ruby. Just
> my $.02!
>
> Jacob
>
> On 10/16/05, Shreyas <sravi2k4@gmail.com> wrote:
> > Hi all --
> >
> > I just started reading up on programming in Ruby. I used to program in
> > VB / VB.NET <http://VB.NET>, and have done some programming in Java, etc
> etc. In any
> > case, I am looking over the basic "how to program in Ruby" tutorials on
> > the web just to get a general idea of how this programming language
> > works, and I was wondering if there was any editor out there that had
> > "autocomplete," i.e., one that will automatically give me a list of
> > functions for the object in question whenever I type in the '.', and
> > also give me the tooltips once I start a function.
> > I installed the one-click Ruby installer (I'm running this on WinXP),
> > and it gave me a copy of SciTE, but it looks like I need to point it to
> > a text file listing the entire ruby API, and I don't know where to find
> > that (I've tried Googling for it, but to no avail). I also have
> > installed RDE, and FreeRide comes with the installer too (but, of
> > course, FreeRide seems to run on top of Scintilla).
> > In any case, I was wondering if anyone knew either (a) how to get a
> > list of all the functions in ruby exported to an API file, or (b) if
> > there is an editor out there that can help out. Many times when I'm
> > programming, it's nice to just be able to see what the valid functions
> > are for the object in question, rather than having to look it up in the
> > API documentation.
> >
> > Thanks!
> > Shreyas
> >
> >
> >
>

Its true that autocomplete is a difficult
proposition in a dynamic language.
There is work being done on this, but nothing yet
that is any good. Anyway,
don't expect to find usuable autocomplete anywhere
in the near future.

Curt, have you tried out the jEdit Ruby Editor Plugin? It provides
type-based method completion for the Ruby system classes. Blog based
feedback suggests that this is a usable autocomplete tool in
combination with other plugin features like the integrated RDoc
viewer[1].

In the short term I intend to extend the method autocompletion
functionality to autocomplete based on methods listed in imported
RDocs. So you'd be able to import RDocs for your own classes or gems
and autocomplete on your own methods.

I disagree that IDE advice, though. One of the nice
things you can get from the current batch of IDEs is
code navigation -- a hierarchical tree that
graphically shows you the modules/classes/methods of
the file being edited, ...

FreeRIDE has this, so does the RDT plugin for
Eclipse (both are free).

The jEdit Ruby Editor Plugin also shows a hierarchical tree of the
Ruby code structure, in a dockable side panel and also in a key-bound
popup dialog. In the popup dialog you're able to navigate to a method
via type-ahead selection.

Rob

[1]Casinonic Australia – how to get much pleasure?
http://blog.corvideon.ie/2005/10/06/a-quick-review-of-jedit-as-a-ruby-on-rails-ide/
http://wqoq.com/2005/08/24/yarpa-the-quest-for-a-ruby-editor/
http://livsey.org/2005/07/13/editors-and-ides/

···

On 10/17/05, Curt Hibbs <curt.hibbs@gmail.com> wrote:

Vim + taglist does this. I don't use it though.

···

On 10/16/05, Curt Hibbs <curt.hibbs@gmail.com> wrote:

Its true that autocomplete is a difficult proposition in a dynamic language.
There is work being done on this, but nothing yet that is any good. Anyway,
don't expect to find usuable autocomplete anywhere in the near future.

I disagree that IDE advice, though. One of the nice things you can get from
the current batch of IDEs is code navigation -- a hierarchical tree that
graphically shows you the modules/classes/methods of the file being edited,
and you can click on one of these to navigate to that element in the code.
This makes it easy to see the structure of the code you are editing.

I'll have t give it a try... thanks!

Curt

···

On 10/19/05, Rob . <rob.02004@gmail.com> wrote:

On 10/17/05, Curt Hibbs <curt.hibbs@gmail.com> wrote:
> Its true that autocomplete is a difficult
> proposition in a dynamic language.
> There is work being done on this, but nothing yet
> that is any good. Anyway,
> don't expect to find usuable autocomplete anywhere
> in the near future.

Curt, have you tried out the jEdit Ruby Editor Plugin? It provides
type-based method completion for the Ruby system classes. Blog based
feedback suggests that this is a usable autocomplete tool in
combination with other plugin features like the integrated RDoc
viewer[1].