doing 1.0.65 → 1.0.66

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a774718572df78395293b6294bcfa4bac94cfe2cde0ffec43e8bbea60b874534
4
- data.tar.gz: fba4b65439084eae5b291bd65f5a1d14d49e5b5c4c8b70abd5e8f73fa39b3545
3
+ metadata.gz: 6e02c8453f718dfa428e578ab1b125528aa07ffee1390bbe8222fb425abd63fa
4
+ data.tar.gz: 333707321b7e92312ee8a2874292b45df782c83eff2ddcdb5279b648b14730ff
5
5
  SHA512:
6
- metadata.gz: 01bf52dbc6e7077e6ff2a67ab22504dda4be927f31da8be7e5383136b5cac500cd7920203b7383ebe302af5ddce375e0ee7389273a275edfde27971de8ae87bb
7
- data.tar.gz: 79e7b8dcf00223118a0e3f5bb648ed33e920dc915909f62d1c21f2a19332f3d35336d3e5ca85a31632416b9fb9364d58db2fb6a4f90e7a200bc7cb706f76e14b
6
+ metadata.gz: 187ce7735035b86ae1233d08dd154f502c7b2def0fc1fd11532de5256647c8cce57bd4ea73ca3fa704c2dfb4a307b94f339222a476e3fd30ba991fea77daa190
7
+ data.tar.gz: 29f7123aa51cb8a5754bca68854dbbb606f69533d8cdbd90a7a2187ca1cc29dd09131aed0787f72fd680e2d04fe9e47a92555cf90c1327b74cba23cc8a2fab2b
data/README.md CHANGED
@@ -29,7 +29,7 @@ _Side note:_ I actually use the library behind this utility as part of another s
29
29
 
30
30
  ## Installation
31
31
 
32
- The current version of `doing` is <!--VER-->1.0.64<!--END VER-->.
32
+ The current version of `doing` is <!--VER-->1.0.65<!--END VER-->.
33
33
 
34
34
  $ [sudo] gem install doing
35
35
 
data/bin/doing CHANGED
@@ -52,7 +52,7 @@ flag %i[f doing_file]
52
52
 
53
53
  desc 'Add an entry'
54
54
  arg_name 'ENTRY'
55
- command [:now, :next] do |c|
55
+ command %i[now next] do |c|
56
56
  c.desc 'Section'
57
57
  c.arg_name 'NAME'
58
58
  c.flag %i[s section], default_value: wwid.current_section
@@ -105,7 +105,8 @@ command [:now, :next] do |c|
105
105
  wwid.add_item(title.cap_first, section, { note: note, back: date, timed: options[:f] })
106
106
  wwid.write(wwid.doing_file)
107
107
  elsif $stdin.stat.size.positive?
108
- title, note = wwid.format_input($stdin.read)
108
+ input = $stdin.read
109
+ title, note = wwid.format_input(input)
109
110
  note.push(options[:n]) if options[:n]
110
111
  wwid.add_item(title.cap_first, section, { note: note, back: date, timed: options[:f] })
111
112
  wwid.write(wwid.doing_file)
@@ -239,7 +240,7 @@ long_desc %(
239
240
 
240
241
  Example `doing template HAML > ~/styles/my_doing.haml`
241
242
  )
242
- arg_name 'TYPE', must_match: /^(html|haml|css)/i
243
+ arg_name 'TYPE', must_match: /^(?:html|haml|css)/i
243
244
  command :template do |c|
244
245
  c.action do |_global_options, options, args|
245
246
  raise 'No type specified, use `doing template [HAML|CSS]`' if args.empty?
@@ -443,7 +444,7 @@ command :cancel do |c|
443
444
 
444
445
  c.desc 'Boolean (AND|OR|NOT) with which to combine multiple tag filters'
445
446
  c.arg_name 'BOOLEAN'
446
- c.flag [:bool], must_match: /^(and|or|not)$/i, default_value: 'AND'
447
+ c.flag [:bool], must_match: /(?:and|all|any|or|not|none)/i, default_value: 'AND'
447
448
 
448
449
  c.action do |_global_options, options, args|
449
450
  section = wwid.guess_section(options[:s]) || options[:s].cap_first
@@ -452,7 +453,16 @@ command :cancel do |c|
452
453
  tags = []
453
454
  else
454
455
  tags = options[:tag].split(/ *, */).map { |t| t.strip.sub(/^@/, '') }
455
- options[:bool] = options[:bool] =~ /^(and|or|not)$/i ? options[:bool].upcase : 'AND'
456
+ options[:bool] = case options[:bool]
457
+ when /(and|all)/i
458
+ 'AND'
459
+ when /(any|or)/i
460
+ 'OR'
461
+ when /(not|none)/i
462
+ 'NOT'
463
+ else
464
+ 'AND'
465
+ end
456
466
  end
457
467
 
458
468
  raise 'Only one argument allowed' if args.length > 1
@@ -500,7 +510,7 @@ command :finish do |c|
500
510
 
501
511
  c.desc 'Boolean (AND|OR|NOT) with which to combine multiple tag filters'
502
512
  c.arg_name 'BOOLEAN'
503
- c.flag [:bool], must_match: /^(and|or|not)$/i, default_value: 'AND'
513
+ c.flag [:bool], must_match: /(?:and|all|any|or|not|none)/i, default_value: 'AND'
504
514
 
505
515
  c.desc %(Auto-generate finish dates from next entry's start time.
506
516
  Automatically generate completion dates 1 minute before next start date.
@@ -537,7 +547,16 @@ command :finish do |c|
537
547
  tags = []
538
548
  else
539
549
  tags = options[:tag].split(/ *, */).map { |t| t.strip.sub(/^@/, '') }
540
- options[:bool] = options[:bool] =~ /^(and|or|not)$/i ? options[:bool].upcase : 'AND'
550
+ options[:bool] = case options[:bool]
551
+ when /(and|all)/i
552
+ 'AND'
553
+ when /(any|or)/i
554
+ 'OR'
555
+ when /(not|none)/i
556
+ 'NOT'
557
+ else
558
+ 'AND'
559
+ end
541
560
  end
542
561
 
543
562
  raise 'Only one argument allowed' if args.length > 1
@@ -582,7 +601,7 @@ command [:again, :resume] do |c|
582
601
 
583
602
  c.desc 'Boolean used to combine multiple tags'
584
603
  c.arg_name 'BOOLEAN'
585
- c.flag [:bool], must_match: /^(and|or|not)$/i, default_value: 'AND'
604
+ c.flag [:bool], must_match: /(?:and|all|any|or|not|none)/i, default_value: 'AND'
586
605
 
587
606
  c.desc 'Note'
588
607
  c.arg_name 'TEXT'
@@ -590,6 +609,16 @@ command [:again, :resume] do |c|
590
609
 
591
610
  c.action do |_global_options, options, _args|
592
611
  tags = options[:tag].nil? ? [] : options[:tag].split(/ *, */).map { |t| t.sub(/^@/, '').strip }
612
+ options[:bool] = case options[:bool]
613
+ when /(and|all)/i
614
+ 'AND'
615
+ when /(any|or)/i
616
+ 'OR'
617
+ when /(not|none)/i
618
+ 'NOT'
619
+ else
620
+ 'AND'
621
+ end
593
622
  opts = {
594
623
  in: options[:in],
595
624
  note: options[:n],
@@ -694,9 +723,9 @@ command :show do |c|
694
723
  c.arg_name 'TAG'
695
724
  c.flag [:tag]
696
725
 
697
- c.desc 'Tag boolean (AND,OR,NONE)'
726
+ c.desc 'Tag boolean (AND,OR,NOT)'
698
727
  c.arg_name 'BOOLEAN'
699
- c.flag %i[b bool], must_match: /^(and|or|not)$/i, default_value: 'OR'
728
+ c.flag %i[b bool], must_match: /(?:and|all|any|or|not|none)/i, default_value: 'OR'
700
729
 
701
730
  c.desc 'Max count to show'
702
731
  c.arg_name 'MAX'
@@ -708,7 +737,7 @@ command :show do |c|
708
737
 
709
738
  c.desc 'Sort order (asc/desc)'
710
739
  c.arg_name 'ORDER'
711
- c.flag %i[s sort], must_match: /^(a|d)/i, default_value: 'ASC'
740
+ c.flag %i[s sort], must_match: /^(?:a|d)/i, default_value: 'ASC'
712
741
 
713
742
  c.desc %(
714
743
  Date range to show, or a single day to filter date on.
@@ -728,14 +757,14 @@ command :show do |c|
728
757
  default = 'time'
729
758
  default = wwid.config['tag_sort'] if wwid.config.key?('tag_sort')
730
759
  c.arg_name 'KEY'
731
- c.flag [:tag_sort], must_match: /^(name|time)/i, default_value: default
760
+ c.flag [:tag_sort], must_match: /^(?:name|time)/i, default_value: default
732
761
 
733
762
  c.desc 'Only show items with recorded time intervals'
734
763
  c.switch [:only_timed], default_value: false, negatable: false
735
764
 
736
765
  c.desc 'Output to export format (csv|html|json|template|timeline)'
737
766
  c.arg_name 'FORMAT'
738
- c.flag %i[o output], must_match: /^(template|html|csv|json|timeline)$/i
767
+ c.flag %i[o output], must_match: /^(?:template|html|csv|json|timeline)$/i
739
768
  c.action do |_global_options, options, args|
740
769
  tag_filter = false
741
770
  tags = []
@@ -757,13 +786,9 @@ command :show do |c|
757
786
  end
758
787
  if args.length.positive?
759
788
  args.each do |arg|
760
- if arg =~ /,/
761
- arg.split(/,/).each do |tag|
762
- tags.push(tag.strip.sub(/^@/, ''))
763
- end
764
- else
765
- tags.push(arg.strip.sub(/^@/, ''))
766
- end
789
+ arg.split(/,/).each do |tag|
790
+ tags.push(tag.strip.sub(/^@/, ''))
791
+ end
767
792
  end
768
793
  end
769
794
  else
@@ -771,11 +796,21 @@ command :show do |c|
771
796
  end
772
797
 
773
798
  tags.concat(options[:tag].split(/ *, */).map { |t| t.sub(/^@/, '').strip }) if options[:tag]
799
+ options[:bool] = case options[:bool]
800
+ when /(and|all)/i
801
+ 'AND'
802
+ when /(any|or)/i
803
+ 'OR'
804
+ when /(not|none)/i
805
+ 'NOT'
806
+ else
807
+ 'AND'
808
+ end
774
809
 
775
810
  unless tags.empty?
776
811
  tag_filter = {
777
812
  'tags' => tags,
778
- 'bool' => options[:b]
813
+ 'bool' => options[:bool]
779
814
  }
780
815
  end
781
816
 
@@ -832,7 +867,7 @@ command [:grep, :search] do |c|
832
867
 
833
868
  c.desc 'Output to export format (csv|html|json|template|timeline)'
834
869
  c.arg_name 'FORMAT'
835
- c.flag %i[o output], must_match: /^(template|html|csv|json|timeline)$/i
870
+ c.flag %i[o output], must_match: /^(?:template|html|csv|json|timeline)$/i
836
871
 
837
872
  c.desc 'Show time intervals on @done tasks'
838
873
  c.switch %i[t times], default_value: true
@@ -844,7 +879,7 @@ command [:grep, :search] do |c|
844
879
  default = 'time'
845
880
  default = wwid.config['tag_sort'] if wwid.config.key?('tag_sort')
846
881
  c.arg_name 'KEY'
847
- c.flag [:tag_sort], must_match: /^(name|time)$/i, default_value: default
882
+ c.flag [:tag_sort], must_match: /^(?:name|time)$/i, default_value: default
848
883
 
849
884
  c.desc 'Only show items with recorded time intervals'
850
885
  c.switch [:only_timed], default_value: false, negatable: false
@@ -891,7 +926,7 @@ command :recent do |c|
891
926
  default = 'time'
892
927
  default = wwid.config['tag_sort'] if wwid.config.key?('tag_sort')
893
928
  c.arg_name 'KEY'
894
- c.flag [:tag_sort], must_match: /^(name|time)$/i, default_value: default
929
+ c.flag [:tag_sort], must_match: /^(?:name|time)$/i, default_value: default
895
930
 
896
931
  c.action do |global_options, options, args|
897
932
  section = wwid.guess_section(options[:s]) || options[:s].cap_first
@@ -931,11 +966,11 @@ command :today do |c|
931
966
  default = 'time'
932
967
  default = wwid.config['tag_sort'] if wwid.config.key?('tag_sort')
933
968
  c.arg_name 'KEY'
934
- c.flag [:tag_sort], must_match: /^(name|time)$/i, default_value: default
969
+ c.flag [:tag_sort], must_match: /^(?:name|time)$/i, default_value: default
935
970
 
936
971
  c.desc 'Output to export format (csv|html|json|template|timeline)'
937
972
  c.arg_name 'FORMAT'
938
- c.flag %i[o output], must_match: /^(template|html|csv|json|timeline)$/i
973
+ c.flag %i[o output], must_match: /^(?:template|html|csv|json|timeline)$/i
939
974
 
940
975
  c.action do |_global_options, options, _args|
941
976
  options[:t] = true if options[:totals]
@@ -966,11 +1001,11 @@ command :on do |c|
966
1001
  default = 'time'
967
1002
  default = wwid.config['tag_sort'] if wwid.config.key?('tag_sort')
968
1003
  c.arg_name 'KEY'
969
- c.flag [:tag_sort], must_match: /^(name|time)$/i, default_value: default
1004
+ c.flag [:tag_sort], must_match: /^(?:name|time)$/i, default_value: default
970
1005
 
971
1006
  c.desc 'Output to export format (csv|html|json|template|timeline)'
972
1007
  c.arg_name 'FORMAT'
973
- c.flag %i[o output], must_match: /^(template|html|csv|json|timeline)$/i
1008
+ c.flag %i[o output], must_match: /^(?:template|html|csv|json|timeline)$/i
974
1009
 
975
1010
  c.action do |_global_options, options, args|
976
1011
  exit_now! 'Missing date argument' if args.empty?
@@ -1008,7 +1043,7 @@ command :yesterday do |c|
1008
1043
 
1009
1044
  c.desc 'Output to export format (csv|html|json|template|timeline)'
1010
1045
  c.arg_name 'FORMAT'
1011
- c.flag %i[o output], must_match: /^(template|html|csv|json|timeline)$/i
1046
+ c.flag %i[o output], must_match: /^(?:template|html|csv|json|timeline)$/i
1012
1047
 
1013
1048
  c.desc 'Show time intervals on @done tasks'
1014
1049
  c.switch %i[t times], default_value: true
@@ -1020,7 +1055,7 @@ command :yesterday do |c|
1020
1055
  default = 'time'
1021
1056
  default = wwid.config['tag_sort'] if wwid.config.key?('tag_sort')
1022
1057
  c.arg_name 'KEY'
1023
- c.flag [:tag_sort], must_match: /^(name|time)$/i, default_value: default
1058
+ c.flag [:tag_sort], must_match: /^(?:name|time)$/i, default_value: default
1024
1059
 
1025
1060
  c.action do |_global_options, options, _args|
1026
1061
  options[:sort_tags] = options[:tag_sort] =~ /^n/i
@@ -1044,7 +1079,7 @@ command :last do |c|
1044
1079
 
1045
1080
  c.desc 'Tag boolean'
1046
1081
  c.arg_name 'BOOLEAN'
1047
- c.flag [:bool], must_match: /(and|or|not)/i, default_value: 'AND'
1082
+ c.flag [:bool], must_match: /(?:and|all|any|or|not|none)/i, default_value: 'AND'
1048
1083
 
1049
1084
  c.desc 'Search filter, surround with slashes for regex (/query/)'
1050
1085
  c.arg_name 'QUERY'
@@ -1057,7 +1092,15 @@ command :last do |c|
1057
1092
  tags = []
1058
1093
  else
1059
1094
  tags = options[:tag].split(/ *, */).map { |t| t.strip.sub(/^@/, '') }
1060
- options[:bool] = options[:bool] =~ /^(and|or|not)$/i ? options[:bool].upcase : 'AND'
1095
+ options[:bool] = case options[:bool]
1096
+ when /(any|or)/i
1097
+ :or
1098
+ when /(not|none)/i
1099
+ :not
1100
+ else
1101
+ :and
1102
+ end
1103
+
1061
1104
  end
1062
1105
 
1063
1106
  if options[:e]
@@ -1130,7 +1173,7 @@ command :view do |c|
1130
1173
 
1131
1174
  c.desc 'Output to export format (csv|html|json|template|timeline)'
1132
1175
  c.arg_name 'FORMAT'
1133
- c.flag %i[o output], must_match: /^(template|html|csv|json|timeline)$/i
1176
+ c.flag %i[o output], must_match: /^(?:template|html|csv|json|timeline)$/i
1134
1177
 
1135
1178
  c.desc 'Show time intervals on @done tasks'
1136
1179
  c.switch %i[t times], default_value: true
@@ -1145,7 +1188,7 @@ command :view do |c|
1145
1188
  default = 'time'
1146
1189
  default = wwid.config['tag_sort'] if wwid.config.key?('tag_sort')
1147
1190
  c.arg_name 'KEY'
1148
- c.flag [:tag_sort], must_match: /^(name|time)$/i, default_value: default
1191
+ c.flag [:tag_sort], must_match: /^(?:name|time)$/i, default_value: default
1149
1192
 
1150
1193
  c.desc 'Only show items with recorded time intervals'
1151
1194
  c.switch [:only_timed], default_value: false, negatable: true
@@ -1178,7 +1221,7 @@ command :view do |c|
1178
1221
  else
1179
1222
  view['tags'].gsub(/[, ]+/, ' ').split(' ').map(&:strip)
1180
1223
  end
1181
- tag_filter['bool'] = view.key?('tags_bool') && !view['tags_bool'].nil? ? view['tags_bool'].upcase : 'OR'
1224
+ tag_filter['bool'] = view.key?('tags_bool') && !view['tags_bool'].nil? ? view['tags_bool'].normalize_bool : :or
1182
1225
  end
1183
1226
 
1184
1227
  # If the -o/--output flag was specified, override any default in the view template
@@ -1257,7 +1300,7 @@ command :archive do |c|
1257
1300
 
1258
1301
  c.desc 'Tag boolean (AND|OR|NOT)'
1259
1302
  c.arg_name 'BOOLEAN'
1260
- c.flag [:bool], must_match: /(and|or|not)/i, default_value: 'AND'
1303
+ c.flag [:bool], must_match: /(?:and|all|any|or|not|none)/i, default_value: 'AND'
1261
1304
 
1262
1305
  c.desc 'Search filter'
1263
1306
  c.arg_name 'QUERY'
@@ -1281,6 +1324,16 @@ command :archive do |c|
1281
1324
 
1282
1325
  tags.concat(options[:tag].split(/ *, */).map { |t| t.sub(/^@/, '').strip }) if options[:tag]
1283
1326
 
1327
+ options[:bool] = case options[:bool]
1328
+ when /(and|all)/i
1329
+ 'AND'
1330
+ when /(any|or)/i
1331
+ 'OR'
1332
+ when /(not|none)/i
1333
+ 'NOT'
1334
+ else
1335
+ 'AND'
1336
+ end
1284
1337
  opts = {
1285
1338
  bool: options[:bool],
1286
1339
  destination: options[:to],
data/lib/doing.rb CHANGED
@@ -8,4 +8,5 @@ require 'tempfile'
8
8
  require 'chronic'
9
9
  require 'haml'
10
10
  require 'json'
11
+ require 'doing/helpers.rb'
11
12
  require 'doing/wwid.rb'
data/lib/doing/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Doing
2
- VERSION = '1.0.65'
2
+ VERSION = '1.0.66'
3
3
  end
data/lib/doing/wwid.rb CHANGED
@@ -4,92 +4,6 @@ require 'deep_merge'
4
4
  require 'open3'
5
5
  require 'pp'
6
6
 
7
- ##
8
- ## @brief Hash helpers
9
- ##
10
- class ::Hash
11
- def has_tags?(tags, bool = 'AND')
12
- tags = tags.split(/ *, */) if tags.is_a? String
13
- item = self
14
- case bool
15
- when 'AND'
16
- result = true
17
- tags.each do |tag|
18
- unless item['title'] =~ /@#{tag}/
19
- result = false
20
- break
21
- end
22
- end
23
- result
24
- when 'NOT'
25
- result = true
26
- tags.each do |tag|
27
- if item['title'] =~ /@#{tag}/
28
- result = false
29
- break
30
- end
31
- end
32
- result
33
- else
34
- result = false
35
- tags.each do |tag|
36
- if item['title'] =~ /@#{tag}/
37
- result = true
38
- break
39
- end
40
- end
41
- result
42
- end
43
- end
44
-
45
- def matches_search?(search)
46
- item = self
47
- text = item['note'] ? item['title'] + item['note'].join(' ') : item['title']
48
- pattern = if search.strip =~ %r{^/.*?/$}
49
- search.sub(%r{/(.*?)/}, '\1')
50
- else
51
- search.split('').join('.{0,3}')
52
- end
53
- text =~ /#{pattern}/i ? true : false
54
- end
55
- end
56
-
57
- ##
58
- ## @brief String helpers
59
- ##
60
- class String
61
- def cap_first
62
- sub(/^\w/) do |m|
63
- m.upcase
64
- end
65
- end
66
-
67
- ##
68
- ## @brief Turn raw urls into HTML links
69
- ##
70
- ## @param opt (Hash) Additional Options
71
- ##
72
- def link_urls(opt = {})
73
- opt[:format] ||= :html
74
- if opt[:format] == :html
75
- gsub(%r{(?mi)((http|https)://)?([\w\-_]+(\.[\w\-_]+)+)([\w\-.,@?^=%&amp;:/~+#]*[\w\-@^=%&amp;/~+#])?}) do |_match|
76
- m = Regexp.last_match
77
- proto = m[1].nil? ? 'http://' : ''
78
- %(<a href="#{proto}#{m[0]}" title="Link to #{m[0]}">[#{m[3]}]</a>)
79
- end.gsub(/<(\w+:.*?)>/) do |match|
80
- m = Regexp.last_match
81
- if m[1] =~ /<a href/
82
- match
83
- else
84
- %(<a href="#{m[1]}" title="Link to #{m[1]}">[link]</a>)
85
- end
86
- end
87
- else
88
- self
89
- end
90
- end
91
- end
92
-
93
7
  ##
94
8
  ## @brief Main "What Was I Doing" methods
95
9
  ##
@@ -791,7 +705,7 @@ class WWID
791
705
  opt[:section] ||= 'all'
792
706
  opt[:note] ||= []
793
707
  opt[:tag] ||= []
794
- opt[:tag_bool] ||= 'AND'
708
+ opt[:tag_bool] ||= :and
795
709
 
796
710
  last = last_entry(opt)
797
711
  if last.nil?
@@ -817,7 +731,7 @@ class WWID
817
731
  ## @param opt (Hash) Additional Options
818
732
  ##
819
733
  def last_entry(opt = {})
820
- opt[:tag_bool] ||= 'AND'
734
+ opt[:tag_bool] ||= :and
821
735
  opt[:section] ||= @current_section
822
736
 
823
737
  sec_arr = []
@@ -1308,7 +1222,7 @@ class WWID
1308
1222
  @content.each do |_k, v|
1309
1223
  combined['items'] += v['items']
1310
1224
  end
1311
- section = if opt[:tag_filter] && opt[:tag_filter]['bool'] != 'NONE'
1225
+ section = if opt[:tag_filter] && opt[:tag_filter]['bool'].normalize_bool != :not
1312
1226
  opt[:tag_filter]['tags'].map do |tag|
1313
1227
  "@#{tag}"
1314
1228
  end.join(' + ')
@@ -1339,31 +1253,7 @@ class WWID
1339
1253
  end
1340
1254
 
1341
1255
  if opt[:tag_filter] && !opt[:tag_filter]['tags'].empty?
1342
- items.delete_if do |item|
1343
- case opt[:tag_filter]['bool']
1344
- when /(AND|ALL)/
1345
- del = false
1346
- opt[:tag_filter]['tags'].each do |tag|
1347
- unless item['title'] =~ /@#{tag}/
1348
- del = true
1349
- break
1350
- end
1351
- end
1352
- del
1353
- when /NONE/
1354
- del = false
1355
- opt[:tag_filter]['tags'].each do |tag|
1356
- del = true if item['title'] =~ /@#{tag}/
1357
- end
1358
- del
1359
- when /(OR|ANY)/
1360
- del = true
1361
- opt[:tag_filter]['tags'].each do |tag|
1362
- del = false if item['title'] =~ /@#{tag}/
1363
- end
1364
- del
1365
- end
1366
- end
1256
+ items.select! { |item| item.has_tags?(opt[:tag_filter]['tags'], opt[:tag_filter]['bool']) }
1367
1257
  end
1368
1258
 
1369
1259
  if opt[:search]
@@ -1655,7 +1545,7 @@ class WWID
1655
1545
  count = options[:keep] || 0
1656
1546
  destination = options[:destination] || 'Archive'
1657
1547
  tags = options[:tags] || []
1658
- bool = options[:bool] || 'AND'
1548
+ bool = options[:bool] || :and
1659
1549
 
1660
1550
  section = choose_section if section.nil? || section =~ /choose/i
1661
1551
  archive_all = section =~ /^all$/i # && !(tags.nil? || tags.empty?)
@@ -1683,7 +1573,7 @@ class WWID
1683
1573
  def do_archive(sect, destination, opt = {})
1684
1574
  count = opt[:count] || 0
1685
1575
  tags = opt[:tags] || []
1686
- bool = opt[:bool] || 'AND'
1576
+ bool = opt[:bool] || :and
1687
1577
  label = opt[:label] || true
1688
1578
 
1689
1579
  if sect =~ /^all$/i
@@ -1696,7 +1586,7 @@ class WWID
1696
1586
  counter = 0
1697
1587
 
1698
1588
  all_sections.each do |section|
1699
- items = @content[section]['items']
1589
+ items = @content[section]['items'].dup
1700
1590
 
1701
1591
  moved_items = []
1702
1592
  if !tags.empty? || opt[:search]
@@ -1720,13 +1610,7 @@ class WWID
1720
1610
  @content[destination]['items'].concat(moved_items)
1721
1611
  @results.push("Archived #{moved_items.length} items from #{section} to #{destination}")
1722
1612
  else
1723
- count = items.length if count == 0 || items.length < count
1724
-
1725
- @content[section]['items'] = if count.zero?
1726
- []
1727
- else
1728
- items[0..count - 1]
1729
- end
1613
+ count = items.length if items.length < count
1730
1614
 
1731
1615
  items.map! do |item|
1732
1616
  if label && section != 'Currently'
@@ -1735,12 +1619,19 @@ class WWID
1735
1619
  end
1736
1620
  item
1737
1621
  end
1622
+
1738
1623
  if items.count > count
1739
1624
  @content[destination]['items'].concat(items[count..-1])
1740
1625
  else
1741
1626
  @content[destination]['items'].concat(items)
1742
1627
  end
1743
1628
 
1629
+ @content[section]['items'] = if count.zero?
1630
+ []
1631
+ else
1632
+ items[0..count - 1]
1633
+ end
1634
+
1744
1635
  @results.push("Archived #{items.length - count} items from #{section} to #{destination}")
1745
1636
  end
1746
1637
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doing
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.65
4
+ version: 1.0.66
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-24 00:00:00.000000000 Z
11
+ date: 2021-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake