taskish 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,415 @@
1
+ ---
2
+ Unit Tests:
3
+ :original_result:
4
+ /Users/blair/Documents/p/taskish/lib/taskish.rb:
5
+ - 1
6
+ - 1
7
+ - 1
8
+ -
9
+ -
10
+ -
11
+ -
12
+ -
13
+ -
14
+ -
15
+ -
16
+ -
17
+ -
18
+ -
19
+ -
20
+ -
21
+ -
22
+ -
23
+ -
24
+ -
25
+ -
26
+ -
27
+ -
28
+ -
29
+ -
30
+ -
31
+ -
32
+ -
33
+ -
34
+ -
35
+ -
36
+ -
37
+ -
38
+ -
39
+ -
40
+ -
41
+ -
42
+ -
43
+ -
44
+ -
45
+ - 1
46
+ - 1
47
+ - 12
48
+ - 12
49
+ -
50
+ -
51
+ -
52
+ - 1
53
+ - 7
54
+ -
55
+ -
56
+ -
57
+ - 1
58
+ - 21
59
+ - 17
60
+ - 17
61
+ -
62
+ -
63
+ - 1
64
+ - 0
65
+ -
66
+ -
67
+ - 1
68
+ - 1
69
+ - 1
70
+ - 13
71
+ -
72
+ - 1
73
+ -
74
+ -
75
+ - 1
76
+ - 1
77
+ - 1
78
+ - 13
79
+ -
80
+ - 3
81
+ -
82
+ -
83
+ -
84
+ - 1
85
+ - 5
86
+ - 5
87
+ - 100
88
+ - 100
89
+ - 100
90
+ - 20
91
+ - 5
92
+ -
93
+ -
94
+ - 15
95
+ - 15
96
+ - 15
97
+ -
98
+ -
99
+ -
100
+ - 10
101
+ - 0
102
+ - 0
103
+ -
104
+ - 10
105
+ -
106
+ - 10
107
+ - 10
108
+ -
109
+ - 0
110
+ - 0
111
+ - 0
112
+ -
113
+ - 0
114
+ -
115
+ - 10
116
+ -
117
+ - 110
118
+ - 10
119
+ - 10
120
+ -
121
+ - 50
122
+ -
123
+ -
124
+ - 20
125
+ -
126
+ - 0
127
+ -
128
+ -
129
+ -
130
+ -
131
+ -
132
+ - 1
133
+ - 39
134
+ -
135
+ -
136
+ - 1
137
+ - 8
138
+ - 5
139
+ - 5
140
+ -
141
+ -
142
+ -
143
+ -
144
+ -
145
+ /Users/blair/Documents/p/taskish/lib/taskish/project.rb:
146
+ - 1
147
+ -
148
+ - 1
149
+ -
150
+ -
151
+ -
152
+ -
153
+ -
154
+ -
155
+ -
156
+ -
157
+ -
158
+ -
159
+ -
160
+ -
161
+ -
162
+ -
163
+ -
164
+ -
165
+ -
166
+ -
167
+ -
168
+ -
169
+ -
170
+ -
171
+ -
172
+ -
173
+ -
174
+ -
175
+ -
176
+ - 1
177
+ - 1
178
+ -
179
+ - 1
180
+ - 95
181
+ - 95
182
+ - 95
183
+ - 95
184
+ -
185
+ -
186
+ - 1
187
+ - 90
188
+ - 2
189
+ -
190
+ - 88
191
+ - 20
192
+ -
193
+ - 88
194
+ - 88
195
+ -
196
+ -
197
+ - 1
198
+ - 0
199
+ - 0
200
+ - 0
201
+ - 0
202
+ -
203
+ -
204
+ -
205
+ - 1
206
+ - 22
207
+ -
208
+ -
209
+ - 1
210
+ - 39
211
+ - 133
212
+ -
213
+ - 0
214
+ -
215
+ -
216
+ -
217
+ -
218
+ - 1
219
+ - 18
220
+ -
221
+ -
222
+ -
223
+ -
224
+ -
225
+ -
226
+ /Users/blair/Documents/p/taskish/lib/taskish/task.rb:
227
+ - 1
228
+ -
229
+ - 1
230
+ -
231
+ -
232
+ -
233
+ -
234
+ -
235
+ -
236
+ -
237
+ -
238
+ -
239
+ -
240
+ -
241
+ -
242
+ -
243
+ - 1
244
+ - 1
245
+ -
246
+ - 1
247
+ - 99
248
+ - 97
249
+ - 95
250
+ - 95
251
+ -
252
+ -
253
+ - 1
254
+ - 15
255
+ -
256
+ -
257
+ - 1
258
+ - 13
259
+ -
260
+ -
261
+ - 1
262
+ - 22
263
+ - 13
264
+ -
265
+ - 8
266
+ -
267
+ - 0
268
+ -
269
+ - 5
270
+ -
271
+ - 0
272
+ -
273
+ - 0
274
+ -
275
+ -
276
+ - 1
277
+ - 25
278
+ -
279
+ -
280
+ - 1
281
+ - 105
282
+ - 103
283
+ -
284
+ -
285
+ - 103
286
+ -
287
+ - 103
288
+ - 19
289
+ - 19
290
+ -
291
+ -
292
+ - 103
293
+ - 14
294
+ - 14
295
+ - 14
296
+ -
297
+ - 25
298
+ - 25
299
+ -
300
+ -
301
+ - 103
302
+ - 103
303
+ -
304
+ -
305
+ - 1
306
+ - 0
307
+ -
308
+ -
309
+ - 1
310
+ - 5
311
+ -
312
+ -
313
+ -
314
+ - 1
315
+ - 3
316
+ - 3
317
+ - 0
318
+ -
319
+ - 3
320
+ -
321
+ -
322
+ -
323
+ -
324
+ -
325
+ /Users/blair/Documents/p/taskish/lib/taskish/version.rb:
326
+ - 1
327
+ - 1
328
+ -
329
+ /Users/blair/Documents/p/taskish/lib/taskish/app.rb:
330
+ -
331
+ - 1
332
+ -
333
+ -
334
+ -
335
+ -
336
+ -
337
+ -
338
+ -
339
+ -
340
+ -
341
+ -
342
+ -
343
+ -
344
+ -
345
+ -
346
+ -
347
+ -
348
+ -
349
+ - 1
350
+ -
351
+ - 1
352
+ -
353
+ - 1
354
+ - 6
355
+ - 6
356
+ - 6
357
+ -
358
+ -
359
+ - 1
360
+ - 0
361
+ - 0
362
+ - 0
363
+ -
364
+ -
365
+ - 1
366
+ - 2
367
+ - 1
368
+ - 1
369
+ - 1
370
+ -
371
+ -
372
+ - 1
373
+ - 0
374
+ - 0
375
+ - 0
376
+ -
377
+ - 0
378
+ -
379
+ - 0
380
+ - 0
381
+ -
382
+ - 0
383
+ - 0
384
+ -
385
+ - 0
386
+ - 0
387
+ - 0
388
+ - 0
389
+ -
390
+ - 0
391
+ -
392
+ - 0
393
+ - 0
394
+ -
395
+ - 0
396
+ - 0
397
+ - 0
398
+ -
399
+ -
400
+ - 0
401
+ -
402
+ -
403
+ -
404
+ -
405
+ -
406
+ -
407
+ - 1
408
+ - 1
409
+ -
410
+ -
411
+ -
412
+ -
413
+ -
414
+ -
415
+ :created_at: 2011-07-09 08:44:29.060371 -05:00
@@ -1,3 +1,4 @@
1
+ require 'taskish/project'
1
2
  require 'taskish/task'
2
3
  require 'taskish/version'
3
4
 
@@ -39,51 +40,83 @@ require 'taskish/version'
39
40
  #
40
41
  class Taskish
41
42
  def initialize
42
- @data = {}
43
+ @projects = {}
43
44
  yield self if block_given?
44
45
  end
45
46
 
47
+ # Get +project+.
48
+ def [](name)
49
+ @projects[name]
50
+ end
51
+
52
+ # Add +project+.
53
+ def <<(project)
54
+ raise(ArgumentError, 'invalid project') if ( project.nil? || !project.kind_of?(Taskish::Project) )
55
+ @projects[project.name] = project
56
+ self
57
+ end
58
+
59
+ def debug
60
+ @projects.values.each { |project| project.debug }
61
+ end
62
+
46
63
  def done
47
64
  task_list = []
48
- @data.each_pair do |project, tasks|
49
- tasks.each { |task| task_list << task if task.done? }
65
+ @projects.each_pair do |name, project|
66
+ project.tasks.each { |task| task_list << task if task.done? }
50
67
  end
51
68
  task_list
52
69
  end
53
70
 
54
71
  def due( due = :today )
55
72
  task_list = []
56
- @data.each_pair do |project, tasks|
57
- tasks.each { |task| task_list << task if ( task.due?(due) and !task.done? ) }
73
+ @projects.each_pair do |name, project|
74
+ project.tasks.each { |task| task_list << task if ( task.due?(due) and !task.done? ) }
58
75
  end
59
- task_list.sort_by { |t| t.due }
60
- end
61
-
62
- def key?(key)
63
- @data.key? key
76
+ task_list.sort_by { |t| [ t.due, t.parent.to_s ] }
64
77
  end
65
78
 
79
+ # TODO Move into "Taskish::Project" to properly handle child projects? #7
66
80
  def parse(lines)
67
- project = nil
81
+ projects = []
68
82
  lines.each_with_index do |l, idx|
69
83
  idx += 1
70
84
  l.chomp!
71
- if l =~ /^(\S.+):$/
72
- if key? $1
73
- # warn "line ##{idx} - duplicate project '#{ $1 }'"
85
+ if l =~ /^(\S.+):$/ # Project
86
+ if project? $1
87
+ projects = [ self[ $1 ] ]
88
+ #warn "RE-USING PROJECT=#{ $1 }"
74
89
  else
75
- @data[ $1 ] = []
90
+ p = Taskish::Project.new( $1 ) unless project?( $1 )
91
+ projects = [ p ]
92
+ self.<<(p)
93
+ #warn "PROJECT=#{ $1 }"
76
94
  end
77
- project = $1
78
- elsif l =~ /^\s+\-\s+(.*)$/
79
- #warn "TASK => #{ $1 }"
80
- if project
81
- @data[project] << Task.new(project, $1)
82
- else
83
- warn "line ##{idx} - no project for task; skipping (#{l})"
95
+ elsif l =~ /^(\s+)(\S+.+):$/ # Child Project
96
+ if projects.empty?
97
+ warn "skipping child project without a parent project - #{ $2 }"
98
+ next
99
+ end
100
+ p = Taskish::Project.new( $2 )
101
+ # TODO This is too ugly to be the best way of handling it.
102
+ if projects[ $1.length ] == nil # First child project at this depth
103
+ projects[-1] << p
104
+ else # Subsequent child project (at some depth)
105
+ while $1.length < ( projects.size + 1 ) # Go up the tree
106
+ projects.pop
107
+ projects.pop while projects.last.nil?
108
+ end
109
+ projects.last << p
84
110
  end
111
+ projects[ $1.length ] = p
112
+ elsif l =~ /^(\s+)\-\s+(.*)$/ # Task
113
+ while $1.length < ( projects.size + 1 )
114
+ projects.pop
115
+ projects.pop while projects.last.nil? # TODO Dubious...
116
+ end
117
+ projects.last << Task.new( projects.last, $2 )
118
+ # warn "\tPROJECT=#{ projects.last.name }\tTASK=#{ $2 }"
85
119
  elsif l =~ /^\S*$/
86
- #warn "SKIP! (#{l})"
87
120
  next
88
121
  else
89
122
  warn "invalid line ##{idx} - (#{l})"
@@ -91,6 +124,11 @@ class Taskish
91
124
  end
92
125
  end
93
126
 
127
+ # Is project +name+ defined?
128
+ def project?(name)
129
+ @projects.key? name
130
+ end
131
+
94
132
  def readlines(fn)
95
133
  raise(ArgumentError, 'file does not exist') if ( fn.nil? || !File.exist?(fn) )
96
134
  parse( File.open(fn).readlines )