Class: ICFS::Store Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/icfs/store.rb

Overview

This class is abstract.

Permanent store for items

Provides storage for:

  • Case

  • Log

  • Entry

  • Attached files

  • Action

  • Indexes

Direct Known Subclasses

StoreFs, StoreS3

Instance Method Summary collapse

Instance Method Details

#action_read(cid, anum, lnum) ⇒ String

Read an action

Parameters:

  • cid (String)

    caseid

  • anum (Integer)

    Action number

  • lnum (Integer)

    Log number

Returns:

  • (String)

    The JSON encoded item



138
139
140
# File 'lib/icfs/store.rb', line 138

def action_read(cid, anum, lnum)
  _read(_action(cid, anum, lnum))
end

#action_write(cid, anum, lnum, item) ⇒ Object

Write an action

Parameters:

  • cid (String)

    caseid

  • anum (Integer)

    Action number

  • lnum (Integer)

    Log number

  • item (String)

    the JSON encoded item



151
152
153
# File 'lib/icfs/store.rb', line 151

def action_write(cid, anum, lnum, item)
  _write(_action(cid, anum, lnum), item)
end

#case_read(cid, lnum) ⇒ String

Read a case

Parameters:

  • cid (String)

    caseid

  • lnum (Integer)

    Log number

Returns:

  • (String)

    The JSON encoded item



37
# File 'lib/icfs/store.rb', line 37

def case_read(cid, lnum); _read(_case(cid, lnum)); end

#case_write(cid, lnum, item) ⇒ Object

Write a case

Parameters:

  • cid (String)

    caseid

  • lnum (Integer)

    Log number

  • item (String)

    the JSON encoded item



47
# File 'lib/icfs/store.rb', line 47

def case_write(cid, lnum, item); _write(_case(cid, lnum), item); end

#close(fi) ⇒ Object

Close the file returned by file_read()

Parameters:

  • fi (File)

    The file to close



196
197
198
199
200
201
202
# File 'lib/icfs/store.rb', line 196

def close(fi)
  if fi.respond_to?( :close! )
    fi.close!
  else
    fi.close
  end
end

#entry_read(cid, enum, lnum) ⇒ String

Read an entry

Parameters:

  • cid (String)

    caseid

  • enum (Integer)

    Entry number

  • lnum (Integer)

    Log number

Returns:

  • (String)

    The JSON encoded item



78
# File 'lib/icfs/store.rb', line 78

def entry_read(cid, enum, lnum); _read(_entry(cid, enum, lnum)); end

#entry_write(cid, enum, lnum, item) ⇒ Object

Write an entry

Parameters:

  • cid (String)

    caseid

  • enum (Integer)

    Entry number

  • lnum (Integer)

    Log number

  • item (String)

    the JSON encoded item



89
90
91
# File 'lib/icfs/store.rb', line 89

def entry_write(cid, enum, lnum, item)
  _write(_entry(cid, enum, lnum), item)
end

#file_read(cid, enum, lnum, fnum) ⇒ File, Tempfile

Read a file

Parameters:

  • cid (String)

    caseid

  • enum (Integer)

    Entry number

  • lnum (Integer)

    Log number

  • fnum (Integer)

    File number

Returns:

  • (File, Tempfile)

    Read only copy of the file

Raises:

  • (NotImplementedError)


103
# File 'lib/icfs/store.rb', line 103

def file_read(cid, enum, lnum, fnum); raise NotImplementedError; end

#file_size(cid, enum, lnum, fnum) ⇒ Integer

Get a file size

Parameters:

  • cid (String)

    caseid

  • enum (Integer)

    Entry number

  • lnum (Integer)

    Log number

  • fnum (Integer)

    File number

Returns:

  • (Integer)

    The size of the file

Raises:

  • (NotImplementedError)


127
# File 'lib/icfs/store.rb', line 127

def file_size(cid, enum, lnum, fnum); raise NotImplementedError; end

#file_write(cid, enum, lnum, fnum, tmpf) ⇒ Object

Write a file

Parameters:

  • cid (String)

    caseid

  • enum (Integer)

    Entry number

  • lnum (Integer)

    Log number

  • fnum (Integer)

    File number

  • tmpf (Tempfile)

    A Tempfile obtained from #tempfile

Raises:

  • (NotImplementedError)


115
# File 'lib/icfs/store.rb', line 115

def file_write(cid, enum, lnum, fnum, tmpf); raise NotImplementedError; end

#index_read(cid, xnum, lnum) ⇒ String

Read an Index

Parameters:

  • cid (String)

    caseid

  • xnum (Integer)

    Index number

  • lnum (Integer)

    Log number

Returns:

  • (String)

    the JSON encoded item



164
165
166
# File 'lib/icfs/store.rb', line 164

def index_read(cid, xnum, lnum)
  _read(_index(cid, xnum, lnum))
end

#index_write(cid, xnum, lnum, item) ⇒ Object

Write an Index

Parameters:

  • cid (String)

    caseid

  • xnum (Integer)

    Index number

  • lnum (Integer)

    Log number

  • item (String)

    the JSON encoded item



177
178
179
# File 'lib/icfs/store.rb', line 177

def index_write(cid, xnum, lnum, item)
  _write(_index(cid, xnum, lnum), item)
end

#log_read(cid, lnum) ⇒ String

Read a log

Parameters:

  • cid (String)

    caseid

  • lnum (Integer)

    Log number

Returns:

  • (String)

    The JSON encoded item



57
# File 'lib/icfs/store.rb', line 57

def log_read(cid, lnum); _read(_log(cid, lnum)); end

#log_write(cid, lnum, item) ⇒ Object

Write a log

Parameters:

  • cid (String)

    caseid

  • lnum (Integer)

    Log number

  • item (String)

    the JSON encoded item



67
# File 'lib/icfs/store.rb', line 67

def log_write(cid, lnum, item); _write(_log(cid, lnum), item); end

#tempfileTempfile

Get a Tempfile to use to write files

Returns:

  • (Tempfile)

    a Tempfile which can be written and passed to #file_write

Raises:

  • (NotImplementedError)


188
# File 'lib/icfs/store.rb', line 188

def tempfile; raise NotImplementedError; end