class ICFS::Store

Permanent store for items

Provides storage for:

@abstract

Public Instance Methods

action_read(cid, anum, lnum) click to toggle source

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
action_write(cid, anum, lnum, item) click to toggle source

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
case_read(cid, lnum) click to toggle source

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
case_write(cid, lnum, item) click to toggle source

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(fi) click to toggle source

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
entry_read(cid, enum, lnum) click to toggle source

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
entry_write(cid, enum, lnum, item) click to toggle source

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
file_read(cid, enum, lnum, fnum) click to toggle source

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
file_size(cid, enum, lnum, fnum) click to toggle source

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
file_write(cid, enum, lnum, fnum, tmpf) click to toggle source

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
index_read(cid, xnum, lnum) click to toggle source

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
index_write(cid, xnum, lnum, item) click to toggle source

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
log_read(cid, lnum) click to toggle source

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
log_write(cid, lnum, item) click to toggle source

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
tempfile() click to toggle source

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

_action(cid, anum, lnum) click to toggle source

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
_case(cid, lnum) click to toggle source

Path for case

# File lib/icfs/store.rb, line 224
def _case(cid, lnum)
  @base + [
    cid,
    'c',
    '%d.json' % lnum
  ].join('/')
end
_entry(cid, enum, lnum) click to toggle source

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
_file(cid, enum, lnum, fnum) click to toggle source

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
_index(cid, xnum, lnum) click to toggle source

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
_log(cid, lnum) click to toggle source

Path for log

# File lib/icfs/store.rb, line 236
def _log(cid, lnum)
  @base + [
    cid,
    'l',
    '%d.json' % lnum
  ].join('/')
end
_read(path) click to toggle source

Read an item

# File lib/icfs/store.rb, line 212
def _read(path); raise NotImplementedError; end
_write(path, item) click to toggle source

Write an item

# File lib/icfs/store.rb, line 218
def _write(path, item); raise NotImplementedError; end