Editing in Ruby

S

Shreyas

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
 
S

SB

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.

http://rubyeclipse.sourceforge.net/

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.
 
C

Curt Hibbs

------=_Part_18794_12674818.1129522050368
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Its true that autocomplete is a difficult proposition in a dynamic language=
 
G

Greg Millam

Shreyas said:
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
 
J

Jeff Wood

------=_Part_8720_17739989.1129537961204
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

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.

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'
=3D> true
irb(main):002:0> f =3D "Hello, world!"
=3D> "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/
=3D> ["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 =3D 1
=3D> 1
irb(main):006:0> i.methods.grep /case/
=3D> []
irb(main):007:0> i.methods.grep /zero/
=3D> ["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

------=_Part_8720_17739989.1129537961204--
 
R

Rob .

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:

http://www.jedit.org/ruby/
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:

http://www.jedit.org/ruby/images/jedit_ruby_editor_plugin.png

cheers,
Rob
http://www.jedit.org/ruby/
 
R

Rob .

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
http://www.jedit.org/ruby/

[1]http://jroller.com/page/thuss?entry=3Din_search_of_a_ruby
http://blog.corvideon.ie/2005/10/06/a-quick-review-of-jedit-as-a-ruby-on-ra=
ils-ide/
http://wqoq.com/2005/08/24/yarpa-the-quest-for-a-ruby-editor/
http://livsey.org/2005/07/13/editors-and-ides/
 
C

Curt Hibbs

------=_Part_4471_24561126.1129735939123
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

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].

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

Curt

------=_Part_4471_24561126.1129735939123--
 
J

jussij

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:

http://www.zeusedit.com/features.html

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

http://ctags.sourceforge.net/languages.html

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:

http://www.zeusedit.com/forum/viewtopic.php?t=185

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).
 
J

Joe Van Dyk

Its true that autocomplete is a difficult proposition in a dynamic langua= ge.
There is work being done on this, but nothing yet that is any good. Anywa= y,
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 fr= om
the current batch of IDEs is code navigation -- a hierarchical tree that
graphically shows you the modules/classes/methods of the file being edite= d,
and you can click on one of these to navigate to that element in the code=
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top