doing 2.1.55 → 2.1.56
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/bin/commands/completion.rb +1 -1
- data/bin/commands/recent.rb +15 -18
- data/bin/commands/tag_dir.rb +1 -1
- data/docs/doc/Array.html +1 -1
- data/docs/doc/BooleanTermParser/Clause.html +1 -1
- data/docs/doc/BooleanTermParser/Operator.html +1 -1
- data/docs/doc/BooleanTermParser/Query.html +1 -1
- data/docs/doc/BooleanTermParser/QueryParser.html +1 -1
- data/docs/doc/BooleanTermParser/QueryTransformer.html +1 -1
- data/docs/doc/BooleanTermParser.html +1 -1
- data/docs/doc/Doing/ArrayCleanup.html +1 -1
- data/docs/doc/Doing/ArrayNestedHash.html +1 -1
- data/docs/doc/Doing/ArrayTags.html +1 -1
- data/docs/doc/Doing/CSVExport.html +1 -1
- data/docs/doc/Doing/CalendarImport.html +1 -1
- data/docs/doc/Doing/Change.html +1 -1
- data/docs/doc/Doing/Changes.html +1 -1
- data/docs/doc/Doing/ChronifyArray.html +1 -1
- data/docs/doc/Doing/ChronifyNumeric.html +1 -1
- data/docs/doc/Doing/ChronifyString.html +1 -1
- data/docs/doc/Doing/Color.html +1 -1
- data/docs/doc/Doing/Completion/BashCompletions.html +1 -1
- data/docs/doc/Doing/Completion/FigCompletions.html +1 -1
- data/docs/doc/Doing/Completion/FishCompletions.html +1 -1
- data/docs/doc/Doing/Completion/StringUtils.html +1 -1
- data/docs/doc/Doing/Completion/ZshCompletions.html +1 -1
- data/docs/doc/Doing/Completion.html +1 -1
- data/docs/doc/Doing/Configuration.html +1 -1
- data/docs/doc/Doing/DayOneRenderer.html +1 -1
- data/docs/doc/Doing/DayoneExport.html +1 -1
- data/docs/doc/Doing/DoingExport.html +1 -1
- data/docs/doc/Doing/DoingImport.html +1 -1
- data/docs/doc/Doing/Entry.html +1 -1
- data/docs/doc/Doing/Errors/DoingNoTraceError.html +1 -1
- data/docs/doc/Doing/Errors/DoingRuntimeError.html +1 -1
- data/docs/doc/Doing/Errors/DoingStandardError.html +1 -1
- data/docs/doc/Doing/Errors/EmptyInput.html +1 -1
- data/docs/doc/Doing/Errors/HistoryLimitError.html +1 -1
- data/docs/doc/Doing/Errors/InvalidPlugin.html +1 -1
- data/docs/doc/Doing/Errors/MissingBackupFile.html +1 -1
- data/docs/doc/Doing/Errors/NoResults.html +1 -1
- data/docs/doc/Doing/Errors/PluginException.html +1 -1
- data/docs/doc/Doing/Errors/UserCancelled.html +1 -1
- data/docs/doc/Doing/Errors/WrongCommand.html +1 -1
- data/docs/doc/Doing/Errors.html +1 -1
- data/docs/doc/Doing/HTMLExport.html +1 -1
- data/docs/doc/Doing/Hooks.html +1 -1
- data/docs/doc/Doing/Item.html +2 -2
- data/docs/doc/Doing/ItemDates.html +1 -1
- data/docs/doc/Doing/ItemQuery.html +82 -1
- data/docs/doc/Doing/ItemState.html +1 -1
- data/docs/doc/Doing/ItemTags.html +1 -1
- data/docs/doc/Doing/Items.html +1 -1
- data/docs/doc/Doing/JSONExport.html +1 -1
- data/docs/doc/Doing/JSONImport.html +1 -1
- data/docs/doc/Doing/Logger.html +1 -1
- data/docs/doc/Doing/MarkdownExport.html +1 -1
- data/docs/doc/Doing/Note.html +1 -1
- data/docs/doc/Doing/Pager.html +1 -1
- data/docs/doc/Doing/Plugins.html +1 -1
- data/docs/doc/Doing/Prompt.html +1 -1
- data/docs/doc/Doing/PromptChoose.html +1 -1
- data/docs/doc/Doing/PromptFZF.html +1 -1
- data/docs/doc/Doing/PromptInput.html +1 -1
- data/docs/doc/Doing/PromptSTD.html +1 -1
- data/docs/doc/Doing/PromptYN.html +1 -1
- data/docs/doc/Doing/Section.html +1 -1
- data/docs/doc/Doing/StringHighlight.html +1 -1
- data/docs/doc/Doing/StringNormalize.html +1 -1
- data/docs/doc/Doing/StringQuery.html +1 -1
- data/docs/doc/Doing/StringTags.html +1 -1
- data/docs/doc/Doing/StringTransform.html +1 -1
- data/docs/doc/Doing/StringTruncate.html +1 -1
- data/docs/doc/Doing/StringURL.html +1 -1
- data/docs/doc/Doing/SymbolNormalize.html +1 -1
- data/docs/doc/Doing/TaskPaperExport.html +1 -1
- data/docs/doc/Doing/TemplateExport.html +1 -1
- data/docs/doc/Doing/TemplateString.html +1 -1
- data/docs/doc/Doing/TimingImport.html +1 -1
- data/docs/doc/Doing/Types.html +1 -1
- data/docs/doc/Doing/Util/Backup.html +1 -1
- data/docs/doc/Doing/Util.html +1 -1
- data/docs/doc/Doing/Version.html +1 -1
- data/docs/doc/Doing/WWID.html +35 -1
- data/docs/doc/Doing.html +2 -2
- data/docs/doc/FalseClass.html +1 -1
- data/docs/doc/GLI/Commands/Help.html +1 -1
- data/docs/doc/GLI/Commands/MarkdownDocumentListener.html +1 -1
- data/docs/doc/GLI/Commands.html +1 -1
- data/docs/doc/GLI.html +1 -1
- data/docs/doc/Hash.html +1 -1
- data/docs/doc/Numeric.html +1 -1
- data/docs/doc/Object.html +1 -1
- data/docs/doc/PhraseParser/Operator.html +1 -1
- data/docs/doc/PhraseParser/PhraseClause.html +1 -1
- data/docs/doc/PhraseParser/Query.html +1 -1
- data/docs/doc/PhraseParser/QueryParser.html +1 -1
- data/docs/doc/PhraseParser/QueryTransformer.html +1 -1
- data/docs/doc/PhraseParser/TermClause.html +1 -1
- data/docs/doc/PhraseParser.html +1 -1
- data/docs/doc/Status.html +1 -1
- data/docs/doc/String.html +1 -1
- data/docs/doc/Symbol.html +1 -1
- data/docs/doc/Time.html +1 -1
- data/docs/doc/TrueClass.html +1 -1
- data/docs/doc/_index.html +1 -1
- data/docs/doc/file.README.html +2 -2
- data/docs/doc/index.html +2 -2
- data/docs/doc/method_list.html +325 -309
- data/docs/doc/top-level-namespace.html +1 -1
- data/doing.rdoc +3 -3
- data/lib/doing/item/query.rb +137 -16
- data/lib/doing/plugins/export/markdown_export.rb +1 -0
- data/lib/doing/version.rb +1 -1
- data/lib/doing/wwid/display.rb +1 -2
- data/lib/doing/wwid/filter.rb +14 -133
- metadata +1 -1
|
@@ -216,7 +216,7 @@
|
|
|
216
216
|
</div>
|
|
217
217
|
|
|
218
218
|
<div id="footer">
|
|
219
|
-
Generated on Thu May 26
|
|
219
|
+
Generated on Thu May 26 10:22:39 2022 by
|
|
220
220
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
221
221
|
0.9.27 (ruby-3.0.1).
|
|
222
222
|
</div>
|
data/doing.rdoc
CHANGED
|
@@ -5,7 +5,7 @@ record of what you've been doing, complete with tag-based time tracking. The
|
|
|
5
5
|
command line tool allows you to add entries, annotate with tags and notes, and
|
|
6
6
|
view your entries with myriad options, with a focus on a "natural" language syntax.
|
|
7
7
|
|
|
8
|
-
v2.1.
|
|
8
|
+
v2.1.56
|
|
9
9
|
|
|
10
10
|
=== Global Options
|
|
11
11
|
=== --config_file arg
|
|
@@ -531,14 +531,14 @@ Deprecated, specify shell as argument to subcommand
|
|
|
531
531
|
====== Command: <tt>generate [zsh|bash|fish|all]</tt>
|
|
532
532
|
Generate completion scripts, including custom plugins and command options
|
|
533
533
|
|
|
534
|
-
Argument specifies which shell to
|
|
534
|
+
Argument specifies which shell to generate for: zsh, bash, fish, all
|
|
535
535
|
======= Options
|
|
536
536
|
======= -f|--file PATH
|
|
537
537
|
|
|
538
538
|
Alternative file to write output to
|
|
539
539
|
|
|
540
540
|
[Default Value] None
|
|
541
|
-
Argument specifies which shell to
|
|
541
|
+
Argument specifies which shell to generate for: zsh, bash, fish, all
|
|
542
542
|
|
|
543
543
|
======= --stdout
|
|
544
544
|
Output result to STDOUT only
|
data/lib/doing/item/query.rb
CHANGED
|
@@ -152,6 +152,133 @@ module Doing
|
|
|
152
152
|
negate ? !matches : matches
|
|
153
153
|
end
|
|
154
154
|
|
|
155
|
+
##
|
|
156
|
+
## Used by filter_items determine whether an item matches a set of criteria
|
|
157
|
+
##
|
|
158
|
+
## @param opt [Hash] filter parameters
|
|
159
|
+
##
|
|
160
|
+
## @return [Boolean] whether the item matches all filter criteria
|
|
161
|
+
##
|
|
162
|
+
def keep_item?(opt)
|
|
163
|
+
item = dup
|
|
164
|
+
time_rx = /^(\d{1,2}+(:\d{1,2}+)?( *(am|pm))?|midnight|noon)$/i
|
|
165
|
+
|
|
166
|
+
keep = true
|
|
167
|
+
if opt[:unfinished]
|
|
168
|
+
finished = item.tags?('done', :and)
|
|
169
|
+
finished = opt[:not] ? !finished : finished
|
|
170
|
+
keep = false if finished
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
if keep && opt[:val]&.count&.positive?
|
|
174
|
+
bool = opt[:bool].normalize_bool if opt[:bool]
|
|
175
|
+
bool ||= :and
|
|
176
|
+
bool = :and if bool == :pattern
|
|
177
|
+
|
|
178
|
+
val_match = opt[:val].nil? || opt[:val].empty? ? true : item.tag_values?(opt[:val], bool)
|
|
179
|
+
keep = false unless val_match
|
|
180
|
+
keep = opt[:not] ? !keep : keep
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
if keep && opt[:tag]
|
|
184
|
+
opt[:tag_bool] = opt[:bool].normalize_bool if opt[:bool]
|
|
185
|
+
opt[:tag_bool] ||= :and
|
|
186
|
+
tag_match = opt[:tag].nil? || opt[:tag].empty? ? true : item.tags?(opt[:tag], opt[:tag_bool])
|
|
187
|
+
keep = false unless tag_match
|
|
188
|
+
keep = opt[:not] ? !keep : keep
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
if keep && opt[:search]
|
|
192
|
+
search_match = if opt[:search].nil? || opt[:search].empty?
|
|
193
|
+
true
|
|
194
|
+
else
|
|
195
|
+
item.search(opt[:search], case_type: opt[:case].normalize_case)
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
keep = false unless search_match
|
|
199
|
+
keep = opt[:not] ? !keep : keep
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
if keep && opt[:date_filter]&.length == 2
|
|
203
|
+
start_date = opt[:date_filter][0]
|
|
204
|
+
end_date = opt[:date_filter][1]
|
|
205
|
+
|
|
206
|
+
in_date_range = if end_date
|
|
207
|
+
item.date >= start_date && item.date <= end_date
|
|
208
|
+
else
|
|
209
|
+
item.date.strftime('%F') == start_date.strftime('%F')
|
|
210
|
+
end
|
|
211
|
+
keep = false unless in_date_range
|
|
212
|
+
keep = opt[:not] ? !keep : keep
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
if keep && opt[:time_filter][0] || opt[:time_filter][1]
|
|
216
|
+
opt[:time_filter].map! { |v| v =~ /(12 *am|midnight)/i ? '00:00' : v }
|
|
217
|
+
|
|
218
|
+
start_string = if opt[:time_filter][0].nil?
|
|
219
|
+
"#{item.date.strftime('%Y-%m-%d')} 00:00"
|
|
220
|
+
else
|
|
221
|
+
"#{item.date.strftime('%Y-%m-%d')} #{opt[:time_filter][0]}"
|
|
222
|
+
end
|
|
223
|
+
start_time = start_string.chronify(guess: :begin)
|
|
224
|
+
|
|
225
|
+
end_string = if opt[:time_filter][1].nil?
|
|
226
|
+
"#{item.date.to_datetime.next_day.strftime('%Y-%m-%d')} 00:00"
|
|
227
|
+
else
|
|
228
|
+
"#{item.date.strftime('%Y-%m-%d')} #{opt[:time_filter][1]}"
|
|
229
|
+
end
|
|
230
|
+
end_time = end_string.chronify(guess: :end) || Time.now
|
|
231
|
+
|
|
232
|
+
in_time_range = item.date >= start_time && item.date <= end_time
|
|
233
|
+
|
|
234
|
+
keep = false unless in_time_range
|
|
235
|
+
keep = opt[:not] ? !keep : keep
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
keep = false if keep && opt[:only_timed] && !item.interval
|
|
239
|
+
|
|
240
|
+
if keep && opt[:tag_filter]
|
|
241
|
+
keep = item.tags?(opt[:tag_filter]['tags'], opt[:tag_filter]['bool'])
|
|
242
|
+
keep = opt[:not] ? !keep : keep
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
if keep && opt[:before]
|
|
246
|
+
before = opt[:before]
|
|
247
|
+
cutoff = if before =~ time_rx
|
|
248
|
+
"#{item.date.strftime('%Y-%m-%d')} #{before}".chronify(guess: :begin)
|
|
249
|
+
elsif before.is_a?(String)
|
|
250
|
+
before.chronify(guess: :begin)
|
|
251
|
+
else
|
|
252
|
+
before
|
|
253
|
+
end
|
|
254
|
+
keep = cutoff && item.date <= cutoff
|
|
255
|
+
keep = opt[:not] ? !keep : keep
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
if keep && opt[:after]
|
|
259
|
+
after = opt[:after]
|
|
260
|
+
cutoff = if after =~ time_rx
|
|
261
|
+
"#{item.date.strftime('%Y-%m-%d')} #{after}".chronify(guess: :end)
|
|
262
|
+
elsif after.is_a?(String)
|
|
263
|
+
after.chronify(guess: :end)
|
|
264
|
+
else
|
|
265
|
+
after
|
|
266
|
+
end
|
|
267
|
+
keep = cutoff && item.date >= cutoff
|
|
268
|
+
keep = opt[:not] ? !keep : keep
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
if keep && opt[:today]
|
|
272
|
+
keep = item.date >= Date.today.to_time && item.date < Date.today.next_day.to_time
|
|
273
|
+
keep = opt[:not] ? !keep : keep
|
|
274
|
+
elsif keep && opt[:yesterday]
|
|
275
|
+
keep = item.date >= Date.today.prev_day.to_time && item.date < Date.today.to_time
|
|
276
|
+
keep = opt[:not] ? !keep : keep
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
keep
|
|
280
|
+
end
|
|
281
|
+
|
|
155
282
|
private
|
|
156
283
|
|
|
157
284
|
def all_searches?(searches, case_type: :smart)
|
|
@@ -191,11 +318,9 @@ module Doing
|
|
|
191
318
|
return true unless tags.good?
|
|
192
319
|
|
|
193
320
|
tags.each do |tag|
|
|
194
|
-
if tag =~ /done/ && !should_finish?
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
return false unless @title =~ /@#{tag.wildcard_to_rx}(?= |\(|\Z)/i
|
|
198
|
-
end
|
|
321
|
+
next if tag =~ /done/ && !should_finish?
|
|
322
|
+
|
|
323
|
+
return false unless @title =~ /@#{tag.wildcard_to_rx}(?= |\(|\Z)/i
|
|
199
324
|
end
|
|
200
325
|
true
|
|
201
326
|
end
|
|
@@ -204,11 +329,9 @@ module Doing
|
|
|
204
329
|
return true unless tags.good?
|
|
205
330
|
|
|
206
331
|
tags.each do |tag|
|
|
207
|
-
if tag =~ /done/ && !should_finish?
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
return false if @title =~ /@#{tag.wildcard_to_rx}(?= |\(|\Z)/i
|
|
211
|
-
end
|
|
332
|
+
return false if tag =~ /done/ && !should_finish?
|
|
333
|
+
|
|
334
|
+
return false if @title =~ /@#{tag.wildcard_to_rx}(?= |\(|\Z)/i
|
|
212
335
|
end
|
|
213
336
|
true
|
|
214
337
|
end
|
|
@@ -217,11 +340,9 @@ module Doing
|
|
|
217
340
|
return true unless tags.good?
|
|
218
341
|
|
|
219
342
|
tags.each do |tag|
|
|
220
|
-
if tag =~ /done/ && !should_finish?
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
return true if @title =~ /@#{tag.wildcard_to_rx}(?= |\(|\Z)/i
|
|
224
|
-
end
|
|
343
|
+
return true if tag =~ /done/ && !should_finish?
|
|
344
|
+
|
|
345
|
+
return true if @title =~ /@#{tag.wildcard_to_rx}(?= |\(|\Z)/i
|
|
225
346
|
end
|
|
226
347
|
false
|
|
227
348
|
end
|
|
@@ -393,7 +514,7 @@ module Doing
|
|
|
393
514
|
return false if val.nil? || tag_val.nil?
|
|
394
515
|
|
|
395
516
|
# Fail unless both values are of the same class (float or date)
|
|
396
|
-
return false unless val.
|
|
517
|
+
return false unless val.instance_of?(tag_val.class)
|
|
397
518
|
|
|
398
519
|
is_match = value_number_matches?(tag_val, comp, val)
|
|
399
520
|
|
data/lib/doing/version.rb
CHANGED
data/lib/doing/wwid/display.rb
CHANGED
|
@@ -212,7 +212,7 @@ module Doing
|
|
|
212
212
|
##
|
|
213
213
|
def recent(count = 10, section = nil, opt)
|
|
214
214
|
opt ||= {}
|
|
215
|
-
|
|
215
|
+
opt[:times] ||= false
|
|
216
216
|
opt[:totals] ||= false
|
|
217
217
|
opt[:sort_tags] ||= false
|
|
218
218
|
|
|
@@ -236,7 +236,6 @@ module Doing
|
|
|
236
236
|
opt[:format] = cfg['date_format']
|
|
237
237
|
opt[:template] = opt[:template] || cfg['template']
|
|
238
238
|
opt[:order] = :asc
|
|
239
|
-
opt[:times] = times
|
|
240
239
|
|
|
241
240
|
list_section(opt)
|
|
242
241
|
end
|
data/lib/doing/wwid/filter.rb
CHANGED
|
@@ -13,15 +13,19 @@ module Doing
|
|
|
13
13
|
# @return [Items] Filtered Items array
|
|
14
14
|
#
|
|
15
15
|
def fuzzy_filter_items(items, query, case_type: :smart)
|
|
16
|
-
scannable = items.map.with_index { |item, idx| "#{item.title} #{item.note.join(' ')}".gsub(/[|*?!]/, '') + "|#{idx}"
|
|
16
|
+
scannable = items.map.with_index { |item, idx| "#{item.title} #{item.note.join(' ')}".gsub(/[|*?!]/, '') + "|#{idx}" }.join("\n")
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
res = `echo #{Shellwords.escape(scannable)}|#{Prompt.fzf} #{fuzzy_filter_args(query, case_type).join(' ')}`
|
|
19
|
+
selected = Items.new
|
|
20
|
+
res.split(/\n/).each do |item|
|
|
21
|
+
idx = item.match(/\|(\d+)$/)[1].to_i
|
|
22
|
+
selected.push(items[idx])
|
|
23
|
+
end
|
|
24
|
+
selected
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def fuzzy_filter_args(query, case_type)
|
|
28
|
+
fzf_args = ['--multi', %(--filter="#{query.sub(/^'?/, "'")}"), '--no-sort', '-d "\|"', '--nth=1']
|
|
25
29
|
fzf_args << case case_type.normalize_case
|
|
26
30
|
when :smart
|
|
27
31
|
query =~ /[A-Z]/ ? '+i' : '-i'
|
|
@@ -30,16 +34,7 @@ module Doing
|
|
|
30
34
|
when :ignore
|
|
31
35
|
'-i'
|
|
32
36
|
end
|
|
33
|
-
|
|
34
|
-
# fzf_args << '-e' if opt[:exact]
|
|
35
|
-
# puts fzf_args.join(' ')
|
|
36
|
-
res = `echo #{Shellwords.escape(scannable)}|#{Prompt.fzf} #{fzf_args.join(' ')}`
|
|
37
|
-
selected = Items.new
|
|
38
|
-
res.split(/\n/).each do |item|
|
|
39
|
-
idx = item.match(/\|(\d+)$/)[1].to_i
|
|
40
|
-
selected.push(items[idx])
|
|
41
|
-
end
|
|
42
|
-
selected
|
|
37
|
+
fzf_args
|
|
43
38
|
end
|
|
44
39
|
|
|
45
40
|
##
|
|
@@ -95,122 +90,8 @@ module Doing
|
|
|
95
90
|
|
|
96
91
|
items.sort_by! { |item| [item.date, item.title.downcase] }.reverse
|
|
97
92
|
|
|
98
|
-
filtered_items = items.select
|
|
99
|
-
keep = true
|
|
100
|
-
if opt[:unfinished]
|
|
101
|
-
finished = item.tags?('done', :and)
|
|
102
|
-
finished = opt[:not] ? !finished : finished
|
|
103
|
-
keep = false if finished
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
if keep && opt[:val]&.count&.positive?
|
|
107
|
-
bool = opt[:bool].normalize_bool if opt[:bool]
|
|
108
|
-
bool ||= :and
|
|
109
|
-
bool = :and if bool == :pattern
|
|
110
|
-
|
|
111
|
-
val_match = opt[:val].nil? || opt[:val].empty? ? true : item.tag_values?(opt[:val], bool)
|
|
112
|
-
keep = false unless val_match
|
|
113
|
-
keep = opt[:not] ? !keep : keep
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
if keep && opt[:tag]
|
|
117
|
-
opt[:tag_bool] = opt[:bool].normalize_bool if opt[:bool]
|
|
118
|
-
opt[:tag_bool] ||= :and
|
|
119
|
-
tag_match = opt[:tag].nil? || opt[:tag].empty? ? true : item.tags?(opt[:tag], opt[:tag_bool])
|
|
120
|
-
keep = false unless tag_match
|
|
121
|
-
keep = opt[:not] ? !keep : keep
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
if keep && opt[:search]
|
|
125
|
-
search_match = if opt[:search].nil? || opt[:search].empty?
|
|
126
|
-
true
|
|
127
|
-
else
|
|
128
|
-
item.search(opt[:search], case_type: opt[:case].normalize_case)
|
|
129
|
-
end
|
|
93
|
+
filtered_items = items.select { |item| item.keep_item?(opt) }
|
|
130
94
|
|
|
131
|
-
keep = false unless search_match
|
|
132
|
-
keep = opt[:not] ? !keep : keep
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
if keep && opt[:date_filter]&.length == 2
|
|
136
|
-
start_date = opt[:date_filter][0]
|
|
137
|
-
end_date = opt[:date_filter][1]
|
|
138
|
-
|
|
139
|
-
in_date_range = if end_date
|
|
140
|
-
item.date >= start_date && item.date <= end_date
|
|
141
|
-
else
|
|
142
|
-
item.date.strftime('%F') == start_date.strftime('%F')
|
|
143
|
-
end
|
|
144
|
-
keep = false unless in_date_range
|
|
145
|
-
keep = opt[:not] ? !keep : keep
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
if keep && opt[:time_filter][0] || opt[:time_filter][1]
|
|
149
|
-
opt[:time_filter].map! { |v| v =~ /(12 *am|midnight)/i ? '00:00' : v }
|
|
150
|
-
|
|
151
|
-
start_string = if opt[:time_filter][0].nil?
|
|
152
|
-
"#{item.date.strftime('%Y-%m-%d')} 00:00"
|
|
153
|
-
else
|
|
154
|
-
"#{item.date.strftime('%Y-%m-%d')} #{opt[:time_filter][0]}"
|
|
155
|
-
end
|
|
156
|
-
start_time = start_string.chronify(guess: :begin)
|
|
157
|
-
|
|
158
|
-
end_string = if opt[:time_filter][1].nil?
|
|
159
|
-
"#{item.date.to_datetime.next_day.strftime('%Y-%m-%d')} 00:00"
|
|
160
|
-
else
|
|
161
|
-
"#{item.date.strftime('%Y-%m-%d')} #{opt[:time_filter][1]}"
|
|
162
|
-
end
|
|
163
|
-
end_time = end_string.chronify(guess: :end) || Time.now
|
|
164
|
-
|
|
165
|
-
in_time_range = item.date >= start_time && item.date <= end_time
|
|
166
|
-
|
|
167
|
-
keep = false unless in_time_range
|
|
168
|
-
keep = opt[:not] ? !keep : keep
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
keep = false if keep && opt[:only_timed] && !item.interval
|
|
172
|
-
|
|
173
|
-
if keep && opt[:tag_filter]
|
|
174
|
-
keep = item.tags?(opt[:tag_filter]['tags'], opt[:tag_filter]['bool'])
|
|
175
|
-
keep = opt[:not] ? !keep : keep
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
if keep && opt[:before]
|
|
179
|
-
before = opt[:before]
|
|
180
|
-
cutoff = if before =~ time_rx
|
|
181
|
-
"#{item.date.strftime('%Y-%m-%d')} #{before}".chronify(guess: :begin)
|
|
182
|
-
elsif before.is_a?(String)
|
|
183
|
-
before.chronify(guess: :begin)
|
|
184
|
-
else
|
|
185
|
-
before
|
|
186
|
-
end
|
|
187
|
-
keep = cutoff && item.date <= cutoff
|
|
188
|
-
keep = opt[:not] ? !keep : keep
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
if keep && opt[:after]
|
|
192
|
-
after = opt[:after]
|
|
193
|
-
cutoff = if after =~ time_rx
|
|
194
|
-
"#{item.date.strftime('%Y-%m-%d')} #{after}".chronify(guess: :end)
|
|
195
|
-
elsif after.is_a?(String)
|
|
196
|
-
after.chronify(guess: :end)
|
|
197
|
-
else
|
|
198
|
-
after
|
|
199
|
-
end
|
|
200
|
-
keep = cutoff && item.date >= cutoff
|
|
201
|
-
keep = opt[:not] ? !keep : keep
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
if keep && opt[:today]
|
|
205
|
-
keep = item.date >= Date.today.to_time && item.date < Date.today.next_day.to_time
|
|
206
|
-
keep = opt[:not] ? !keep : keep
|
|
207
|
-
elsif keep && opt[:yesterday]
|
|
208
|
-
keep = item.date >= Date.today.prev_day.to_time && item.date < Date.today.to_time
|
|
209
|
-
keep = opt[:not] ? !keep : keep
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
keep
|
|
213
|
-
end
|
|
214
95
|
count = opt[:count].to_i&.positive? ? opt[:count].to_i : filtered_items.count
|
|
215
96
|
|
|
216
97
|
output = Items.new
|