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 60
def initialize (dir, options={})

  FileUtils.mkdir_p(dir)

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

  @options = options

  @cloche.put(@options.merge('type' => 'configurations', '_id' => 'engine'))
end

Public Instance Methods

add_type(type) click to toggle source

No need for that here (FsStorage adds type on the fly).

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

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

  s = "=== #{type} ===\n"

  @cloche.get_many(type).inject(s) do |s1, e|
    s1 << "\n"
    e.keys.sort.inject(s1) do |s2, k|
      s2 << "  #{k} => #{e[k].inspect}\n"
    end
  end
end
get(type, key) click to toggle source
# File lib/ruote/storage/fs_storage.rb, line 77
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 87
def get_many (type, key=nil, opts={})

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

  @cloche.ids(type)
end
purge!() click to toggle source
# File lib/ruote/storage/fs_storage.rb, line 97
def purge!

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

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

  @cloche.put(doc.merge!('put_at' => Ruote.now_to_utc_s), opts)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.