Project

fs

0.0
No commit activity in last 3 years
No release in over 3 years
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.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 0
>= 0
 Project Readme

FS (FileSystem) Build Status

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
  • rmdir => :removedir
  • rm_r => :removedirs
  • cd => :changedir
  • pwd => :currentdir
  • mv => :move
  • cp => :copy
  • rm => :remove
  • cat => :read
  • ln => :link
  • dir? => :directory?
  • expand => :expand_path
  • [] => :join

Todo

Here is my mind …

  • maybe use underscores (remove_dir)
  • remove! to force something
  • maybe makedir! to mkdir -p
  • maybe touch! to mkdir -p && touch
  • use Find#find in FS#find ;)
  • file type / ftype
  • list_dirs
  • list_files
  • find_dirs
  • find_files
  • FS.link('a.txt' => 'b.txt') with a hash