todo-txt 0.2.1 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +20 -0
- data/README.md +3 -0
- data/gems/todo-txt-0.2.1.gem +0 -0
- data/lib/todo-txt/task.rb +22 -1
- data/spec/todo-txt/list_spec.rb +2 -1
- data/spec/todo-txt/task_spec.rb +16 -1
- data/todo-txt.gemspec +1 -1
- metadata +10 -8
data/Gemfile.lock
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.3)
|
5
|
+
rake (0.9.2.2)
|
6
|
+
rspec (2.9.0)
|
7
|
+
rspec-core (~> 2.9.0)
|
8
|
+
rspec-expectations (~> 2.9.0)
|
9
|
+
rspec-mocks (~> 2.9.0)
|
10
|
+
rspec-core (2.9.0)
|
11
|
+
rspec-expectations (2.9.1)
|
12
|
+
diff-lcs (~> 1.1.3)
|
13
|
+
rspec-mocks (2.9.0)
|
14
|
+
|
15
|
+
PLATFORMS
|
16
|
+
ruby
|
17
|
+
|
18
|
+
DEPENDENCIES
|
19
|
+
rake
|
20
|
+
rspec
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Todo.txt
|
2
2
|
|
3
|
+
[![Development Build Status](https://secure.travis-ci.org/samwho/todo-txt-gem.png?branch=develop)](http://travis-ci.org/samwho/todo-txt-gem)
|
4
|
+
[![Master Build Status](https://secure.travis-ci.org/samwho/todo-txt-gem.png?branch=master)](http://travis-ci.org/samwho/todo-txt-gem)
|
5
|
+
|
3
6
|
This is a Ruby client library for Gina Trapani's [todo.txt](https://github.com/ginatrapani/todo.txt-cli/). It allows for easy parsing of task lists and tasks in the todo.txt format.
|
4
7
|
|
5
8
|
Find the project on GitHub: [http://github.com/samwho/todo-txt-gem](http://github.com/samwho/todo-txt-gem).
|
Binary file
|
data/lib/todo-txt/task.rb
CHANGED
@@ -21,7 +21,12 @@ module Todo
|
|
21
21
|
|
22
22
|
# The regex used to match dates.
|
23
23
|
def self.date_regex
|
24
|
-
/(?:\
|
24
|
+
/(?:\s+|^)([0-9]{4}-[0-9]{2}-[0-9]{2})/
|
25
|
+
end
|
26
|
+
|
27
|
+
# The regex used to match completion.
|
28
|
+
def self.done_regex
|
29
|
+
/^x\s+/
|
25
30
|
end
|
26
31
|
|
27
32
|
# Creates a new task. The argument that you pass in must be a string.
|
@@ -85,6 +90,7 @@ module Todo
|
|
85
90
|
# task.text #=> "Testing!"
|
86
91
|
def text
|
87
92
|
@text ||= orig.
|
93
|
+
gsub(self.class.done_regex, '').
|
88
94
|
gsub(self.class.date_regex, '').
|
89
95
|
gsub(self.class.priotity_regex, '').
|
90
96
|
gsub(self.class.contexts_regex, '').
|
@@ -131,6 +137,21 @@ module Todo
|
|
131
137
|
end
|
132
138
|
end
|
133
139
|
|
140
|
+
# Returns if the task is done.
|
141
|
+
#
|
142
|
+
# Example:
|
143
|
+
#
|
144
|
+
# task = Todo::Task.new "x 2012-12-08 Task."
|
145
|
+
# task.done?
|
146
|
+
# #=> true
|
147
|
+
#
|
148
|
+
# task = Todo::Task.new "Task."
|
149
|
+
# task.done?
|
150
|
+
# #=> false
|
151
|
+
def done?
|
152
|
+
@done ||= !(orig =~ self.class.done_regex).nil?
|
153
|
+
end
|
154
|
+
|
134
155
|
# Compares the priorities of two tasks.
|
135
156
|
#
|
136
157
|
# Example:
|
data/spec/todo-txt/list_spec.rb
CHANGED
data/spec/todo-txt/task_spec.rb
CHANGED
@@ -38,7 +38,7 @@ describe Todo::Task do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'should be able to get just the text, no contexts etc.' do
|
41
|
-
task = Todo::Task.new "(B) 2012-03-04 This is a sweet task. @context +project"
|
41
|
+
task = Todo::Task.new "x (B) 2012-03-04 This is a sweet task. @context +project"
|
42
42
|
task.text.should == "This is a sweet task."
|
43
43
|
end
|
44
44
|
|
@@ -100,4 +100,19 @@ describe Todo::Task do
|
|
100
100
|
task = Todo::Task.new "2012-56-99 This has a malformed date!"
|
101
101
|
task.date.should be_nil
|
102
102
|
end
|
103
|
+
|
104
|
+
it 'should be able to recognise completed tasks' do
|
105
|
+
task = Todo::Task.new "x 2012-12-08 This is done!"
|
106
|
+
task.done?.should be_true
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'should not recognize incomplete tasks as done' do
|
110
|
+
task = Todo::Task.new "2012-12-08 This is ain't done!"
|
111
|
+
task.done?.should be_false
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should be able to recognise completion dates' do
|
115
|
+
task = Todo::Task.new "x 2012-12-08 This is done!"
|
116
|
+
task.date.should == Date.parse("8th December 2012")
|
117
|
+
end
|
103
118
|
end
|
data/todo-txt.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: todo-txt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.3'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-31 00:00:00.
|
12
|
+
date: 2012-03-31 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Allows for simple parsing of todo.txt files, as per Gina Trapani's todo.txt
|
15
15
|
project.
|
@@ -18,17 +18,19 @@ executables: []
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
-
-
|
22
|
-
- lib/todo-txt/task.rb
|
23
|
-
- lib/todo-txt.rb
|
21
|
+
- Gemfile.lock
|
24
22
|
- gems/todo-txt-0.1.1.gem
|
25
23
|
- gems/todo-txt-0.1.gem
|
24
|
+
- gems/todo-txt-0.2.1.gem
|
26
25
|
- gems/todo-txt-0.2.gem
|
26
|
+
- lib/todo-txt/list.rb
|
27
|
+
- lib/todo-txt/task.rb
|
28
|
+
- lib/todo-txt.rb
|
27
29
|
- README.md
|
30
|
+
- spec/data/todo.txt
|
31
|
+
- spec/spec_helper.rb
|
28
32
|
- spec/todo-txt/list_spec.rb
|
29
33
|
- spec/todo-txt/task_spec.rb
|
30
|
-
- spec/spec_helper.rb
|
31
|
-
- spec/data/todo.txt
|
32
34
|
- todo-txt.gemspec
|
33
35
|
- .gemtest
|
34
36
|
homepage: http://github.com/samwho/todo-txt-gem
|
@@ -52,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
54
|
version: '0'
|
53
55
|
requirements: []
|
54
56
|
rubyforge_project:
|
55
|
-
rubygems_version: 1.8.
|
57
|
+
rubygems_version: 1.8.24
|
56
58
|
signing_key:
|
57
59
|
specification_version: 3
|
58
60
|
summary: A client library for parsing todo.txt files.
|