todo-jsonl 0.1.8 → 0.1.9

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/todo.rb +13 -7
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ce5f15989aea79c3d9cea13d312faec53a31fbfc92593bdabaea225d9e9fb70
4
- data.tar.gz: ffb39beeaa6f6a9b4e1e1c053c98e8e473d687d4cdde406e577b1339fece18a4
3
+ metadata.gz: 889bafbe16e82bf4bc1d64a7cc4991a582693677c02a1a6ace65bdd04f20f4b6
4
+ data.tar.gz: 67def741aa050ac753c55af39488712aa3aed696f17c28366020233a59673810
5
5
  SHA512:
6
- metadata.gz: 71ac2951cad1bc62ccaf9aead3aece8b33c1a7139f5f21eee214b1994a94aacf67f61a1b3619db26f1cb539a30371f9a33bd9838e0de15b474a525a98ff3b733
7
- data.tar.gz: 016e953216f6360811ba62ada07389ff8788258d03449db38dca10c730bdb90b5ceb30ec31768a387ac5f1db8077155e135fef1fc7ea50c137c5d33d8702fcaa
6
+ metadata.gz: 5de24eee9c08a01b1abfe1315bbc75444d0d7fa26e0f3c6c99f25911104ec5b3d428e4ae13c23cb3f7d6b931c6b059759b870b65af33ff795786676545813e2c
7
+ data.tar.gz: 4b10d821af4c52d466f621cc77961551556f915f063032b5e7525c8f5d3fff84b838d1564eeabf899c1480e64235654d1ca669922552ddb53bc4be6941033aab
@@ -74,11 +74,8 @@ QUERIES = {
74
74
  }
75
75
 
76
76
  TODAY = DateTime.now
77
-
78
- DUE_DATE_DAYS = ['today', 'tomorrow']
79
- (2..6).each do |day|
80
- DUE_DATE_DAYS.push((TODAY.to_date + day).strftime('%A').downcase)
81
- end
77
+ DUE_DATE_DAYS = (0..6).map do |day| (TODAY.to_date + day).strftime('%A').downcase end
78
+ DUE_DATE_DAYS_SIMPLE = ['today', 'tomorrow']
82
79
 
83
80
  PRIORITY_FLAG = '*'
84
81
 
@@ -195,7 +192,12 @@ end
195
192
 
196
193
  def due_date(item, date = '')
197
194
  tasks = load_tasks(item)
198
- tasks[item][:due] = date.nil? || date.empty? ? nil : Date.parse(date).strftime(DATE_FORMAT)
195
+ day_index = DUE_DATE_DAYS.index(date.to_s.downcase) || DUE_DATE_DAYS_SIMPLE.index(date.to_s.downcase)
196
+ if day_index
197
+ tasks[item][:due] = (TODAY.to_date + day_index).strftime(DATE_FORMAT)
198
+ else
199
+ tasks[item][:due] = date.nil? || date.empty? ? nil : Date.parse(date).strftime(DATE_FORMAT)
200
+ end
199
201
  tasks[item][:modified] = Time.now.strftime(DATE_FORMAT)
200
202
  write_tasks(tasks)
201
203
  list(tasks)
@@ -229,7 +231,7 @@ def list(tasks = nil, patterns = nil)
229
231
  if date_diff < 0
230
232
  due_date = colorize("(#{date_diff.abs}d overdue)", :red)
231
233
  elsif date_diff == 0 || date_diff == 1
232
- due_date = colorize("(#{DUE_DATE_DAYS[date_diff]})", :yellow)
234
+ due_date = colorize("(#{DUE_DATE_DAYS_SIMPLE[date_diff]})", :yellow)
233
235
  else
234
236
  due_date = colorize("(#{DUE_DATE_DAYS[date_diff] || task[:due]})", :magenta) if date_diff > 1
235
237
  end
@@ -291,12 +293,16 @@ def read(arguments)
291
293
  raise action + ' command requires at least one parameter' if args.nil? || args.empty?
292
294
  add(args.join(' '))
293
295
  when 'start'
296
+ raise action + ' command can receive only one task number' if args.length > 1
294
297
  args.length == 1 ? change_state(args.first.to_i, 'started') : list(nil, [':started'])
295
298
  when 'done'
299
+ raise action + ' command can receive only one task number' if args.length > 1
296
300
  args.length == 1 ? change_state(args.first.to_i, 'done') : list(nil, [':done'])
297
301
  when 'block'
302
+ raise action + ' command can receive only one task number' if args.length > 1
298
303
  args.length == 1 ? change_state(args.first.to_i, 'blocked') : list(nil, [':blocked'])
299
304
  when 'reset'
305
+ raise action + ' command can receive only one task number' if args.length > 1
300
306
  args.length == 1 ? change_state(args.first.to_i, 'new') : list(nil, [':new'])
301
307
  when 'prio'
302
308
  raise action + ' command requires exactly one parameter' if args.length != 1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: todo-jsonl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabor Bata