todo-jsonl 1.0.2 → 1.0.7
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 +39 -32
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e5df379407838c3c11f109e146fdddcb560fffdfc30ed29885913b8362ae565
|
4
|
+
data.tar.gz: 4dafcccddbc47174db8dfa37c09e508a10943e5b94ef339784a1e4097dd0443e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 936dcca49f95ba126bb7b072f09ae4f3e6e05bfc31635b9d7acdee7b7393c5495e2e1f9ccb5cbab0a52d31509b3b94016cfbf102aad1e6ceaea292a890b2c777
|
7
|
+
data.tar.gz: d4c0ca6ed381cd2a38f40c88a3c451b45851c35dfeebe4afde82be5022c17d5b45d5e43c954c52418324df38bf319d4719bbe214b039521aa6b8fca6d742712d
|
data/bin/todo.rb
CHANGED
@@ -75,40 +75,40 @@ class Todo
|
|
75
75
|
begin
|
76
76
|
setup
|
77
77
|
action = arguments.first
|
78
|
-
args = arguments
|
78
|
+
args = arguments.drop(1)
|
79
79
|
case action
|
80
80
|
when 'add'
|
81
81
|
raise action + ' command requires at least one parameter' if args.nil? || args.empty?
|
82
82
|
add(args.join(' '))
|
83
83
|
when 'start'
|
84
|
-
args.length > 0 ? change_state(args.first.to_i, 'started', (
|
84
|
+
args.length > 0 ? change_state(args.first.to_i, 'started', args.drop(1).join(' ')) : list(nil, [':started'])
|
85
85
|
when 'done'
|
86
|
-
args.length > 0 ? change_state(args.first.to_i, 'done', (
|
86
|
+
args.length > 0 ? change_state(args.first.to_i, 'done', args.drop(1).join(' ')) : list(nil, [':done'])
|
87
87
|
when 'block'
|
88
|
-
args.length > 0 ? change_state(args.first.to_i, 'blocked', (
|
88
|
+
args.length > 0 ? change_state(args.first.to_i, 'blocked', args.drop(1).join(' ')) : list(nil, [':blocked'])
|
89
89
|
when 'reset'
|
90
|
-
args.length > 0 ? change_state(args.first.to_i, 'new', (
|
90
|
+
args.length > 0 ? change_state(args.first.to_i, 'new', args.drop(1).join(' ')) : list(nil, [':new'])
|
91
91
|
when 'prio'
|
92
92
|
raise action + ' command requires at least one parameter' if args.length < 1
|
93
|
-
set_priority(args.first.to_i, (
|
93
|
+
set_priority(args.first.to_i, args.drop(1).join(' '))
|
94
94
|
when 'due'
|
95
95
|
raise action + ' command requires at least one parameter' if args.length < 1
|
96
|
-
due_date(args.first.to_i, (
|
96
|
+
due_date(args.first.to_i, args.drop(1).join(' '))
|
97
97
|
when 'append'
|
98
98
|
raise action + ' command requires at least two parameters' if args.length < 2
|
99
|
-
append(args.first.to_i, args
|
99
|
+
append(args.first.to_i, args.drop(1).join(' '))
|
100
100
|
when 'rename'
|
101
101
|
raise action + ' command requires at least two parameters' if args.length < 2
|
102
|
-
rename(args.first.to_i, args
|
102
|
+
rename(args.first.to_i, args.drop(1).join(' '))
|
103
103
|
when 'del'
|
104
104
|
raise action + ' command requires exactly one parameter' if args.length != 1
|
105
105
|
delete(args.first.to_i)
|
106
106
|
when 'note'
|
107
107
|
raise action + ' command requires at least two parameters' if args.length < 2
|
108
|
-
add_note(args.first.to_i, args
|
108
|
+
add_note(args.first.to_i, args.drop(1).join(' '))
|
109
109
|
when 'delnote'
|
110
|
-
raise action + ' command requires
|
111
|
-
delete_note(args.first.to_i)
|
110
|
+
raise action + ' command requires one or two parameters' if args.length < 1 || args.length > 2
|
111
|
+
delete_note(args.first.to_i, args[1])
|
112
112
|
when 'list'
|
113
113
|
list(nil, args)
|
114
114
|
when 'show'
|
@@ -151,7 +151,7 @@ class Todo
|
|
151
151
|
* rename <tasknumber> <text> rename task
|
152
152
|
* del <tasknumber> delete task
|
153
153
|
* note <tasknumber> <text> add note to task
|
154
|
-
* delnote <tasknumber>
|
154
|
+
* delnote <tasknumber> [number] delete a specific or all notes from task
|
155
155
|
|
156
156
|
* list <regex> [regex...] list tasks (only active tasks by default)
|
157
157
|
* show <tasknumber> show all task details
|
@@ -177,6 +177,7 @@ class Todo
|
|
177
177
|
next_7_days = (0..6).map { |day| @today + day }
|
178
178
|
@due_date_days = next_7_days.map { |day| day.strftime('%A').downcase }
|
179
179
|
due_dates_for_queries = next_7_days.map { |day| day.strftime(DATE_FORMAT) }
|
180
|
+
recent_date = (@today - 7).strftime(DATE_FORMAT)
|
180
181
|
@queries = {
|
181
182
|
':active' => lambda { |task| /(new|started|blocked)/.match(task[:state]) },
|
182
183
|
':done' => lambda { |task| 'done' == task[:state] },
|
@@ -190,7 +191,8 @@ class Todo
|
|
190
191
|
':tomorrow' => lambda { |task| due_dates_for_queries[1] == task[:due] },
|
191
192
|
':next7days' => lambda { |task| /(#{due_dates_for_queries.join('|')})/.match(task[:due]) },
|
192
193
|
':overdue' => lambda { |task| task[:due] && task[:due] < due_dates_for_queries[0] },
|
193
|
-
':due' => lambda { |task| task[:due] }
|
194
|
+
':due' => lambda { |task| task[:due] },
|
195
|
+
':recent' => lambda { |task| recent_date <= task[:modified] }
|
194
196
|
}
|
195
197
|
end
|
196
198
|
|
@@ -212,9 +214,7 @@ class Todo
|
|
212
214
|
|
213
215
|
def write_tasks(tasks)
|
214
216
|
File.open(TODO_FILE, 'w:UTF-8') do |file|
|
215
|
-
tasks.keys.sort.each
|
216
|
-
file.write(JSON.generate(tasks[key]) + "\n")
|
217
|
-
end
|
217
|
+
tasks.keys.sort.each { |key| file.write(JSON.generate(tasks[key]) + "\n") }
|
218
218
|
end
|
219
219
|
end
|
220
220
|
|
@@ -228,15 +228,9 @@ class Todo
|
|
228
228
|
end
|
229
229
|
|
230
230
|
def add(text)
|
231
|
-
task = {
|
232
|
-
state: 'new',
|
233
|
-
title: text,
|
234
|
-
modified: @today.strftime(DATE_FORMAT)
|
235
|
-
}
|
231
|
+
task = { state: 'new', title: text, modified: @today.strftime(DATE_FORMAT) }
|
236
232
|
postprocess_tags(task)
|
237
|
-
File.open(TODO_FILE, 'a:UTF-8')
|
238
|
-
file.write(JSON.generate(task) + "\n")
|
239
|
-
end
|
233
|
+
File.open(TODO_FILE, 'a:UTF-8') { |file| file.write(JSON.generate(task) + "\n") }
|
240
234
|
list
|
241
235
|
end
|
242
236
|
|
@@ -306,7 +300,12 @@ class Todo
|
|
306
300
|
patterns ||= []
|
307
301
|
patterns += [':active'] if (patterns & [':active', ':done', ':blocked', ':started', ':new', ':all']).empty?
|
308
302
|
items = filter_tasks(tasks, patterns).sort_by do |num, task|
|
309
|
-
[
|
303
|
+
[
|
304
|
+
task[:priority] && task[:state] != 'done' ? 0 : 1,
|
305
|
+
ORDER[task[:state] || 'default'],
|
306
|
+
task[:state] != 'done' ? task[:due] || 'n/a' : task[:modified],
|
307
|
+
num
|
308
|
+
]
|
310
309
|
end
|
311
310
|
items.each do |num, task|
|
312
311
|
state = task[:state] || 'default'
|
@@ -327,7 +326,7 @@ class Todo
|
|
327
326
|
end
|
328
327
|
due_date = ' ' + due_date
|
329
328
|
end
|
330
|
-
puts "#{num.to_s.rjust(task_indent
|
329
|
+
puts "#{num.to_s.rjust(task_indent)}:#{priority_flag}#{display_state} #{title}#{due_date}"
|
331
330
|
end
|
332
331
|
puts 'No todos found' if items.empty?
|
333
332
|
end
|
@@ -339,17 +338,25 @@ class Todo
|
|
339
338
|
end)
|
340
339
|
end
|
341
340
|
|
342
|
-
def delete_note(item)
|
341
|
+
def delete_note(item, num = nil)
|
343
342
|
update_task(item, :show, lambda do |task|
|
344
|
-
|
343
|
+
if num.to_s.empty?
|
344
|
+
task.delete(:note)
|
345
|
+
else
|
346
|
+
raise "#{num.to_i}: Note does not exist" if num.to_i <= 0 || task[:note].to_a.size < num.to_i
|
347
|
+
task[:note].delete_at(num.to_i - 1)
|
348
|
+
task.delete(:note) if task[:note].empty?
|
349
|
+
end
|
345
350
|
end)
|
346
351
|
end
|
347
352
|
|
348
353
|
def show(item, tasks = nil)
|
349
354
|
tasks ||= load_tasks(item)
|
350
|
-
tasks[item].each do |
|
351
|
-
|
352
|
-
|
355
|
+
tasks[item].each do |k, v|
|
356
|
+
v = "\n" + v.each_with_index.
|
357
|
+
map { |n, i| v.size > 1 ? "#{(i + 1).to_s.rjust(v.size.to_s.size)}: #{n}" : n }.
|
358
|
+
join("\n") if v.is_a?(Array)
|
359
|
+
puts "#{colorize(k.to_s.rjust(10) + ':', :cyan)} #{v}"
|
353
360
|
end
|
354
361
|
end
|
355
362
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: todo-jsonl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabor Bata
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -32,7 +32,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
32
32
|
requirements:
|
33
33
|
- - ">="
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
35
|
+
version: 2.5.0
|
36
36
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|