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



140
141
142
# 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) ⇒ Object

Write an action

Parameters:

  • cid (String)

    caseid

  • anum (Integer)

    Action number

  • lnum (Integer)

    Log number

  • item (String)

    the JSON encoded item



153
154
155
# 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) ⇒ String

Read a case

Parameters:

  • cid (String)

    caseid

  • lnum (Integer)

    Log number

Returns:

  • (String)

    The JSON encoded item



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

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



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

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



198
199
200
201
202
203
204
# 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) ⇒ String

Read an entry

Parameters:

  • cid (String)

    caseid

  • enum (Integer)

    Entry number

  • lnum (Integer)

    Log number

Returns:

  • (String)

    The JSON encoded item



80
# 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) ⇒ Object

Write an entry

Parameters:

  • cid (String)

    caseid

  • enum (Integer)

    Entry number

  • lnum (Integer)

    Log number

  • item (String)

    the JSON encoded item



91
92
93
# 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) ⇒ 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)


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

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)


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

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)


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

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



166
167
168
# 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) ⇒ Object

Write an Index

Parameters:

  • cid (String)

    caseid

  • xnum (Integer)

    Index number

  • lnum (Integer)

    Log number

  • item (String)

    the JSON encoded item



179
180
181
# 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) ⇒ String

Read a log

Parameters:

  • cid (String)

    caseid

  • lnum (Integer)

    Log number

Returns:

  • (String)

    The JSON encoded item



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

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



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

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)


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

def tempfile; raise NotImplementedError; end