Module: Basket
- Defined in:
- lib/basket.rb
Defined Under Namespace
Classes: Base
Constant Summary collapse
- VERSION =
'0.0.1'
- DIR =
File.(File.dirname(File.(__FILE__)))
Class Attribute Summary collapse
-
.logging ⇒ Object
Returns the value of attribute logging.
Class Method Summary collapse
-
.process(input, opts = {}, &block) ⇒ Object
Basket Process a directory of files, one at a time.
Class Attribute Details
.logging ⇒ Object
Returns the value of attribute logging.
16 17 18 |
# File 'lib/basket.rb', line 16 def logging @logging end |
Class Method Details
.process(input, opts = {}, &block) ⇒ Object
Basket
Process a directory of files, one at a time.
Overview
Take root
folder and look for the directory inbox
. Each file in inbox
is first mv
‘d to pending
and then yielded to block
. Upon completion of the block the file is mv
’d to a directory, as specifed in the options.
Options
-
:inbox
: the name of the inbox folder (defaultinbox
) -
:pending
: the name of the pending folder (defaultpending
) -
:archive
: the name of the archive folder (defaultarchive
) -
:other
: ifother
is specified then the files are not moved to the archive or any other directory automatically. You must specify where the file will go or it will remain ininbox
. incompatable withconditional
. -
:logdev
: device to log to. For example:STDOUT
or"/path/to/log.log"
(default:/dev/null
) -
:conditional
: ifconditional
is specified then then the result of the #process block is interpreted as boolean. if the result istrue
then the file is mv’d tosuccess
otherwise it is mv’d tofail
Block Arity
If the block takes a single argument, then a string containing the path to the pending
file is yielded. If the block accepts two arugments then the file index is also yielded. Does not work for parallel processing with forkoff.
40 41 42 43 |
# File 'lib/basket.rb', line 40 def self.process(input, opts={}, &block) b = Base.new(input, opts) b.process(&block) end |