Method Index [+]

Generated with Newfish 0.1.0


Ruby-based Batch Scripts


Ratch is Ruby-based DSL for building batch scripts. It’s intent is to ease the burden of batch script writers by supplementing the standard ruby environment to be more conducive to the needs of batch scripting.

In addition to using Ratch to write stand-alone batch scripts, it makes a very powerful library for other applications that require batch-like functionality. In general any program that access the file system extensively could benefit from it’s use.



Batch Scripting

To use for your own scripts, simply add a bang line.

  #!/usr/bin/env ratch

On Windows, of course, you will want to associate the .ratch extension name to the ratch executable instead.

As a Library

To use Ratch as a library, require ‘ratch’ and create an instance of Ratch::Shell.

If you wish to extend Ratch::Shell for your application, it is recommend that you either subclass Ratch::Shell, e.g.

  require 'ratch'

  class MyClass < Ratch::Shell


Or delegate to a Ratch::Shell instance, e.g.

  require 'ratch'

  class MyClass

    def initialize(path)
      @shell = Ratch::Shell.new(path)


For details on all the functionality Ratch provides, please refer to the API documentation.

Bonus Feature

Ratch also includes the `ludo` command, which stands for “lookup and do”. It will ascend up the directory tree searching for a matching executable script. If it finds one it will execute the script relative the currently ascended directory.


Standard installation procedure apply.

  $ gem install ratch

or manually using Setup.rb

  $ tar -xzf ratch-1.0.0.tgz
  $ cd ratch-1.0.0
  $ setup.rb


Ratch is hosted on GitHub.

To pull the ‘ratch’ repository anonymously, use:

    git clone git://github.com/rubyworks/ratch.git


Copyright © 2008 Thomas Sawyer

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this program except in compliance with the License. You may obtain a copy of the License at


Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.