todo-txt 0.4 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +9 -2
- data/Gemfile +1 -0
- data/Gemfile.lock +6 -0
- data/README.md +1 -2
- data/lib/todo-txt/list.rb +21 -0
- data/lib/todo-txt/task.rb +9 -10
- data/spec/data/todo.txt +2 -0
- data/spec/spec_helper.rb +4 -1
- data/spec/todo-txt/list_spec.rb +33 -4
- data/spec/todo-txt/task_spec.rb +260 -240
- data/todo-txt.gemspec +2 -2
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5ea0833c5149c1d21070734169a778a83ed3f7b
|
4
|
+
data.tar.gz: 724cb858a02a59ad571fc995b8a178192de40241
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73a69125b40e283c7df6e4498ca590b99b515d7f4ea1494de09be3fe73a1c0cd0ac6c71e45c83685c87fe5dfcb04c8e263f36012cf0e75cde0e8ae7d9e0006d9
|
7
|
+
data.tar.gz: 1fc66ed9062ce514ac6e15140f8035ac1ab9d0a955ebc34f51bea1643765e1beedbe11f97389f28171c8554d4edd0eb0c2fe2157f09d9d75c587a7d5bc90d82f
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,6 +2,7 @@ GEM
|
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
4
|
diff-lcs (1.1.3)
|
5
|
+
multi_json (1.8.0)
|
5
6
|
rake (0.9.2.2)
|
6
7
|
rspec (2.9.0)
|
7
8
|
rspec-core (~> 2.9.0)
|
@@ -11,6 +12,10 @@ GEM
|
|
11
12
|
rspec-expectations (2.9.1)
|
12
13
|
diff-lcs (~> 1.1.3)
|
13
14
|
rspec-mocks (2.9.0)
|
15
|
+
simplecov (0.7.1)
|
16
|
+
multi_json (~> 1.0)
|
17
|
+
simplecov-html (~> 0.7.1)
|
18
|
+
simplecov-html (0.7.1)
|
14
19
|
timecop (0.6.1)
|
15
20
|
|
16
21
|
PLATFORMS
|
@@ -20,4 +25,5 @@ DEPENDENCIES
|
|
20
25
|
bundler
|
21
26
|
rake
|
22
27
|
rspec
|
28
|
+
simplecov
|
23
29
|
timecop
|
data/README.md
CHANGED
data/lib/todo-txt/list.rb
CHANGED
@@ -83,5 +83,26 @@ module Todo
|
|
83
83
|
def by_project project
|
84
84
|
Todo::List.new self.select { |task| task.projects.include? project }
|
85
85
|
end
|
86
|
+
|
87
|
+
# Filters the list by completed tasks and returns a new list.
|
88
|
+
#
|
89
|
+
# Example:
|
90
|
+
#
|
91
|
+
# list = Todo::List.new "/path/to/list"
|
92
|
+
# list.by_done #=> Will be a new list with only tasks marked with
|
93
|
+
# an [x]
|
94
|
+
def by_done
|
95
|
+
Todo::List.new self.select { |task| task.done? }
|
96
|
+
end
|
97
|
+
|
98
|
+
# Filters the list by incomplete tasks and returns a new list.
|
99
|
+
#
|
100
|
+
# Example:
|
101
|
+
#
|
102
|
+
# list = Todo::List.new "/path/to/list"
|
103
|
+
# list.by_not_done #=> Will be a new list with only incomplete tasks
|
104
|
+
def by_not_done
|
105
|
+
Todo::List.new self.select { |task| task.done? == false }
|
106
|
+
end
|
86
107
|
end
|
87
108
|
end
|
data/lib/todo-txt/task.rb
CHANGED
@@ -20,11 +20,6 @@ module Todo
|
|
20
20
|
/(?:^|\s+)\(([A-Za-z])\)\s+/
|
21
21
|
end
|
22
22
|
|
23
|
-
# The regex used to match dates.
|
24
|
-
def self.date_regex
|
25
|
-
/(?:\s+|^)([0-9]{4}-[0-9]{2}-[0-9]{2})/
|
26
|
-
end
|
27
|
-
|
28
23
|
# The regex used to match creation date.
|
29
24
|
def self.created_on_regex
|
30
25
|
/(?:^|-\d{2}\s|\)\s)(\d{4}-\d{2}-\d{2})\s/
|
@@ -204,26 +199,30 @@ module Todo
|
|
204
199
|
# task.do!
|
205
200
|
# task.done?
|
206
201
|
# #=> true
|
207
|
-
# task.
|
202
|
+
# task.created_on
|
203
|
+
# #=> <Date: 2012-12-08 (4911981/2,0,2299161)>
|
204
|
+
# task.completed_on
|
208
205
|
# #=> # the current date
|
209
206
|
def do!
|
210
207
|
@completed_on = Date.today
|
211
208
|
@priority = nil
|
212
209
|
end
|
213
210
|
|
214
|
-
# Marks the task as incomplete and resets its original
|
211
|
+
# Marks the task as incomplete and resets its original priority.
|
215
212
|
#
|
216
213
|
# Example:
|
217
214
|
#
|
218
|
-
# task = Todo::Task.new "x 2012-12-08 Task."
|
215
|
+
# task = Todo::Task.new "x 2012-12-08 2012-03-04 Task."
|
219
216
|
# task.done?
|
220
217
|
# #=> true
|
221
218
|
#
|
222
219
|
# task.undo!
|
223
220
|
# task.done?
|
224
221
|
# #=> false
|
225
|
-
# task.
|
226
|
-
# #=>
|
222
|
+
# task.created_on
|
223
|
+
# #=> <Date: 2012-03-04 (4911981/2,0,2299161)>
|
224
|
+
# task.completed_on
|
225
|
+
# #=> nil
|
227
226
|
def undo!
|
228
227
|
@completed_on = nil
|
229
228
|
@priority = orig_priority
|
data/spec/data/todo.txt
CHANGED
@@ -7,3 +7,5 @@ Just a POD: Plain old task.
|
|
7
7
|
(B) 2012-03-04 +project @context This one has a date and a context AND a project!
|
8
8
|
2012-04-03 This one has no priority and a date.
|
9
9
|
03-04-2012 This one has a malformed date.
|
10
|
+
x 2015-01-09 This task is completed and has a completion date
|
11
|
+
x 2015-01-09 2015-01-08 This task is completed and has created and completion dates
|
data/spec/spec_helper.rb
CHANGED
data/spec/todo-txt/list_spec.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
|
1
|
+
require File.join(File.dirname(__FILE__), "../spec_helper.rb")
|
2
2
|
|
3
3
|
describe Todo::List do
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
let(:path) { File.dirname(__FILE__) + '/../data/todo.txt' }
|
5
|
+
let(:list) { Todo::List.new(path) }
|
6
|
+
|
7
|
+
it 'should have the correct path' do
|
8
|
+
list.path.should == path
|
7
9
|
end
|
8
10
|
|
9
11
|
it 'should grab a list of Todo::Tasks' do
|
@@ -57,6 +59,22 @@ describe Todo::List do
|
|
57
59
|
filtered.length.should be > 0
|
58
60
|
end
|
59
61
|
|
62
|
+
it 'should be able to filter by done' do
|
63
|
+
list.by_done.each do |task|
|
64
|
+
task.text.should include 'This task is completed'
|
65
|
+
end
|
66
|
+
|
67
|
+
list.by_done.length.should be == 2
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should be able to filter by not done' do
|
71
|
+
list.by_not_done.each do |task|
|
72
|
+
task.text.should_not include 'This task is completed'
|
73
|
+
end
|
74
|
+
|
75
|
+
list.by_not_done.length.should be == 9
|
76
|
+
end
|
77
|
+
|
60
78
|
it 'should be sortable' do
|
61
79
|
list.sort.each_cons(2) do |task_a, task_b|
|
62
80
|
task_a.should be <= task_b
|
@@ -69,4 +87,15 @@ describe Todo::List do
|
|
69
87
|
# This assertion currently fails. TODO.
|
70
88
|
# list.sort.should be_a Todo::List
|
71
89
|
end
|
90
|
+
|
91
|
+
describe 'manual list creation' do
|
92
|
+
it 'should be possible with a mix of tasks and strings' do
|
93
|
+
l = Todo::List.new([
|
94
|
+
"A task!",
|
95
|
+
Todo::Task.new("Another task!"),
|
96
|
+
])
|
97
|
+
|
98
|
+
l.length.should == 2
|
99
|
+
end
|
100
|
+
end
|
72
101
|
end
|
data/spec/todo-txt/task_spec.rb
CHANGED
@@ -1,304 +1,324 @@
|
|
1
|
-
|
1
|
+
require File.join(File.dirname(__FILE__), "../spec_helper.rb")
|
2
2
|
require 'date'
|
3
3
|
require 'timecop'
|
4
4
|
|
5
5
|
describe Todo::Task do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
describe "Descriptions:" do
|
7
|
+
it 'should convert to a string' do
|
8
|
+
task = Todo::Task.new "(A) 2012-12-08 My task @test +test2"
|
9
|
+
task.to_s.should == "(A) 2012-12-08 My task @test +test2"
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should keep track of the original string after changing the task' do
|
13
|
+
task = Todo::Task.new "(A) 2012-12-08 My task @test +test2"
|
14
|
+
Timecop.freeze(2013, 12, 8) do
|
15
|
+
task.do!
|
16
|
+
task.orig.should == "(A) 2012-12-08 My task @test +test2"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should be modifiable' do
|
21
|
+
task = Todo::Task.new "2012-12-08 My task @test +test2"
|
22
|
+
task.projects.clear
|
23
|
+
task.contexts << ["@test3"]
|
24
|
+
Timecop.freeze(2013, 12, 8) do
|
25
|
+
task.do!
|
26
|
+
task.to_s.should == "x 2013-12-08 2012-12-08 My task @test @test3"
|
27
|
+
end
|
28
|
+
end
|
15
29
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
30
|
+
it 'should be able to get just the text, no due date etc.' do
|
31
|
+
task = Todo::Task.new "x 2012-09-11 (B) 2012-03-04 This is a sweet task. @context due:2012-01-01 +project"
|
32
|
+
task.text.should == "This is a sweet task."
|
33
|
+
end
|
20
34
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
35
|
+
it 'should retain the original task creation string' do
|
36
|
+
task = Todo::Task.new "(A) This is an awesome task, yo. +winning"
|
37
|
+
task.orig.should == "(A) This is an awesome task, yo. +winning"
|
38
|
+
end
|
25
39
|
|
26
|
-
|
27
|
-
|
28
|
-
|
40
|
+
it 'should be able to get just the text, no contexts etc.' do
|
41
|
+
task = Todo::Task.new "x 2012-09-11 (B) 2012-03-04 This is a sweet task. @context +project"
|
42
|
+
task.text.should == "This is a sweet task."
|
43
|
+
end
|
29
44
|
end
|
45
|
+
|
46
|
+
describe "Priorities:" do
|
47
|
+
it 'should recognise priorities' do
|
48
|
+
task = Todo::Task.new "(A) Hello world!"
|
49
|
+
task.priority.should == "A"
|
50
|
+
end
|
30
51
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
52
|
+
it 'should only recognise priorities at the start of a task' do
|
53
|
+
task = Todo::Task.new "Hello, world! (A)"
|
54
|
+
task.priority.should == nil
|
55
|
+
end
|
35
56
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
57
|
+
it 'should recognize priorities around dates' do
|
58
|
+
task = Todo::Task.new "x 2012-09-11 (B) 2012-03-04 This is a sweet task. @context +project"
|
59
|
+
task.priority.should == "B"
|
60
|
+
end
|
40
61
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
62
|
+
it 'should remove the priority when calling Task#do!' do
|
63
|
+
task = Todo::Task.new "(A) Task"
|
64
|
+
task.do!
|
65
|
+
task.priority.should be_nil
|
66
|
+
end
|
45
67
|
|
46
|
-
|
47
|
-
|
48
|
-
|
68
|
+
it 'should reset to the original priority when calling Task#undo!' do
|
69
|
+
task = Todo::Task.new "(A) Task"
|
70
|
+
task.do!
|
71
|
+
task.undo!
|
72
|
+
task.priority.should == "A"
|
73
|
+
end
|
49
74
|
end
|
50
75
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
assertion.should == true
|
57
|
-
end
|
76
|
+
describe "Completion:" do
|
77
|
+
it 'should be not done with missing date' do
|
78
|
+
task = Todo::Task.new "x This is not done"
|
79
|
+
task.done?.should be false
|
80
|
+
end
|
58
81
|
|
59
|
-
|
60
|
-
|
61
|
-
|
82
|
+
it 'should be not done with malformed date' do
|
83
|
+
task = Todo::Task.new "x 01-01-2013 This is not done"
|
84
|
+
task.done?.should be false
|
85
|
+
task.completed_on.should be nil
|
86
|
+
end
|
62
87
|
|
63
|
-
|
64
|
-
|
65
|
-
|
88
|
+
it 'should be not done with an invalid date' do
|
89
|
+
task = Todo::Task.new "x 2013-02-31 This is not done"
|
90
|
+
task.done?.should be false
|
91
|
+
task.completed_on.should be nil
|
92
|
+
end
|
66
93
|
|
67
|
-
|
68
|
-
|
69
|
-
|
94
|
+
it 'should be done on 2013-04-22' do
|
95
|
+
task = Todo::Task.new "x 2013-04-22 This is really done"
|
96
|
+
task.done?.should be true
|
97
|
+
task.completed_on.should == Date.parse('22th April 2013')
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should be able to recognise completed tasks' do
|
101
|
+
task = Todo::Task.new "x 2012-12-08 This is done!"
|
102
|
+
task.done?.should be_true
|
103
|
+
end
|
70
104
|
|
71
|
-
|
72
|
-
|
73
|
-
|
105
|
+
it 'should not recognize incomplete tasks as done' do
|
106
|
+
task = Todo::Task.new "2012-12-08 This ain't done!"
|
107
|
+
task.done?.should be_false
|
108
|
+
end
|
74
109
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
110
|
+
it 'should be completable' do
|
111
|
+
task = Todo::Task.new "2012-12-08 This ain't done!"
|
112
|
+
task.do!
|
113
|
+
task.done?.should be_true
|
114
|
+
end
|
79
115
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
116
|
+
it 'should be marked as incomplete' do
|
117
|
+
task = Todo::Task.new "x 2012-12-08 This is done!"
|
118
|
+
task.undo!
|
119
|
+
task.done?.should be_false
|
120
|
+
end
|
84
121
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
122
|
+
it 'should be marked as incomplete without any date' do
|
123
|
+
task = Todo::Task.new "x 2012-12-08 This is done!"
|
124
|
+
task.undo!
|
125
|
+
task.completed_on.should be_nil
|
126
|
+
task.created_on.should be_nil
|
127
|
+
end
|
89
128
|
|
90
|
-
|
91
|
-
|
92
|
-
|
129
|
+
it 'should be toggable' do
|
130
|
+
task = Todo::Task.new "2012-12-08 This ain't done!"
|
131
|
+
task.toggle!
|
132
|
+
task.done?.should be_true
|
133
|
+
task.toggle!
|
134
|
+
task.done?.should be_false
|
135
|
+
end
|
93
136
|
end
|
137
|
+
|
138
|
+
describe "Contexts:" do
|
139
|
+
it 'should recognise contexts' do
|
140
|
+
task = Todo::Task.new "Hello, world! @test"
|
141
|
+
task.contexts.should == ["@test"]
|
142
|
+
end
|
94
143
|
|
95
|
-
|
96
|
-
|
97
|
-
|
144
|
+
it 'should recognise multiple contexts' do
|
145
|
+
task = Todo::Task.new "Hello, world! @test @test2"
|
146
|
+
task.contexts.should == ["@test", "@test2"]
|
147
|
+
end
|
98
148
|
end
|
149
|
+
|
150
|
+
describe "Projects:" do
|
151
|
+
it 'should recognise projects' do
|
152
|
+
task = Todo::Task.new "Hello, world! +test"
|
153
|
+
task.projects.should == ["+test"]
|
154
|
+
end
|
99
155
|
|
100
|
-
|
101
|
-
|
102
|
-
|
156
|
+
it 'should recognise multiple projects' do
|
157
|
+
task = Todo::Task.new "Hello, world! +test +test2"
|
158
|
+
task.projects.should == ["+test", "+test2"]
|
159
|
+
end
|
103
160
|
end
|
161
|
+
|
162
|
+
describe "Creation dates:" do
|
163
|
+
it 'should be able to recognise creation dates' do
|
164
|
+
task = Todo::Task.new "(C) 2012-03-04 This has a date!"
|
165
|
+
task.created_on.should == Date.parse("4th March 2012")
|
166
|
+
end
|
104
167
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
168
|
+
it 'should be able to recognise creation dates without priority' do
|
169
|
+
task = Todo::Task.new "2012-03-04 This has a date!"
|
170
|
+
task.created_on.should == Date.parse("4th March 2012")
|
171
|
+
end
|
109
172
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
173
|
+
it 'should return nil if no creation date is present' do
|
174
|
+
task = Todo::Task.new "No date!"
|
175
|
+
task.created_on.should be_nil
|
176
|
+
end
|
114
177
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
178
|
+
it 'should not recognise malformed dates' do
|
179
|
+
task = Todo::Task.new "03-04-2012 This has a malformed date!"
|
180
|
+
task.created_on.should be_nil
|
181
|
+
end
|
182
|
+
|
183
|
+
it 'should be able to tell if the task is overdue' do
|
184
|
+
task = Todo::Task.new((Date.today - 1).to_s + " This task is overdue!")
|
185
|
+
task.overdue?.should be_false
|
186
|
+
end
|
119
187
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
end
|
188
|
+
it 'should return false on overdue? if there is no creation date' do
|
189
|
+
task = Todo::Task.new "No date!"
|
190
|
+
task.overdue?.should be_false
|
191
|
+
end
|
125
192
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
193
|
+
it 'should return nil on ridiculous date data' do
|
194
|
+
task = Todo::Task.new "2012-56-99 This has a malformed date!"
|
195
|
+
task.created_on.should be_nil
|
196
|
+
end
|
130
197
|
end
|
198
|
+
|
199
|
+
describe "Completion dates:" do
|
200
|
+
it 'should be able to recognise completion dates' do
|
201
|
+
task = Todo::Task.new "x 2012-12-08 This is done!"
|
202
|
+
task.completed_on.should == Date.parse("8th December 2012")
|
203
|
+
end
|
131
204
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
205
|
+
it 'should set the current completion dates when calling Task#do!' do
|
206
|
+
task = Todo::Task.new "2012-12-08 Task"
|
207
|
+
Timecop.freeze(2013, 12, 8) do
|
208
|
+
task.do!
|
209
|
+
task.completed_on.should == Date.parse("8th December 2013")
|
210
|
+
end
|
211
|
+
end
|
137
212
|
end
|
138
213
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
task.done?.should be_false
|
145
|
-
end
|
214
|
+
describe "Due dates:" do
|
215
|
+
its 'should have a due date' do
|
216
|
+
task = Todo::Task.new '(A) this task has due date due:2013-12-22'
|
217
|
+
task.due_on.should_not be_nil
|
218
|
+
end
|
146
219
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
220
|
+
it 'should due on 2013-12-22' do
|
221
|
+
task = Todo::Task.new '(A) this task has due date due:2013-12-22'
|
222
|
+
task.due_on.should == Date.parse('22th December 2013')
|
223
|
+
end
|
151
224
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
225
|
+
it 'should not be overdue on 2013-12-01' do
|
226
|
+
task = Todo::Task.new '(A) this task has due date due:2013-12-22'
|
227
|
+
Timecop.freeze(2013, 12, 01) do
|
228
|
+
task.overdue?.should be_false
|
229
|
+
end
|
230
|
+
end
|
157
231
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
232
|
+
it 'should be overdue on 2013-12-23' do
|
233
|
+
task = Todo::Task.new '(A) this task has due date due:2013-12-22'
|
234
|
+
Timecop.freeze(2013, 12, 23) do
|
235
|
+
task.overdue?.should be_true
|
236
|
+
end
|
237
|
+
end
|
164
238
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
task.do!
|
169
|
-
task.completed_on.should == Date.parse("8th December 2013")
|
239
|
+
it 'should convert to a string with due date' do
|
240
|
+
task = Todo::Task.new "x 2012-09-11 (B) 2012-03-04 This is a sweet task. @context due:2012-01-01 +project"
|
241
|
+
task.to_s.should == "x 2012-09-11 (B) 2012-03-04 This is a sweet task. @context +project due:2012-01-01"
|
170
242
|
end
|
171
|
-
end
|
172
243
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
task.do!
|
177
|
-
task.undo!
|
178
|
-
task.created_on.should == Date.parse("8th December 2012")
|
244
|
+
it 'should have no due date with malformed date' do
|
245
|
+
task = Todo::Task.new "x 2012-09-11 (B) 2012-03-04 This is a sweet task. @context due:01-01-2012 +project"
|
246
|
+
task.due_on.should be_nil
|
179
247
|
end
|
180
|
-
end
|
181
248
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
task.toggle!
|
186
|
-
task.completed_on.should == Date.parse("8th December 2013")
|
187
|
-
task.created_on.should == Date.parse("8th December 2012")
|
188
|
-
task.toggle!
|
189
|
-
task.created_on.should == Date.parse("8th December 2012")
|
190
|
-
task.completed_on.should be_nil
|
249
|
+
it 'should have no due date with invalid date' do
|
250
|
+
task = Todo::Task.new "x 2012-09-11 (B) 2012-03-04 This is a sweet task. @context due:2012-02-31 +project"
|
251
|
+
task.due_on.should be_nil
|
191
252
|
end
|
192
|
-
end
|
193
253
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
end
|
198
|
-
|
199
|
-
it 'should keep track of the original string after changing the task' do
|
200
|
-
task = Todo::Task.new "(A) 2012-12-08 My task @test +test2"
|
201
|
-
Timecop.freeze(2013, 12, 8) do
|
202
|
-
task.do!
|
203
|
-
task.orig.should == "(A) 2012-12-08 My task @test +test2"
|
254
|
+
it 'should recognize DUE:2013-12-22 (case insensitive)' do
|
255
|
+
task = Todo::Task.new '(A) this task has due date DUE:2013-12-22'
|
256
|
+
task.due_on.should == Date.parse('22th December 2013')
|
204
257
|
end
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
task.to_s.should == "x 2013-12-08 2012-12-08 My task @test @test3"
|
258
|
+
|
259
|
+
it 'should reset to the original due date when calling Task#undo!' do
|
260
|
+
task = Todo::Task.new "2012-12-08 Task"
|
261
|
+
Timecop.freeze(2013, 12, 8) do
|
262
|
+
task.do!
|
263
|
+
task.undo!
|
264
|
+
task.created_on.should == Date.parse("8th December 2012")
|
265
|
+
end
|
214
266
|
end
|
215
|
-
end
|
216
267
|
|
217
|
-
|
218
|
-
|
219
|
-
|
268
|
+
it 'should manage dates when calling Task#toggle!' do
|
269
|
+
task = Todo::Task.new "2012-12-08 This ain't done!"
|
270
|
+
Timecop.freeze(2013, 12, 8) do
|
271
|
+
task.toggle!
|
272
|
+
task.completed_on.should == Date.parse("8th December 2013")
|
273
|
+
task.created_on.should == Date.parse("8th December 2012")
|
274
|
+
task.toggle!
|
275
|
+
task.created_on.should == Date.parse("8th December 2012")
|
276
|
+
task.completed_on.should be_nil
|
277
|
+
end
|
278
|
+
end
|
220
279
|
end
|
221
280
|
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
end
|
281
|
+
describe "Comparisons:" do
|
282
|
+
it 'should be comparable' do
|
283
|
+
task1 = Todo::Task.new "(A) Top priority, y'all!"
|
284
|
+
task2 = Todo::Task.new "(B) Not quite so high."
|
227
285
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
task.completed_on.should be nil
|
232
|
-
end
|
286
|
+
assertion = task1 > task2
|
287
|
+
assertion.should == true
|
288
|
+
end
|
233
289
|
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
task.completed_on.should == Date.parse('22th April 2013')
|
238
|
-
end
|
290
|
+
it 'should be comparable to task without priority' do
|
291
|
+
task1 = Todo::Task.new "Top priority, y'all!"
|
292
|
+
task2 = Todo::Task.new "(B) Not quite so high."
|
239
293
|
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
end
|
294
|
+
assertion = task1 < task2
|
295
|
+
assertion.should == true
|
296
|
+
end
|
244
297
|
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
end
|
298
|
+
it 'should be able to compare two tasks without priority' do
|
299
|
+
task1 = Todo::Task.new "Top priority, y'all!"
|
300
|
+
task2 = Todo::Task.new "Not quite so high."
|
249
301
|
|
250
|
-
|
251
|
-
|
252
|
-
Timecop.freeze(2013, 12, 01) do
|
253
|
-
task.overdue?.should be_false
|
302
|
+
assertion = task1 == task2
|
303
|
+
assertion.should == true
|
254
304
|
end
|
255
305
|
end
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
task.
|
306
|
+
|
307
|
+
describe "Logging:" do
|
308
|
+
it 'should have a logger' do
|
309
|
+
task = Todo::Task.new "x 2012-09-11 (B) 2012-03-04 This is a sweet task. @context due:2012-02-31 +project"
|
310
|
+
task.logger.should_not be nil
|
261
311
|
end
|
262
|
-
end
|
263
|
-
|
264
|
-
it 'should be able to get just the text, no due date etc.' do
|
265
|
-
task = Todo::Task.new "x 2012-09-11 (B) 2012-03-04 This is a sweet task. @context due:2012-01-01 +project"
|
266
|
-
task.text.should == "This is a sweet task."
|
267
|
-
end
|
268
312
|
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
end
|
273
|
-
|
274
|
-
it 'should have no due date with malformed date' do
|
275
|
-
task = Todo::Task.new "x 2012-09-11 (B) 2012-03-04 This is a sweet task. @context due:01-01-2012 +project"
|
276
|
-
task.due_on.should be_nil
|
277
|
-
end
|
313
|
+
it 'should call @logger.warn if #date called as deprecated method' do
|
314
|
+
logger = double(Logger)
|
315
|
+
Todo::Logger.logger = logger
|
278
316
|
|
279
|
-
|
280
|
-
|
281
|
-
task.due_on.should be_nil
|
282
|
-
end
|
317
|
+
task = Todo::Task.new "x 2012-09-11 (B) 2012-03-04 This is a sweet task. @context due:2012-02-31 +project"
|
318
|
+
error_message = 'Task#date is deprecated, use created_on instead.'
|
283
319
|
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
end
|
288
|
-
|
289
|
-
it 'should have a logger' do
|
290
|
-
task = Todo::Task.new "x 2012-09-11 (B) 2012-03-04 This is a sweet task. @context due:2012-02-31 +project"
|
291
|
-
task.logger.should_not be nil
|
292
|
-
end
|
293
|
-
|
294
|
-
it 'should call @logger.warn if #date called as deprecated method' do
|
295
|
-
logger = double(Logger)
|
296
|
-
Todo::Logger.logger = logger
|
297
|
-
|
298
|
-
task = Todo::Task.new "x 2012-09-11 (B) 2012-03-04 This is a sweet task. @context due:2012-02-31 +project"
|
299
|
-
error_message = 'Task#date is deprecated, use created_on instead.'
|
300
|
-
|
301
|
-
logger.should_receive(:warn).with(error_message)
|
302
|
-
task.date
|
320
|
+
logger.should_receive(:warn).with(error_message)
|
321
|
+
task.date
|
322
|
+
end
|
303
323
|
end
|
304
324
|
end
|
data/todo-txt.gemspec
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{todo-txt}
|
3
|
-
s.version = "0.
|
3
|
+
s.version = "0.5"
|
4
4
|
s.authors = ["Sam Rose"]
|
5
5
|
s.email = %q{samwho@lbak.co.uk}
|
6
6
|
s.summary = %q{A client library for parsing todo.txt files.}
|
7
7
|
s.homepage = %q{http://github.com/samwho/todo-txt-gem}
|
8
8
|
s.description = %q{Allows for simple parsing of todo.txt files, as per Gina Trapani's todo.txt project.}
|
9
|
-
s.required_ruby_version = '>= 1.
|
9
|
+
s.required_ruby_version = '>= 1.8.7'
|
10
10
|
s.license = 'GPL-2'
|
11
11
|
|
12
12
|
# Add all files to the files parameter.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: todo-txt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Rose
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Allows for simple parsing of todo.txt files, as per Gina Trapani's todo.txt
|
14
14
|
project.
|
@@ -17,9 +17,9 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
- .gemtest
|
21
|
-
- .gitignore
|
22
|
-
- .travis.yml
|
20
|
+
- ".gemtest"
|
21
|
+
- ".gitignore"
|
22
|
+
- ".travis.yml"
|
23
23
|
- Gemfile
|
24
24
|
- Gemfile.lock
|
25
25
|
- LICENSE
|
@@ -44,18 +44,19 @@ require_paths:
|
|
44
44
|
- lib
|
45
45
|
required_ruby_version: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- -
|
47
|
+
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 1.
|
49
|
+
version: 1.8.7
|
50
50
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
requirements: []
|
56
56
|
rubyforge_project:
|
57
|
-
rubygems_version: 2.
|
57
|
+
rubygems_version: 2.2.2
|
58
58
|
signing_key:
|
59
59
|
specification_version: 4
|
60
60
|
summary: A client library for parsing todo.txt files.
|
61
61
|
test_files: []
|
62
|
+
has_rdoc:
|