doing 2.1.24 → 2.1.25

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.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/.yardoc/checksums +11 -10
  3. data/.yardoc/object_types +0 -0
  4. data/.yardoc/objects/root.dat +0 -0
  5. data/CHANGELOG.md +17 -0
  6. data/Gemfile.lock +1 -1
  7. data/README.md +1 -1
  8. data/Rakefile +2 -1
  9. data/bin/doing +81 -37
  10. data/docs/doc/Array.html +70 -7
  11. data/docs/doc/BooleanTermParser/Clause.html +5 -5
  12. data/docs/doc/BooleanTermParser/Operator.html +4 -4
  13. data/docs/doc/BooleanTermParser/Query.html +8 -8
  14. data/docs/doc/BooleanTermParser/QueryParser.html +2 -2
  15. data/docs/doc/BooleanTermParser/QueryTransformer.html +2 -2
  16. data/docs/doc/BooleanTermParser.html +1 -1
  17. data/docs/doc/Doing/Color.html +4 -4
  18. data/docs/doc/Doing/Completion.html +2 -2
  19. data/docs/doc/Doing/Configuration.html +14 -16
  20. data/docs/doc/Doing/Errors/DoingNoTraceError.html +2 -2
  21. data/docs/doc/Doing/Errors/DoingRuntimeError.html +2 -2
  22. data/docs/doc/Doing/Errors/DoingStandardError.html +2 -2
  23. data/docs/doc/Doing/Errors/EmptyInput.html +2 -2
  24. data/docs/doc/Doing/Errors/NoResults.html +2 -2
  25. data/docs/doc/Doing/Errors/PluginException.html +3 -3
  26. data/docs/doc/Doing/Errors/UserCancelled.html +2 -2
  27. data/docs/doc/Doing/Errors/WrongCommand.html +2 -2
  28. data/docs/doc/Doing/Errors.html +1 -1
  29. data/docs/doc/Doing/Hooks.html +6 -6
  30. data/docs/doc/Doing/Item.html +50 -16
  31. data/docs/doc/Doing/Items.html +10 -10
  32. data/docs/doc/Doing/LogAdapter.html +24 -24
  33. data/docs/doc/Doing/Note.html +7 -7
  34. data/docs/doc/Doing/Pager.html +4 -4
  35. data/docs/doc/Doing/Plugins.html +7 -7
  36. data/docs/doc/Doing/Prompt.html +14 -14
  37. data/docs/doc/Doing/Section.html +6 -6
  38. data/docs/doc/Doing/TemplateString.html +8 -8
  39. data/docs/doc/Doing/Types.html +6 -1
  40. data/docs/doc/Doing/Util/Backup.html +10 -10
  41. data/docs/doc/Doing/Util.html +15 -15
  42. data/docs/doc/Doing/WWID.html +65 -53
  43. data/docs/doc/Doing.html +3 -3
  44. data/docs/doc/GLI/Commands/Help.html +3 -3
  45. data/docs/doc/GLI/Commands/MarkdownDocumentListener.html +17 -17
  46. data/docs/doc/GLI/Commands.html +1 -1
  47. data/docs/doc/GLI.html +1 -1
  48. data/docs/doc/Hash.html +45 -11
  49. data/docs/doc/Numeric.html +5 -5
  50. data/docs/doc/PhraseParser/Operator.html +4 -4
  51. data/docs/doc/PhraseParser/PhraseClause.html +5 -5
  52. data/docs/doc/PhraseParser/Query.html +10 -10
  53. data/docs/doc/PhraseParser/QueryParser.html +2 -2
  54. data/docs/doc/PhraseParser/QueryTransformer.html +2 -2
  55. data/docs/doc/PhraseParser/TermClause.html +5 -5
  56. data/docs/doc/PhraseParser.html +1 -1
  57. data/docs/doc/Status.html +7 -7
  58. data/docs/doc/String.html +107 -44
  59. data/docs/doc/Symbol.html +8 -8
  60. data/docs/doc/Time.html +6 -6
  61. data/docs/doc/_index.html +41 -18
  62. data/docs/doc/class_list.html +1 -1
  63. data/docs/doc/file.README.html +2 -2
  64. data/docs/doc/index.html +2 -2
  65. data/docs/doc/method_list.html +369 -313
  66. data/docs/doc/top-level-namespace.html +2 -2
  67. data/doing.rdoc +19 -11
  68. data/example_plugin.rb +2 -2
  69. data/lib/completion/_doing.zsh +12 -12
  70. data/lib/completion/doing.bash +2 -2
  71. data/lib/completion/doing.fish +9 -8
  72. data/lib/doing/changelog/changes.rb +1 -1
  73. data/lib/doing/configuration.rb +4 -6
  74. data/lib/doing/good.rb +64 -0
  75. data/lib/doing/hash.rb +4 -0
  76. data/lib/doing/hooks.rb +3 -3
  77. data/lib/doing/item.rb +14 -10
  78. data/lib/doing/plugins/import/calendar_import.rb +1 -1
  79. data/lib/doing/plugins/import/doing_import.rb +1 -1
  80. data/lib/doing/plugins/import/timing_import.rb +1 -1
  81. data/lib/doing/string.rb +1 -1
  82. data/lib/doing/template_string.rb +2 -2
  83. data/lib/doing/types.rb +1 -0
  84. data/lib/doing/util.rb +10 -10
  85. data/lib/doing/version.rb +1 -1
  86. data/lib/doing/wwid.rb +40 -18
  87. data/lib/doing.rb +1 -0
  88. data/lib/helpers/threaded_tests.rb +35 -64
  89. data/lib/helpers/threaded_tests_string.rb +50 -0
  90. metadata +4 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19f61c0a50ba9d72b2513bfa7c12e90a0b7d1dc63d0f478b7530a1a5be603418
4
- data.tar.gz: 2239357f17bc9ac71e85447062bafae9e1e7e176fb8dfe41370f5ff621b400d0
3
+ metadata.gz: 1210e69ba2e32a9e2c91d5e98c203f062c6b439bb37be2e675a8078a2ca34927
4
+ data.tar.gz: 95b84f63985564c18f4c352fdeb1dfc3ae02b1f78417159d83d354d87ab8df51
5
5
  SHA512:
6
- metadata.gz: 474677211983ca71287f1eef0bfe1de455e97f5123a4947ec5b533fd3148d0e21a27697337748ef1a3e20a422de0e0d0db3da9d243943ce37340be2375ea7e8f
7
- data.tar.gz: 69f35f030a2b761e26ba9b81668c6f03abcd8f6e45400f07ddca4bc8c632cfdb4cc9f6b974837327dd0073f38aaf40cc349632200586832c4894314e5e434856
6
+ metadata.gz: 2b3a4fae4e4b530809b4d580e258dbd1e7d9382bec476725af3e8c551188bb85c071859db50d7c4686ab8c5208332850276c40c0411592546e43718ec07c1d56
7
+ data.tar.gz: 9808b2d41cd54c0a7ce52c714cf8111ad3cc81bbd1332acad49979f0ab9785b817911eb3bf9ca889a90fbd5ec9960974234611ce05fe96f35eb8f83479510588
data/.yardoc/checksums CHANGED
@@ -1,32 +1,33 @@
1
- lib/doing/hash.rb 48b7ed855f33b2f10b4be41b09cee1efcb855b4b
2
- lib/doing/item.rb b508a3da515f86981b30d61083e0dbb8549f894c
1
+ lib/doing/good.rb de4a18a87ac6d316037750944f91f0a3739adafc
2
+ lib/doing/hash.rb 321c27f54f332260c6adced7e451016b79574d38
3
+ lib/doing/item.rb 8aec1775784e73fd7181efca4482dac94d466619
3
4
  lib/doing/note.rb bbadd9e34e6dc43a2af1110a5107f46c39d2547f
4
5
  lib/doing/time.rb 60183c3c31532ffea1440c766de0f90042e0fd10
5
- lib/doing/util.rb 170f0eb8ac4cb0f47d517eb6a87f94850b7f1f41
6
- lib/doing/wwid.rb 0c879394cb2ae617bda567b00dab17ff0b3c8254
6
+ lib/doing/util.rb 183577d0d9dee966dcf65645b312b17b958e46d6
7
+ lib/doing/wwid.rb 1410410c6072cc330baedea27e30a371ec7d3136
7
8
  lib/doing/array.rb b50c4604cb685dff87bc16bc20f21a5956b2b396
8
- lib/doing/hooks.rb 9ffc1f719b06b18d64e548f52f7d2eaf6c21b06a
9
+ lib/doing/hooks.rb 1b75ca731f9e8cb0b7a32785d6e496ee67a70d5c
9
10
  lib/doing/items.rb 69c762d337d9dad2b780cd08cc1c8785310e23ba
10
11
  lib/doing/pager.rb a5dc55e1163d1b8476617e924a3aee4f9bf8be00
11
- lib/doing/types.rb eed3ee1071ffa4a2f9caf50beb7523a24146cd1d
12
+ lib/doing/types.rb df05c1282d5f6b8efda68c6f289499683a5cc7d1
12
13
  lib/doing/colors.rb b7239a69e10c5df9378a5843441af5b93c1872f8
13
14
  lib/doing/errors.rb af07e482a5389924edc2337749c81cda501098f0
14
15
  lib/doing/prompt.rb d241935b209e69a14c55a9c3a035f1751c576b4c
15
- lib/doing/string.rb 443e238f1c4e205a61734b4be3d22f41388e9713
16
+ lib/doing/string.rb 32fd00cfdfb01a664e194e70ffcad199cd217741
16
17
  lib/doing/symbol.rb 309799458a1bc715c2707307c9a62ab26086275e
17
18
  lib/doing/section.rb 206e119cf818f1e76798753e611180fe77bc299a
18
- lib/doing/version.rb 7a231babfa24987f2616244664899d7e39d293ea
19
+ lib/doing/version.rb 7ee8c2f346a5dc0402119b87bb46593f3e368254
19
20
  lib/doing/changelog.rb f7d1bd424e63400ab0613ef3358e614fdf53e2b5
20
21
  lib/doing/cli_status.rb dbedd454c4cbbd0fed9ef30120f6ec85d18b9356
21
22
  lib/doing/completion.rb c658e7dc7898fb022a21b2bd77bedb958ca3b067
22
23
  lib/doing/log_adapter.rb 62ee66981878bd7285ccf0dfeca90a3d6d2af985
23
24
  lib/doing/util_backup.rb c13f71072581b1f0d2269853611ba09273261bf9
24
- lib/doing/configuration.rb 26c86add1bf9ab00bec24ba0c01774b5617fe2d9
25
+ lib/doing/configuration.rb 390e07a32720bd6db576bf6ad909529a9228de8d
25
26
  lib/doing/phrase_parser.rb 8f1789d7cf8326d8cc231b4a21505a93f8de20d2
26
27
  lib/doing/array_chronify.rb b39b40268b1751b18acf6bae4e53885818e45f62
27
28
  lib/doing/plugin_manager.rb cb16a82c3182ef7008359670ab96ff6b39270ccc
28
29
  lib/doing/string_chronify.rb 888afa2175f3bb6cac0d68e3cb0f27cf162bb1bf
29
- lib/doing/template_string.rb 736f6e7645160f75061db1856a62101238fe8c56
30
+ lib/doing/template_string.rb 3b35970f2a68112192d2bb97c1298b90cf717b3d
30
31
  lib/doing/numeric_chronify.rb bedeff62a95f8a8ff116e1bf0cc1d9eb2707a900
31
32
  lib/doing/help_monkey_patch.rb 6aa514c249e519db507ae528de2604c18cc36045
32
33
  lib/doing/boolean_term_parser.rb 075977892ac5c6e3435cb8877d8b8b68eb1962e3
data/.yardoc/object_types CHANGED
Binary file
Binary file
data/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ ### 2.1.25
2
+
3
+ 2022-01-23 09:20
4
+
5
+ #### NEW
6
+
7
+ - `doing now --from 'TIME [to TIME]'` flag, sets start date and optionally adds dated @done tag.
8
+
9
+ #### IMPROVED
10
+
11
+ - :post_entry_updated hook now receives both the updated item (mutable) and a copy of the original item
12
+
13
+ #### FIXED
14
+
15
+ - Regex warning on Ruby 2.7
16
+ - :post_entry_added hook was receiving new items couldn't be modified
17
+
1
18
  ### 2.1.24
2
19
 
3
20
  2022-01-22 17:27
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- doing (2.1.24)
4
+ doing (2.1.25)
5
5
  chronic (~> 0.10, >= 0.10.2)
6
6
  deep_merge (~> 1.2, >= 1.2.1)
7
7
  gli (~> 2.20, >= 2.20.1)
data/README.md CHANGED
@@ -8,7 +8,7 @@ _If you're one of the rare people like me who find this useful, feel free to
8
8
 
9
9
  <!--README-->
10
10
 
11
- The current version of `doing` is <!--VER-->2.1.22<!--END VER-->.
11
+ The current version of `doing` is <!--VER-->2.1.24<!--END VER-->.
12
12
 
13
13
  Find all of the documentation in the [doing wiki][wiki].
14
14
 
data/Rakefile CHANGED
@@ -77,10 +77,11 @@ task :dockertest, :version, :login do |_, args|
77
77
  file = 'Dockerfile'
78
78
  end
79
79
 
80
- exec "docker run -it #{img} /bin/bash -l" if args[:login]
81
80
 
82
81
  puts `docker build . --file #{file} -t #{img}`
83
82
 
83
+ exec "docker run -it #{img} /bin/bash -l" if args[:login]
84
+
84
85
  spinner = TTY::Spinner.new('[:spinner] Running tests ...', hide_cursor: true)
85
86
 
86
87
  spinner.auto_spin
data/bin/doing CHANGED
@@ -69,7 +69,7 @@ end
69
69
 
70
70
  accept TemplateName do |value|
71
71
  res = settings['templates'].keys.select { |k| k =~ value.to_rx(distance: 2) }
72
- raise InvalidArgument, "Unknown template: #{value}" if res.empty?
72
+ raise InvalidArgument, "Unknown template: #{value}" unless res.good?
73
73
 
74
74
  res.group_by(&:length).min.last[0]
75
75
  end
@@ -104,6 +104,13 @@ accept DateRangeString do |value|
104
104
  [start, finish]
105
105
  end
106
106
 
107
+ accept DateRangeOptionalString do |value|
108
+ start, finish = value.split_date_range
109
+ raise InvalidTimeExpression, 'Invalid range' unless start
110
+
111
+ [start, finish]
112
+ end
113
+
107
114
  accept DateIntervalString do |value|
108
115
  res = value.chronify_qty
109
116
  raise InvalidTimeExpression, 'Invalid time quantity' unless res
@@ -253,7 +260,7 @@ command %i[again resume] do |c|
253
260
 
254
261
  options[:note] = note
255
262
 
256
- opts = options.dup
263
+ opts = options.clone
257
264
 
258
265
  opts[:tag] = tags
259
266
  opts[:tag_bool] = options[:bool].normalize_bool
@@ -504,7 +511,7 @@ command %i[done did] do |c|
504
511
  raise NoResults, 'No results'
505
512
  end
506
513
 
507
- old_entry = last_entry.dup
514
+ old_entry = last_entry.clone
508
515
  last_entry.note.add(note)
509
516
  input = ["#{last_entry.date.strftime('%F %R | ')}#{last_entry.title}", last_entry.note.strip_lines.join("\n")].join("\n")
510
517
  else
@@ -513,13 +520,13 @@ command %i[done did] do |c|
513
520
  end
514
521
 
515
522
  input = wwid.fork_editor(input).strip
516
- raise EmptyInput, 'No content' unless input && !input.empty?
523
+ raise EmptyInput, 'No content' unless input.good?
517
524
 
518
525
  d, title, note = wwid.format_input(input)
519
526
 
520
527
  if options[:ask]
521
528
  ask_note = Doing::Prompt.read_lines(prompt: 'Add a note')
522
- note.add(ask_note) unless ask_note.empty?
529
+ note.add(ask_note) if ask_note.good?
523
530
  end
524
531
 
525
532
  date = d.nil? ? date : d
@@ -535,15 +542,16 @@ command %i[done did] do |c|
535
542
  if (is_new)
536
543
  Doing::Hooks.trigger :pre_entry_add, wwid, new_entry
537
544
  wwid.content.push(new_entry)
538
- Doing::Hooks.trigger :post_entry_added, wwid, new_entry.dup
545
+ Doing::Hooks.trigger :post_entry_added, wwid, new_entry
539
546
  else
547
+ old = old_entry.clone
540
548
  wwid.content.update_item(old_entry, new_entry)
541
- Doing::Hooks.trigger :post_entry_updated, wwid, new_entry unless options[:archive]
549
+ Doing::Hooks.trigger :post_entry_updated, wwid, new_entry, old unless options[:archive]
542
550
  end
543
551
 
544
552
  if options[:archive]
545
553
  wwid.move_item(new_entry, 'Archive', label: true)
546
- Doing::Hooks.trigger :post_entry_updated, wwid, new_entry
554
+ Doing::Hooks.trigger :post_entry_updated, wwid, new_entry, old_entry
547
555
  end
548
556
 
549
557
  wwid.write(wwid.doing_file)
@@ -582,7 +590,7 @@ command %i[done did] do |c|
582
590
 
583
591
  Doing::Hooks.trigger :pre_entry_add, wwid, new_entry
584
592
  wwid.content.push(new_entry)
585
- Doing::Hooks.trigger :post_entry_added, wwid, new_entry.dup
593
+ Doing::Hooks.trigger :post_entry_added, wwid, new_entry
586
594
  wwid.write(wwid.doing_file)
587
595
  Doing.logger.info('New entry:', %(added "#{new_entry.date.relative_date}: #{new_entry.title}" to #{section}))
588
596
  elsif $stdin.stat.size.positive?
@@ -606,7 +614,7 @@ command %i[done did] do |c|
606
614
 
607
615
  Doing::Hooks.trigger :pre_entry_add, wwid, new_entry
608
616
  wwid.content.push(new_entry)
609
- Doing::Hooks.trigger :post_entry_added, wwid, new_entry.dup
617
+ Doing::Hooks.trigger :post_entry_added, wwid, new_entry
610
618
 
611
619
  wwid.write(wwid.doing_file)
612
620
  Doing.logger.info('New entry:', %(added "#{new_entry.date.relative_date}: #{new_entry.title}" to #{section}))
@@ -950,7 +958,7 @@ command :meanwhile do |c|
950
958
  input += date.strftime('%F %R | ')
951
959
  input += args.join(' ') unless args.empty?
952
960
  input += "\n#{options[:note]}" if options[:note]
953
- input += "\n#{ask_note}" unless ask_note.empty?
961
+ input += "\n#{ask_note}" unless ask_note.good?
954
962
 
955
963
  input = wwid.fork_editor(input).strip
956
964
  elsif !args.empty?
@@ -959,7 +967,7 @@ command :meanwhile do |c|
959
967
  input = $stdin.read.strip
960
968
  end
961
969
 
962
- if input && !input.empty?
970
+ if input.good?
963
971
  d, input, note = wwid.format_input(input)
964
972
  unless d.nil?
965
973
  Doing.logger.debug('Parser:', 'Date detected in input, overriding command line values')
@@ -972,7 +980,7 @@ command :meanwhile do |c|
972
980
 
973
981
  unless options[:editor]
974
982
  note.add(options[:note]) if options[:note]
975
- note.add(ask_note) unless ask_note.empty?
983
+ note.add(ask_note) if ask_note.good?
976
984
  end
977
985
 
978
986
  wwid.stop_start('meanwhile', { new_item: input, back: date, section: section, archive: options[:archive], note: note })
@@ -1058,6 +1066,7 @@ command :note do |c|
1058
1066
  end
1059
1067
 
1060
1068
  last_entry = wwid.last_entry(options)
1069
+ old_entry = last_entry.clone
1061
1070
 
1062
1071
  unless last_entry
1063
1072
  Doing.logger.warn('Not found:', 'No entry matching parameters was found.')
@@ -1091,19 +1100,19 @@ command :note do |c|
1091
1100
  end
1092
1101
 
1093
1102
  if (new_note.empty? && !options[:remove]) || options[:ask]
1094
- $stderr.puts last_note unless last_note.empty?
1095
- $stderr.puts new_note unless new_note.empty?
1103
+ $stderr.puts last_note if last_note.good?
1104
+ $stderr.puts new_note if new_note.good?
1096
1105
  new_note.add(Doing::Prompt.read_lines(prompt: 'Add a note'))
1097
1106
  end
1098
1107
 
1099
- raise EmptyInput, 'You must provide content when adding a note' unless options[:remove] || !new_note.empty?
1108
+ raise EmptyInput, 'You must provide content when adding a note' unless options[:remove] || new_note.good?
1100
1109
 
1101
1110
  if last_note.equal?(new_note)
1102
1111
  Doing.logger.debug('Skipped:', 'No note change')
1103
1112
  else
1104
1113
  last_note.add(new_note, replace: options[:remove])
1105
1114
  Doing.logger.info('Entry updated:', last_entry.title)
1106
- Doing::Hooks.trigger :post_entry_updated, wwid, last_entry
1115
+ Doing::Hooks.trigger :post_entry_updated, wwid, last_entry, old_entry
1107
1116
  end
1108
1117
  # new_entry = Doing::Item.new(last_entry.date, last_entry.title, last_entry.section, new_note)
1109
1118
  wwid.write(wwid.doing_file)
@@ -1139,6 +1148,13 @@ command %i[now next] do |c|
1139
1148
  c.arg_name 'DATE_STRING'
1140
1149
  c.flag %i[b back started], type: DateBeginString
1141
1150
 
1151
+ c.desc %(
1152
+ Set a start and optionally end time as a date range ("from 1pm to 2:30pm").
1153
+ If an end time is provided, a dated @done tag will be added
1154
+ )
1155
+ c.arg_name 'TIME_RANGE'
1156
+ c.flag [:from], type: DateRangeString
1157
+
1142
1158
  c.desc 'Timed entry, marks last entry in section as @done'
1143
1159
  c.switch %i[f finish_last], negatable: false, default_value: false
1144
1160
 
@@ -1154,13 +1170,17 @@ command %i[now next] do |c|
1154
1170
  # # c.flag [:a, :app]
1155
1171
 
1156
1172
  c.action do |_global_options, options, args|
1173
+ raise InvalidArgument, "--back and --from cannot be used together" if options[:back] && options[:from]
1174
+
1157
1175
  if options[:back]
1158
1176
  date = options[:back]
1159
-
1160
- raise InvalidTimeExpression.new('unable to parse date string', topic: 'Parser:') if date.nil?
1177
+ elsif options[:from]
1178
+ date, finish_date = options[:from]
1179
+ options[:done] = finish_date
1161
1180
  else
1162
1181
  date = Time.now
1163
1182
  end
1183
+ raise InvalidTimeExpression.new('unable to parse date string', topic: 'Parser:') if date.nil?
1164
1184
 
1165
1185
  if options[:section]
1166
1186
  section = wwid.guess_section(options[:section]) || options[:section].cap_first
@@ -1175,16 +1195,17 @@ command %i[now next] do |c|
1175
1195
 
1176
1196
  input = date.strftime('%F %R | ')
1177
1197
  input += args.join(' ') unless args.empty?
1198
+ input += " @done(#{options[:done].strftime('%F %R')})" if options[:done]
1178
1199
  input += "\n#{options[:note]}" if options[:note]
1179
- input += "\n#{ask_note}" unless ask_note.empty?
1200
+ input += "\n#{ask_note}" if ask_note.good?
1180
1201
  input = wwid.fork_editor(input).strip
1181
1202
 
1182
1203
  d, title, note = wwid.format_input(input)
1183
- raise EmptyInput, 'No content' if title.strip.empty?
1204
+ raise EmptyInput, 'No content' unless title.good?
1184
1205
 
1185
1206
  if ask_note.empty? && options[:ask]
1186
1207
  ask_note = Doing::Prompt.read_lines(prompt: 'Add a note')
1187
- note.add(ask_note) unless ask_note.empty?
1208
+ note.add(ask_note) if ask_note.good?
1188
1209
  end
1189
1210
 
1190
1211
  date = d.nil? ? date : d
@@ -1194,8 +1215,15 @@ command %i[now next] do |c|
1194
1215
  d, title, note = wwid.format_input(args.join(' '))
1195
1216
  date = d.nil? ? date : d
1196
1217
  note.add(options[:note]) if options[:note]
1197
- note.add(ask_note) unless ask_note.empty?
1198
- wwid.add_item(title.cap_first, section, { note: note, back: date, timed: options[:finish_last] })
1218
+ note.add(ask_note) if ask_note.good?
1219
+ entry = wwid.add_item(title.cap_first, section, { note: note, back: date, timed: options[:finish_last] })
1220
+ if options[:done] && entry.should_finish?
1221
+ if entry.should_time?
1222
+ entry.tag('done', value: options[:done])
1223
+ else
1224
+ entry.tag('done')
1225
+ end
1226
+ end
1199
1227
  wwid.write(wwid.doing_file)
1200
1228
  elsif $stdin.stat.size.positive?
1201
1229
  input = $stdin.read.strip
@@ -1207,15 +1235,22 @@ command %i[now next] do |c|
1207
1235
  note.add(options[:note]) if options[:note]
1208
1236
  if ask_note.empty? && options[:ask]
1209
1237
  ask_note = Doing::Prompt.read_lines(prompt: 'Add a note')
1210
- note.add(ask_note) unless ask_note.empty?
1238
+ note.add(ask_note) if ask_note.good?
1239
+ end
1240
+ entry = wwid.add_item(title.cap_first, section, { note: note, back: date, timed: options[:finish_last] })
1241
+ if options[:done] && entry.should_finish?
1242
+ if entry.should_time?
1243
+ entry.tag('done', value: options[:done])
1244
+ else
1245
+ entry.tag('done')
1246
+ end
1211
1247
  end
1212
- wwid.add_item(title.cap_first, section, { note: note, back: date, timed: options[:finish_last] })
1213
1248
  wwid.write(wwid.doing_file)
1214
1249
  else
1215
1250
  tags = wwid.all_tags(wwid.content)
1216
1251
  $stderr.puts Doing::Color.boldgreen("Add a new entry. Tab will autocomplete known tags. Ctrl-c to cancel.")
1217
1252
  title = Doing::Prompt.read_line(prompt: 'Entry content', completions: tags)
1218
- raise EmptyInput, 'You must provide content when creating a new entry' if title.strip.empty?
1253
+ raise EmptyInput, 'You must provide content when creating a new entry' unless title.good?
1219
1254
 
1220
1255
  note = Doing::Note.new
1221
1256
  note.add(options[:note]) if options[:note]
@@ -1223,7 +1258,14 @@ command %i[now next] do |c|
1223
1258
  ask_note = res ? Doing::Prompt.read_lines(prompt: 'Enter note') : []
1224
1259
  note.add(ask_note)
1225
1260
 
1226
- wwid.add_item(title.cap_first, section, { note: note, back: date, timed: options[:finish_last] })
1261
+ entry = wwid.add_item(title.cap_first, section, { note: note, back: date, timed: options[:finish_last] })
1262
+ if options[:done] && entry.should_finish?
1263
+ if entry.should_time?
1264
+ entry.tag('done', value: options[:done])
1265
+ else
1266
+ entry.tag('done')
1267
+ end
1268
+ end
1227
1269
  wwid.write(wwid.doing_file)
1228
1270
  end
1229
1271
  end
@@ -1326,8 +1368,10 @@ command %i[reset begin] do |c|
1326
1368
  return
1327
1369
  end
1328
1370
 
1371
+ old_item = last_entry.clone
1372
+
1329
1373
  wwid.reset_item(last_entry, date: reset_date, resume: options[:resume])
1330
- Doing::Hooks.trigger :post_entry_updated, wwid, last_entry
1374
+ Doing::Hooks.trigger :post_entry_updated, wwid, last_entry, old_item
1331
1375
  # new_entry = Doing::Item.new(last_entry.date, last_entry.title, last_entry.section, new_note)
1332
1376
 
1333
1377
  wwid.write(wwid.doing_file)
@@ -2156,7 +2200,7 @@ command :show do |c|
2156
2200
 
2157
2201
  options[:section] = section
2158
2202
 
2159
- unless tags.empty?
2203
+ if tags.good?
2160
2204
  tag_filter = {
2161
2205
  'tags' => tags,
2162
2206
  'bool' => options[:bool].normalize_bool
@@ -2175,7 +2219,7 @@ command :show do |c|
2175
2219
  # options[:bool] = :and unless tags.empty?
2176
2220
 
2177
2221
  tags = tag.split(/ +/).map { |t| t.strip.sub(/^@?/, '') } if tag =~ /^@/
2178
- unless tags.empty?
2222
+ if tags.good?
2179
2223
  tag_filter = {
2180
2224
  'tags' => tags,
2181
2225
  'bool' => options[:bool].normalize_bool
@@ -2186,7 +2230,7 @@ command :show do |c|
2186
2230
 
2187
2231
  options[:age] ||= :newest
2188
2232
 
2189
- opt = options.dup
2233
+ opt = options.clone
2190
2234
  opt[:age] = options[:age].normalize_age(:newest) if options[:age]
2191
2235
  opt[:sort_tags] = options[:tag_sort] =~ /^n/i
2192
2236
  opt[:count] = options[:count].to_i
@@ -2645,7 +2689,7 @@ command :view do |c|
2645
2689
  else
2646
2690
  options[:tag].gsub(/[, ]+/, ' ').split(' ').map(&:strip)
2647
2691
  end
2648
- elsif view.key?('tags') && !(view['tags'].nil? || view['tags'].empty?)
2692
+ elsif view.key?('tags') && view['tags'].good?
2649
2693
  tag_filter = { 'tags' => [], 'bool' => 'OR' }
2650
2694
  bool = view.key?('tags_bool') && !view['tags_bool'].nil? ? view['tags_bool'].normalize_bool : :pattern
2651
2695
  tag_filter['bool'] = bool
@@ -2703,7 +2747,7 @@ command :view do |c|
2703
2747
 
2704
2748
  options[:age] ||= :newest
2705
2749
 
2706
- opts = options.dup
2750
+ opts = options.clone
2707
2751
  opts[:age] = options[:age].normalize_age(:newest)
2708
2752
  opts[:count] = count
2709
2753
  opts[:format] = date_format
@@ -2798,7 +2842,7 @@ command :yesterday do |c|
2798
2842
  end.join(' to ').split_date_range
2799
2843
  end
2800
2844
 
2801
- opt = options.dup
2845
+ opt = options.clone
2802
2846
  opt[:tag_order] = options[:tag_order].normalize_order
2803
2847
  opt[:order] = settings.dig('templates', options[:config_template], 'order')
2804
2848
 
@@ -3090,7 +3134,7 @@ command :open do |c|
3090
3134
  end
3091
3135
 
3092
3136
  c.action do |_global_options, options, _args|
3093
- params = options.dup
3137
+ params = options.clone
3094
3138
  params.delete_if do |k, v|
3095
3139
  k.instance_of?(String) || v.nil? || v == false
3096
3140
  end
@@ -3242,7 +3286,7 @@ command %i[archive move] do |c|
3242
3286
  search.sub!(/^'?/, "'") if options[:exact]
3243
3287
  end
3244
3288
 
3245
- opts = options.dup
3289
+ opts = options.clone
3246
3290
  opts[:search] = search
3247
3291
  opts[:bool] = options[:bool].normalize_bool
3248
3292
  opts[:destination] = options[:to]
data/docs/doc/Array.html CHANGED
@@ -69,10 +69,10 @@
69
69
  <dl>
70
70
  <dt>Inherits:</dt>
71
71
  <dd>
72
- <span class="inheritName">Object</span>
72
+ <span class="inheritName"><span class='object_link'><a href="Object.html" title="Object (class)">Object</a></span></span>
73
73
 
74
74
  <ul class="fullTree">
75
- <li>Object</li>
75
+ <li><span class='object_link'><a href="Object.html" title="Object (class)">Object</a></span></li>
76
76
 
77
77
  <li class="next">Array</li>
78
78
 
@@ -95,7 +95,7 @@
95
95
  <dl>
96
96
  <dt>Defined in:</dt>
97
97
  <dd>lib/doing/array.rb<span class="defines">,<br />
98
- lib/doing/array_chronify.rb</span>
98
+ lib/doing/good.rb,<br /> lib/doing/array_chronify.rb</span>
99
99
  </dd>
100
100
  </dl>
101
101
 
@@ -133,6 +133,29 @@
133
133
  <li class="public ">
134
134
  <span class="summary_signature">
135
135
 
136
+ <a href="#good%3F-instance_method" title="#good? (instance method)">#<strong>good?</strong> &#x21d2; Boolean </a>
137
+
138
+
139
+
140
+ </span>
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+ <span class="summary_desc"><div class='inline'><p>Tests if object is nil or empty.</p>
151
+ </div></span>
152
+
153
+ </li>
154
+
155
+
156
+ <li class="public ">
157
+ <span class="summary_signature">
158
+
136
159
  <a href="#highlight_tags-instance_method" title="#highlight_tags (instance method)">#<strong>highlight_tags</strong>(color = &#39;cyan&#39;) &#x21d2; String </a>
137
160
 
138
161
 
@@ -300,7 +323,47 @@
300
323
 
301
324
 
302
325
  <div class="method_details first">
303
- <h3 class="signature first" id="highlight_tags-instance_method">
326
+ <h3 class="signature first" id="good?-instance_method">
327
+
328
+ #<strong>good?</strong> &#x21d2; <tt>Boolean</tt>
329
+
330
+
331
+
332
+
333
+
334
+ </h3><div class="docstring">
335
+ <div class="discussion">
336
+ <p>Tests if object is nil or empty</p>
337
+
338
+
339
+ </div>
340
+ </div>
341
+ <div class="tags">
342
+
343
+ <p class="tag_title">Returns:</p>
344
+ <ul class="return">
345
+
346
+ <li>
347
+
348
+
349
+ <span class='type'>(<tt>Boolean</tt>)</span>
350
+
351
+
352
+
353
+ &mdash;
354
+ <div class='inline'><p>true if object is defined and
355
+ has content</p>
356
+ </div>
357
+
358
+ </li>
359
+
360
+ </ul>
361
+
362
+ </div>
363
+ </div>
364
+
365
+ <div class="method_details ">
366
+ <h3 class="signature " id="highlight_tags-instance_method">
304
367
 
305
368
  #<strong>highlight_tags</strong>(color = &#39;cyan&#39;) &#x21d2; <tt><span class='object_link'><a href="String.html" title="String (class)">String</a></span></tt>
306
369
 
@@ -402,7 +465,7 @@ with</p>
402
465
  <div class="method_details ">
403
466
  <h3 class="signature " id="nested_hash-instance_method">
404
467
 
405
- #<strong>nested_hash</strong>(value) &#x21d2; <tt>Object</tt>
468
+ #<strong>nested_hash</strong>(value) &#x21d2; <tt><span class='object_link'><a href="Object.html" title="Object (class)">Object</a></span></tt>
406
469
 
407
470
 
408
471
 
@@ -617,7 +680,7 @@ with</p>
617
680
  <div class="method_details ">
618
681
  <h3 class="signature " id="to_tags!-instance_method">
619
682
 
620
- #<strong>to_tags!</strong> &#x21d2; <tt>Object</tt>
683
+ #<strong>to_tags!</strong> &#x21d2; <tt><span class='object_link'><a href="Object.html" title="Object (class)">Object</a></span></tt>
621
684
 
622
685
 
623
686
 
@@ -631,7 +694,7 @@ with</p>
631
694
  </div>
632
695
 
633
696
  <div id="footer">
634
- Generated on Sat Jan 22 17:30:14 2022 by
697
+ Generated on Sun Jan 23 09:24:05 2022 by
635
698
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
636
699
  0.9.27 (ruby-3.0.1).
637
700
  </div>
@@ -69,10 +69,10 @@
69
69
  <dl>
70
70
  <dt>Inherits:</dt>
71
71
  <dd>
72
- <span class="inheritName">Object</span>
72
+ <span class="inheritName"><span class='object_link'><a href="../Object.html" title="Object (class)">Object</a></span></span>
73
73
 
74
74
  <ul class="fullTree">
75
- <li>Object</li>
75
+ <li><span class='object_link'><a href="../Object.html" title="Object (class)">Object</a></span></li>
76
76
 
77
77
  <li class="next">BooleanTermParser::Clause</li>
78
78
 
@@ -234,7 +234,7 @@
234
234
  <div class="method_details first">
235
235
  <h3 class="signature first" id="operator-instance_method">
236
236
 
237
- #<strong>operator</strong> &#x21d2; <tt>Object</tt>
237
+ #<strong>operator</strong> &#x21d2; <tt><span class='object_link'><a href="../Object.html" title="Object (class)">Object</a></span></tt>
238
238
 
239
239
 
240
240
 
@@ -258,7 +258,7 @@
258
258
  <div class="method_details ">
259
259
  <h3 class="signature " id="term-instance_method">
260
260
 
261
- #<strong>term</strong> &#x21d2; <tt>Object</tt>
261
+ #<strong>term</strong> &#x21d2; <tt><span class='object_link'><a href="../Object.html" title="Object (class)">Object</a></span></tt>
262
262
 
263
263
 
264
264
 
@@ -283,7 +283,7 @@
283
283
  </div>
284
284
 
285
285
  <div id="footer">
286
- Generated on Sat Jan 22 17:30:14 2022 by
286
+ Generated on Sun Jan 23 09:24:05 2022 by
287
287
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
288
288
  0.9.27 (ruby-3.0.1).
289
289
  </div>
@@ -69,10 +69,10 @@
69
69
  <dl>
70
70
  <dt>Inherits:</dt>
71
71
  <dd>
72
- <span class="inheritName">Object</span>
72
+ <span class="inheritName"><span class='object_link'><a href="../Object.html" title="Object (class)">Object</a></span></span>
73
73
 
74
74
  <ul class="fullTree">
75
- <li>Object</li>
75
+ <li><span class='object_link'><a href="../Object.html" title="Object (class)">Object</a></span></li>
76
76
 
77
77
  <li class="next">BooleanTermParser::Operator</li>
78
78
 
@@ -148,7 +148,7 @@
148
148
  <div class="method_details first">
149
149
  <h3 class="signature first" id="symbol-class_method">
150
150
 
151
- .<strong>symbol</strong>(str) &#x21d2; <tt>Object</tt>
151
+ .<strong>symbol</strong>(str) &#x21d2; <tt><span class='object_link'><a href="../Object.html" title="Object (class)">Object</a></span></tt>
152
152
 
153
153
 
154
154
 
@@ -162,7 +162,7 @@
162
162
  </div>
163
163
 
164
164
  <div id="footer">
165
- Generated on Sat Jan 22 17:30:14 2022 by
165
+ Generated on Sun Jan 23 09:24:05 2022 by
166
166
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
167
167
  0.9.27 (ruby-3.0.1).
168
168
  </div>