todo-txt 0.5 → 0.6

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: b5ea0833c5149c1d21070734169a778a83ed3f7b
4
- data.tar.gz: 724cb858a02a59ad571fc995b8a178192de40241
3
+ metadata.gz: 87c3206db6b8a924eeedaaee0699cbaa9a63ea0f
4
+ data.tar.gz: ba6c31c870bd51c7a191a250bf20c9e1a8fbb5ea
5
5
  SHA512:
6
- metadata.gz: 73a69125b40e283c7df6e4498ca590b99b515d7f4ea1494de09be3fe73a1c0cd0ac6c71e45c83685c87fe5dfcb04c8e263f36012cf0e75cde0e8ae7d9e0006d9
7
- data.tar.gz: 1fc66ed9062ce514ac6e15140f8035ac1ab9d0a955ebc34f51bea1643765e1beedbe11f97389f28171c8554d4edd0eb0c2fe2157f09d9d75c587a7d5bc90d82f
6
+ metadata.gz: 0ee77ef0490c7b423a52f779b810af66521ed1ed253560cd08c5a1b207102fcf36e4ab6d3f78666039c49d748c27e9d96d2149e28eeb0d2b3ad60e7cc6307760
7
+ data.tar.gz: 82050a6db87b76ef1c3ab51c428d26b7f045242628eeebbd3817b1c884634f73f159004435db20b9967bf40feb99a0d043afb4dab5502d9d7389417ba32909f9
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  .rvmrc
2
2
  pkg/
3
3
  coverage/
4
+ Gemfile.lock
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  group :test do
4
- gem 'rspec'
4
+ gem 'rspec', '~> 3.4'
5
5
  gem 'rake'
6
6
  gem 'timecop'
7
7
  gem 'simplecov', :require => false
data/Rakefile CHANGED
@@ -5,6 +5,4 @@ require 'rspec/core/rake_task'
5
5
  task :default => [:test]
6
6
 
7
7
  desc "Run all tests"
8
- RSpec::Core::RakeTask.new(:test) do |t|
9
- t.rspec_opts = '-cfs'
10
- end
8
+ RSpec::Core::RakeTask.new(:test)
data/lib/todo-txt.rb CHANGED
@@ -3,5 +3,6 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  require 'logger'
5
5
  require 'todo-txt/logger'
6
+ require 'todo-txt/syntax'
6
7
  require 'todo-txt/list'
7
8
  require 'todo-txt/task'
@@ -0,0 +1,33 @@
1
+ module Todo
2
+ module Syntax
3
+ # The regular expression used to match contexts.
4
+ def contexts_regex
5
+ /(?:\s+|^)@[^\s]+/
6
+ end
7
+
8
+ # The regex used to match projects.
9
+ def projects_regex
10
+ /(?:\s+|^)\+[^\s]+/
11
+ end
12
+
13
+ # The regex used to match priorities.
14
+ def priority_regex
15
+ /(?:^|\s+)\(([A-Za-z])\)\s+/
16
+ end
17
+
18
+ # The regex used to match creation date.
19
+ def created_on_regex
20
+ /(?:^|-\d{2}\s|\)\s)(\d{4}-\d{2}-\d{2})\s/
21
+ end
22
+
23
+ # The regex used to match completion.
24
+ def done_regex
25
+ /^x\s+(\d{4}-\d{2}-\d{2})\s+/
26
+ end
27
+
28
+ # The regex used to match due date.
29
+ def due_on_regex
30
+ /(?:due:)(\d{4}-\d{2}-\d{2})(?:\s+|$)/i
31
+ end
32
+ end
33
+ end
data/lib/todo-txt/task.rb CHANGED
@@ -4,36 +4,7 @@ module Todo
4
4
  class Task
5
5
  include Comparable
6
6
  include Todo::Logger
7
-
8
- # The regular expression used to match contexts.
9
- def self.contexts_regex
10
- /(?:\s+|^)@\w+/
11
- end
12
-
13
- # The regex used to match projects.
14
- def self.projects_regex
15
- /(?:\s+|^)\+\w+/
16
- end
17
-
18
- # The regex used to match priorities.
19
- def self.priority_regex
20
- /(?:^|\s+)\(([A-Za-z])\)\s+/
21
- end
22
-
23
- # The regex used to match creation date.
24
- def self.created_on_regex
25
- /(?:^|-\d{2}\s|\)\s)(\d{4}-\d{2}-\d{2})\s/
26
- end
27
-
28
- # The regex used to match completion.
29
- def self.done_regex
30
- /^x\s+(\d{4}-\d{2}-\d{2})\s+/
31
- end
32
-
33
- # The regex used to match due date.
34
- def self.due_on_regex
35
- /(?:due:)(\d{4}-\d{2}-\d{2})(?:\s+|$)/i
36
- end
7
+ include Todo::Syntax
37
8
 
38
9
  # Creates a new task. The argument that you pass in must be the string
39
10
  # representation of a task.
@@ -46,8 +17,8 @@ module Todo
46
17
  @completed_on = get_completed_date #orig.scan(self.class.done_regex)[1] ||= nil
47
18
  @priority, @created_on = orig_priority, orig_created_on
48
19
  @due_on = get_due_on_date
49
- @contexts ||= orig.scan(self.class.contexts_regex).map { |item| item.strip }
50
- @projects ||= orig.scan(self.class.projects_regex).map { |item| item.strip }
20
+ @contexts ||= orig.scan(contexts_regex).map { |item| item.strip }
21
+ @projects ||= orig.scan(projects_regex).map { |item| item.strip }
51
22
  end
52
23
 
53
24
  # Returns the original content of the task.
@@ -133,12 +104,12 @@ module Todo
133
104
  # task.text #=> "Testing!"
134
105
  def text
135
106
  @text ||= orig.
136
- gsub(self.class.done_regex, '').
137
- gsub(self.class.priority_regex, '').
138
- gsub(self.class.created_on_regex, '').
139
- gsub(self.class.contexts_regex, '').
140
- gsub(self.class.projects_regex, '').
141
- gsub(self.class.due_on_regex, '').
107
+ gsub(done_regex, '').
108
+ gsub(priority_regex, '').
109
+ gsub(created_on_regex, '').
110
+ gsub(contexts_regex, '').
111
+ gsub(projects_regex, '').
112
+ gsub(due_on_regex, '').
142
113
  strip
143
114
  end
144
115
 
@@ -169,8 +140,7 @@ module Todo
169
140
  # task.overdue?
170
141
  # #=> true
171
142
  def overdue?
172
- return true if !due_on.nil? && due_on < Date.today
173
- false
143
+ !due_on.nil? && due_on < Date.today
174
144
  end
175
145
 
176
146
  # Returns if the task is done.
@@ -294,13 +264,13 @@ module Todo
294
264
  private
295
265
 
296
266
  def orig_priority
297
- @orig.match(self.class.priority_regex)[1] if @orig =~ self.class.priority_regex
267
+ @orig.match(priority_regex)[1] if @orig =~ priority_regex
298
268
  end
299
269
 
300
270
  def orig_created_on
301
271
  begin
302
- if @orig =~ self.class.created_on_regex
303
- date = @orig.match self.class.created_on_regex
272
+ if @orig =~ created_on_regex
273
+ date = @orig.match created_on_regex
304
274
  return Date.parse(date[1]) unless date.nil?
305
275
  end
306
276
  rescue; end
@@ -309,14 +279,14 @@ module Todo
309
279
 
310
280
  def get_completed_date
311
281
  begin
312
- return Date.parse(self.class.done_regex.match(@orig)[1])
282
+ return Date.parse(done_regex.match(@orig)[1])
313
283
  rescue; end
314
284
  nil
315
285
  end
316
286
 
317
287
  def get_due_on_date
318
288
  begin
319
- return Date.parse(self.class.due_on_regex.match(@orig)[1])
289
+ return Date.parse(due_on_regex.match(@orig)[1])
320
290
  rescue; end
321
291
  nil
322
292
  end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,13 @@
1
+ require 'date'
2
+ require 'timecop'
1
3
  require 'simplecov'
4
+
2
5
  SimpleCov.start
3
6
 
4
7
  require File.join(File.dirname(__FILE__), "../lib/todo-txt.rb")
8
+
9
+ RSpec.configure do |config|
10
+ config.expect_with(:rspec) do |c|
11
+ c.syntax = :expect
12
+ end
13
+ end
@@ -1,47 +1,47 @@
1
- require File.join(File.dirname(__FILE__), "../spec_helper.rb")
1
+ require 'spec_helper'
2
2
 
3
3
  describe Todo::List do
4
4
  let(:path) { File.dirname(__FILE__) + '/../data/todo.txt' }
5
5
  let(:list) { Todo::List.new(path) }
6
6
 
7
7
  it 'should have the correct path' do
8
- list.path.should == path
8
+ expect(list.path).to eq(path)
9
9
  end
10
10
 
11
11
  it 'should grab a list of Todo::Tasks' do
12
12
  list.each do |task|
13
- task.class.should == Todo::Task
13
+ expect(task.class).to eq(Todo::Task)
14
14
  end
15
15
 
16
16
  # This is a little bit fragile but it helps me sleep at night.
17
- list[0].priority.should == "A"
17
+ expect(list[0].priority).to eq("A")
18
18
  end
19
19
 
20
20
  it 'should be able to filter by priority' do
21
21
  list.by_priority("A").each do |task|
22
- task.priority.should == "A"
22
+ expect(task.priority).to eq("A")
23
23
  end
24
24
 
25
25
  # Make sure some data was actually checked
26
- list.by_priority("A").length.should be > 0
26
+ expect(list.by_priority("A").length).to be > 0
27
27
  end
28
28
 
29
29
  it 'should be able to filter by context' do
30
30
  list.by_context("@context").each do |task|
31
- task.contexts.should include "@context"
31
+ expect(task.contexts).to include "@context"
32
32
  end
33
33
 
34
34
  # Make sure some data was actually checked
35
- list.by_context("@context").length.should be > 0
35
+ expect(list.by_context("@context").length).to be > 0
36
36
  end
37
37
 
38
38
  it 'should be able to filter by project' do
39
39
  list.by_project("+project").each do |task|
40
- task.projects.should include "+project"
40
+ expect(task.projects).to include "+project"
41
41
  end
42
42
 
43
43
  # Make sure some data was actually checked
44
- list.by_project("+project").length.should be > 0
44
+ expect(list.by_project("+project").length).to be > 0
45
45
  end
46
46
 
47
47
  it 'should be able to filter by project, context and priority' do
@@ -50,38 +50,38 @@ describe Todo::List do
50
50
  by_priority("C")
51
51
 
52
52
  filtered.each do |task|
53
- task.projects.should include "+project"
54
- task.contexts.should include "@context"
55
- task.priority.should == "C"
53
+ expect(task.projects).to include "+project"
54
+ expect(task.contexts).to include "@context"
55
+ expect(task.priority).to eq("C")
56
56
  end
57
57
 
58
58
  # Make sure some data was actually checked
59
- filtered.length.should be > 0
59
+ expect(filtered.length).to be > 0
60
60
  end
61
61
 
62
62
  it 'should be able to filter by done' do
63
63
  list.by_done.each do |task|
64
- task.text.should include 'This task is completed'
64
+ expect(task.text).to include 'This task is completed'
65
65
  end
66
66
 
67
- list.by_done.length.should be == 2
67
+ expect(list.by_done.length).to eq(2)
68
68
  end
69
69
 
70
70
  it 'should be able to filter by not done' do
71
71
  list.by_not_done.each do |task|
72
- task.text.should_not include 'This task is completed'
72
+ expect(task.text).not_to include 'This task is completed'
73
73
  end
74
74
 
75
- list.by_not_done.length.should be == 9
75
+ expect(list.by_not_done.length).to eq(9)
76
76
  end
77
77
 
78
78
  it 'should be sortable' do
79
79
  list.sort.each_cons(2) do |task_a, task_b|
80
- task_a.should be <= task_b
80
+ expect(task_a).to be <= task_b
81
81
  end
82
82
 
83
83
  # Make sure some data was actually checked
84
- list.sort.length.should be > 0
84
+ expect(list.sort.length).to be > 0
85
85
 
86
86
  # Class should still be Todo::List
87
87
  # This assertion currently fails. TODO.
@@ -95,7 +95,7 @@ describe Todo::List do
95
95
  Todo::Task.new("Another task!"),
96
96
  ])
97
97
 
98
- l.length.should == 2
98
+ expect(l.length).to eq(2)
99
99
  end
100
100
  end
101
101
  end
@@ -1,267 +1,275 @@
1
- require File.join(File.dirname(__FILE__), "../spec_helper.rb")
2
- require 'date'
3
- require 'timecop'
1
+ require 'spec_helper'
4
2
 
5
3
  describe Todo::Task do
6
4
  describe "Descriptions:" do
7
5
  it 'should convert to a string' do
8
6
  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"
7
+ expect(task.to_s).to eq("(A) 2012-12-08 My task @test +test2")
10
8
  end
11
-
9
+
12
10
  it 'should keep track of the original string after changing the task' do
13
11
  task = Todo::Task.new "(A) 2012-12-08 My task @test +test2"
14
12
  Timecop.freeze(2013, 12, 8) do
15
13
  task.do!
16
- task.orig.should == "(A) 2012-12-08 My task @test +test2"
14
+ expect(task.orig).to eq("(A) 2012-12-08 My task @test +test2")
17
15
  end
18
16
  end
19
-
17
+
20
18
  it 'should be modifiable' do
21
19
  task = Todo::Task.new "2012-12-08 My task @test +test2"
22
20
  task.projects.clear
23
21
  task.contexts << ["@test3"]
24
22
  Timecop.freeze(2013, 12, 8) do
25
23
  task.do!
26
- task.to_s.should == "x 2013-12-08 2012-12-08 My task @test @test3"
24
+ expect(task.to_s).to eq("x 2013-12-08 2012-12-08 My task @test @test3")
27
25
  end
28
26
  end
29
27
 
30
28
  it 'should be able to get just the text, no due date etc.' do
31
29
  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."
30
+ expect(task.text).to eq("This is a sweet task.")
33
31
  end
34
32
 
35
33
  it 'should retain the original task creation string' do
36
34
  task = Todo::Task.new "(A) This is an awesome task, yo. +winning"
37
- task.orig.should == "(A) This is an awesome task, yo. +winning"
35
+ expect(task.orig).to eq("(A) This is an awesome task, yo. +winning")
38
36
  end
39
37
 
40
38
  it 'should be able to get just the text, no contexts etc.' do
41
39
  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."
40
+ expect(task.text).to eq("This is a sweet task.")
43
41
  end
44
42
  end
45
-
43
+
46
44
  describe "Priorities:" do
47
45
  it 'should recognise priorities' do
48
46
  task = Todo::Task.new "(A) Hello world!"
49
- task.priority.should == "A"
47
+ expect(task.priority).to eq("A")
50
48
  end
51
49
 
52
50
  it 'should only recognise priorities at the start of a task' do
53
51
  task = Todo::Task.new "Hello, world! (A)"
54
- task.priority.should == nil
52
+ expect(task.priority).to eq(nil)
55
53
  end
56
54
 
57
55
  it 'should recognize priorities around dates' do
58
56
  task = Todo::Task.new "x 2012-09-11 (B) 2012-03-04 This is a sweet task. @context +project"
59
- task.priority.should == "B"
57
+ expect(task.priority).to eq("B")
60
58
  end
61
59
 
62
60
  it 'should remove the priority when calling Task#do!' do
63
61
  task = Todo::Task.new "(A) Task"
64
62
  task.do!
65
- task.priority.should be_nil
63
+ expect(task.priority).to be_nil
66
64
  end
67
65
 
68
66
  it 'should reset to the original priority when calling Task#undo!' do
69
67
  task = Todo::Task.new "(A) Task"
70
68
  task.do!
71
69
  task.undo!
72
- task.priority.should == "A"
70
+ expect(task.priority).to eq("A")
73
71
  end
74
72
  end
75
73
 
76
74
  describe "Completion:" do
77
75
  it 'should be not done with missing date' do
78
76
  task = Todo::Task.new "x This is not done"
79
- task.done?.should be false
77
+ expect(task.done?).to be false
80
78
  end
81
79
 
82
80
  it 'should be not done with malformed date' do
83
81
  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
82
+ expect(task.done?).to be false
83
+ expect(task.completed_on).to be nil
86
84
  end
87
85
 
88
86
  it 'should be not done with an invalid date' do
89
87
  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
88
+ expect(task.done?).to be false
89
+ expect(task.completed_on).to be nil
92
90
  end
93
91
 
94
92
  it 'should be done on 2013-04-22' do
95
93
  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')
94
+ expect(task.done?).to be true
95
+ expect(task.completed_on).to eq(Date.parse('22th April 2013'))
98
96
  end
99
-
97
+
100
98
  it 'should be able to recognise completed tasks' do
101
99
  task = Todo::Task.new "x 2012-12-08 This is done!"
102
- task.done?.should be_true
100
+ expect(task.done?).to be true
103
101
  end
104
102
 
105
103
  it 'should not recognize incomplete tasks as done' do
106
104
  task = Todo::Task.new "2012-12-08 This ain't done!"
107
- task.done?.should be_false
105
+ expect(task.done?).to be false
108
106
  end
109
107
 
110
108
  it 'should be completable' do
111
109
  task = Todo::Task.new "2012-12-08 This ain't done!"
112
110
  task.do!
113
- task.done?.should be_true
111
+ expect(task.done?).to be true
114
112
  end
115
113
 
116
114
  it 'should be marked as incomplete' do
117
115
  task = Todo::Task.new "x 2012-12-08 This is done!"
118
116
  task.undo!
119
- task.done?.should be_false
117
+ expect(task.done?).to be false
120
118
  end
121
119
 
122
120
  it 'should be marked as incomplete without any date' do
123
121
  task = Todo::Task.new "x 2012-12-08 This is done!"
124
122
  task.undo!
125
- task.completed_on.should be_nil
126
- task.created_on.should be_nil
123
+ expect(task.completed_on).to be_nil
124
+ expect(task.created_on).to be_nil
127
125
  end
128
126
 
129
127
  it 'should be toggable' do
130
128
  task = Todo::Task.new "2012-12-08 This ain't done!"
131
129
  task.toggle!
132
- task.done?.should be_true
130
+ expect(task.done?).to be true
133
131
  task.toggle!
134
- task.done?.should be_false
132
+ expect(task.done?).to be false
135
133
  end
136
134
  end
137
-
135
+
138
136
  describe "Contexts:" do
139
137
  it 'should recognise contexts' do
140
138
  task = Todo::Task.new "Hello, world! @test"
141
- task.contexts.should == ["@test"]
139
+ expect(task.contexts).to eq(["@test"])
142
140
  end
143
141
 
144
142
  it 'should recognise multiple contexts' do
145
143
  task = Todo::Task.new "Hello, world! @test @test2"
146
- task.contexts.should == ["@test", "@test2"]
144
+ expect(task.contexts).to eq(["@test", "@test2"])
145
+ end
146
+
147
+ it 'should recognise contexts with dashes and underscores' do
148
+ task = Todo::Task.new "Hello, world! @test-me @test2_me"
149
+ expect(task.contexts).to eq(["@test-me", "@test2_me"])
147
150
  end
148
151
  end
149
-
152
+
150
153
  describe "Projects:" do
151
154
  it 'should recognise projects' do
152
155
  task = Todo::Task.new "Hello, world! +test"
153
- task.projects.should == ["+test"]
156
+ expect(task.projects).to eq(["+test"])
154
157
  end
155
158
 
156
159
  it 'should recognise multiple projects' do
157
160
  task = Todo::Task.new "Hello, world! +test +test2"
158
- task.projects.should == ["+test", "+test2"]
161
+ expect(task.projects).to eq(["+test", "+test2"])
162
+ end
163
+
164
+ it 'should recognise projects with dashes and underscores' do
165
+ task = Todo::Task.new "Hello, world! +test-me +test2_me"
166
+ expect(task.projects).to eq(["+test-me", "+test2_me"])
159
167
  end
160
168
  end
161
-
169
+
162
170
  describe "Creation dates:" do
163
171
  it 'should be able to recognise creation dates' do
164
172
  task = Todo::Task.new "(C) 2012-03-04 This has a date!"
165
- task.created_on.should == Date.parse("4th March 2012")
173
+ expect(task.created_on).to eq(Date.parse("4th March 2012"))
166
174
  end
167
175
 
168
176
  it 'should be able to recognise creation dates without priority' do
169
177
  task = Todo::Task.new "2012-03-04 This has a date!"
170
- task.created_on.should == Date.parse("4th March 2012")
178
+ expect(task.created_on).to eq(Date.parse("4th March 2012"))
171
179
  end
172
180
 
173
181
  it 'should return nil if no creation date is present' do
174
182
  task = Todo::Task.new "No date!"
175
- task.created_on.should be_nil
183
+ expect(task.created_on).to be_nil
176
184
  end
177
185
 
178
186
  it 'should not recognise malformed dates' do
179
187
  task = Todo::Task.new "03-04-2012 This has a malformed date!"
180
- task.created_on.should be_nil
188
+ expect(task.created_on).to be_nil
181
189
  end
182
-
190
+
183
191
  it 'should be able to tell if the task is overdue' do
184
192
  task = Todo::Task.new((Date.today - 1).to_s + " This task is overdue!")
185
- task.overdue?.should be_false
193
+ expect(task.overdue?).to be false
186
194
  end
187
195
 
188
196
  it 'should return false on overdue? if there is no creation date' do
189
197
  task = Todo::Task.new "No date!"
190
- task.overdue?.should be_false
198
+ expect(task.overdue?).to be false
191
199
  end
192
200
 
193
201
  it 'should return nil on ridiculous date data' do
194
202
  task = Todo::Task.new "2012-56-99 This has a malformed date!"
195
- task.created_on.should be_nil
203
+ expect(task.created_on).to be_nil
196
204
  end
197
205
  end
198
-
206
+
199
207
  describe "Completion dates:" do
200
208
  it 'should be able to recognise completion dates' do
201
209
  task = Todo::Task.new "x 2012-12-08 This is done!"
202
- task.completed_on.should == Date.parse("8th December 2012")
210
+ expect(task.completed_on).to eq(Date.parse("8th December 2012"))
203
211
  end
204
212
 
205
213
  it 'should set the current completion dates when calling Task#do!' do
206
214
  task = Todo::Task.new "2012-12-08 Task"
207
215
  Timecop.freeze(2013, 12, 8) do
208
216
  task.do!
209
- task.completed_on.should == Date.parse("8th December 2013")
217
+ expect(task.completed_on).to eq(Date.parse("8th December 2013"))
210
218
  end
211
219
  end
212
220
  end
213
221
 
214
222
  describe "Due dates:" do
215
- its 'should have a due date' do
223
+ it 'should have a due date' do
216
224
  task = Todo::Task.new '(A) this task has due date due:2013-12-22'
217
- task.due_on.should_not be_nil
225
+ expect(task.due_on).not_to be_nil
218
226
  end
219
227
 
220
228
  it 'should due on 2013-12-22' do
221
229
  task = Todo::Task.new '(A) this task has due date due:2013-12-22'
222
- task.due_on.should == Date.parse('22th December 2013')
230
+ expect(task.due_on).to eq(Date.parse('22th December 2013'))
223
231
  end
224
232
 
225
233
  it 'should not be overdue on 2013-12-01' do
226
234
  task = Todo::Task.new '(A) this task has due date due:2013-12-22'
227
235
  Timecop.freeze(2013, 12, 01) do
228
- task.overdue?.should be_false
236
+ expect(task.overdue?).to be false
229
237
  end
230
238
  end
231
239
 
232
240
  it 'should be overdue on 2013-12-23' do
233
241
  task = Todo::Task.new '(A) this task has due date due:2013-12-22'
234
242
  Timecop.freeze(2013, 12, 23) do
235
- task.overdue?.should be_true
243
+ expect(task.overdue?).to be true
236
244
  end
237
245
  end
238
246
 
239
247
  it 'should convert to a string with due date' do
240
248
  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"
249
+ expect(task.to_s).to eq("x 2012-09-11 (B) 2012-03-04 This is a sweet task. @context +project due:2012-01-01")
242
250
  end
243
251
 
244
252
  it 'should have no due date with malformed date' do
245
253
  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
254
+ expect(task.due_on).to be_nil
247
255
  end
248
256
 
249
257
  it 'should have no due date with invalid date' do
250
258
  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
259
+ expect(task.due_on).to be_nil
252
260
  end
253
261
 
254
262
  it 'should recognize DUE:2013-12-22 (case insensitive)' do
255
263
  task = Todo::Task.new '(A) this task has due date DUE:2013-12-22'
256
- task.due_on.should == Date.parse('22th December 2013')
264
+ expect(task.due_on).to eq(Date.parse('22th December 2013'))
257
265
  end
258
-
266
+
259
267
  it 'should reset to the original due date when calling Task#undo!' do
260
268
  task = Todo::Task.new "2012-12-08 Task"
261
269
  Timecop.freeze(2013, 12, 8) do
262
270
  task.do!
263
271
  task.undo!
264
- task.created_on.should == Date.parse("8th December 2012")
272
+ expect(task.created_on).to eq(Date.parse("8th December 2012"))
265
273
  end
266
274
  end
267
275
 
@@ -269,11 +277,11 @@ describe Todo::Task do
269
277
  task = Todo::Task.new "2012-12-08 This ain't done!"
270
278
  Timecop.freeze(2013, 12, 8) do
271
279
  task.toggle!
272
- task.completed_on.should == Date.parse("8th December 2013")
273
- task.created_on.should == Date.parse("8th December 2012")
280
+ expect(task.completed_on).to eq(Date.parse("8th December 2013"))
281
+ expect(task.created_on).to eq(Date.parse("8th December 2012"))
274
282
  task.toggle!
275
- task.created_on.should == Date.parse("8th December 2012")
276
- task.completed_on.should be_nil
283
+ expect(task.created_on).to eq(Date.parse("8th December 2012"))
284
+ expect(task.completed_on).to be_nil
277
285
  end
278
286
  end
279
287
  end
@@ -284,7 +292,7 @@ describe Todo::Task do
284
292
  task2 = Todo::Task.new "(B) Not quite so high."
285
293
 
286
294
  assertion = task1 > task2
287
- assertion.should == true
295
+ expect(assertion).to eq(true)
288
296
  end
289
297
 
290
298
  it 'should be comparable to task without priority' do
@@ -292,7 +300,7 @@ describe Todo::Task do
292
300
  task2 = Todo::Task.new "(B) Not quite so high."
293
301
 
294
302
  assertion = task1 < task2
295
- assertion.should == true
303
+ expect(assertion).to eq(true)
296
304
  end
297
305
 
298
306
  it 'should be able to compare two tasks without priority' do
@@ -300,14 +308,14 @@ describe Todo::Task do
300
308
  task2 = Todo::Task.new "Not quite so high."
301
309
 
302
310
  assertion = task1 == task2
303
- assertion.should == true
311
+ expect(assertion).to eq(true)
304
312
  end
305
313
  end
306
-
314
+
307
315
  describe "Logging:" do
308
316
  it 'should have a logger' do
309
317
  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
318
+ expect(task.logger).not_to be nil
311
319
  end
312
320
 
313
321
  it 'should call @logger.warn if #date called as deprecated method' do
@@ -317,7 +325,7 @@ describe Todo::Task do
317
325
  task = Todo::Task.new "x 2012-09-11 (B) 2012-03-04 This is a sweet task. @context due:2012-02-31 +project"
318
326
  error_message = 'Task#date is deprecated, use created_on instead.'
319
327
 
320
- logger.should_receive(:warn).with(error_message)
328
+ expect(logger).to receive(:warn).with(error_message)
321
329
  task.date
322
330
  end
323
331
  end
data/todo-txt.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{todo-txt}
3
- s.version = "0.5"
3
+ s.version = "0.6"
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.}
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.5'
4
+ version: '0.6'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Rose
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-22 00:00:00.000000000 Z
11
+ date: 2016-03-10 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.
@@ -21,13 +21,13 @@ files:
21
21
  - ".gitignore"
22
22
  - ".travis.yml"
23
23
  - Gemfile
24
- - Gemfile.lock
25
24
  - LICENSE
26
25
  - README.md
27
26
  - Rakefile
28
27
  - lib/todo-txt.rb
29
28
  - lib/todo-txt/list.rb
30
29
  - lib/todo-txt/logger.rb
30
+ - lib/todo-txt/syntax.rb
31
31
  - lib/todo-txt/task.rb
32
32
  - spec/data/todo.txt
33
33
  - spec/spec_helper.rb
data/Gemfile.lock DELETED
@@ -1,29 +0,0 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- diff-lcs (1.1.3)
5
- multi_json (1.8.0)
6
- rake (0.9.2.2)
7
- rspec (2.9.0)
8
- rspec-core (~> 2.9.0)
9
- rspec-expectations (~> 2.9.0)
10
- rspec-mocks (~> 2.9.0)
11
- rspec-core (2.9.0)
12
- rspec-expectations (2.9.1)
13
- diff-lcs (~> 1.1.3)
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)
19
- timecop (0.6.1)
20
-
21
- PLATFORMS
22
- ruby
23
-
24
- DEPENDENCIES
25
- bundler
26
- rake
27
- rspec
28
- simplecov
29
- timecop