module ICFS::Items

Items

Constants

FieldCaseid

Caseid

FieldContent

Content

FieldFilename

a filename

FieldHash

a hash

FieldIcfs

ICFS version

FieldPermAny

Any perm

FieldPermCase

A case perm

FieldPermGlobal

A global permission curly brackets, no control characters

FieldPermNormal

a normal perm name No control characters may not start with square brackets, curly brackets, or whitespace

FieldPermReserve

A reserved case name square brackets

FieldStat

a stat name

FieldTag

Tag No control characters may not start with brackets or whitespace

FieldTagAny

Any tag, including empty

FieldTagEntry

Tag for Entry

FieldTagSpecial

Special tags

FieldTitle

Title

FieldUsergrp

a user/group name No control characters no space, no punctuation except , - : _

ItemAction

Action

ItemActionEdit

Action - Edit or New

ItemCase

Case

ItemCaseEdit

Case - Edit

ItemCurrent

Current

ItemEntry

Entry

ItemEntryEdit

Entry - Edit or New

ItemEntryNew

Entry - New only

ItemIndex

Index

ItemIndexEdit

Index - Edit or New

ItemLog

Log

SubAccess

Access

SubCaseStats

Case stats

SubFileNew

A new file

SubFileOld

An old file

SubGrant

Grant

SubIndexes

Indexes

SubLogItem

An item in a log

SubPerms

Perms

SubStats

Stats

SubTags

Tags

SubTagsEmpty

Empty Tags

SubTagsEntry

Entry Tags

SubTagsNormal

Tags

SubTaskCase

Case task

SubTaskEditCase

Case task

SubTaskEditNormal

Normal task

SubTaskNormal

Normal task

SubTasks

Tasks

SubTasksEdit

TasksEdit

Public Class Methods

generate(itm, name, val) click to toggle source

Validate and generate JSON

@param itm [Object] item to validate @param name [String] description of the item @param val [Hash] the check to use @return [String] JSON encoded item

@raise [Error::Value] if validation fails

# File lib/icfs/items.rb, line 61
def self.generate(itm, name, val)
  Items.validate(itm, name, val)
  return JSON.pretty_generate(itm)
end
parse(json, name, val) click to toggle source

Parse JSON string and validate

@param json [String] the JSON to parse @param name [String] description of the item @param val [Hash] the check to use @return [Object] the item

@raise [Error::NotFound] if json is nil @raise [Error::Value] if parsing or validation fails

# File lib/icfs/items.rb, line 37
def self.parse(json, name, val)
  if json.nil?
    raise(Error::NotFound, '%s not found' % name)
  end
  begin
    itm = JSON.parse(json)
  rescue
    raise(Error::Value, 'JSON parsing failed')
  end
  Items.validate(itm, name, val)
  return itm
end
validate(obj, name, val) click to toggle source

Validate an object

@param obj [Object] object to validate @param name [String] description of the object @param val [Hash] the check to use

@raise [Error::Value] if validation fails

# File lib/icfs/items.rb, line 76
def self.validate(obj, name, val)
  err = Validate.check(obj, val)
  if err
    raise(Error::Value, '%s has bad values: %s' %
      [name, err.inspect])
  end
end