Hugh Sasse's Ruby Page

Introduction | Translation Tools (Tradukiloj) | Where to get Ruby | Organisations | The Latest on Ruby | Tutorials | Documentation (including FAQ and FXRuby) | Newsgroup and mailing list | Conference | Ruby on Rails | JRuby | Other Sites | Ruby-Related Vim stuff | Heuristics for Improving Performance of Ruby Code | My software

Introduction

Ruby is an Object Oriented Scripting language with Perl-like regular expressions. See http://www.ruby-lang.org/ which is the Ruby Home page. (Not to be confused with the Ruby VLSI design language.)

Translation tools (Tradukiloj)

When searching the web, much of the information available about Ruby is in Japanese. However the Excite Japan machine translation service can give an idea of what the pages are about. This service's default mode is to translate from English to Japanese, so select the other "radio button" to translate the other way.

There is now a site providing machine translation of maling lists at http://translator.rubynow.com/. Eksistas, nun, TTT-ejo kio eldonas masxinajn tradukojn de la ret-listoj.

There is also Babelfish, which can take a url or a text fragment, as can Globalgate.

There are many translation engines listed at http://www.google.com/Top/Science/Social_Sciences/Linguistics/Translation/Tools/Translation_Engines/. (Estas multaj tradukaj masxinoj montritaj cxe http://www.google.com/Top/Science/Social_Sciences/Linguistics/Translation/Tools/Translation_Engines/. ) If you know of better translation tools I would be happy to hear about them. Se vi scias plibonajn tradukilojn, mi felicxus audi pri ilin.

The links I have here are in English, mostly.

Where to get Ruby

This is covered in Section 3 of the Ruby FAQ. See the Download page at www.ruby-lang.org. The single download for Ruby under Windows has support from the google group. (The Windows distribution was originally provided by The Pragmatic Programmers.)

The CVS repository no longer exists, as ruby has used svn for a while now How to get ruby using the cvs command-line is also documented.

There are snapshots available at http://ftp.ruby-lang.org/pub/ruby/snapshots/ and your local mirror server.

Ruby Applications can generally be found at The Ruby Toolbox now that the Ruby Application Archive has been retired. See also Rubygems.org.

There is a growing number of projects hosted at rubyforge.org.

An increasingly popular package distribution system is Rubygems. the actual gems can be downloaded with something like gem install -r gemname, where gemname is the name of the gem. To find out which ones exist one can do gem query -n pattern, where -n means the same as --name-matches. There is more documentation at the RubyGems Manuals site.

Organisations.

Ruby Central, Inc..
On Ruby's 10th "Birthday" (24-FEB-2003) there was an announcement Ruby-Talk [Ruby-Talk:65632] declaring the creation of this organisation.

The Latest on Ruby

Rubygarden vanished a while ago. Ruby Change Requests are now held at http://rcrchive.net/, and are likely to be added to fairly frequently. There is an RSS feed (see the reference to Rubric below for details about RSS) for this at http://kapheine.hypa.net/rcrchive.xml, or, if you want a smaller URL, http://tinyurl.com/2tagj. And, of course, there is the Newsgroup and Mailing list. I have an automatically generated list of frequently changing sites with timestamps, for the cases where the site issues a timestamp in the headers. Those that don't show up as being changed in 1970, "which is, of course, impossible".

Tutorials

The Ruby User Guide from "An Invitation to Ruby".

Learning Ruby is a tutorial by Daniel Carrera, and is avaliable for download (0.3).

There are also some slides giving an introduction to Ruby and some more from the The Pragmatic Programmers, Andy Hunt and Dave Thomas.

Mark Slagell's Ruby page has links to a tutorial in various forms.

The Ruby Cookbook is/will be a site where code examples can be found.

PLEAC-Ruby, part of the PLEAC (Programming Language Examples Alike Cookbook), has examples of Ruby code that perform the same tasks as code in the Perl Cookbook.

Ruby Code and Style has a good article on Creating DSLs with Ruby, by Jim Freeze.

Documentation

Principle sources

Documentation is available from the home page.

Programming Ruby The Pragmatic Programmer's Guide, Second Edition (The Pickaxe II) is the most cited work in English on Ruby.

http://www.ruby-doc.org/ is the Ruby community's documentation project. It has several search facilities built into it. For example you can find information about a class by using the URL http://www.ruby-doc.org/find/ri/class, or http://www.ruby-doc.org/find/pickaxe/class. Adding /method to the URL will give documentation for that method. The Standard Library documentation project is managed at http://rubyforge.org/projects/stdlib-doc/. There is a Wiki to discuss this.

The FAQ.

Many questions are answered in Ruby FAQ in HTML See also Ruby Documentation from the ruby site..

Other docs.

Things That Newcomers to Ruby Should Know covers things differently from the FAQ.

The reference at Ruby Central is definitely worth looking at. See What's new at RubyCentral.com. It is by The Pragmatic Programmers, Dave Thomas and Andy Hunt, who have written the book Programming Ruby, which Matz regards as the 1.6 reference now. It is now available online at RubyCentral and at ruby-doc.org, and for download. My intranet copy is here.

There is a (new 06-FEB-2004) version of the on-line Pickaxe which has links to the RubyGarden Wiki pages thar are relevant.

Why's (Poignant) Guide to Ruby is a gentle introduction to Ruby, supported by cartoon characters and other illustrations. Not quite Ruby in Manga, but certainly unorthodox. It will suit people fairly new to programming. At present it is a work in progress. The source code is available from the RubyForge project page.

Documentation for 1.8 is coming along at http://stdlib-doc.rubyforge.org/.

For people writing extensions, most of the information is in README.EXT I have a local copy of README.EXT from 1.9, and a copy of 1.9 README.EXT in HTML. This was created with:


brains hgs 585 %> to_markdown.rb README.EXT README_EXT_markdown > scratch
brains hgs 586 %> filter_markdown_blocks.rb README_EXT_markdown README_EXT_markdown_filtered
brains hgs 587 %> markdown_to_html.rb README_EXT_markdown_filtered README_EXT_markdown.html

There is a Wiki Book 'Programming:Ruby". (mentioned in Ruby-doc:991).

I used to have Rdoc docs of my copy of the Ruby CVS tree created with do_rubycvsdocs.sh. I also have Rdoc docs of my copy of the Ruby 1.8 CVS tree created with do_rubycvsdocs_1.8.sh.

I have a local copy of the reference manual downloaded from there. I have created an A-Z index of the 1.4 Manual based on those files.

I have created a small document describing the background and usage of Masaki Suketa's RubyUnit. I hope this will be of help to some people. I also have a page about Watir, with links to information about Web Application Testing in Ruby.

There is an Introduction to DRb available in English, from Chad Fowler. This documents dRuby or drb as it is sometimes called. I have started to write my own documentation for this, see my dRuby page. At the time of writing this, there is little information there.

RACC is now bundled with Ruby 1.8.x.

My FXRuby Page now contains the documentation that occupied this paragraph.

Resources for Tk include Ruby/Tk Tutorial; a three part article by Christopher Roach - parts 1, 2 and 3; Ruby-Tk FAQ; and Ruby/Tk classes and Modules.

There is also WideStudio

There is a page about callcc and continuations in Ruby on the Merd site.

Newsgroup and mailing list

Details of the mailing lists are held in Question 1.7 of the Ruby FAQ and on ruby-lang.org.

There is also the newsgroup comp.lang.ruby, see Question 1.6 of the Ruby FAQ.

Conference

There is now a site for the annual Ruby Conference.

Ruby on Rails

I am beginning a foray into the world of Ruby on Rails, the web development framework based on Ruby (and a database). There is a documentation site for RoR. There are full manuals site. There is a book Agile Web Development with Ruby on Rails by Dave Thomas, David Heinemeier Hansson, et al [ISBN: 0-9766940-0-X].

There is a mailing list with archives, and another interface to the archives. There is also a Wiki.

There is a Ruby on Rails Newcomers FAQ.

The Dwarves on Rails has good example code for a small model, with table joins. etc.

Debugging Rails Application[s] from datanoise.com.

I am making a few notes on it myself.

JRuby

I haven't done a whole lot with jruby yet. Some time last year (2013) I was finding it faster than MRI (using 1.7.1 version). Here are some odd notes and links. The whole of this page could do with being refreshed.

JRuby.
See also Getting Started with JRuby and JRuby and Java Code Examples.
Using Java Classes in JRuby.
Let's Build a Simple Video Game with JRuby: A Tutorial from 2011.
A bit old now, predates include Java, but still looks useful at the moment. At least with my knowledge of Java at the moment.

Other Sites

Ruby Central has been created by The Pragmatic Programmers, Andy Hunt and Dave Thomas. They have also created a Wiki for discussion of Ruby development. It is at http://www.pragprog.com:8080/ruby or http://www.pragprog.com/ruby.

The Ruby Quiz contains quizzes posted to Ruby-Talk with digests of answers. These answers are usually pretty insightful, as well as the problems being quite interesting in themselves.

The Ruby Ring has a page for the list of sites.

Facets contains a lot of classes and methods that one might consider writing oneself.

The arkadia.com Ruby Page, from their Programming Languages page.

Shoes a very easy to pick up GUI toolkit from Whytheluckystiff. The Shoebox is a collection of Shoes applications. There is documentation called "Nobody Knows Shoes" free at Hackety Press for shoes is to be soul of the new Hackety Hack, see http://hackety.org/ for more of this sort of thing.

See also Takaaki Tateishi's Ruby page.

The RDtool page for Ruby Document format processing,

The announcement of Rockit version 0-3-5 points to where the tar file can be had, and contains the README file. The Rockit Home Page is the place to look for the latest on this project.

Matju's AST system was also announced, and should tie in well with Rockit.

Hal Fulton's Ruby Page has lots of useful links on it.

Paul Rubel's FormatR brings Perl style formats to ruby. This is something I wanted to write, but he got there first! It looks like he has ironed some of the bugs out of the system in its re-implementation.

RDoc - Documentation from Ruby Source Files from the Pragmatic Programmers. This package parses ruby and extracts comments which precede each class and method, associating them with that method. It then produces (currently HTML) documentation describing the methods and classes in the package.

SWIG has some ruby facilities now. " SWIG is a software development tool that connects programs written in C, C++, and Objective-C with a variety of high-level programming languages." - to quote the site. The documentation for using Ruby with SWIG needs work. There is also a SwigWiki. I have made modifications to the SWIG documentation for Ruby which I have put here for constructive criticism. 31-JAN-2002: These were accepted into SWIG-1.3.11 and since then further dramatic improvements have been made by others.

Ruby-Lua allows the embedding of Lua interpreters in Ruby.

YAML4R is an interesting project to provide access to the YAML human readable data description language through ruby. YAML uses indentation to show the structure of data, but because there are ways to cross-reference data in the same file, it is not limited to tree structures. The project's homepage has more links on the subject.

Using YAML in my datafiles for my current work will create an extra dependency on other people's code. This is a problem for the system as I am designing it so I'd like to avoid that. There are actually a lot of nuances in the full yaml spec, and so I'm not confident about writing my own module to handle this. Looking into "Self Describing Data" yielded this document stating how XML can be used to describe data formats, (the doc is best read from the beginning). Also Learning XML: a guide to creating self-desribing data from the O'Reilly catalog has a good sample chapter. However, I conclude that for simple tables of floats, the format is excessive, even though DTD syntax is now much clearer to me than it was. Even though REXML wraps a lot of this, you still need to be familiar with things like XPath and SAX to use it properly, and the nested nature of XML makes some of the commands feel to "heavy" for me. (05-FEB-2003 -- My opinion has changed somewhat now. REXML simplifies things considerably, and the XPath usage is simpler than I thought. See my XML informationn elsewhere. Jack Herrington's Code Generation book, and this page from IBM (which seems to be the same as this article from gnosis.cx show how easy it can be to use REXML.) My local copy of the REXML 2.7.3 API docs and my local copy of the REXML 3.1.2 API docs are available, as is my local copy of the tutorial. There is also MyXML which is built on top of REXML, though I have not used it yet (13-SEP-2004). The RubyXML site referred to xmlsuck.com, which has a list of XML alternatives, of which ONX looks the simplest for my purposes. This paragraph is not particularly relevant to ruby but may be of some use to rubyists.

There is a MiniRubyWiki, with source code available via the CVS links, (then click on download). {This being CVS I expect the exact URL of this is rather too dynamic to be held here.}

There is an interesting collection of libraries and applications at http://ttsky.net/ruby/.

There are a number of Directory pages about Ruby: The Open Directory (dmoz.org)'s Ruby page; The Google Directory's Ruby page.

There is an extensive collection of links on this Yet Another Ruby Links page.

Ruby Mine belongs to Aleksi Niemelä, but it seems to have gone 23-JUL-2002. This has news and links on it, and its coverage for the new user is very good.

Mod_Ruby is the Ruby interpreter that can be embedded in the Apache Web server. It lives at http://www.modruby.net/.

Erubis is a faster version of eruby. (See also stdlib docs of erb.) Erubis supports more languages (ruby, perl, javascript, scheme).

There is a lot of software in ftp://ftp.netlab.co.jp/pub/lang/ruby/contrib/.

rbison.

Rubric is a news aggregator written in Ruby. The news in this case is not newsgroups, but RSS[1][2][3] -- Rich, or RDF, Site Summaries.

glark deserves to be better known. It is a "grep" that can find expressions on different lines in the same file, will highlight the results, and uses ruby regexps. It is written in ruby. The highlighting is by means of ANSI colour. The latest (on 07-JUL-2004) is :

MD5 (glark-1.7.0.tar.gz) = c5bcd6346550b35fbf34992a701ee0d5

See the glark download page for the various distributions.

glark occupies almost the same space as ack, which is a Perl program for searching code (including HTML and LaTeX) using fast ststing searching algorithms. Being Perl it is very portable. Somewhat faster but less portable is ag: the silver searcher, which uses a faster string algorithm (at the time or writing and mmap. I mention these (a) so as not to lose the info, but (b) because it may be of use to someone.

metaprogramming.rb is code extracted from http://whytheluckystiff.net/articles/seeingMetaclassesClearly.html (or http://tinyurl.com/9qmo3 for short). It is by Why the Lucky Stiff of Redhanded fame. On the topic of metaprogramming, this ruby-talk posting about class instance variables is useful. as is this entry from the MobCode blog's Code category.

The Kirbybase database is a simple plain text database system. It is also available for Python.

Ruby Programming Language Enables Concise Network Programming by Mark Watson is a good collection of short networking exaples for HTTP and XML servers and clients, including SOAP and XML-RPC. It is from devx.com.

Ruby-Related Vim stuff

The support files for Vim that apply to ruby are now available from http://vim-ruby.rubyforge.org/, and the pages referenced from there. I contributed folding to the syntax file, and rolled a very basic compiler file for vim6.1 To actually enable the folding syntax you need to give the command

:set fdm=syntax

which will enable folding and fold as much as it can.

My own version of the syntax file has

highlight Folded ctermfg=Blue ctermbg=DarkRed
set fdm=syntax

because I find the white background of the folds to be too bright.

To enable the compiler features you need to use the

:compiler ruby

or

:comp ruby

command and then you can run a script with

:make %

and have the errors located by vim for ease of editing.

Tim Hammerquist has improved on my compiler file with his version which can be found at http://vim.sourceforge.net/scripts/script.php?script_id=349.

Gavin Sinclair has become the maintainer of the Ruby Indent file and the file type plugin for Ruby, see [Ruby-Talk:47005], See his page for more information.

Doug Kearns is maintaining the Ruby Syntax file now [Ruby-Talk:46932], and it is at ruby.vim.

Heuristics for Improving Performance of Ruby Code.

My software

Most of this will be trivial to start with, but as I become more familiar with the language the standard of the code should improve. It does not include the software on My Applied Electromagnetics Group Intranet pages.

indexblob.rb
Produce a "blob" of HTML as a skeleton for an index page. mkcontents.rb will create a contents chunk from the headings in an HTML file. It takes 3 args, input, modified input, and contents. The contents is plugged back in in the appropriate place in modified input to create the completed file.
UDP communicating pair
A pair of programs to act as a "server" and a "client", which may be extended so the server may be a client of something else. Thus UDP was chosen as the protocol. These are bare-bones programs which don't provide any kind of service.
udpclient.rb
udpserver.rb
nestedyields.rb a script to test/demonstrate nesting of functions with yield calls.
take_two_procs.rb and take_two_procs2.rb
demonstrate two styles of passing procedures into another procedure. This is useful if you need more than one thing yielded in a procedure.
timed_read.rb
demonstrates the results of using the timeout library, by using gets as the operation to time out.
partial_nesting.rb
demonstrates how a container of containers can be built to allow access to the lowest level without going through the intermediate level. In this example a "crate" contains 4 "things" but they may be regarded as being in two "boxes" within the crate. Different ways of accessing the data are basically equivalent.
Enumeration.rb
Not to be confused with the much newer thing in Ruby 1.9!!! Enumerated types as in C. There are two kinds, one is "names for numbers" (Enumeration) and the other is "names for bits" (Bitfield). The code to perform various tests on these classes is Enumeration_test.rb
gnudecode.rb
gnudecode2.rb
two scripts to decode files written with Gnu uuencode -m, i.e base 64. They check that the file doesn't already exist, and keep appending % to the name until the file does not exist, then write the file out. Permissions are ignored. This was just an exercise in file handling, I have the real gnu program anyway.
display_diffs.rb
Script to display all diffs below a directory. Assumes that the originals are held in name.orig and the file name has subsequently been edited.
attributes2.rb
Script to demonstrate the use of attributes in ruby.
docs_in_here_doc.rb
A program to see which has precedence, a here document or the ruby documentation standard. Can you embed =begin...=end in a here document, and have these sections ignored when the string is constructed? It seems not. The solution to this was suggested by Dave Thomas and it is to have the information in DATA, the file after __END__.
self_print.rb
A self printing program relying on the way DATA behaves when rewound
argftest.rb
A program to show how to make use of ARGF. It shows how lines can be read in sequence from all input files, and how a change in the input file can be detected. It doesn't demonstrate that if ARGV is changed, ARGF will change dynamically.
hash_bang.txt
Shows how ruby can do intelligent things with the #! line at the start of scripts. This means it can pickup warning flags and so on from that line.
Rubyweb
The basis of a Literate Programming system for Ruby
prepatch
Pre-process patches so the -p n option of patch need not be used on the resulting patch file..
revision.rb
A revision class with methods to detect lesser and greater revisions.
rpermute.rb
Extends the Array class with a method to randomly permute the array.
timeout.rb
A replacement for the library routine timeout.rb. The reason for writing it was that the old version behaves like a boolean or a success/failure producing timeout, but, like Schrödinger's cat, you cannot tell how it will behave till you invoke the timeout method. I wanted it to behave as a something that would return a boolean, or behave as something that would give a result on success, and an exception on failure. So I re-wrote it.
stderr_to, stderr_append.
The C shell is not terribly good for redirecting STDERR to somewhere unlike the Bourne shell, but even the Bourne shell's syntax is not very user-friendly. I wrote these utilities to allow me to redirect the standard error output to a file, or to append it to a file. I was using ruby -r profile script at the time. They are invoked as
stderr_to filename command with args
stderr_append filename command with args
where filename is where the output is to go. Be careful about quoting in command with args, because of the way the shell will consume one level of \ before the command string reaches ruby.
Comparisons in Ruby - a Proposal/Investigation
This "paper" (rather a grand title for it!) is put forward a suggestion on the comparison operators in Ruby, so people can discuss it.
rdescriber.rb
This is a program to go through the files in a directory and sift out the ruby programs, and list which modules and classes they use or modify/extend. The idea is that the inter-relationships between files can be more clearly seen. Caveat: the parser which picks out the require, class, module, include and new keywords is very simplistic. Example output can be seen in rdescriber_out.html. Modified so that when it is recursing it no longer descends into "." and "..". for a version that descends directories (up to 10 deep) there is deeprdescriber. This has now been out-evolved by RDoc - Documentation from Ruby Source Files from the Pragmatic Programmers (see above). Nonetheless, I still find it has its uses. I've extended it in the past year to produce diagrams in GIF, SVG, and PNG formats, (nested with the <OBJECT> tag) with Graphvis, and it now puts all its output into the directory ./RDESCRIBER/, so as not to clutter up the current directory. And I have further enhanced it to produce the diagrams in colour. At present these are preset, and unalterable values of colour. Its detection of of Class.new missed those occurrences which were not next to an = sign. Now more are picked up and multiple occurrences on one line for keywords will work now as well, improving the coverage. If this is actually useful, something to detect memory leaks might be more useful, in which case looking at Visualizing memory leaks in Ruby would be useful, found from [HN:7385380].
Whats_new_from_rcs.rb
A program to find out which files are newer than some file and print out the RCS information for them. This would be used for logging changes on a Web site for example.
Array_myuniq.rb
A uniq operator for Array that uses == for comparisons, rather than .id. This is important when nesting structures, which may be similar but will have different ids.
bagsubtract.rb
An array subtraction that treats array as a bag, rather than a set.
rcs_history.rb
Descend directories, examining RCS files, and list the changes in chronological order. Output in HTML, plain text is less sophisticated and as yet untested. Depends on rlog, rather than parsing the files directly.
html_spell.rb
Filter an HTML file (removing tags) and spell check. Return the unfiltered file, preceded by the misspelled words. This should be usable in vi[m] with the
:[range]!html_spell.rb
or !{motion}html_spell.rb (etc) commands so that the misspelled words precede the text. In vim use * to find the next occurrence of the word under the cursor.
comment.rb
As html_spell.rb above, but comment lines out.
adjust_date_from
The rdate command allows time to be synchronised between two machines, but it results in a jump in the local time, which may be a backward jump. The date command has a -a option to overcome this, but rdate does not. This command calculates the offset for data -a so time can be adjusted smoothly. It relies on the timex module by Tanaka Akira.
module_class_vars.rb
To see if a module can add class variables to a class. It seems it can.
module_super.rb
An exploration of how inheritance in modules works. This was written when attempting to use modules to extend the functionality of a class.
class_to_reload.rb, extensions_to_example.rb and class_reload_test.rb
Dynamic redefinition of methods in a class, without using modules. This is considerably easier than using module_override.rb.
varargs.rb
How to use variable argument syntax.
id.rb
Test the use of id on various objects, to see which have unique ids.
top.rb
The top utility (http://www.groupsys.com/top/) displays the processes most utilising the CPU on a system, but does not work under solaris7, excepting the beta version. Since the program must be run setuid root under solaris, I'm reluctant to use beta code. Furthermore, development seems to have ceased in 2000. So I have written this, which post-processes the output from ps, and uses tput to clear the screen. I might add command-line options to allow adjustment of the refresh rate and number of processes, but since it does what I want at the moment, this is unlikely.
upload.rb
This was a script to get a large file off a PC without kermit onto a Unix box. It uses FXRuby to do its job. Written with a LOT of help from Lyle Johnson, it was lashed together originally in Ruby/Tk using the Pig Latin example from the "pickaxe book". This dependance on FXRuby is not a problem given that this now comes in the Windows Distribution of Ruby.
make_forward.rb
A script to create a .forward file for our unix system that will save messages our hub flags up as spam. Probably of limited interest to people outside dmu.ac.uk, but it makes a stab at detecting Exim filter files and responding sensibly to that knowledge.
pass_array.rb
I often get mixed up passing arrays around, and knowing when to use * in a parameter list. As this program shows, the only thing to rememeber is that *formal_parameter will wrap the remaining arguemts in an array, and *a will expand a in place. This means that return *a is pretty redundant, and using * in a formal parameter means an extra level of nesting which may not be needed.
remove_spaces
A script to take a list of filenames (ARGV) and rename those which contain spaces so that the spaces are replaced by underscore characters. Useful for Unix people who get stuff from Windows users.
replace_case.rb
I had a class with a switch statement to interpret configuration file entries of the form:
name=value
and I wanted to create a subclass without copying the case statement again. This code shows how a table can be used instead of the case statement for this purpose.
pine_send_filter
My pine send filter, written so I don't send mail to obviously munged addresses by mistake. A work in progress, but it seems to do the job. The file documents how to install it, more or less.
splitter.rb
A program to split files into chunks which can then be e-mailed, saveed to disk, faxed somewhere, or whatever and re-assembled at the other end. The program uses md5 sums to check the integrity of each part and the constructed whole. It works by require'ing the files so they are assembled in the correct order.
I have written a similar program in Lua which, together with a Lua distribution for windows and WiZ from InfoZip (both of which fit on one 1.44MB floppy), allowed me to get the latest (Nov-2004) version of the Windows installer for Ruby on a machine with no CDROM or working network. It took 23 floppy transfers to do it though, but it was feasible.
Since then I have added Deflate compression to the program, which admittedly means the size limits are only rough estimates when compressing. Also the -u option allows the program to create just one file, instead of at least 2, to act like a shar file, but in ruby.
md5sum.rb
A ruby program to calculate md5 sums, as per OneLiners. This is actually in the form of a shell script. It is also available as a DOS/Windows batch file md5sum.bat.
mbox_each.rb
This library file has an iterator for Unix mbox files. It has been used to process files of up to 200 MB which won't fit in memory (with several other people using the system). This made it impractical to use the mbox library from the RAA. It includes a string stack class to make the concatenation of data more efficient, as is done in Lua, and it does run much quicker than using buffer += string repeatedly. It may be quicker still just to add the strings to an array and do the join('') once...it was much quicker. This has been revised to reflect this.
split_mbox.rb
The program to split an mbox into chunks of (for this example) 200 messages.
colourize
This, which is an example of using available rubygems, is a simple colourizer for the command line. One may invoke it like this:
gmake check | colourize red FAIL yellow PASS blue SKIP
and it will highlight the words in the given colours.
method_in_singleton.rb
When a number of different subclasses are needed for differential behaviour, but their use is sparse, it may be better to use singleton classes (by using class <<variable; ... end) inside a class_eval(string) call. This way even the definition of methods becomes dynamic.
deflate.rb and inflate.rb
Compress a file to standard output or decompress a file to standard output using the Deflate method of RFC1951.
rdtordoc.rb
A program I developed a while ago (and forgot about!) to do a first pass at converting RD (rdtool) format to RDoc format.
c_code_gen.rb
A library for taking the repetitive nature out of creating C programs. This is for creating "object oriented" C code, like the FILE interface, where each method has a prefix denoting the class it belongs to, and the first argument is a pointer to the instance of that class. So for example, fprintf(FILE *stream, char * const format, ...). It is pretty much a work in progress, but it seems to be functioning correctly.
qdfinder.rb
A Quick And Dirty Finder -- a recursive grep program for finding files, on a system where I failed to install glark.
rcsood
A script to find which files in the current directory are out of date with respect to their RCS logs, so that one knows which ones to check in.
new_dryer.rb
I proposed Ruby Quiz 53, "TumbleDRYer", to see if there were novel solutions to correcting repetition in code. Once I had explored the solutions and attempted to use an automatic system for correcting repetition in code, I concluded that often this is a symptom of a design fault that cannot be corrected by simple programmatic means. So, I decided to write a tool simply to detect the problem of repetition and list which things are repeated. This is about the second major iteration of the tool. If given no options or filenames, it will self-test. If given the file '-', it will read standard input. If given the option -n it will remove the prefixes of the longest outputs.
block_to_constructor.rb
An example of how to pass a block to a constructor. There was a nice article about this on the original Ruby Central site, before Ruby Central existed as a company, but it has gone. So using The Ruby Way book I've made this example so I can find it again.
mergesort.rb
Needed a sort guaranteed to be stable, so implemented a merge sort. In case it helps someone else, here it is.
drive_excel.rb.
Routine to drive Excel and crate a 3d chart. It took quite a bit of digging to get this to work. The casing of constants is different from VB, EXCEL_CONST is referred to as ExcelConst in some sources. etc. This seems to work for me and I hope it helps someone else.
ff.rb and ferret_helper.rb
Modified ff.rb, Stuart Rackham's Ferret based search engine, which he now regards as abandonware, so has passed on to me. My mods allow configuration to work if not all the programs are present, list files as they are indexed, remove duplication between ff.rb and ferret_helper, where the list of acceptable extensions is defined in both files. ff.rb now refers to the constant in ferret_helper.rb, and extend the types of files supported. It will now pull text out of rtf files and PostScript files, and pull tags out of JPEG images where that is possible. It does attempt to access the contents of compressed files, if they are not too big. I've also extended the list of mime_types supported and regarded as text. One of my reasons for using Ferret is that on Windows the Windows search won't look in things which are programs, but that includes script files which obviously contain useful comments. I've not bumped the version number yet or stuck my name in there either.
add_assertions.rb
Wondering how to add the assert facility into a class without adding the whole of Test Unit. This seems to work OK. Using extend works, include won't work.

Created on 01-MAR-2000 by

Hugh G. Sasse

.

Last Modified on 12-MAR-2014 by

Hugh G. Sasse

. Re-validate this page.

RCS: $Id: index.html,v 1.169 2014/03/12 12:23:16 hgs Exp hgs $


For automatic address collectors: <postmaster@localhost> <abuse@localhost> blockme@relays.osirusoft.com