taskish 0.3 → 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.
Files changed (62) hide show
  1. data/HISTORY +12 -0
  2. data/coverage/assets/0.4.5/app.js +66 -0
  3. data/coverage/assets/0.4.5/fancybox/blank.gif +0 -0
  4. data/coverage/assets/0.4.5/fancybox/fancy_close.png +0 -0
  5. data/coverage/assets/0.4.5/fancybox/fancy_loading.png +0 -0
  6. data/coverage/assets/0.4.5/fancybox/fancy_nav_left.png +0 -0
  7. data/coverage/assets/0.4.5/fancybox/fancy_nav_right.png +0 -0
  8. data/coverage/assets/0.4.5/fancybox/fancy_shadow_e.png +0 -0
  9. data/coverage/assets/0.4.5/fancybox/fancy_shadow_n.png +0 -0
  10. data/coverage/assets/0.4.5/fancybox/fancy_shadow_ne.png +0 -0
  11. data/coverage/assets/0.4.5/fancybox/fancy_shadow_nw.png +0 -0
  12. data/coverage/assets/0.4.5/fancybox/fancy_shadow_s.png +0 -0
  13. data/coverage/assets/0.4.5/fancybox/fancy_shadow_se.png +0 -0
  14. data/coverage/assets/0.4.5/fancybox/fancy_shadow_sw.png +0 -0
  15. data/coverage/assets/0.4.5/fancybox/fancy_shadow_w.png +0 -0
  16. data/coverage/assets/0.4.5/fancybox/fancy_title_left.png +0 -0
  17. data/coverage/assets/0.4.5/fancybox/fancy_title_main.png +0 -0
  18. data/coverage/assets/0.4.5/fancybox/fancy_title_over.png +0 -0
  19. data/coverage/assets/0.4.5/fancybox/fancy_title_right.png +0 -0
  20. data/coverage/assets/0.4.5/fancybox/fancybox-x.png +0 -0
  21. data/coverage/assets/0.4.5/fancybox/fancybox-y.png +0 -0
  22. data/coverage/assets/0.4.5/fancybox/fancybox.png +0 -0
  23. data/coverage/assets/0.4.5/fancybox/jquery.fancybox-1.3.1.css +363 -0
  24. data/coverage/assets/0.4.5/fancybox/jquery.fancybox-1.3.1.pack.js +44 -0
  25. data/coverage/assets/0.4.5/favicon.png +0 -0
  26. data/coverage/assets/0.4.5/jquery-1.4.2.min.js +155 -0
  27. data/coverage/assets/0.4.5/jquery.dataTables.min.js +152 -0
  28. data/coverage/assets/0.4.5/jquery.timeago.js +141 -0
  29. data/coverage/assets/0.4.5/jquery.url.js +174 -0
  30. data/coverage/assets/0.4.5/loading.gif +0 -0
  31. data/coverage/assets/0.4.5/magnify.png +0 -0
  32. data/coverage/assets/0.4.5/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  33. data/coverage/assets/0.4.5/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  34. data/coverage/assets/0.4.5/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  35. data/coverage/assets/0.4.5/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  36. data/coverage/assets/0.4.5/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  37. data/coverage/assets/0.4.5/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  38. data/coverage/assets/0.4.5/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  39. data/coverage/assets/0.4.5/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  40. data/coverage/assets/0.4.5/smoothness/images/ui-icons_222222_256x240.png +0 -0
  41. data/coverage/assets/0.4.5/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  42. data/coverage/assets/0.4.5/smoothness/images/ui-icons_454545_256x240.png +0 -0
  43. data/coverage/assets/0.4.5/smoothness/images/ui-icons_888888_256x240.png +0 -0
  44. data/coverage/assets/0.4.5/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  45. data/coverage/assets/0.4.5/smoothness/jquery-ui-1.8.4.custom.css +295 -0
  46. data/coverage/assets/0.4.5/stylesheet.css +341 -0
  47. data/coverage/index.html +5499 -0
  48. data/coverage/resultset.yml +415 -0
  49. data/lib/taskish.rb +61 -23
  50. data/lib/taskish/app.rb +5 -6
  51. data/lib/taskish/project.rb +80 -0
  52. data/lib/taskish/task.rb +16 -8
  53. data/lib/taskish/version.rb +1 -1
  54. data/taskish.gemspec +1 -0
  55. data/test/app_test.rb +1 -1
  56. data/test/project_test.rb +125 -0
  57. data/test/task_test.rb +50 -31
  58. data/test/taskish.txt +9 -0
  59. data/test/taskish_test.rb +53 -2
  60. data/test/test_helper.rb +5 -0
  61. data/test/version_test.rb +2 -2
  62. metadata +68 -3
@@ -57,15 +57,14 @@ class Taskish # :nodoc:
57
57
  Taskish.new do |taskish|
58
58
  app.files.each { |f| taskish.readlines(f) }
59
59
  case app.command
60
+ when 'debug'
61
+ taskish.debug
60
62
  when 'done'
61
- # taskish.readlines(app.file)
62
- puts "DONE\n~~~~~"
63
+ puts "DONE\n~~~~"
63
64
  taskish.done.each { |task| puts task }
64
- when 'today', 'week'
65
- # taskish.readlines(app.file)
65
+ when 'today', 'tomorrow', 'week'
66
66
  tasks = taskish.due( app.command.to_sym )
67
67
  if tasks.size > 0
68
- puts "#{ app.command.upcase }\n#{ '~' * app.command.length }"
69
68
  tasks.each { |task| puts task }
70
69
  end
71
70
  else
@@ -77,7 +76,7 @@ class Taskish # :nodoc:
77
76
  end
78
77
 
79
78
  def usage
80
- "USAGE: taskish { done | today | week } <file>"
79
+ "USAGE: taskish { debug | done | today | tomorrow | week } <file>"
81
80
  end
82
81
 
83
82
  end # class Taskish::App
@@ -0,0 +1,80 @@
1
+ require 'date'
2
+
3
+ class Taskish # :nodoc:
4
+
5
+ # = Taskish::Project - A single project
6
+ #
7
+ # == USAGE
8
+ #
9
+ # Taskish::Project.new(project) do |project|
10
+ # # Get project's name
11
+ # project.name
12
+ #
13
+ # # Add task to project
14
+ # project << Taskish::Task.new( project.name, 'my task' )
15
+ #
16
+ # # Add child project to project
17
+ # project << Taskish::Project.new( 'child project' )
18
+ #
19
+ # # Get project's child projects
20
+ # project.projects
21
+ #
22
+ # # Get project's tasks
23
+ # project.tasks
24
+ #
25
+ # end
26
+ #
27
+ # == SEE ALSO
28
+ #
29
+ # <Taskish>, <Taskish::Task>
30
+ #
31
+ class Project
32
+ attr_reader :name, :parent
33
+
34
+ def initialize(project)
35
+ @name = project
36
+ @children = []
37
+ @parent = nil
38
+ yield self if block_given?
39
+ end
40
+
41
+ def <<(child)
42
+ if ( child.nil? || !( child.kind_of?(Taskish::Project) || child.kind_of?(Taskish::Task) ) )
43
+ raise(ArgumentError, 'invalid project/task')
44
+ end
45
+ if child.kind_of?(Taskish::Project)
46
+ child.instance_variable_set( :@parent, self )
47
+ end
48
+ @children << child
49
+ self
50
+ end
51
+
52
+ def debug(depth = 0)
53
+ puts "%s#{ @name }:" % [ ' ' * depth ]
54
+ projects.each { |p| p.debug( depth + 1 ) }
55
+ tasks(false).each do |t|
56
+ puts "%s- #{ t.raw }" % [ ' ' * ( depth + 1 ) ]
57
+ end
58
+ end
59
+
60
+ def projects
61
+ @children.select { |child| child.kind_of? Taskish::Project }
62
+ end
63
+
64
+ def tasks(recurse = true)
65
+ if recurse
66
+ return @children.collect { |child| child.kind_of?( Taskish::Project ) ? child.tasks : child }.flatten
67
+ else
68
+ return @children.select { |child| child.kind_of?( Taskish::Task ) }
69
+ end
70
+ end
71
+
72
+ # TODO Include parent information?
73
+ def to_s
74
+ @parent ? sprintf( "%s: %s" % [ self.parent, @name ] ) : @name
75
+ end
76
+
77
+ end # class Taskish::Project
78
+
79
+ end # class Taskish
80
+
@@ -15,8 +15,12 @@ class Taskish # :nodoc:
15
15
  # <Taskish>
16
16
  #
17
17
  class Task
18
+ attr_reader :parent
19
+
18
20
  def initialize(project, task)
19
- @data = Task.parse(project, task)
21
+ raise(ArgumentError, 'invalid project') if ( project.nil? || !project.kind_of?(Taskish::Project) )
22
+ @data = Task.parse(task)
23
+ @parent = project
20
24
  yield self if block_given?
21
25
  end
22
26
 
@@ -33,10 +37,10 @@ class Taskish # :nodoc:
33
37
  case date
34
38
  when :today
35
39
  return @data[:due] <= Date.today
40
+ when :tomorrow
41
+ return @data[:due] > Date.today && @data[:due] <= ( Date.today + 1 )
36
42
  when :week
37
- d = Date.today + 7
38
- week = DateTime.new( d.year, d.mon, d.mday, 23, 59 )
39
- return @data[:due] <= week
43
+ return @data[:due] <= ( Date.today + 7 )
40
44
  else
41
45
  warn "invalid due date specification - '#{date}'"
42
46
  end
@@ -47,10 +51,9 @@ class Taskish # :nodoc:
47
51
  @data.key? key
48
52
  end
49
53
 
50
- def self.parse(project, task)
51
- raise(ArgumentError, 'invalid project') if ( project.nil? || project.empty? )
54
+ def self.parse(task)
52
55
  raise(ArgumentError, 'invalid task') if ( task.nil? || task.empty? )
53
- data = { :project => project }
56
+ data = { :raw => task }
54
57
 
55
58
  # TODO Extract to something that sucks less.
56
59
  task.gsub!(/\s*$/, '')
@@ -73,12 +76,17 @@ class Taskish # :nodoc:
73
76
  data
74
77
  end
75
78
 
79
+ def raw
80
+ @data[:raw]
81
+ end
82
+
76
83
  def task
77
84
  @data[:task]
78
85
  end
79
86
 
87
+ # TODO Make more flexible
80
88
  def to_s
81
- s = sprintf( "%-20s\t%s" % [ @data[:project], @data[:task] ] )
89
+ s = sprintf( "%-25s\t%s" % [ self.parent.to_s + ':', @data[:task] ] )
82
90
  if key? :due
83
91
  s = sprintf( "%s @due(%s)" % [ s, @data[:due] ] )
84
92
  end
@@ -1,3 +1,3 @@
1
1
  class Taskish # :nodoc:
2
- VERSION = '0.3'
2
+ VERSION = '0.4'
3
3
  end
@@ -20,4 +20,5 @@ Gem::Specification.new do |s|
20
20
 
21
21
  s.add_development_dependency( %q<rdoc-readme>, [ '>=0.1.1' ] )
22
22
  s.add_development_dependency( %q<shoulda>, [ '>=2.11.3' ] )
23
+ s.add_development_dependency( %q<simplecov>, [ '>=0.4.2' ] )
23
24
  end
@@ -46,7 +46,7 @@ class AppTest < Test::Unit::TestCase
46
46
 
47
47
  context '#usage()' do
48
48
  should 'return expected usage string' do
49
- assert_equal "USAGE: taskish { done | today | week } <file>", Taskish::App.new.usage
49
+ assert_equal "USAGE: taskish { debug | done | today | tomorrow | week } <file>", Taskish::App.new.usage
50
50
  end
51
51
  end
52
52
 
@@ -0,0 +1,125 @@
1
+ require 'test_helper'
2
+ #require 'date'
3
+
4
+ class ProjectTest < Test::Unit::TestCase
5
+
6
+ context '#initialize()' do
7
+ should 'return object if no block given' do
8
+ assert_instance_of Taskish::Project, Taskish::Project.new("p")
9
+ end
10
+ should 'work as a block' do
11
+ Taskish::Project.new("p") do |project|
12
+ assert_instance_of Taskish::Project, project
13
+ end
14
+ end
15
+ end
16
+
17
+ context 'accessors' do
18
+ setup do
19
+ @name = 'my project'
20
+ @project = Taskish::Project.new(@name)
21
+ @tasks = []
22
+ end
23
+ should 'provide getter for :name' do
24
+ assert_equal @name, @project.name
25
+ end
26
+ should 'provide getter for :tasks' do
27
+ assert_equal @tasks, @project.tasks
28
+ end
29
+ should 'raise NoMethodError for :name setter' do
30
+ assert_raise(NoMethodError, 'undefined method `name=') { @project.name = 'foo' }
31
+ end
32
+ should 'raise NoMethodError for :tasks setter' do
33
+ assert_raise(NoMethodError, 'undefined method `tasks=') { @project.tasks = [] }
34
+ end
35
+ end
36
+
37
+ context '#<<(child)' do
38
+ setup do
39
+ @project = Taskish::Project.new('my project')
40
+ end
41
+ should 'raise ArgumentError if child nil' do
42
+ assert_raise(ArgumentError, 'invalid project/task') { @project << nil }
43
+ end
44
+ should 'raise ArgumentError if child string' do
45
+ assert_raise(ArgumentError, 'invalid project/task') { @project << '' }
46
+ end
47
+ end
48
+
49
+ context 'tasks' do
50
+ setup do
51
+ @project = Taskish::Project.new('my project')
52
+ end
53
+ should 'default to 0 tasks' do
54
+ assert_equal 0, @project.tasks.size
55
+ end
56
+ should 'be able to add tasks' do
57
+ ( 1 .. 5 ).to_a.each do |n|
58
+ assert_equal n - 1, @project.tasks.size
59
+ @project << Taskish::Task.new( @project, n.to_s )
60
+ assert_equal n, @project.tasks.size
61
+ end
62
+ ( 1 .. 5 ).to_a.each do |n|
63
+ assert_equal n.to_s, @project.tasks[n - 1].task
64
+ end
65
+ end
66
+ end
67
+
68
+ context 'child projects' do
69
+ setup do
70
+ @parent = Taskish::Project.new('parent project')
71
+ @child = Taskish::Project.new('child project')
72
+ @parent_task = Taskish::Task.new( @parent, 'parent task' )
73
+ @child_task = Taskish::Task.new( @child, 'child task' )
74
+ @parent << @parent_task
75
+ @child << @child_task
76
+ @parent << @child
77
+ end
78
+ should 'be able to add child project to a project' do
79
+ @parent << @child
80
+ end
81
+ should 'return appropriate tasks for child' do
82
+ assert_equal 1, @child.tasks.size
83
+ assert_equal false, @child.tasks.include?( @parent_task )
84
+ assert_equal true, @child.tasks.include?( @child_task )
85
+ end
86
+ should 'return appropriate tasks for parent' do
87
+ assert_equal 2, @parent.tasks.size
88
+ assert_equal true, @parent.tasks.include?( @parent_task )
89
+ assert_equal true, @parent.tasks.include?( @child_task )
90
+ end
91
+ should 'return appropriate projects for child' do
92
+ assert_equal 0, @child.projects.size
93
+ assert_equal false, @child.projects.include?( @parent )
94
+ assert_equal false, @child.projects.include?( @child )
95
+ end
96
+ should 'return appropriate projects for parent' do
97
+ assert_equal 1, @parent.projects.size
98
+ assert_equal false, @parent.projects.include?( @parent )
99
+ assert_equal true, @parent.projects.include?( @child )
100
+ end
101
+ end
102
+
103
+ context '#to_s()' do
104
+ setup do
105
+ @parent = Taskish::Project.new('parent project')
106
+ @child_1 = Taskish::Project.new('child project #1')
107
+ @child_2 = Taskish::Project.new('child project #2')
108
+ end
109
+ should 'return correct string representation when solo' do
110
+ assert_equal 'parent project', @parent.to_s
111
+ assert_equal 'child project #1', @child_1.to_s
112
+ assert_equal 'child project #2', @child_2.to_s
113
+ end
114
+ should 'return correct string representation when child projects have been added' do
115
+ @parent << @child_1
116
+ @parent << @child_2
117
+ assert_equal 'parent project', @parent.to_s
118
+ assert_equal 'parent project: child project #1', @child_1.to_s
119
+ assert_equal 'parent project: child project #2', @child_2.to_s
120
+ end
121
+ end
122
+
123
+
124
+ end # class ProjectTest
125
+
@@ -4,22 +4,28 @@ require 'date'
4
4
  class TaskTest < Test::Unit::TestCase
5
5
 
6
6
  context '#initialize()' do
7
+ setup do
8
+ @p = Taskish::Project.new('my project')
9
+ end
7
10
  should 'return object if no block given' do
8
- assert_instance_of Taskish::Task, Taskish::Task.new("p", "t")
11
+ assert_instance_of Taskish::Task, Taskish::Task.new(@p, "t")
9
12
  end
10
13
  should 'work as a block' do
11
- Taskish::Task.new("p", "t") do |task|
14
+ Taskish::Task.new(@p, "t") do |task|
12
15
  assert_instance_of Taskish::Task, task
13
16
  end
14
17
  end
15
18
  end
16
19
 
17
20
  context '#done?' do
21
+ setup do
22
+ @p = Taskish::Project.new('my project')
23
+ end
18
24
  should 'return false if @done not set' do
19
- assert_equal false, Taskish::Task.new('proj', 'foo').done?
25
+ assert_equal false, Taskish::Task.new(@p, 'foo').done?
20
26
  end
21
27
  should 'return true if @done set' do
22
- assert_equal true, Taskish::Task.new('proj', 'foo @done').done?
28
+ assert_equal true, Taskish::Task.new(@p, 'foo @done').done?
23
29
  end
24
30
  end
25
31
 
@@ -27,7 +33,7 @@ class TaskTest < Test::Unit::TestCase
27
33
 
28
34
  context ' with no due date' do
29
35
  setup do
30
- @task = Taskish::Task.new('proj', 'do something')
36
+ @task = Taskish::Task.new( Taskish::Project.new('my project'), 'do something')
31
37
  end
32
38
  should 'be nil' do
33
39
  assert_nil @task.due
@@ -43,7 +49,7 @@ class TaskTest < Test::Unit::TestCase
43
49
  context ' with implicit due date of today' do
44
50
  setup do
45
51
  @d = Date.today
46
- @task = Taskish::Task.new('proj', 'do something @due')
52
+ @task = Taskish::Task.new( Taskish::Project.new('my project') , 'do something @due' )
47
53
  end
48
54
  should 'not be nil' do
49
55
  assert_not_nil @task.due
@@ -62,7 +68,7 @@ class TaskTest < Test::Unit::TestCase
62
68
  context ' with implicit due date of today and additional tag' do
63
69
  setup do
64
70
  @d = Date.today
65
- @task = Taskish::Task.new('proj', 'do something @due @weekly')
71
+ @task = Taskish::Task.new( Taskish::Project.new('my project'), 'do something @due @weekly' )
66
72
  end
67
73
  should 'not be nil' do
68
74
  assert_not_nil @task.due
@@ -81,7 +87,7 @@ class TaskTest < Test::Unit::TestCase
81
87
  context ' with explicit due date of today' do
82
88
  setup do
83
89
  @d = Date.today
84
- @task = Taskish::Task.new('proj', "do something @due(#{ @d.strftime('%Y-%m-%d') })")
90
+ @task = Taskish::Task.new( Taskish::Project.new('my project'), "do something @due(#{ @d.strftime('%Y-%m-%d') })" )
85
91
  end
86
92
  should 'not be nil' do
87
93
  assert_not_nil @task.due
@@ -100,7 +106,7 @@ class TaskTest < Test::Unit::TestCase
100
106
  context ' with explicit due date of today and additional tag' do
101
107
  setup do
102
108
  @d = Date.today
103
- @task = Taskish::Task.new('proj', "do something @due(#{ @d.strftime('%Y-%m-%d') }) @weekly")
109
+ @task = Taskish::Task.new( Taskish::Project.new('my project'), "do something @due(#{ @d.strftime('%Y-%m-%d') }) @weekly" )
104
110
  end
105
111
  should 'not be nil' do
106
112
  assert_not_nil @task.due
@@ -119,7 +125,7 @@ class TaskTest < Test::Unit::TestCase
119
125
  context ' with explicit due date of tomorrow' do
120
126
  setup do
121
127
  @d = Date.today + 1
122
- @task = Taskish::Task.new('proj', "do something @due(#{ @d.strftime('%Y-%m-%d') })")
128
+ @task = Taskish::Task.new( Taskish::Project.new('my project'), "do something @due(#{ @d.strftime('%Y-%m-%d') })" )
123
129
  end
124
130
  should 'not be nil' do
125
131
  assert_not_nil @task.due
@@ -138,28 +144,27 @@ class TaskTest < Test::Unit::TestCase
138
144
 
139
145
  context 'parse()' do
140
146
  setup do
141
- @project = 'some project'
147
+ @project = Taskish::Project.new('my project')
142
148
  @task = 'some task'
143
149
  @today = Date.today
144
150
  end
145
151
 
146
152
  should 'raise ArgumentError if nil project' do
147
- assert_raise(ArgumentError, 'invalid project') { Taskish::Task.new(nil, @task) }
153
+ assert_raise(ArgumentError, 'invalid project') { Taskish::Task.new(nil, @task) }
148
154
  end
149
155
  should 'raise ArgumentError if empty project' do
150
- assert_raise(ArgumentError, 'invalid project') { Taskish::Task.new('', @task) }
156
+ assert_raise(ArgumentError, 'invalid project') { Taskish::Task.new('', @task) }
151
157
  end
152
158
  should 'raise ArgumentError if nil task' do
153
- assert_raise(ArgumentError, 'invalid task') { Taskish::Task.new(@project, nil) }
159
+ assert_raise(ArgumentError, 'invalid project/task') { Taskish::Task.new(@project, nil) }
154
160
  end
155
161
  should 'raise ArgumentError if empty task' do
156
- assert_raise(ArgumentError, 'invalid task') { Taskish::Task.new(@project, '') }
162
+ assert_raise(ArgumentError, 'invalid project/task') { Taskish::Task.new(@project, '') }
157
163
  end
158
164
 
159
165
  should 'handle :project and :task' do
160
166
  task = @task
161
- hash = Taskish::Task.parse(@project, task)
162
- assert_equal @project, hash[:project]
167
+ hash = Taskish::Task.parse(task)
163
168
  assert_equal @task, hash[:task]
164
169
  assert_equal false, hash.key?(:due)
165
170
  assert_equal false, hash.key?(:done)
@@ -168,8 +173,7 @@ class TaskTest < Test::Unit::TestCase
168
173
 
169
174
  should 'handle :project and :task with trailing whitespace' do
170
175
  task = "#{ @task } "
171
- hash = Taskish::Task.parse(@project, task)
172
- assert_equal @project, hash[:project]
176
+ hash = Taskish::Task.parse(task)
173
177
  assert_equal @task, hash[:task]
174
178
  assert_equal false, hash.key?(:due)
175
179
  assert_equal false, hash.key?(:done)
@@ -178,8 +182,7 @@ class TaskTest < Test::Unit::TestCase
178
182
 
179
183
  should 'handle :project, :task and implicit :due' do
180
184
  task = "#{ @task } @due"
181
- hash = Taskish::Task.parse(@project, task)
182
- assert_equal @project, hash[:project]
185
+ hash = Taskish::Task.parse(task)
183
186
  assert_equal @task, hash[:task]
184
187
  assert_equal @today.to_s, hash[:due].to_s
185
188
  assert_equal false, hash.key?(:done)
@@ -188,8 +191,7 @@ class TaskTest < Test::Unit::TestCase
188
191
 
189
192
  should 'handle :project, :task and :done' do
190
193
  task = "#{ @task } @done"
191
- hash = Taskish::Task.parse(@project, task)
192
- assert_equal @project, hash[:project]
194
+ hash = Taskish::Task.parse(task)
193
195
  assert_equal @task, hash[:task]
194
196
  assert_equal false, hash.key?(:due)
195
197
  assert_equal true, hash.key?(:done)
@@ -198,8 +200,7 @@ class TaskTest < Test::Unit::TestCase
198
200
 
199
201
  should 'handle :project, :task, implicit :due and :done' do
200
202
  task = "#{ @task } @due @done"
201
- hash = Taskish::Task.parse(@project, task)
202
- assert_equal @project, hash[:project]
203
+ hash = Taskish::Task.parse(task)
203
204
  assert_equal @task, hash[:task]
204
205
  assert_equal @today.to_s, hash[:due].to_s
205
206
  assert_equal true, hash.key?(:done)
@@ -208,8 +209,7 @@ class TaskTest < Test::Unit::TestCase
208
209
 
209
210
  should 'handle :project, :task and explicit :due' do
210
211
  task = "#{ @task } @due(#{ @today.to_s })"
211
- hash = Taskish::Task.parse(@project, task)
212
- assert_equal @project, hash[:project]
212
+ hash = Taskish::Task.parse(task)
213
213
  assert_equal @task, hash[:task]
214
214
  assert_equal @today.to_s, hash[:due].to_s
215
215
  assert_equal false, hash.key?(:done)
@@ -218,8 +218,7 @@ class TaskTest < Test::Unit::TestCase
218
218
 
219
219
  should 'handle :project, :task, explicit :due and :done' do
220
220
  task = "#{ @task } @due(#{ @today.to_s }) @done"
221
- hash = Taskish::Task.parse(@project, task)
222
- assert_equal @project, hash[:project]
221
+ hash = Taskish::Task.parse(task)
223
222
  assert_equal @task, hash[:task]
224
223
  assert_equal @today.to_s, hash[:due].to_s
225
224
  assert_equal true, hash.key?(:done)
@@ -228,8 +227,7 @@ class TaskTest < Test::Unit::TestCase
228
227
 
229
228
  should 'handle :project, :task and random other tag (by ignoring random other tag)' do
230
229
  task = "#{ @task } @weekly"
231
- hash = Taskish::Task.parse(@project, task)
232
- assert_equal @project, hash[:project]
230
+ hash = Taskish::Task.parse(task)
233
231
  assert_equal task, hash[:task]
234
232
  assert_equal false, hash.key?(:due)
235
233
  assert_equal false, hash.key?(:done)
@@ -237,5 +235,26 @@ class TaskTest < Test::Unit::TestCase
237
235
  end
238
236
  end
239
237
 
238
+ context '#to_s()' do
239
+ setup do
240
+ @parent = Taskish::Project.new('parent project')
241
+ @task = Taskish::Task.new( @parent, 'child task #1' )
242
+ @child_p1 = Taskish::Project.new('child project #1')
243
+ @child_p2 = Taskish::Project.new('child project #2')
244
+ @child_t1 = Taskish::Task.new( @child_p1, 'child project #1 task #1' )
245
+ @child_t2 = Taskish::Task.new( @child_p2, 'child project #2 task #1' )
246
+ @parent << @task
247
+ @child_p1 << @child_t1
248
+ @child_p2 << @child_t2
249
+ @parent << @child_p1
250
+ @parent << @child_p2
251
+ end
252
+ should 'return correct string representation' do
253
+ assert_equal "parent project: \tchild task #1", @task.to_s
254
+ assert_equal "parent project: child project #1:\tchild project #1 task #1", @child_t1.to_s
255
+ assert_equal "parent project: child project #2:\tchild project #2 task #1", @child_t2.to_s
256
+ end
257
+ end
258
+
240
259
  end # class TaskTest
241
260