icfs 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/icfs/items.rb CHANGED
@@ -499,9 +499,10 @@ module Items
499
499
  'template' => Validate::IsBoolean,
500
500
  'status' => Validate::IsBoolean,
501
501
  'title' => FieldTitle,
502
- 'access' => SubAccess
502
+ 'access' => SubAccess,
503
503
  }.freeze,
504
504
  optional: {
505
+ 'caseid' => FieldCaseid,
505
506
  'tags' => SubTags,
506
507
  'stats' => SubCaseStats,
507
508
  }.freeze
@@ -512,11 +513,11 @@ module Items
512
513
  ItemEntryNew = {
513
514
  method: :hash,
514
515
  required: {
515
- 'caseid' => FieldCaseid,
516
516
  'title' => FieldTitle,
517
517
  'content' => FieldContent,
518
518
  }.freeze,
519
519
  optional: {
520
+ 'caseid' => FieldCaseid,
520
521
  'time' => Validate::IsIntPos,
521
522
  'tags' => SubTagsNormal,
522
523
  'index' => SubIndexes,
@@ -536,11 +537,11 @@ module Items
536
537
  ItemEntryEdit = {
537
538
  method: :hash,
538
539
  required: {
539
- 'caseid' => FieldCaseid,
540
540
  'title' => FieldTitle,
541
541
  'content' => FieldContent,
542
542
  }.freeze,
543
543
  optional: {
544
+ 'caseid' => FieldCaseid,
544
545
  'entry' => Validate::IsIntPos,
545
546
  'time' => Validate::IsIntPos,
546
547
  'tags' => SubTagsEntry,
@@ -567,6 +568,7 @@ module Items
567
568
  'tasks' => SubTasksEdit
568
569
  }.freeze,
569
570
  optional: {
571
+ 'caseid' => FieldCaseid,
570
572
  'action' => Validate::IsIntPos
571
573
  }.freeze
572
574
  }.freeze
@@ -580,6 +582,7 @@ module Items
580
582
  'content' => FieldContent,
581
583
  }.freeze,
582
584
  optional: {
585
+ 'caseid' => FieldCaseid,
583
586
  'index' => Validate::IsIntPos,
584
587
  'tags' => SubTags,
585
588
  }.freeze
@@ -605,6 +608,7 @@ module Items
605
608
  }.freeze,
606
609
  optional: {
607
610
  'stats' => SubCaseStats,
611
+ 'entry' => Validate::IsIntPos,
608
612
  }.freeze,
609
613
  }.freeze
610
614
 
@@ -619,12 +623,18 @@ module Items
619
623
  'prev' => FieldHash,
620
624
  'time' => Validate::IsIntPos,
621
625
  'user' => FieldUsergrp,
622
- 'entry' => SubLogItem,
623
626
  }.freeze,
624
627
  optional: {
628
+ 'entry' => SubLogItem,
625
629
  'index' => SubLogItem,
626
630
  'action' => SubLogItem,
627
- 'case_hash' => FieldHash,
631
+ 'case' => {
632
+ method: :hash,
633
+ required: {
634
+ 'set' => Validate::IsBoolean,
635
+ 'hash' => FieldHash,
636
+ }.freeze,
637
+ }.freeze,
628
638
  'files_hash' => {
629
639
  method: :array,
630
640
  min: 1,
@@ -677,6 +687,9 @@ module Items
677
687
  'action' => Validate::IsIntPos,
678
688
  'log' => Validate::IsIntPos,
679
689
  'tasks' => SubTasks
690
+ }.freeze,
691
+ optional: {
692
+ 'entry' => Validate::IsIntPos,
680
693
  }.freeze
681
694
  }.freeze
682
695
 
@@ -693,6 +706,9 @@ module Items
693
706
  'content' => FieldContent,
694
707
  'tags' => SubTags
695
708
  }.freeze,
709
+ optional: {
710
+ 'entry' => Validate::IsIntPos,
711
+ }.freeze
696
712
  }.freeze
697
713
 
698
714
 
@@ -111,13 +111,15 @@ class Backup
111
111
  end
112
112
 
113
113
  # entry
114
- enum = log['entry']['num']
115
- _copy_item(dest,
116
- 'entry %d-%d' % [enum, lnum],
117
- :entry_read,
118
- :entry_write,
119
- [cid, enum, lnum]
120
- )
114
+ if log['entry']
115
+ enum = log['entry']['num']
116
+ _copy_item(dest,
117
+ 'entry %d-%d' % [enum, lnum],
118
+ :entry_read,
119
+ :entry_write,
120
+ [cid, enum, lnum]
121
+ )
122
+ end
121
123
 
122
124
  # index
123
125
  if log['index']
@@ -142,7 +144,7 @@ class Backup
142
144
  end
143
145
 
144
146
  # case
145
- if log['case_hash']
147
+ if log['case']
146
148
  _copy_item(dest,
147
149
  'case %d' % lnum,
148
150
  :case_read,
@@ -280,15 +282,17 @@ class Backup
280
282
  end
281
283
 
282
284
  # entry
283
- enum = log['entry']['num']
284
- _restore_item(src,
285
- 'entry %d-%d' % [enum, lnum],
286
- :entry_read,
287
- :entry_write,
288
- [cid, enum, lnum],
289
- [cid, enum]
290
- )
291
- emax = enum if enum > emax
285
+ if log['entry']
286
+ enum = log['entry']['num']
287
+ _restore_item(src,
288
+ 'entry %d-%d' % [enum, lnum],
289
+ :entry_read,
290
+ :entry_write,
291
+ [cid, enum, lnum],
292
+ [cid, enum]
293
+ )
294
+ emax = enum if enum > emax
295
+ end
292
296
 
293
297
  # index
294
298
  if log['index']
@@ -317,7 +321,7 @@ class Backup
317
321
  end
318
322
 
319
323
  # case
320
- if log['case_hash']
324
+ if log['case']
321
325
  _restore_item(src,
322
326
  'case %d' % lnum,
323
327
  :case_read,
@@ -138,27 +138,29 @@ class Check
138
138
  end
139
139
 
140
140
  # entry
141
- enum = log['entry']['num']
142
- ent = _item(
143
- 'entry %d-%d' % [enum, lnum],
144
- :entry_read,
145
- [cid, enum, lnum],
146
- ent_cur.include?(enum),
147
- log['entry']['hash'],
148
- Items::ItemEntry,
149
- [
150
- ['caseid', 0].freeze,
151
- ['entry', 1].freeze,
152
- ['log', 2].freeze
153
- ].freeze,
154
- )
141
+ if log['entry']
142
+ enum = log['entry']['num']
143
+ ent = _item(
144
+ 'entry %d-%d' % [enum, lnum],
145
+ :entry_read,
146
+ [cid, enum, lnum],
147
+ ent_cur.include?(enum),
148
+ log['entry']['hash'],
149
+ Items::ItemEntry,
150
+ [
151
+ ['caseid', 0].freeze,
152
+ ['entry', 1].freeze,
153
+ ['log', 2].freeze
154
+ ].freeze,
155
+ )
155
156
 
156
- # current entry
157
- unless ent_cur.include?(enum)
158
- ent_cur.add(enum)
159
- if ent['files']
160
- ent['files'].each do |fd|
161
- file_cur.add( '%d-%d-%d' % [enum, fd['num'], fd['log']] )
157
+ # current entry
158
+ unless ent_cur.include?(enum)
159
+ ent_cur.add(enum)
160
+ if ent['files']
161
+ ent['files'].each do |fd|
162
+ file_cur.add( '%d-%d-%d' % [enum, fd['num'], fd['log']] )
163
+ end
162
164
  end
163
165
  end
164
166
  end
@@ -202,13 +204,13 @@ class Check
202
204
  end
203
205
 
204
206
  # case
205
- if log['case_hash']
207
+ if log['case']
206
208
  cse = _item(
207
209
  'case %d' % lnum,
208
210
  :case_read,
209
211
  [cid, lnum],
210
212
  cse_cur,
211
- log['case_hash'],
213
+ log['case']['hash'],
212
214
  Items::ItemCase,
213
215
  [
214
216
  ['caseid', 0].freeze,