/cotta.rb

File operation that easier, more sensible, and testable

Primary LanguageRuby

Welcome to the Ruby version of the {Cotta file API}[http://cotta.rubyforge.org]

= Introduction

Cotta project is created to provide a lightweight, simple and sensible API to file operation and testing.
See {Cotta Power}[http://cotta.sourceforge.net/power.html] for its motivation


= Install It

The easiest way to install the install cotta using RubyGems:

  sudo gem install cotta

= Features

Cotta is just a plain Ruby API, so you can use it wherever you can use Ruby.

To used the new API just require the client driver:

   require "rubygems"
   require "cotta"

For a fully backward compatible API you can start with:

   require "rubygems"
   gem "cotta"
   require "cotta"

For instance
to write a little Ruby script using cotta you could write something like:

    #!/usr/bin/env ruby
    #
    # Sample Ruby script using the Cotta API
    #
    require "rubygems"
    gem "cotta", ">=1.0.0"
    require "cotta"

    #system implementation is injected here
    cotta = Cotta.physical
    file = cotta.file('dir/file.txt')
    file.should_not be_exists
    # parent directories are created automatically
    file.save('my content')
    file2 = cotta.file('dir/file2.txt')
    file2.should_not be_exists
    file.copy_to(file2)
    file2.should be_exists
    file2.load.should == 'my content'
    file2.read {|file| puts file.gets}

= Writing Tests

To test your code that uses Cotta API, you just need to pass in a Cotta instance that is backed by an in-memory
file system:

    cotta = Cotta.in_memory

= Resources

* Source Code at http://github.com/wolfdancer/cotta
* Report bugs at http://github.com/wolfdancer/cotta/issues
* Browse API at http://cotta.rubyforge.org
* Discuss at http://groups.google.com/group/cotta

= Reports

* rSpec: {rspec}[link:rspec/index.html]
* code coverage:{rcov}[link:rcov/index.html]

= Team

* Shane Duan