lib/ruote/storage/fs_storage.rb in ruote-2.1.11 vs lib/ruote/storage/fs_storage.rb in ruote-2.2.0

- old
+ new

@@ -1,7 +1,7 @@ #-- -# Copyright (c) 2005-2010, John Mettraux, jmettraux@gmail.com +# Copyright (c) 2005-2011, John Mettraux, jmettraux@gmail.com # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell @@ -55,11 +55,11 @@ # 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. # - def initialize (dir, options={}) + def initialize(dir, options={}) FileUtils.mkdir_p(dir) @cloche = Rufus::Cloche.new( :dir => dir, :nolock => options['cloche_nolock']) @@ -67,37 +67,37 @@ @options = options @cloche.put(@options.merge('type' => 'configurations', '_id' => 'engine')) end - def put (doc, opts={}) + def put(doc, opts={}) @cloche.put(doc.merge!('put_at' => Ruote.now_to_utc_s), opts) end - def get (type, key) + def get(type, key) @cloche.get(type, key) end - def delete (doc) + def delete(doc) @cloche.delete(doc) end - def get_many (type, key=nil, opts={}) + def get_many(type, key=nil, opts={}) if key key = Array(key) key = key.map { |k| "!#{k}" } if key.first.is_a?(String) end # assuming /!#{wfid}$/... @cloche.get_many(type, key, opts) end - def ids (type) + def ids(type) @cloche.ids(type) end # Purges the storage completely. @@ -107,27 +107,34 @@ FileUtils.rm_rf(@cloche.dir) end # No need for that here (FsStorage adds type on the fly). # - def add_type (type) + def add_type(type) end - def purge_type! (type) + def purge_type!(type) @cloche.purge_type!(type) end - def dump (type) + 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 + + # Shuts this storage down. + # + def shutdown + + # nothing to do end end end