Module: ICFS
- Defined in:
- lib/icfs.rb,
lib/icfs/api.rb,
lib/icfs/cache.rb,
lib/icfs/items.rb,
lib/icfs/store.rb,
lib/icfs/users.rb,
lib/icfs/config.rb,
lib/icfs/elastic.rb,
lib/icfs/store_fs.rb,
lib/icfs/store_s3.rb,
lib/icfs/users_fs.rb,
lib/icfs/users_s3.rb,
lib/icfs/validate.rb,
lib/icfs/config_s3.rb,
lib/icfs/demo/auth.rb,
lib/icfs/email/core.rb,
lib/icfs/email/from.rb,
lib/icfs/email/imap.rb,
lib/icfs/web/client.rb,
lib/icfs/demo/static.rb,
lib/icfs/email/basic.rb,
lib/icfs/email/smime.rb,
lib/icfs/users_redis.rb,
lib/icfs/utils/check.rb,
lib/icfs/config_redis.rb,
lib/icfs/utils/backup.rb,
lib/icfs/web/auth_ssl.rb,
lib/icfs/cache_elastic.rb
Overview
Investigative Case File System
Defined Under Namespace
Modules: Demo, Elastic, Email, Error, Items, Utils, Validate, Web Classes: Api, Cache, CacheElastic, Config, ConfigRedis, ConfigS3, Store, StoreFs, StoreS3, Users, UsersFs, UsersRedis, UsersS3
Constant Summary collapse
- Version =
version: major, minor, patch
[0, 2, 0].freeze
- VersionPre =
version pre-release
nil- VersionString =
version string
( '%d.%d.%d' % Version + (VersionPre ? ('-' + VersionPre) : '') ).freeze
- TagNone =
no tags
'[none]'- TagAction =
edits an action
'[action]'- TagIndex =
edits an index
'[index]'- TagCase =
edits the case
'[case]'- PermRead =
permission to read case
'[read]'- PermWrite =
permission to write case
'[write]'- PermManage =
permission to manage case
'[manage]'- PermAction =
permission to manage actions
'[action]'- PermSearch =
global permission to search
'{[search]}'- UserCase =
user group
'[case]'- TimeDelta =
A time delta spec
/^[[:space:]]*([Nn][Oo][Ww])?[[:space:]]*([+\-])[[:space:]]*(\d+)[[:space:]]*([^[space]]+)[[:space]]*$/.freeze
- TimeRel =
a relative spec
/^[[:space:]]*([Nn][Ee][Xx][Tt]|[Pp][Rr][Ee][Vv]|[Ll][Aa][Ss][Tt])[[:space:]]+([^[:space:]]+)[[:space:]]*$/.freeze
- TimeFuture =
future time spec
/^[[:space:]]*[Ii][Nn][[:space:]]+(\d+)[[:space:]]*([^[space]]+)[[:space]]*$/.freeze
- TimeHistory =
historic time spec
/^[[:space:]]*(\d+)[[:space:]]*([^[:space:]]+)[[:space:]]*[Aa][Gg][Oo][[:space:]]*$/.freeze
- TimeEmpty =
empty time spec
/^[[:space:]]*([Nn][Oo][Ww])?[[:space:]]*$/.freeze
- TimeZone =
A timezone spec
/[+\-]\d{2}:\d{2}[[:space:]]*$/.freeze
Class Method Summary collapse
-
._time_adjust(num, type) ⇒ Object
private
Adjust the time.
-
._time_type(str) ⇒ Object
private
Pull a time type.
-
.hash(str) ⇒ Object
Hash a string.
-
.hash_temp(tf) ⇒ Object
Hash a tempfile.
-
.time_parse(str, cfg) ⇒ Object
Parse a time string.
Class Method Details
._time_adjust(num, type) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Adjust the time
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/icfs.rb', line 116 def self._time_adjust(num, type) case type when :year ary = Time.now.utc.to_a dte = Date.new(ary[5], ary[4], ary[3]) dte = dte << (-12 * num) return Time.utc(dte.year, dte.month, dte.day, ary[2], ary[1], ary[0]).to_i when :month ary = Time.now.utc.to_a dte = Date.new(ary[5], ary[4], ary[3]) dte = dte << (-1 * num) return Time.utc(dte.year, dte.month, dte.day, ary[2], ary[1], ary[0]).to_i when :week return (Time.now + num * 7*24*60*60).to_i when :day return (Time.now + num * 24*60*60).to_i when :hour return (Time.now + num * 60*60).to_i when :minute return (Time.now + num * 60).to_i when :second return (Time.now + num).to_i else return nil end end |
._time_type(str) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Pull a time type
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/icfs.rb', line 89 def self._time_type(str) case str.downcase when 'y', 'yr', 'yrs', 'year', 'years' return :year when 'm', 'mon', 'mons', 'month', 'months' return :month when 'w', 'wk', 'wks', 'week', 'weeks' return :week when 'd', 'day', 'days' return :day when 'h', 'hr', 'hrs', 'hour', 'hours' return :hour when 'min', 'mins', 'minute', 'minutes' return :minute when 's', 'sec', 'secs', 'second', 'seconds' return :second else return nil end end |
.hash(str) ⇒ Object
Hash a string
71 72 73 |
# File 'lib/icfs.rb', line 71 def self.hash(str) Digest::SHA256.hexdigest(str) end |
.hash_temp(tf) ⇒ Object
Hash a tempfile
79 80 81 |
# File 'lib/icfs.rb', line 79 def self.hash_temp(tf) Digest::SHA256.file(tf.path).hexdigest end |
.time_parse(str, cfg) ⇒ Object
Parse a time string
Handles:
-
blank or now
-
[now] +\- <num> <type>
-
next\prev <type>
-
in <num> <type>
-
<num> <type> ago
-
a specifc parseable time
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/icfs.rb', line 190 def self.time_parse(str, cfg) return nil if( !str || !str.is_a?(String) ) # empty if ma = TimeEmpty.match(str) return Time.now.to_i # delta elsif ma = TimeDelta.match(str) num = ma[3].to_i num = num * -1 if ma[2] == '-' type = ICFS._time_type(ma[4]) return ICFS._time_adjust(num, type) # relative elsif ma = TimeRel.match(str) num = (ma[1].downcase == 'next') ? 1 : -1 type = ICFS._time_type(ma[2]) return ICFS._time_adjust(num, type) # future elsif ma = TimeFuture.match(str) num = ma[1].to_i type = ICFS._time_type(ma[2]) return ICFS._time_adjust(num, type) # history elsif ma = TimeHistory.match(str) p ma num = -1 * ma[1].to_i type = ICFS._time_type(ma[2]) return ICFS._time_adjust(num, type) # parse a time spec else ma = TimeZone.match(str) tstr = ma ? str : str + cfg.get('tz') return Time.parse(tstr).to_i end rescue ArgumentError return nil end |