Parent

Included Modules

Class/Module Index [+]

Quicksearch

Ruote::FsStorage

A basic FS-bound ruote storage. Leverages rufus-cloche (github.com/jmettraux/rufus-cloche).

Warning : for JRuby 1.4.0 on Ubuntu, passing the cloche_nolock option set to true seems necessary. See groups.google.com/group/openwferu-users/t/d82516ed3bdd8f23

Public Class Methods

new(dir, options={}) click to toggle source

Creates a FsStorage pointing to the given dir.

The options are classical engine configuration, but the ‘cloche_nolock’ option is read by the storage and followed.

# File lib/ruote/storage/fs_storage.rb, line 51
def initialize(dir, options={})

  if dir.is_a?(Hash) && options == {}
    options = dir
    dir = options.delete('dir')
  end

  FileUtils.mkdir_p(dir)

  @cloche = Rufus::Cloche.new(
    :dir => dir, :nolock => options['cloche_nolock'])

  replace_engine_configuration(options)
end

Public Instance Methods

add_type(type) click to toggle source

No need for that here (FsStorage can add types on the fly).

# File lib/ruote/storage/fs_storage.rb, line 115
def add_type(type)
end
delete(doc) click to toggle source
# File lib/ruote/storage/fs_storage.rb, line 85
def delete(doc)

  @cloche.delete(doc)
end
dir() click to toggle source
# File lib/ruote/storage/fs_storage.rb, line 66
def dir

  @cloche.dir
end
get(type, key) click to toggle source
# File lib/ruote/storage/fs_storage.rb, line 80
def get(type, key)

  @cloche.get(type, key)
end
get_many(type, key=nil, opts={}) click to toggle source
# File lib/ruote/storage/fs_storage.rb, line 90
def get_many(type, key=nil, opts={})

  keys = key ? Array(key) : nil

  keys = keys.map { |k|
    type == 'schedules' ? /!#{k}-\d+$/ : "!#{k}"
  } if keys && keys.first.is_a?(String)

  @cloche.get_many(type, keys, opts)
end
ids(type) click to toggle source
# File lib/ruote/storage/fs_storage.rb, line 101
def ids(type)

  @cloche.ids(type)
end
purge!() click to toggle source

Purges the storage completely.

# File lib/ruote/storage/fs_storage.rb, line 108
def purge!

  FileUtils.rm_rf(@cloche.dir)
end
purge_type!(type) click to toggle source
# File lib/ruote/storage/fs_storage.rb, line 118
def purge_type!(type)

  @cloche.purge_type!(type)
end
put(doc, opts={}) click to toggle source
# File lib/ruote/storage/fs_storage.rb, line 71
def put(doc, opts={})

  doc = doc.send(
    opts[:update_rev] ? 'merge!' : 'merge',
    'put_at' => Ruote.now_to_utc_s)

  @cloche.put(doc, opts)
end
shutdown() click to toggle source

Shuts this storage down.

# File lib/ruote/storage/fs_storage.rb, line 125
def shutdown

  # nothing to do
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.