todo.txt 0.0.8 → 0.0.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.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/todo/cli/archive.rb +3 -3
- data/lib/todo/cli/list.rb +1 -1
- data/lib/todo/cli/push.rb +1 -1
- data/lib/todo/cli/toggle.rb +1 -1
- data/lib/todo/data/item.rb +4 -0
- data/lib/todo/format.rb +7 -5
- data/lib/todo/support/date.rb +1 -1
- data/lib/todo/version.rb +1 -1
- data/spec/todo/format_spec.rb +8 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5b63b055ac551315b984024f1ef75a955c0df45
|
4
|
+
data.tar.gz: 63fd44c8d49144d1938333b42d53d7a2e8d03fed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f83e57cd0ac6eb857a7dd8ee12e87852fcc4aac8d86604effedc4fb933cd5c7579537fa7d67aa6d59d6ae1dd664843e53e5ddb99ac8ecc54dc2fcadb72e11029
|
7
|
+
data.tar.gz: e6a40b432d91e781df79340aab7be09e1f1e66623522de650a1bbea3dd61b4d10974d47fa62705c5b6d0a6798b905ee7b226aebac077dc9205cd908afd897f1f
|
data/README.md
CHANGED
@@ -40,7 +40,8 @@ $ todo toggle foo # should assume ./TODO.txt but i can't figure
|
|
40
40
|
|
41
41
|
# Filtering items
|
42
42
|
|
43
|
-
$ todo list --since 2015-12-01
|
43
|
+
$ todo list --since 2015-12-01 # by done date
|
44
|
+
$ todo list --after 2015-11-01 --before 2015-12-01 # by done date
|
44
45
|
$ todo list --status pending # by status
|
45
46
|
$ todo list --status done # by status
|
46
47
|
$ todo list --project foo # by project
|
data/lib/todo/cli/archive.rb
CHANGED
@@ -14,9 +14,9 @@ module Todo
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def run
|
17
|
-
|
18
|
-
archive.write(format(
|
19
|
-
io.write(format(list.
|
17
|
+
selected = list.select(status: :done, before: before)
|
18
|
+
archive.write(format(selected))
|
19
|
+
io.write(format(list.reject { |item| selected.items.include?(item) }))
|
20
20
|
end
|
21
21
|
|
22
22
|
private
|
data/lib/todo/cli/list.rb
CHANGED
data/lib/todo/cli/push.rb
CHANGED
data/lib/todo/cli/toggle.rb
CHANGED
data/lib/todo/data/item.rb
CHANGED
data/lib/todo/format.rb
CHANGED
@@ -3,7 +3,7 @@ require 'todo/helpers/hash/format'
|
|
3
3
|
require 'todo/helpers/object/presence'
|
4
4
|
|
5
5
|
module Todo
|
6
|
-
class Format < Struct.new(:
|
6
|
+
class Format < Struct.new(:list, :opts)
|
7
7
|
FORMATS = {
|
8
8
|
full: [:status, :text, :tags, :id],
|
9
9
|
short: [:status, :done_date, :text]
|
@@ -12,17 +12,19 @@ module Todo
|
|
12
12
|
include Helpers::Hash::Format, Helpers::Object::Presence
|
13
13
|
|
14
14
|
def apply
|
15
|
-
items.map { |item| format(item) }
|
15
|
+
list.items.map { |item| format(item) }
|
16
16
|
end
|
17
17
|
|
18
18
|
private
|
19
19
|
|
20
20
|
def format(item)
|
21
|
-
cols.map { |col| format_col(col, item
|
21
|
+
cols.map { |col| format_col(col, item) }.compact.join(' ')
|
22
22
|
end
|
23
23
|
|
24
|
-
def format_col(col,
|
25
|
-
|
24
|
+
def format_col(col, item)
|
25
|
+
value = item.send(col)
|
26
|
+
value = list.next_id if item.item? && col == :id && value.nil?
|
27
|
+
send(:"format_#{col}", value) if value
|
26
28
|
end
|
27
29
|
|
28
30
|
def format_status(status)
|
data/lib/todo/support/date.rb
CHANGED
data/lib/todo/version.rb
CHANGED
data/spec/todo/format_spec.rb
CHANGED
@@ -2,8 +2,8 @@ require 'todo/format'
|
|
2
2
|
|
3
3
|
describe Todo::Format do
|
4
4
|
let(:lines) { ['- foo [1]', 'x bar done:2015-12-01 [2]'] }
|
5
|
-
let(:
|
6
|
-
subject { described_class.new(
|
5
|
+
let(:list) { Todo::Data::List.parse(lines) }
|
6
|
+
subject { described_class.new(list, format: format) }
|
7
7
|
|
8
8
|
describe 'default columns' do
|
9
9
|
let(:format) {}
|
@@ -19,4 +19,10 @@ describe Todo::Format do
|
|
19
19
|
let(:format) { :short }
|
20
20
|
it { expect(subject.apply).to eq(['- foo', 'x 2015-12-01 bar']) }
|
21
21
|
end
|
22
|
+
|
23
|
+
describe 'adds missing ids' do
|
24
|
+
let(:format) { :full }
|
25
|
+
let(:lines) { ['- foo', 'x bar done:2015-12-01'] }
|
26
|
+
it { expect(subject.apply).to eq(['- foo [1]', 'x bar done:2015-12-01 [2]']) }
|
27
|
+
end
|
22
28
|
end
|