tudu 0.0.5 → 0.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 +7 -0
- data/.rubocop.yml +0 -4
- data/Gemfile +0 -4
- data/Rakefile +1 -1
- data/bin/tudu +2 -0
- data/lib/task.rb +33 -0
- data/lib/tasks.rb +66 -135
- data/lib/tudu/version.rb +1 -1
- data/lib/tudu_core.rb +23 -19
- data/lib/tudu_dsl.rb +11 -11
- data/lib/tudu_file_keys.rb +17 -0
- data/lib/tudu_paths.rb +37 -0
- data/lib/tudu_templates.rb +38 -0
- data/spec/tasks_spec.rb +160 -158
- data/spec/tudu_core_spec.rb +51 -46
- data/spec/tudu_dsl_spec.rb +4 -3
- data/tudu.gemspec +28 -27
- metadata +56 -25
data/lib/tudu_dsl.rb
CHANGED
@@ -23,19 +23,19 @@ module Tudu
|
|
23
23
|
|
24
24
|
# == initialize Dsl
|
25
25
|
# === Params
|
26
|
-
#-
|
27
|
-
def target_type(
|
28
|
-
return if
|
29
|
-
return unless
|
30
|
-
|
31
|
-
return unless TARGET_TYPES.include?
|
32
|
-
@_target_type =
|
26
|
+
#- target_type: target notice type
|
27
|
+
def target_type(target_type)
|
28
|
+
return if target_type.nil?
|
29
|
+
return unless [String, Symbol].include?(target_type.class)
|
30
|
+
target_type = target_type.to_sym if target_type.instance_of? String
|
31
|
+
return unless TARGET_TYPES.include? target_type
|
32
|
+
@_target_type = target_type
|
33
33
|
end
|
34
34
|
|
35
|
-
def targets(
|
36
|
-
return if
|
37
|
-
return unless
|
38
|
-
@_targets =
|
35
|
+
def targets(target_type)
|
36
|
+
return if target_type.nil?
|
37
|
+
return unless target_type.instance_of? Array
|
38
|
+
@_targets = target_type
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Tudu
|
4
|
+
# = Tudu::TuduFileKeys
|
5
|
+
module TuduFileKeys
|
6
|
+
# == Tudufile key
|
7
|
+
TUDU_FILE_KEY = :tudufile
|
8
|
+
# == todo key
|
9
|
+
TUDU_TODO_KEY = :todo
|
10
|
+
# == doing key
|
11
|
+
TUDU_DOING_KEY = :doing
|
12
|
+
# == done key
|
13
|
+
TUDU_DONE_KEY = :done
|
14
|
+
# == file's key
|
15
|
+
TUDU_KEYS = [TUDU_FILE_KEY, TUDU_TODO_KEY, TUDU_DOING_KEY, TUDU_DONE_KEY]
|
16
|
+
end
|
17
|
+
end
|
data/lib/tudu_paths.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'tudu_file_keys'
|
3
|
+
|
4
|
+
module Tudu
|
5
|
+
# = Tudu::TuduPaths
|
6
|
+
module TuduPaths
|
7
|
+
# == Tudufile file name
|
8
|
+
TUDU_FILE = 'Tudufile'
|
9
|
+
# == Tudufile file name
|
10
|
+
TUDU_DIR = 'tudu'
|
11
|
+
# == todo file name
|
12
|
+
TUDU_TODOS_FILE = 'todos'
|
13
|
+
# == todo file path
|
14
|
+
TUDU_TODOS_FILE_PATH = "./#{TUDU_DIR}/#{TUDU_TODOS_FILE}"
|
15
|
+
# == doing file name
|
16
|
+
TUDU_DOINGS_FILE = 'doings'
|
17
|
+
# == doing file path
|
18
|
+
TUDU_DOINGS_FILE_PATH = "./#{TUDU_DIR}/#{TUDU_DOINGS_FILE}"
|
19
|
+
# == done file name
|
20
|
+
TUDU_DONES_FILE = 'dones'
|
21
|
+
# == done file path
|
22
|
+
TUDU_DONES_FILE_PATH = "./#{TUDU_DIR}/#{TUDU_DONES_FILE}"
|
23
|
+
# == file names
|
24
|
+
INIT_FILES = {
|
25
|
+
TuduFileKeys::TUDU_FILE_KEY => TUDU_FILE,
|
26
|
+
TuduFileKeys::TUDU_TODO_KEY => TUDU_TODOS_FILE,
|
27
|
+
TuduFileKeys::TUDU_DOING_KEY => TUDU_DOINGS_FILE,
|
28
|
+
TuduFileKeys::TUDU_DONE_KEY => TUDU_DONES_FILE
|
29
|
+
}
|
30
|
+
# == task file names
|
31
|
+
TASK_FILES = {
|
32
|
+
TuduFileKeys::TUDU_TODO_KEY => TUDU_TODOS_FILE,
|
33
|
+
TuduFileKeys::TUDU_DOING_KEY => TUDU_DOINGS_FILE,
|
34
|
+
TuduFileKeys::TUDU_DONE_KEY => TUDU_DONES_FILE
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'tudu_file_keys'
|
3
|
+
|
4
|
+
module Tudu
|
5
|
+
# = Tudu::Templates
|
6
|
+
module Templates
|
7
|
+
# == Tudufile file template
|
8
|
+
TUDU_FILE_TEMPLATE = <<-EOS
|
9
|
+
# encoding: utf-8
|
10
|
+
|
11
|
+
# !!!!!!! in tudu ver 0.0.1 this file not using !!!!!!!
|
12
|
+
|
13
|
+
# if you want to use notification, set target type. default => :none
|
14
|
+
# you can set :none, :mail
|
15
|
+
# target_type :mail
|
16
|
+
|
17
|
+
# if you want to use notification, set targets. default => []
|
18
|
+
# if you choose target_type none, you must not set targets.
|
19
|
+
# if you choose mail, you must set target email addresses.
|
20
|
+
# targets ["target1@abcdefg", "target2@abcdefg"]
|
21
|
+
EOS
|
22
|
+
|
23
|
+
# == todo file template
|
24
|
+
TUDU_TODOS_FILE_TEMPLATE = ''
|
25
|
+
# == doing file template
|
26
|
+
TUDU_DOINGS_FILE_TEMPLATE = ''
|
27
|
+
# == done file template
|
28
|
+
TUDU_DONES_FILE_TEMPLATE = ''
|
29
|
+
|
30
|
+
# == template files
|
31
|
+
INIT_FILES_TEMPLATE = {
|
32
|
+
TuduFileKeys::TUDU_FILE_KEY => TUDU_FILE_TEMPLATE,
|
33
|
+
TuduFileKeys::TUDU_TODO_KEY => TUDU_TODOS_FILE_TEMPLATE,
|
34
|
+
TuduFileKeys::TUDU_DOING_KEY => TUDU_DOINGS_FILE_TEMPLATE,
|
35
|
+
TuduFileKeys::TUDU_DONE_KEY => TUDU_DONES_FILE_TEMPLATE
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
data/spec/tasks_spec.rb
CHANGED
@@ -2,7 +2,9 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
require 'tudu_core'
|
4
4
|
require 'tasks'
|
5
|
+
require 'task'
|
5
6
|
|
7
|
+
# rubocop:disable LineLength, UnusedMethodArgument
|
6
8
|
describe Tudu::Tasks do
|
7
9
|
|
8
10
|
context :todo? do
|
@@ -12,15 +14,15 @@ describe Tudu::Tasks do
|
|
12
14
|
case_title: 'todo task',
|
13
15
|
name: 'task_name',
|
14
16
|
type: 'todos',
|
15
|
-
expected: true
|
17
|
+
expected: true
|
16
18
|
},
|
17
19
|
{
|
18
20
|
case_no: 2,
|
19
21
|
case_title: 'not todo task',
|
20
22
|
name: 'task_name',
|
21
23
|
type: 'doings',
|
22
|
-
expected: false
|
23
|
-
}
|
24
|
+
expected: false
|
25
|
+
}
|
24
26
|
]
|
25
27
|
|
26
28
|
cases.each do |c|
|
@@ -29,7 +31,7 @@ describe Tudu::Tasks do
|
|
29
31
|
case_before c
|
30
32
|
|
31
33
|
# -- given --
|
32
|
-
tudu_task = Tudu::
|
34
|
+
tudu_task = Tudu::Task.new(c[:type], c[:name])
|
33
35
|
|
34
36
|
# -- when --
|
35
37
|
actual = tudu_task.todo?
|
@@ -58,15 +60,15 @@ describe Tudu::Tasks do
|
|
58
60
|
case_title: 'doing task',
|
59
61
|
name: 'task_name',
|
60
62
|
type: 'doings',
|
61
|
-
expected: true
|
63
|
+
expected: true
|
62
64
|
},
|
63
65
|
{
|
64
66
|
case_no: 2,
|
65
67
|
case_title: 'not doing task',
|
66
68
|
name: 'task_name',
|
67
69
|
type: 'todos',
|
68
|
-
expected: false
|
69
|
-
}
|
70
|
+
expected: false
|
71
|
+
}
|
70
72
|
]
|
71
73
|
|
72
74
|
cases.each do |c|
|
@@ -75,7 +77,7 @@ describe Tudu::Tasks do
|
|
75
77
|
case_before c
|
76
78
|
|
77
79
|
# -- given --
|
78
|
-
tudu_task = Tudu::
|
80
|
+
tudu_task = Tudu::Task.new(c[:type], c[:name])
|
79
81
|
|
80
82
|
# -- when --
|
81
83
|
actual = tudu_task.doing?
|
@@ -105,15 +107,15 @@ describe Tudu::Tasks do
|
|
105
107
|
case_title: 'done task',
|
106
108
|
name: 'task_name',
|
107
109
|
type: 'dones',
|
108
|
-
expected: true
|
110
|
+
expected: true
|
109
111
|
},
|
110
112
|
{
|
111
113
|
case_no: 2,
|
112
114
|
case_title: 'not done task',
|
113
115
|
name: 'task_name',
|
114
116
|
type: 'doings',
|
115
|
-
expected: false
|
116
|
-
}
|
117
|
+
expected: false
|
118
|
+
}
|
117
119
|
]
|
118
120
|
|
119
121
|
cases.each do |c|
|
@@ -122,7 +124,7 @@ describe Tudu::Tasks do
|
|
122
124
|
case_before c
|
123
125
|
|
124
126
|
# -- given --
|
125
|
-
tudu_task = Tudu::
|
127
|
+
tudu_task = Tudu::Task.new(c[:type], c[:name])
|
126
128
|
|
127
129
|
# -- when --
|
128
130
|
actual = tudu_task.done?
|
@@ -150,23 +152,23 @@ describe Tudu::Tasks do
|
|
150
152
|
case_no: 1,
|
151
153
|
case_title: 'get todos from file',
|
152
154
|
type: 'todos',
|
153
|
-
texts: %w
|
154
|
-
expected: %w
|
155
|
+
texts: %w(task1 task2 task3),
|
156
|
+
expected: %w(task1 task2 task3)
|
155
157
|
},
|
156
158
|
{
|
157
159
|
case_no: 2,
|
158
160
|
case_title: 'get doings from file',
|
159
161
|
type: 'doings',
|
160
|
-
texts: %w
|
161
|
-
expected: %w
|
162
|
+
texts: %w(task1 task2 task3),
|
163
|
+
expected: %w(task1 task2 task3)
|
162
164
|
},
|
163
165
|
{
|
164
166
|
case_no: 3,
|
165
167
|
case_title: 'get done from file',
|
166
168
|
type: 'dones',
|
167
|
-
texts: %w
|
168
|
-
expected: %w
|
169
|
-
}
|
169
|
+
texts: %w(task1 task2 task3),
|
170
|
+
expected: %w(task1 task2 task3)
|
171
|
+
}
|
170
172
|
]
|
171
173
|
|
172
174
|
cases.each do |c|
|
@@ -189,14 +191,14 @@ describe Tudu::Tasks do
|
|
189
191
|
|
190
192
|
def case_before(c)
|
191
193
|
# implement each case before
|
192
|
-
Dir.mkdir("./#{Tudu::
|
193
|
-
File.open("./#{Tudu::
|
194
|
+
Dir.mkdir("./#{Tudu::TuduPaths::TUDU_DIR}")
|
195
|
+
File.open("./#{Tudu::TuduPaths::TUDU_DIR}/#{c[:type]}", 'w') { |f|f.puts c[:texts].join("\n") }
|
194
196
|
end
|
195
197
|
|
196
198
|
def case_after(c)
|
197
199
|
# implement each case after
|
198
|
-
return unless File.
|
199
|
-
FileUtils.rm_rf(Tudu::
|
200
|
+
return unless File.exist? Tudu::TuduPaths::TUDU_DIR
|
201
|
+
FileUtils.rm_rf(Tudu::TuduPaths::TUDU_DIR)
|
200
202
|
end
|
201
203
|
end
|
202
204
|
end
|
@@ -207,35 +209,35 @@ describe Tudu::Tasks do
|
|
207
209
|
case_no: 1,
|
208
210
|
case_title: 'get todos from file',
|
209
211
|
type: 'todos',
|
210
|
-
texts: %w
|
212
|
+
texts: %w(task1 task2 task3),
|
211
213
|
expected: [
|
212
|
-
Tudu::
|
213
|
-
Tudu::
|
214
|
-
Tudu::
|
215
|
-
]
|
214
|
+
Tudu::Task.new('todos', 'task1'),
|
215
|
+
Tudu::Task.new('todos', 'task2'),
|
216
|
+
Tudu::Task.new('todos', 'task3')
|
217
|
+
]
|
216
218
|
},
|
217
219
|
{
|
218
220
|
case_no: 2,
|
219
221
|
case_title: 'get doings from file',
|
220
222
|
type: 'doings',
|
221
|
-
texts: %w
|
223
|
+
texts: %w(task1 task2 task3),
|
222
224
|
expected: [
|
223
|
-
Tudu::
|
224
|
-
Tudu::
|
225
|
-
Tudu::
|
226
|
-
]
|
225
|
+
Tudu::Task.new('doings', 'task1'),
|
226
|
+
Tudu::Task.new('doings', 'task2'),
|
227
|
+
Tudu::Task.new('doings', 'task3')
|
228
|
+
]
|
227
229
|
},
|
228
230
|
{
|
229
231
|
case_no: 3,
|
230
232
|
case_title: 'get done from file',
|
231
233
|
type: 'dones',
|
232
|
-
texts: %w
|
234
|
+
texts: %w(task1 task2 task3),
|
233
235
|
expected: [
|
234
|
-
Tudu::
|
235
|
-
Tudu::
|
236
|
-
Tudu::
|
237
|
-
]
|
238
|
-
}
|
236
|
+
Tudu::Task.new('dones', 'task1'),
|
237
|
+
Tudu::Task.new('dones', 'task2'),
|
238
|
+
Tudu::Task.new('dones', 'task3')
|
239
|
+
]
|
240
|
+
}
|
239
241
|
]
|
240
242
|
|
241
243
|
cases.each do |c|
|
@@ -258,31 +260,31 @@ describe Tudu::Tasks do
|
|
258
260
|
|
259
261
|
def case_before(c)
|
260
262
|
# implement each case before
|
261
|
-
Dir.mkdir("./#{Tudu::
|
262
|
-
File.open("./#{Tudu::
|
263
|
+
Dir.mkdir("./#{Tudu::TuduPaths::TUDU_DIR}")
|
264
|
+
File.open("./#{Tudu::TuduPaths::TUDU_DIR}/#{c[:type]}", 'w') { |f|f.puts c[:texts].join("\n") }
|
263
265
|
end
|
264
266
|
|
265
267
|
def case_after(c)
|
266
268
|
# implement each case after
|
267
|
-
return unless File.
|
268
|
-
FileUtils.rm_rf(Tudu::
|
269
|
+
return unless File.exist? Tudu::TuduPaths::TUDU_DIR
|
270
|
+
FileUtils.rm_rf(Tudu::TuduPaths::TUDU_DIR)
|
269
271
|
end
|
270
272
|
end
|
271
273
|
end
|
272
274
|
|
273
|
-
context :
|
275
|
+
context :todos do
|
274
276
|
cases = [
|
275
277
|
{
|
276
278
|
case_no: 1,
|
277
279
|
case_title: 'get doings from file',
|
278
280
|
type: 'doings',
|
279
|
-
texts: %w
|
281
|
+
texts: %w(task1 task2 task3),
|
280
282
|
expected: [
|
281
|
-
Tudu::
|
282
|
-
Tudu::
|
283
|
-
Tudu::
|
284
|
-
]
|
285
|
-
}
|
283
|
+
Tudu::Task.new('doings', 'task1'),
|
284
|
+
Tudu::Task.new('doings', 'task2'),
|
285
|
+
Tudu::Task.new('doings', 'task3')
|
286
|
+
]
|
287
|
+
}
|
286
288
|
]
|
287
289
|
|
288
290
|
cases.each do |c|
|
@@ -294,7 +296,7 @@ describe Tudu::Tasks do
|
|
294
296
|
# nothing
|
295
297
|
|
296
298
|
# -- when --
|
297
|
-
actual = Tudu::Tasks.
|
299
|
+
actual = Tudu::Tasks.doings
|
298
300
|
|
299
301
|
# -- then --
|
300
302
|
expect(actual).to eq(c[:expected])
|
@@ -305,31 +307,31 @@ describe Tudu::Tasks do
|
|
305
307
|
|
306
308
|
def case_before(c)
|
307
309
|
# implement each case before
|
308
|
-
Dir.mkdir("./#{Tudu::
|
309
|
-
File.open("./#{Tudu::
|
310
|
+
Dir.mkdir("./#{Tudu::TuduPaths::TUDU_DIR}")
|
311
|
+
File.open("./#{Tudu::TuduPaths::TUDU_DIR}/#{c[:type]}", 'w') { |f|f.puts c[:texts].join("\n") }
|
310
312
|
end
|
311
313
|
|
312
314
|
def case_after(c)
|
313
315
|
# implement each case after
|
314
|
-
return unless File.
|
315
|
-
FileUtils.rm_rf(Tudu::
|
316
|
+
return unless File.exist? Tudu::TuduPaths::TUDU_DIR
|
317
|
+
FileUtils.rm_rf(Tudu::TuduPaths::TUDU_DIR)
|
316
318
|
end
|
317
319
|
end
|
318
320
|
end
|
319
321
|
|
320
|
-
context :
|
322
|
+
context :dones do
|
321
323
|
cases = [
|
322
324
|
{
|
323
325
|
case_no: 1,
|
324
326
|
case_title: 'get done from file',
|
325
327
|
type: 'dones',
|
326
|
-
texts: %w
|
328
|
+
texts: %w(task1 task2 task3),
|
327
329
|
expected: [
|
328
|
-
Tudu::
|
329
|
-
Tudu::
|
330
|
-
Tudu::
|
331
|
-
]
|
332
|
-
}
|
330
|
+
Tudu::Task.new('dones', 'task1'),
|
331
|
+
Tudu::Task.new('dones', 'task2'),
|
332
|
+
Tudu::Task.new('dones', 'task3')
|
333
|
+
]
|
334
|
+
}
|
333
335
|
]
|
334
336
|
|
335
337
|
cases.each do |c|
|
@@ -341,7 +343,7 @@ describe Tudu::Tasks do
|
|
341
343
|
# nothing
|
342
344
|
|
343
345
|
# -- when --
|
344
|
-
actual = Tudu::Tasks.
|
346
|
+
actual = Tudu::Tasks.dones
|
345
347
|
|
346
348
|
# -- then --
|
347
349
|
expect(actual).to eq(c[:expected])
|
@@ -352,14 +354,14 @@ describe Tudu::Tasks do
|
|
352
354
|
|
353
355
|
def case_before(c)
|
354
356
|
# implement each case before
|
355
|
-
Dir.mkdir("./#{Tudu::
|
356
|
-
File.open("./#{Tudu::
|
357
|
+
Dir.mkdir("./#{Tudu::TuduPaths::TUDU_DIR}")
|
358
|
+
File.open("./#{Tudu::TuduPaths::TUDU_DIR}/#{c[:type]}", 'w') { |f|f.puts c[:texts].join("\n") }
|
357
359
|
end
|
358
360
|
|
359
361
|
def case_after(c)
|
360
362
|
# implement each case after
|
361
|
-
return unless File.
|
362
|
-
FileUtils.rm_rf(Tudu::
|
363
|
+
return unless File.exist? Tudu::TuduPaths::TUDU_DIR
|
364
|
+
FileUtils.rm_rf(Tudu::TuduPaths::TUDU_DIR)
|
363
365
|
end
|
364
366
|
end
|
365
367
|
end
|
@@ -370,34 +372,34 @@ describe Tudu::Tasks do
|
|
370
372
|
case_no: 1,
|
371
373
|
case_title: 'find todos from tasks',
|
372
374
|
type: 'todos',
|
373
|
-
texts: %w
|
375
|
+
texts: %w(task1 task2 task3),
|
374
376
|
search_name: 'task1',
|
375
|
-
expected: Tudu::
|
377
|
+
expected: Tudu::Task.new('todos', 'task1')
|
376
378
|
},
|
377
379
|
{
|
378
380
|
case_no: 2,
|
379
381
|
case_title: 'find doings from tasks',
|
380
382
|
type: 'doings',
|
381
|
-
texts: %w
|
383
|
+
texts: %w(task1 task2 task3),
|
382
384
|
search_name: 'task1',
|
383
|
-
expected: Tudu::
|
385
|
+
expected: Tudu::Task.new('doings', 'task1')
|
384
386
|
},
|
385
387
|
{
|
386
388
|
case_no: 3,
|
387
389
|
case_title: 'find done from tasks',
|
388
390
|
type: 'dones',
|
389
|
-
texts: %w
|
391
|
+
texts: %w(task1 task2 task3),
|
390
392
|
search_name: 'task1',
|
391
|
-
expected: Tudu::
|
393
|
+
expected: Tudu::Task.new('dones', 'task1')
|
392
394
|
},
|
393
395
|
{
|
394
396
|
case_no: 4,
|
395
397
|
case_title: 'not find',
|
396
398
|
type: 'dones',
|
397
|
-
texts: %w
|
399
|
+
texts: %w(task1 task2 task3),
|
398
400
|
search_name: 'task4',
|
399
401
|
expected: nil
|
400
|
-
}
|
402
|
+
}
|
401
403
|
]
|
402
404
|
|
403
405
|
cases.each do |c|
|
@@ -421,14 +423,14 @@ describe Tudu::Tasks do
|
|
421
423
|
def case_before(c)
|
422
424
|
# implement each case before
|
423
425
|
Tudu::Core.new.init
|
424
|
-
Dir.mkdir(Tudu::
|
425
|
-
File.open("./#{Tudu::
|
426
|
+
Dir.mkdir(Tudu::TuduPaths::TUDU_DIR) unless File.exist?(Tudu::TuduPaths::TUDU_DIR)
|
427
|
+
File.open("./#{Tudu::TuduPaths::TUDU_DIR}/#{c[:type]}", 'w') { |f|f.puts c[:texts].join("\n") }
|
426
428
|
end
|
427
429
|
|
428
430
|
def case_after(c)
|
429
431
|
# implement each case after
|
430
|
-
return unless File.
|
431
|
-
FileUtils.rm_rf(Tudu::
|
432
|
+
return unless File.exist? Tudu::TuduPaths::TUDU_DIR
|
433
|
+
FileUtils.rm_rf(Tudu::TuduPaths::TUDU_DIR)
|
432
434
|
end
|
433
435
|
end
|
434
436
|
end
|
@@ -439,87 +441,86 @@ describe Tudu::Tasks do
|
|
439
441
|
case_no: 1,
|
440
442
|
case_title: 'choose task',
|
441
443
|
type: 'todos',
|
442
|
-
texts: %w
|
444
|
+
texts: %w(task1 task2 task3),
|
443
445
|
choose: 'task1',
|
444
446
|
expected: [
|
445
|
-
Tudu::
|
446
|
-
Tudu::
|
447
|
-
Tudu::
|
447
|
+
Tudu::Task.new('todos', 'task2'),
|
448
|
+
Tudu::Task.new('todos', 'task3'),
|
449
|
+
Tudu::Task.new('doings', 'task1')
|
448
450
|
]
|
449
451
|
},
|
450
452
|
{
|
451
453
|
case_no: 2,
|
452
454
|
case_title: 'aleady exists doing',
|
453
455
|
type: 'doings',
|
454
|
-
texts: %w
|
456
|
+
texts: %w(task1 task2 task3),
|
455
457
|
choose: 'task1',
|
456
458
|
expected: [
|
457
|
-
Tudu::
|
458
|
-
Tudu::
|
459
|
-
Tudu::
|
459
|
+
Tudu::Task.new('doings', 'task1'),
|
460
|
+
Tudu::Task.new('doings', 'task2'),
|
461
|
+
Tudu::Task.new('doings', 'task3')
|
460
462
|
]
|
461
463
|
},
|
462
464
|
{
|
463
465
|
case_no: 3,
|
464
466
|
case_title: 'not exists task',
|
465
467
|
type: 'todos',
|
466
|
-
texts: %w
|
468
|
+
texts: %w(task1 task2 task3),
|
467
469
|
choose: 'task4',
|
468
470
|
expected: [
|
469
|
-
Tudu::
|
470
|
-
Tudu::
|
471
|
-
Tudu::
|
471
|
+
Tudu::Task.new('todos', 'task1'),
|
472
|
+
Tudu::Task.new('todos', 'task2'),
|
473
|
+
Tudu::Task.new('todos', 'task3')
|
472
474
|
]
|
473
475
|
},
|
474
476
|
{
|
475
477
|
case_no: 4,
|
476
478
|
case_title: 'task exists, but dones',
|
477
479
|
type: 'dones',
|
478
|
-
texts: %w
|
480
|
+
texts: %w(task1 task2 task3),
|
479
481
|
choose: 'task1',
|
480
482
|
expected: [
|
481
|
-
Tudu::
|
482
|
-
Tudu::
|
483
|
-
Tudu::
|
483
|
+
Tudu::Task.new('dones', 'task1'),
|
484
|
+
Tudu::Task.new('dones', 'task2'),
|
485
|
+
Tudu::Task.new('dones', 'task3')
|
484
486
|
]
|
485
487
|
},
|
486
488
|
{
|
487
489
|
case_no: 5,
|
488
490
|
case_title: 'task exists, empty args',
|
489
491
|
type: 'todos',
|
490
|
-
texts: %w
|
492
|
+
texts: %w(task1 task2 task3),
|
491
493
|
choose: '',
|
492
494
|
expected: [
|
493
|
-
Tudu::
|
494
|
-
Tudu::
|
495
|
-
Tudu::
|
495
|
+
Tudu::Task.new('todos', 'task2'),
|
496
|
+
Tudu::Task.new('todos', 'task3'),
|
497
|
+
Tudu::Task.new('doings', 'task1')
|
496
498
|
]
|
497
499
|
},
|
498
500
|
{
|
499
501
|
case_no: 6,
|
500
502
|
case_title: 'task exists, nil args',
|
501
503
|
type: 'todos',
|
502
|
-
texts: %w
|
504
|
+
texts: %w(task1 task2 task3),
|
503
505
|
choose: nil,
|
504
506
|
expected: [
|
505
|
-
Tudu::
|
506
|
-
Tudu::
|
507
|
-
Tudu::
|
507
|
+
Tudu::Task.new('todos', 'task2'),
|
508
|
+
Tudu::Task.new('todos', 'task3'),
|
509
|
+
Tudu::Task.new('doings', 'task1')
|
508
510
|
]
|
509
511
|
},
|
510
512
|
{
|
511
513
|
case_no: 7,
|
512
514
|
case_title: 'todos not exists, empty args',
|
513
515
|
type: 'doings',
|
514
|
-
texts: %w
|
516
|
+
texts: %w(task1 task2 task3),
|
515
517
|
choose: nil,
|
516
518
|
expected: [
|
517
|
-
Tudu::
|
518
|
-
Tudu::
|
519
|
-
Tudu::
|
519
|
+
Tudu::Task.new('doings', 'task1'),
|
520
|
+
Tudu::Task.new('doings', 'task2'),
|
521
|
+
Tudu::Task.new('doings', 'task3')
|
520
522
|
]
|
521
|
-
}
|
522
|
-
|
523
|
+
}
|
523
524
|
]
|
524
525
|
|
525
526
|
cases.each do |c|
|
@@ -543,13 +544,13 @@ describe Tudu::Tasks do
|
|
543
544
|
def case_before(c)
|
544
545
|
# implement each case before
|
545
546
|
Tudu::Core.new.init
|
546
|
-
File.open("./#{Tudu::
|
547
|
+
File.open("./#{Tudu::TuduPaths::TUDU_DIR}/#{c[:type]}", 'w') { |f|f.puts c[:texts].join("\n") }
|
547
548
|
end
|
548
549
|
|
549
550
|
def case_after(c)
|
550
551
|
# implement each case after
|
551
|
-
return unless File.
|
552
|
-
FileUtils.rm_rf(Tudu::
|
552
|
+
return unless File.exist? Tudu::TuduPaths::TUDU_DIR
|
553
|
+
FileUtils.rm_rf(Tudu::TuduPaths::TUDU_DIR)
|
553
554
|
end
|
554
555
|
end
|
555
556
|
end
|
@@ -559,12 +560,12 @@ describe Tudu::Tasks do
|
|
559
560
|
{
|
560
561
|
case_no: 1,
|
561
562
|
case_title: 'one doing to done, shift todo to doing',
|
562
|
-
task_names: %w
|
563
|
+
task_names: %w(task1 task2 task3),
|
563
564
|
choose: 'task1',
|
564
565
|
expected: [
|
565
|
-
Tudu::
|
566
|
-
Tudu::
|
567
|
-
Tudu::
|
566
|
+
Tudu::Task.new('todos', 'task3'),
|
567
|
+
Tudu::Task.new('doings', 'task2'),
|
568
|
+
Tudu::Task.new('dones', 'task1')
|
568
569
|
]
|
569
570
|
},
|
570
571
|
{
|
@@ -573,7 +574,7 @@ describe Tudu::Tasks do
|
|
573
574
|
task_names: ['task1'],
|
574
575
|
choose: 'task1',
|
575
576
|
expected: [
|
576
|
-
Tudu::
|
577
|
+
Tudu::Task.new('dones', 'task1')
|
577
578
|
]
|
578
579
|
},
|
579
580
|
{
|
@@ -582,9 +583,9 @@ describe Tudu::Tasks do
|
|
582
583
|
task_names: ['task1'],
|
583
584
|
choose: '',
|
584
585
|
expected: [
|
585
|
-
Tudu::
|
586
|
+
Tudu::Task.new('todos', 'task1')
|
586
587
|
]
|
587
|
-
}
|
588
|
+
}
|
588
589
|
]
|
589
590
|
|
590
591
|
cases.each do |c|
|
@@ -613,8 +614,8 @@ describe Tudu::Tasks do
|
|
613
614
|
|
614
615
|
def case_after(c)
|
615
616
|
# implement each case after
|
616
|
-
return unless File.
|
617
|
-
FileUtils.rm_rf(Tudu::
|
617
|
+
return unless File.exist? Tudu::TuduPaths::TUDU_DIR
|
618
|
+
FileUtils.rm_rf(Tudu::TuduPaths::TUDU_DIR)
|
618
619
|
end
|
619
620
|
end
|
620
621
|
end
|
@@ -628,7 +629,7 @@ describe Tudu::Tasks do
|
|
628
629
|
task_names2: nil,
|
629
630
|
task_names3: nil,
|
630
631
|
expected: [
|
631
|
-
Tudu::
|
632
|
+
Tudu::Task.new('todos', 'task_name')
|
632
633
|
]
|
633
634
|
},
|
634
635
|
{
|
@@ -646,9 +647,9 @@ describe Tudu::Tasks do
|
|
646
647
|
task_names2: 'task_name2',
|
647
648
|
task_names3: 'task_name3',
|
648
649
|
expected: [
|
649
|
-
Tudu::
|
650
|
-
Tudu::
|
651
|
-
Tudu::
|
650
|
+
Tudu::Task.new('todos', 'task_name1'),
|
651
|
+
Tudu::Task.new('todos', 'task_name2'),
|
652
|
+
Tudu::Task.new('todos', 'task_name3')
|
652
653
|
]
|
653
654
|
},
|
654
655
|
{
|
@@ -658,9 +659,9 @@ describe Tudu::Tasks do
|
|
658
659
|
task_names2: 'task_name1',
|
659
660
|
task_names3: nil,
|
660
661
|
expected: [
|
661
|
-
Tudu::
|
662
|
+
Tudu::Task.new('todos', 'task_name1')
|
662
663
|
]
|
663
|
-
}
|
664
|
+
}
|
664
665
|
]
|
665
666
|
|
666
667
|
cases.each do |c|
|
@@ -675,7 +676,7 @@ describe Tudu::Tasks do
|
|
675
676
|
Tudu::Tasks.add c[:task_names1], c[:task_names2], c[:task_names3]
|
676
677
|
|
677
678
|
# -- then --
|
678
|
-
actual = Tudu::Tasks.
|
679
|
+
actual = Tudu::Tasks.todos
|
679
680
|
expect(actual).to eq(c[:expected])
|
680
681
|
ensure
|
681
682
|
case_after c
|
@@ -687,8 +688,8 @@ describe Tudu::Tasks do
|
|
687
688
|
end
|
688
689
|
|
689
690
|
def case_after(c)
|
690
|
-
return unless File.
|
691
|
-
FileUtils.rm_rf(Tudu::
|
691
|
+
return unless File.exist? Tudu::TuduPaths::TUDU_DIR
|
692
|
+
FileUtils.rm_rf(Tudu::TuduPaths::TUDU_DIR)
|
692
693
|
end
|
693
694
|
end
|
694
695
|
end
|
@@ -700,22 +701,22 @@ describe Tudu::Tasks do
|
|
700
701
|
case_title: 'single remove',
|
701
702
|
add_tasks: ['task_name'],
|
702
703
|
remove_tasks: ['task_name'],
|
703
|
-
expected_tasks: []
|
704
|
+
expected_tasks: []
|
704
705
|
},
|
705
706
|
{
|
706
707
|
case_no: 2,
|
707
708
|
case_title: 'multi remove',
|
708
|
-
add_tasks: %w
|
709
|
-
remove_tasks: %w
|
710
|
-
expected_tasks: []
|
709
|
+
add_tasks: %w(task_name1 task_name2 task_name3),
|
710
|
+
remove_tasks: %w(task_name1 task_name2 task_name3),
|
711
|
+
expected_tasks: []
|
711
712
|
},
|
712
713
|
{
|
713
714
|
case_no: 3,
|
714
715
|
case_title: 'not remove',
|
715
716
|
add_tasks: ['task_name'],
|
716
717
|
remove_tasks: ['invalid name'],
|
717
|
-
expected_tasks: [Tudu::
|
718
|
-
}
|
718
|
+
expected_tasks: [Tudu::Task.new('todos', 'task_name')]
|
719
|
+
}
|
719
720
|
]
|
720
721
|
|
721
722
|
cases.each do |c|
|
@@ -743,8 +744,8 @@ describe Tudu::Tasks do
|
|
743
744
|
end
|
744
745
|
|
745
746
|
def case_after(c)
|
746
|
-
return unless File.
|
747
|
-
FileUtils.rm_rf(Tudu::
|
747
|
+
return unless File.exist? Tudu::TuduPaths::TUDU_DIR
|
748
|
+
FileUtils.rm_rf(Tudu::TuduPaths::TUDU_DIR)
|
748
749
|
end
|
749
750
|
end
|
750
751
|
end
|
@@ -755,13 +756,13 @@ describe Tudu::Tasks do
|
|
755
756
|
case_no: 1,
|
756
757
|
case_title: 'get todos from file',
|
757
758
|
tasks: [
|
758
|
-
Tudu::
|
759
|
-
Tudu::
|
760
|
-
Tudu::
|
759
|
+
Tudu::Task.new('doings', 'task1_1'),
|
760
|
+
Tudu::Task.new('doings', 'task1_2'),
|
761
|
+
Tudu::Task.new('doings', 'task3')
|
761
762
|
],
|
762
763
|
filter_word: 'task1_1',
|
763
|
-
expected: [Tudu::
|
764
|
-
}
|
764
|
+
expected: [Tudu::Task.new('doings', 'task1_1')]
|
765
|
+
}
|
765
766
|
]
|
766
767
|
|
767
768
|
cases.each do |c|
|
@@ -797,27 +798,27 @@ describe Tudu::Tasks do
|
|
797
798
|
{
|
798
799
|
case_no: 1,
|
799
800
|
case_title: 'display progress',
|
800
|
-
todos: %w
|
801
|
-
doings: %w
|
802
|
-
dones: %w
|
803
|
-
expected: '2/6|===> |33%'
|
801
|
+
todos: %w(task5 task6),
|
802
|
+
doings: %w(task3 task4),
|
803
|
+
dones: %w(task1 task2),
|
804
|
+
expected: '2/6|===> |33%'
|
804
805
|
},
|
805
806
|
{
|
806
807
|
case_no: 2,
|
807
808
|
case_title: 'display none progress',
|
808
|
-
todos: %w
|
809
|
-
doings: %w
|
809
|
+
todos: %w(task3 task4),
|
810
|
+
doings: %w(task1 task2),
|
810
811
|
dones: [],
|
811
|
-
expected: '0/4|> |0%'
|
812
|
+
expected: '0/4|> |0%'
|
812
813
|
},
|
813
814
|
{
|
814
815
|
case_no: 3,
|
815
816
|
case_title: 'display complete progress',
|
816
817
|
todos: [],
|
817
818
|
doings: [],
|
818
|
-
dones: %w
|
819
|
-
expected: '2/2|==========>|100%'
|
820
|
-
}
|
819
|
+
dones: %w(task1 task2),
|
820
|
+
expected: '2/2|==========>|100%'
|
821
|
+
}
|
821
822
|
]
|
822
823
|
|
823
824
|
cases.each do |c|
|
@@ -841,16 +842,17 @@ describe Tudu::Tasks do
|
|
841
842
|
def case_before(c)
|
842
843
|
# implement each case before
|
843
844
|
Tudu::Core.new.init
|
844
|
-
File.open("./#{Tudu::
|
845
|
-
File.open("./#{Tudu::
|
846
|
-
File.open("./#{Tudu::
|
845
|
+
File.open("./#{Tudu::TuduPaths::TUDU_DIR}/todos", 'w') { |f|f.puts c[:todos].join("\n") }
|
846
|
+
File.open("./#{Tudu::TuduPaths::TUDU_DIR}/doings", 'w') { |f|f.puts c[:doings].join("\n") }
|
847
|
+
File.open("./#{Tudu::TuduPaths::TUDU_DIR}/dones", 'w') { |f|f.puts c[:dones].join("\n") }
|
847
848
|
end
|
848
849
|
|
849
850
|
def case_after(c)
|
850
851
|
# implement each case after
|
851
|
-
return unless File.
|
852
|
-
FileUtils.rm_rf(Tudu::
|
852
|
+
return unless File.exist? Tudu::TuduPaths::TUDU_DIR
|
853
|
+
FileUtils.rm_rf(Tudu::TuduPaths::TUDU_DIR)
|
853
854
|
end
|
854
855
|
end
|
855
856
|
end
|
856
857
|
end
|
858
|
+
# rubocop:enable LineLength, UnusedMethodArgument
|