Module: Basket

Defined in:
lib/basket.rb

Defined Under Namespace

Classes: Base

Constant Summary collapse

VERSION =
'0.0.1'
DIR =
File.expand_path(File.dirname(File.expand_path(__FILE__)))

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loggingObject

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 (default inbox)

  • :pending: the name of the pending folder (default pending)

  • :archive: the name of the archive folder (default archive)

  • :other: if other 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 in inbox. incompatable with conditional.

  • :logdev: device to log to. For example: STDOUT or "/path/to/log.log" (default: /dev/null)

  • :conditional: if conditional is specified then then the result of the #process block is interpreted as boolean. if the result is true then the file is mv’d to success otherwise it is mv’d to fail

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