Project

em-fs

0.0
No commit activity in last 3 years
No release in over 3 years
`em-fs` provides libraries to access file system commands through an API similar to the Ruby file API for eventmachine.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

EM::FS

EM::FS provides a simple interface to gain simple filesystem access in eventmachine via EM::SystemCommand.

EM::FileUtils attempts to mimic the behavoir of the filesystem API of the Ruby stdlib. In the background it invokes linux/unix system commands - like rsync, mkdir etc. - via the em-systemcommand gem.

Furthermore EM::Dir and EM::File provide abstractions to crawl directory structures via find command without blocking the reactor.

Installation

Add this line to your application's Gemfile:

gem 'em-fs'

And then execute:

$ bundle

Or install it yourself as:

$ gem install em-fs

Usage

EM::FS using rsync and find

To invoke bare commands you can either use EM::SystemCommand directly or the methods EM::FS.rsync and EM::FS.find.

EM::FileUtils for simple filesystem operations

The FileUtils methods from the Ruby Standard Library may block the eventmachine reactor. That´s why em-fs uses EM::SystemCommand to provide a similar non-blocking feature set.

EM.run do
  EM::FileUtils.cp 'some_file', 'some_copy' do |on|
    on.exit do |status|
      puts 'Copied!'
    end
  end
end

For a full list of methods, have a look at the documentation.

Abstraction via EM::Dir and EM::File

EM::Dir[] returns a EM::Dir::Glob object, containing the information for the find command. On this object you can invoke multiple methods to see the resulting filesystem objects:

EM::Dir['./**/*.*'].each do |stat|
  puts "Some stat: #{stat.inspect}"
end

EM::Dir['./**/*.lisp'].each_entry do |entry|
  puts "Some entry: #{entry}"
end

EM::Dir['./**/*.rb'].each_path do |path|
  puts "Some path: #{path}"
end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request