todo-txt 0.4 → 0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aab28ef27bccaf771aff05bbc5dbff0ac330143f
4
- data.tar.gz: 454ff5faf63eaf1fbec2ed0e25fbb87ae6784c41
3
+ metadata.gz: b5ea0833c5149c1d21070734169a778a83ed3f7b
4
+ data.tar.gz: 724cb858a02a59ad571fc995b8a178192de40241
5
5
  SHA512:
6
- metadata.gz: 25cddbf92e85d098afa16bda2a3cf33a9ed5d8dc7fe60362194c8993b8073f6595838b982ca6e173b884da5cdd009211925270b3bc0e4063874fc0b2b80713f4
7
- data.tar.gz: 2855f72b5b3417517d1126ab35c68c80a96663e8676309f31b5ab853d8a70d1e4406c051159abe317abd051f1fc585097c4ad189f155fceccf167b0921ad74e7
6
+ metadata.gz: 73a69125b40e283c7df6e4498ca590b99b515d7f4ea1494de09be3fe73a1c0cd0ac6c71e45c83685c87fe5dfcb04c8e263f36012cf0e75cde0e8ae7d9e0006d9
7
+ data.tar.gz: 1fc66ed9062ce514ac6e15140f8035ac1ab9d0a955ebc34f51bea1643765e1beedbe11f97389f28171c8554d4edd0eb0c2fe2157f09d9d75c587a7d5bc90d82f
data/.gitignore CHANGED
@@ -1 +1,3 @@
1
1
  .rvmrc
2
+ pkg/
3
+ coverage/
@@ -1,4 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
- - 2.0.0
3
+ rvm:
4
+ - 2.0
5
+ - 2.1
6
+ - 2.2
7
+ - 2.3.0
8
+ - rbx-2
9
+ - jruby-9000
10
+ - jruby-head
11
+ - ruby-head
data/Gemfile CHANGED
@@ -4,6 +4,7 @@ group :test do
4
4
  gem 'rspec'
5
5
  gem 'rake'
6
6
  gem 'timecop'
7
+ gem 'simplecov', :require => false
7
8
  end
8
9
 
9
10
  group :development do
@@ -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
@@ -107,5 +107,4 @@ Tasks without a priority will always be less than a task with a priority.
107
107
 
108
108
  # Requirements
109
109
 
110
- The todo-txt gem requires Ruby 1.9.2 or higher. It doesn't currently run on
111
- 1.8.7.
110
+ The todo-txt gem requires Ruby 1.8.7 or higher.
@@ -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
@@ -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.date
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 due date.
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.date
226
- # #=> # <Date: 2012-03-04 (4911981/2,0,2299161)>
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
@@ -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
@@ -1 +1,4 @@
1
- require_relative '../lib/todo-txt'
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
4
+ require File.join(File.dirname(__FILE__), "../lib/todo-txt.rb")
@@ -1,9 +1,11 @@
1
- require_relative '../spec_helper'
1
+ require File.join(File.dirname(__FILE__), "../spec_helper.rb")
2
2
 
3
3
  describe Todo::List do
4
- # A helper method to grab the test data list.
5
- def list
6
- Todo::List.new(File.dirname(__FILE__) + '/../data/todo.txt')
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
@@ -1,304 +1,324 @@
1
- require_relative '../spec_helper'
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
- it 'should recognise priorities' do
7
- task = Todo::Task.new "(A) Hello world!"
8
- task.priority.should == "A"
9
- end
10
-
11
- it 'should only recognise priorities at the start of a task' do
12
- task = Todo::Task.new "Hello, world! (A)"
13
- task.priority.should == nil
14
- end
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
- it 'should recognize priorities around dates' do
17
- task = Todo::Task.new "x 2012-09-11 (B) 2012-03-04 This is a sweet task. @context +project"
18
- task.priority.should == "B"
19
- end
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
- it 'should recognise contexts' do
22
- task = Todo::Task.new "Hello, world! @test"
23
- task.contexts.should == ["@test"]
24
- end
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
- it 'should recognise multiple contexts' do
27
- task = Todo::Task.new "Hello, world! @test @test2"
28
- task.contexts.should == ["@test", "@test2"]
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
- it 'should recognise projects' do
32
- task = Todo::Task.new "Hello, world! +test"
33
- task.projects.should == ["+test"]
34
- end
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
- it 'should recognise multiple projects' do
37
- task = Todo::Task.new "Hello, world! +test +test2"
38
- task.projects.should == ["+test", "+test2"]
39
- end
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
- it 'should retain the original task' do
42
- task = Todo::Task.new "(A) This is an awesome task, yo. +winning"
43
- task.orig.should == "(A) This is an awesome task, yo. +winning"
44
- end
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
- it 'should be able to get just the text, no contexts etc.' do
47
- task = Todo::Task.new "x 2012-09-11 (B) 2012-03-04 This is a sweet task. @context +project"
48
- task.text.should == "This is a sweet task."
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
- it 'should be comparable' do
52
- task1 = Todo::Task.new "(A) Top priority, y'all!"
53
- task2 = Todo::Task.new "(B) Not quite so high."
54
-
55
- assertion = task1 > task2
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
- it 'should be comparable to task without priority' do
60
- task1 = Todo::Task.new "Top priority, y'all!"
61
- task2 = Todo::Task.new "(B) Not quite so high."
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
- assertion = task1 < task2
64
- assertion.should == true
65
- end
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
- it 'should be able to compare two tasks without priority' do
68
- task1 = Todo::Task.new "Top priority, y'all!"
69
- task2 = Todo::Task.new "Not quite so high."
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
- assertion = task1 == task2
72
- assertion.should == true
73
- end
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
- it 'should be able to recognise dates' do
76
- task = Todo::Task.new "(C) 2012-03-04 This has a date!"
77
- task.created_on.should == Date.parse("4th March 2012")
78
- end
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
- it 'should be able to recognise dates without priority' do
81
- task = Todo::Task.new "2012-03-04 This has a date!"
82
- task.created_on.should == Date.parse("4th March 2012")
83
- end
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
- it 'should return nil if no date is present' do
86
- task = Todo::Task.new "No date!"
87
- task.created_on.should be_nil
88
- end
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
- it 'should not recognise malformed dates' do
91
- task = Todo::Task.new "03-04-2012 This has a malformed date!"
92
- task.created_on.should be_nil
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
- it 'should be able to tell if the task is overdue' do
96
- task = Todo::Task.new((Date.today - 1).to_s + " This task is overdue!")
97
- task.overdue?.should be_false
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
- it 'should return false on overdue? if there is no date' do
101
- task = Todo::Task.new "No date!"
102
- task.overdue?.should be_false
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
- it 'should return nil on ridiculous date data' do
106
- task = Todo::Task.new "2012-56-99 This has a malformed date!"
107
- task.created_on.should be_nil
108
- end
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
- it 'should be able to recognise completed tasks' do
111
- task = Todo::Task.new "x 2012-12-08 This is done!"
112
- task.done?.should be_true
113
- end
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
- it 'should not recognize incomplete tasks as done' do
116
- task = Todo::Task.new "2012-12-08 This ain't done!"
117
- task.done?.should be_false
118
- end
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
- it 'should be completable' do
121
- task = Todo::Task.new "2012-12-08 This ain't done!"
122
- task.do!
123
- task.done?.should be_true
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
- it 'should be marked as incomplete' do
127
- task = Todo::Task.new "x 2012-12-08 This is done!"
128
- task.undo!
129
- task.done?.should be_false
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
- it 'should be marked as incomplete without any date' do
133
- task = Todo::Task.new "x 2012-12-08 This is done!"
134
- task.undo!
135
- task.completed_on.should be_nil
136
- task.created_on.should be_nil
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
- it 'should be toggable' do
140
- task = Todo::Task.new "2012-12-08 This ain't done!"
141
- task.toggle!
142
- task.done?.should be_true
143
- task.toggle!
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
- it 'should be able to recognise completion dates' do
148
- task = Todo::Task.new "x 2012-12-08 This is done!"
149
- task.completed_on.should == Date.parse("8th December 2012")
150
- end
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
- it 'should remove the priority when calling Task#do!' do
153
- task = Todo::Task.new "(A) Task"
154
- task.do!
155
- task.priority.should be_nil
156
- end
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
- it 'should reset to the original priority when calling Task#undo!' do
159
- task = Todo::Task.new "(A) Task"
160
- task.do!
161
- task.undo!
162
- task.priority.should == "A"
163
- end
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
- it 'should set the current completion dates when calling Task#do!' do
166
- task = Todo::Task.new "2012-12-08 Task"
167
- Timecop.freeze(2013, 12, 8) do
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
- it 'should reset to the original due date when calling Task#undo!' do
174
- task = Todo::Task.new "2012-12-08 Task"
175
- Timecop.freeze(2013, 12, 8) do
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
- it 'should manage dates when calling Task#toggle!' do
183
- task = Todo::Task.new "2012-12-08 This ain't done!"
184
- Timecop.freeze(2013, 12, 8) do
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
- it 'should convert to a string' do
195
- task = Todo::Task.new "(A) 2012-12-08 My task @test +test2"
196
- task.to_s.should == "(A) 2012-12-08 My task @test +test2"
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
- end
206
-
207
- it 'should show be modifiable' do
208
- task = Todo::Task.new "2012-12-08 My task @test +test2"
209
- task.projects.clear
210
- task.contexts << ["@test3"]
211
- Timecop.freeze(2013, 12, 8) do
212
- task.do!
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
- it 'should be not done with missing date' do
218
- task = Todo::Task.new "x This is not done"
219
- task.done?.should be false
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
- it 'should be not done with malformed date' do
223
- task = Todo::Task.new "x 01-01-2013 This is not done"
224
- task.done?.should be false
225
- task.completed_on.should be nil
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
- it 'should be not done with an invalid date' do
229
- task = Todo::Task.new "x 2013-02-31 This is not done"
230
- task.done?.should be false
231
- task.completed_on.should be nil
232
- end
286
+ assertion = task1 > task2
287
+ assertion.should == true
288
+ end
233
289
 
234
- it 'should be done on 2013-04-22' do
235
- task = Todo::Task.new "x 2013-04-22 This is really done"
236
- task.done?.should be true
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
- its 'should have a due date' do
241
- task = Todo::Task.new '(A) this task has due date due:2013-12-22'
242
- task.due_on.should_not be_nil
243
- end
294
+ assertion = task1 < task2
295
+ assertion.should == true
296
+ end
244
297
 
245
- it 'should due on 2013-12-22' do
246
- task = Todo::Task.new '(A) this task has due date due:2013-12-22'
247
- task.due_on.should == Date.parse('22th December 2013')
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
- it 'should not be overdue on 2013-12-01' do
251
- task = Todo::Task.new '(A) this task has due date due:2013-12-22'
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
- it 'should be overdue on 2013-12-23' do
258
- task = Todo::Task.new '(A) this task has due date due:2013-12-22'
259
- Timecop.freeze(2013, 12, 23) do
260
- task.overdue?.should be_true
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
- it 'should convert to a string with due date' do
270
- task = Todo::Task.new "x 2012-09-11 (B) 2012-03-04 This is a sweet task. @context due:2012-01-01 +project"
271
- task.to_s.should == "x 2012-09-11 (B) 2012-03-04 This is a sweet task. @context +project due:2012-01-01"
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
- it 'should have no due date with invalid date' do
280
- task = Todo::Task.new "x 2012-09-11 (B) 2012-03-04 This is a sweet task. @context due:2012-02-31 +project"
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
- it 'should recognize DUE:2013-12-22 (case insensitive)' do
285
- task = Todo::Task.new '(A) this task has due date DUE:2013-12-22'
286
- task.due_on.should == Date.parse('22th December 2013')
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
@@ -1,12 +1,12 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{todo-txt}
3
- s.version = "0.4"
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.2'
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'
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: 2013-11-15 00:00:00.000000000 Z
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.9.2
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.0.3
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: