todo-jsonl 0.1.33 → 1.0.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.
- checksums.yaml +4 -4
- data/bin/todo.rb +19 -21
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f9f0379dadc07a6aa67bc1dc0662fcb6df0b4183f55de8abbda1020e8393bfc
|
4
|
+
data.tar.gz: c61ac4593f27a6bb737fe2c419fb28b356eed555291c68b33dd17a7a2589ce8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce2c81b1964521382cfef561aa92e7c954a4537664966243132d9d6b8752593bcc8fe4386ff7e565e751856697ca08e1a12a798b26cb2f83856db78adea4e2a2
|
7
|
+
data.tar.gz: 6235a7b73886fd6a9a8944287c8c47f012797affac60f492eb7551dd19e4690f06ad7986d63523474cf730d74507ab0caae03de5af6b296ba9613788ed408581
|
data/bin/todo.rb
CHANGED
@@ -173,19 +173,19 @@ class Todo
|
|
173
173
|
|
174
174
|
def setup
|
175
175
|
@today = Date.today
|
176
|
-
next_7_days = (0..6).map
|
177
|
-
@due_date_days = next_7_days.map
|
178
|
-
due_dates_for_queries = next_7_days.map
|
176
|
+
next_7_days = (0..6).map { |day| @today + day }
|
177
|
+
@due_date_days = next_7_days.map { |day| day.strftime('%A').downcase }
|
178
|
+
due_dates_for_queries = next_7_days.map { |day| day.strftime(DATE_FORMAT) }
|
179
179
|
@queries = {
|
180
|
-
':active' => lambda
|
181
|
-
':done' => lambda
|
182
|
-
':blocked' => lambda
|
183
|
-
':started' => lambda
|
184
|
-
':new' => lambda
|
185
|
-
':all' => lambda
|
186
|
-
':today' => lambda
|
187
|
-
':tomorrow' => lambda
|
188
|
-
':next7days' => lambda
|
180
|
+
':active' => lambda { |task| /(new|started|blocked)/.match(task[:state]) },
|
181
|
+
':done' => lambda { |task| 'done' == task[:state] },
|
182
|
+
':blocked' => lambda { |task| 'blocked' == task[:state] },
|
183
|
+
':started' => lambda { |task| 'started' == task[:state] },
|
184
|
+
':new' => lambda { |task| 'new' == task[:state] },
|
185
|
+
':all' => lambda { |task| /\w+/.match(task[:state]) },
|
186
|
+
':today' => lambda { |task| due_dates_for_queries[0] == task[:due] },
|
187
|
+
':tomorrow' => lambda { |task| due_dates_for_queries[1] == task[:due] },
|
188
|
+
':next7days' => lambda { |task| /(#{due_dates_for_queries.join('|')})/.match(task[:due]) }
|
189
189
|
}
|
190
190
|
end
|
191
191
|
|
@@ -224,8 +224,8 @@ class Todo
|
|
224
224
|
|
225
225
|
def add(text)
|
226
226
|
task = {
|
227
|
-
state:
|
228
|
-
title:
|
227
|
+
state: 'new',
|
228
|
+
title: text,
|
229
229
|
modified: @today.strftime(DATE_FORMAT)
|
230
230
|
}
|
231
231
|
postprocess_tags(task)
|
@@ -365,20 +365,18 @@ class Todo
|
|
365
365
|
tasks = load_tasks
|
366
366
|
patterns = [':done'] + patterns.to_a
|
367
367
|
items = filter_tasks(tasks, patterns)
|
368
|
-
items.each_key
|
368
|
+
items.each_key { |num| tasks.delete(num) }
|
369
369
|
write_tasks(tasks)
|
370
370
|
puts "Deleted #{items.size} todo(s)"
|
371
371
|
end
|
372
372
|
|
373
373
|
def filter_tasks(tasks, patterns)
|
374
|
-
|
375
|
-
tasks.
|
376
|
-
|
374
|
+
patterns = patterns.uniq
|
375
|
+
tasks.select do |num, task|
|
376
|
+
patterns.all? do |pattern|
|
377
377
|
@queries[pattern] ? @queries[pattern].call(task) : /#{pattern}/ix.match(task[:title])
|
378
378
|
end
|
379
|
-
items[num] = task if match
|
380
379
|
end
|
381
|
-
items
|
382
380
|
end
|
383
381
|
|
384
382
|
def colorize(text, color)
|
@@ -388,7 +386,7 @@ class Todo
|
|
388
386
|
def convert_due_date(date)
|
389
387
|
day_index = @due_date_days.index(date.to_s.downcase) ||
|
390
388
|
DUE_DATE_DAYS_SIMPLE.index(date.to_s.downcase) ||
|
391
|
-
@due_date_days.map
|
389
|
+
@due_date_days.map { |day| day[0..2] }.index(date.to_s.downcase)
|
392
390
|
return (@today + day_index).strftime(DATE_FORMAT) if day_index
|
393
391
|
date.nil? || date.empty? ? nil : Date.strptime(date, DATE_FORMAT).strftime(DATE_FORMAT)
|
394
392
|
end
|