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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/todo.rb +19 -21
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89f9cb1d9f24fe4077faebac43c8fe85041021f560a9cd812e67acace53441cc
4
- data.tar.gz: cddf8951cc9afbdea4ee6831f3c86fc5419a4f00582a2b1292007bba15b9cf13
3
+ metadata.gz: 1f9f0379dadc07a6aa67bc1dc0662fcb6df0b4183f55de8abbda1020e8393bfc
4
+ data.tar.gz: c61ac4593f27a6bb737fe2c419fb28b356eed555291c68b33dd17a7a2589ce8b
5
5
  SHA512:
6
- metadata.gz: 9e90bb2be2db37e6bfdcee15f7953112bba1db7804562dd4ab697a033a7d38ec4cd495abb394320263ff2a76fb5ff23c0886eb8ae381959a170828a0d7d83d9f
7
- data.tar.gz: ab376c488d6a86676ee134154ef62e7c63f801d3002ef1df28ec2aee521f535730739ff4a13847dd0d77ad19bab0b6b36d5ce7732d6b317696e125293fa95d28
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 do |day| @today + day end
177
- @due_date_days = next_7_days.map do |day| day.strftime('%A').downcase end
178
- due_dates_for_queries = next_7_days.map do |day| day.strftime(DATE_FORMAT) end
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 do |task| /(new|started|blocked)/.match(task[:state]) end,
181
- ':done' => lambda do |task| 'done' == task[:state] end,
182
- ':blocked' => lambda do |task| 'blocked' == task[:state] end,
183
- ':started' => lambda do |task| 'started' == task[:state] end,
184
- ':new' => lambda do |task| 'new' == task[:state] end,
185
- ':all' => lambda do |task| /\w+/.match(task[:state]) end,
186
- ':today' => lambda do |task| due_dates_for_queries[0] == task[:due] end,
187
- ':tomorrow' => lambda do |task| due_dates_for_queries[1] == task[:due] end,
188
- ':next7days' => lambda do |task| /(#{due_dates_for_queries.join('|')})/.match(task[:due]) end
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: 'new',
228
- title: text,
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 do |num| tasks.delete(num) end
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
- items = {}
375
- tasks.each do |num, task|
376
- match = patterns.uniq.all? do |pattern|
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 do |day| day[0..2] end.index(date.to_s.downcase)
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
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.33
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabor Bata