class ICFS::Store
Permanent store for items
Provides storage for:
-
Case
-
Log
-
Entry
-
Attached files
-
Action
-
Indexes
@abstract
Public Instance Methods
Read an action
@param cid [String] caseid @param anum [Integer] Action number @param lnum [Integer] Log number @return [String] The JSON encoded item
# File lib/icfs/store.rb, line 140 def action_read(cid, anum, lnum) _read(_action(cid, anum, lnum)) end
Write an action
@param cid [String] caseid @param anum [Integer] Action number @param lnum [Integer] Log number @param item [String] the JSON encoded item
# File lib/icfs/store.rb, line 153 def action_write(cid, anum, lnum, item) _write(_action(cid, anum, lnum), item) end
Read a case
@param cid [String] caseid @param lnum [Integer] Log number @return [String] The JSON encoded item
# File lib/icfs/store.rb, line 39 def case_read(cid, lnum); _read(_case(cid, lnum)); end
Write a case
@param cid [String] caseid @param lnum [Integer] Log number @param item [String] the JSON encoded item
# File lib/icfs/store.rb, line 49 def case_write(cid, lnum, item); _write(_case(cid, lnum), item); end
Close the file returned by file_read
()
@param fi [File] The file to close
# File lib/icfs/store.rb, line 198 def close(fi) if fi.respond_to?( :close! ) fi.close! else fi.close end end
Read an entry
@param cid [String] caseid @param enum [Integer] Entry number @param lnum [Integer] Log number @return [String] The JSON encoded item
# File lib/icfs/store.rb, line 80 def entry_read(cid, enum, lnum); _read(_entry(cid, enum, lnum)); end
Write an entry
@param cid [String] caseid @param enum [Integer] Entry number @param lnum [Integer] Log number @param item [String] the JSON encoded item
# File lib/icfs/store.rb, line 91 def entry_write(cid, enum, lnum, item) _write(_entry(cid, enum, lnum), item) end
Read a file
@param cid [String] caseid @param enum [Integer] Entry number @param lnum [Integer] Log number @param fnum [Integer] File number @return [File,Tempfile] Read only copy of the file
# File lib/icfs/store.rb, line 105 def file_read(cid, enum, lnum, fnum); raise NotImplementedError; end
Get a file size
@param cid [String] caseid @param enum [Integer] Entry number @param lnum [Integer] Log number @param fnum [Integer] File number @return [Integer] The size of the file
# File lib/icfs/store.rb, line 129 def file_size(cid, enum, lnum, fnum); raise NotImplementedError; end
Write a file
@param cid [String] caseid @param enum [Integer] Entry number @param lnum [Integer] Log number @param fnum [Integer] File number @param tmpf [Tempfile] A Tempfile obtained from tempfile
# File lib/icfs/store.rb, line 117 def file_write(cid, enum, lnum, fnum, tmpf); raise NotImplementedError; end
Read an Index
@param cid [String] caseid @param xnum [Integer] Index number @param lnum [Integer] Log number @return [String] the JSON encoded item
# File lib/icfs/store.rb, line 166 def index_read(cid, xnum, lnum) _read(_index(cid, xnum, lnum)) end
Write an Index
@param cid [String] caseid @param xnum [Integer] Index number @param lnum [Integer] Log number @param item [String] the JSON encoded item
# File lib/icfs/store.rb, line 179 def index_write(cid, xnum, lnum, item) _write(_index(cid, xnum, lnum), item) end
Read a log
@param cid [String] caseid @param lnum [Integer] Log number @return [String] The JSON encoded item
# File lib/icfs/store.rb, line 59 def log_read(cid, lnum); _read(_log(cid, lnum)); end
Write a log
@param cid [String] caseid @param lnum [Integer] Log number @param item [String] the JSON encoded item
# File lib/icfs/store.rb, line 69 def log_write(cid, lnum, item); _write(_log(cid, lnum), item); end
Get a Tempfile to use to write files
@return [Tempfile] a Tempfile which can be written and passed to
#file_write
# File lib/icfs/store.rb, line 190 def tempfile; raise NotImplementedError; end
Private Instance Methods
Filename for action
# File lib/icfs/store.rb, line 274 def _action(cid, anum, lnum) @base + [ cid, 'a', anum.to_s, lnum.to_s + '.json' ].join('/') end
Path for case
# File lib/icfs/store.rb, line 224 def _case(cid, lnum) @base + [ cid, 'c', '%d.json' % lnum ].join('/') end
Path for entry
# File lib/icfs/store.rb, line 248 def _entry(cid, enum, lnum) @base + [ cid, 'e', enum.to_s, '%d.json' % lnum ].join('/') end
Path for file
# File lib/icfs/store.rb, line 261 def _file(cid, enum, lnum, fnum) @base + [ cid, 'e', enum.to_s, '%d-%d.bin' % [lnum, fnum] ].join('/') end
Filename for index
# File lib/icfs/store.rb, line 287 def _index(cid, xnum, lnum) @base + [ cid, 'i', xnum.to_s, lnum.to_s + '.json' ].join('/') end
Path for log
# File lib/icfs/store.rb, line 236 def _log(cid, lnum) @base + [ cid, 'l', '%d.json' % lnum ].join('/') end
Read an item
# File lib/icfs/store.rb, line 212 def _read(path); raise NotImplementedError; end
Write an item
# File lib/icfs/store.rb, line 218 def _write(path, item); raise NotImplementedError; end