tdo 0.0.3 → 0.0.4
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.
- data/VERSION +1 -1
- data/lib/tdo.rb +12 -1
- data/tdo.gemspec +2 -2
- data/test/test_tdo.rb +23 -5
- data/test/todo.txt +0 -3
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/lib/tdo.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
module Tdo
|
3
2
|
|
4
3
|
class InvalidGroup < ArgumentError; end
|
@@ -14,6 +13,7 @@ module Tdo
|
|
14
13
|
File.new(TODO_FILE, "r").read
|
15
14
|
else
|
16
15
|
t = File.new(TODO_FILE, "r").read
|
16
|
+
raise InvalidGroup, "'#{group}' is not a valid group name", caller unless self.group?(group)
|
17
17
|
to_s( to_hash(t)[ group[1..-1] ] )
|
18
18
|
end
|
19
19
|
end
|
@@ -85,6 +85,7 @@ module Tdo
|
|
85
85
|
s = tasks.size
|
86
86
|
r += tasks.delete_if {|i| i.include? ' #done' }.size - s
|
87
87
|
end
|
88
|
+
t.delete_if {|k, v| v == [] }
|
88
89
|
write_hash t
|
89
90
|
r
|
90
91
|
end
|
@@ -96,6 +97,16 @@ module Tdo
|
|
96
97
|
File.open(TODO_FILE, "w") {|f| f.write( to_s(hash) )}
|
97
98
|
end
|
98
99
|
|
100
|
+
|
101
|
+
# Tests whether the group exists
|
102
|
+
#
|
103
|
+
# @param [String] group name
|
104
|
+
# @return [Boolean] whether the group exists
|
105
|
+
def self.group?( name )
|
106
|
+
t = to_hash( self.read_tasks )
|
107
|
+
t.has_key?(name[1..-1])
|
108
|
+
end
|
109
|
+
|
99
110
|
# Converts the string read from the file to a hash so it can easily be used
|
100
111
|
#
|
101
112
|
# @param [String] read file string
|
data/tdo.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{tdo}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Joshua Hawxwell"]
|
12
|
-
s.date = %q{2010-06-
|
12
|
+
s.date = %q{2010-06-26}
|
13
13
|
s.default_executable = %q{tdo}
|
14
14
|
s.description = %q{Tdo is a simple ruby app to add, edit and read your todo list. It stores the list at ~/.todo.txt}
|
15
15
|
s.email = %q{m@hawx.me}
|
data/test/test_tdo.rb
CHANGED
@@ -15,24 +15,32 @@ class TestTdo < Test::Unit::TestCase
|
|
15
15
|
should "add new task" do
|
16
16
|
clear_todo
|
17
17
|
b = Tdo.read_tasks
|
18
|
-
Tdo.add_task(
|
18
|
+
Tdo.add_task("Pick up milk")
|
19
19
|
|
20
20
|
assert_equal Tdo.read_tasks.size, b.size + " - Pick up milk".size
|
21
21
|
end
|
22
22
|
|
23
23
|
should "add new task to group" do
|
24
24
|
clear_todo
|
25
|
-
Tdo.add_task(
|
25
|
+
Tdo.add_task('Pick up milk', '@test')
|
26
26
|
|
27
27
|
assert_equal Tdo.read_tasks('@test').size, " - Pick up milk".size
|
28
28
|
end
|
29
29
|
|
30
30
|
should "mark task as done" do
|
31
31
|
clear_todo
|
32
|
-
b = Tdo.read_tasks(
|
33
|
-
Tdo.mark_done(
|
32
|
+
b = Tdo.read_tasks('@ungrouped').strip
|
33
|
+
Tdo.mark_done('A task', '@ungrouped')
|
34
34
|
|
35
|
-
assert_equal Tdo.read_tasks(
|
35
|
+
assert_equal Tdo.read_tasks('@ungrouped'), b + " #done\n"
|
36
|
+
end
|
37
|
+
|
38
|
+
should "mark task at index as done" do
|
39
|
+
clear_todo
|
40
|
+
b = Tdo.read_tasks( '@ungrouped').strip
|
41
|
+
Tdo.mark_done(0, '@ungrouped')
|
42
|
+
|
43
|
+
assert_equal Tdo.read_tasks('@ungrouped'), b + " #done\n"
|
36
44
|
end
|
37
45
|
|
38
46
|
should "remove all tasks marked done" do
|
@@ -42,4 +50,14 @@ class TestTdo < Test::Unit::TestCase
|
|
42
50
|
assert_equal Tdo.read_tasks('@group'), "- Another task\n"
|
43
51
|
end
|
44
52
|
|
53
|
+
should "remove group when all tasks are cleared" do
|
54
|
+
clear_todo
|
55
|
+
Tdo.mark_done(0, '@home')
|
56
|
+
Tdo.clear_done
|
57
|
+
|
58
|
+
assert_raise Tdo::InvalidGroup do
|
59
|
+
Tdo.read_tasks('@home')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
45
63
|
end
|
data/test/todo.txt
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 4
|
9
|
+
version: 0.0.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Joshua Hawxwell
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-06-
|
17
|
+
date: 2010-06-26 00:00:00 +01:00
|
18
18
|
default_executable: tdo
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|