Sha256: 3737675cd97cedca40ab006ef9da02588ef543e383b8244be9a5b1cab06c4755

Contents?: true

Size: 1.71 KB

Versions: 1

Compression:

Stored size: 1.71 KB

Contents

# FS (FileSystem)

Work with your filesystem!

## Problem

This Gem shouldn't reinvent the wheel or be a replacement.
But in Ruby working with the filesystem really hurts!

In your toolbox are at least `File`, `Dir`, `FileUtils`, `Find`, and maybe some more.
Good tools, but to complicated for most cases. 
It's not about piping, or copying the shell as it is.
But think about a simple `ls` in the shell, than how you would do this in Ruby. 
Got the idea?

## Solution

`FS` gathers the cluttered methods for working with files and dirs. Internally 
using the good old standard library, but providing simple methods in a single place.

## Examples

    FS.changedir('~/Projects/fs')
    ==> "/Users/bjuenger/Projects/fs"
    FS.list('.')
    ==> [".git", ".gitignore", ".rvmrc", "fs.gemspec", "Gemfile", "Gemfile.lock", "lib", "Rakefile", "README.mdown", "spec"]
    FS.makedirs('tmp/demo')
    FS.touch('tmp/demo/newfile.txt')
    FS.list('tmp/demo')
    ==> ["newfile.txt"]
    FS.remove('tmp/demo/newfile.txt')
    FS.list('tmp/demo')
    ==> []

## Aliases

Although verbose method names are good, there are some aliases for unix shell 
commands (unsorted).

- ls => list
- mkdir => makedir
- mkdir_p => makedirs
- cd => changedir
- mv => move
- cp => copy
- rm => remove
- ln => link
- cat => read (no concatenate)

## Todo

Here is my mind … here is my mind …

- maybe use underscores (remove_dir)
- remove! to force something
- maybe makedir! to mkdir -p
- use Find#find in FS#find ;)
- some kind of #tree output
- file type
- exist?
- list_dirs
- list_files
- find_dirs
- find_files
- FS.link('a.txt' => 'b.txt') with a hash

## BTW

If you need a replacement for the shell in pure ruby, than have a look at 
[Rush](http://rush.heroku.com/).

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fs-0.1.0 README.mdown