tudu 0.0.1 → 0.0.2
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/README.md +35 -5
- data/lib/tasks.rb +289 -281
- data/lib/tudu/version.rb +1 -1
- data/spec/{task_spec.rb → tasks_spec.rb} +799 -762
- data/spec/tudu_core_spec.rb +569 -574
- data/spec/tudu_dsl_spec.rb +120 -120
- metadata +14 -15
- data/lib/task.rb +0 -281
data/README.md
CHANGED
@@ -86,8 +86,8 @@ $ tudu todos
|
|
86
86
|
hige
|
87
87
|
~~~
|
88
88
|
|
89
|
-
### choose task from todo to doing
|
90
|
-
* choose
|
89
|
+
### choose task name. from todo to doing
|
90
|
+
* choose task_name
|
91
91
|
|
92
92
|
~~~
|
93
93
|
$ tudu add hoge
|
@@ -97,13 +97,25 @@ $ tudu doings
|
|
97
97
|
hoge
|
98
98
|
~~~
|
99
99
|
|
100
|
-
|
100
|
+
* choose
|
101
|
+
|
102
|
+
### choose no args. from first todo to doing
|
103
|
+
~~~
|
104
|
+
$ tudu add hoge hige
|
105
|
+
$ tudu choose
|
106
|
+
$ tudu todos
|
107
|
+
hige
|
108
|
+
$ tudu doings
|
109
|
+
hoge
|
110
|
+
~~~
|
111
|
+
|
112
|
+
### done. from doing to done and from first todos to doing
|
101
113
|
* done
|
102
114
|
|
103
115
|
~~~
|
104
116
|
$ tudu add one two three
|
105
117
|
$ tudu choose one
|
106
|
-
$ done
|
118
|
+
$ tudu done
|
107
119
|
$ tudu todos
|
108
120
|
three
|
109
121
|
$ tudu doings
|
@@ -112,13 +124,29 @@ $ tudu done
|
|
112
124
|
one
|
113
125
|
~~~
|
114
126
|
|
127
|
+
### done. from doing to done and from first todos to doing. after, if there is no todos, show celebration message.
|
128
|
+
* done
|
129
|
+
|
130
|
+
~~~
|
131
|
+
$ tudu add one two
|
132
|
+
$ tudu choose one
|
133
|
+
$ tudu done
|
134
|
+
$ tudu done
|
135
|
+
All Tasks Finish!!
|
136
|
+
$ tudu todos
|
137
|
+
$ tudu doings
|
138
|
+
$ tudu done
|
139
|
+
one
|
140
|
+
two
|
141
|
+
~~~
|
142
|
+
|
115
143
|
### tasks show all tasks from [todos, doings, dones].
|
116
144
|
* tudu tasks
|
117
145
|
|
118
146
|
~~~
|
119
147
|
$ tudu add one two three
|
120
148
|
$ tudu choose one
|
121
|
-
$ done
|
149
|
+
$ tudu done
|
122
150
|
$ tudu tasks
|
123
151
|
three
|
124
152
|
two
|
@@ -185,6 +213,8 @@ if you want to do other operation, edit [todos, doings, dones] directly.
|
|
185
213
|
it's only plain text, so you can edit freely.
|
186
214
|
|
187
215
|
## History
|
216
|
+
* version 0.0.2 : after execute 'done', if there is no todos and doings, display celebration message.
|
217
|
+
* version 0.0.2 : if 'choose' no args. choose first tudu.
|
188
218
|
* version 0.0.1 : first release.
|
189
219
|
|
190
220
|
## Contributing
|
data/lib/tasks.rb
CHANGED
@@ -1,281 +1,289 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Tudu
|
4
|
-
#= Tudu::Tasks
|
5
|
-
class Tasks
|
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
|
-
|
17
|
-
#== Tudufile file name
|
18
|
-
TUDU_FILE = "Tudufile"
|
19
|
-
#== Tudufile file name
|
20
|
-
TUDU_DIR = "tudu"
|
21
|
-
#== todo file name
|
22
|
-
TUDU_TODOS_FILE = "todos"
|
23
|
-
#== todo file path
|
24
|
-
TUDU_TODOS_FILE_PATH = "./#{TUDU_DIR}/#{TUDU_TODOS_FILE}"
|
25
|
-
#== doing file name
|
26
|
-
TUDU_DOINGS_FILE = "doings"
|
27
|
-
#== doing file path
|
28
|
-
TUDU_DOINGS_FILE_PATH = "./#{TUDU_DIR}/#{TUDU_DOINGS_FILE}"
|
29
|
-
#== done file name
|
30
|
-
TUDU_DONES_FILE = "dones"
|
31
|
-
#== done file path
|
32
|
-
TUDU_DONES_FILE_PATH = "./#{TUDU_DIR}/#{TUDU_DONES_FILE}"
|
33
|
-
#== file names
|
34
|
-
INIT_FILES = {
|
35
|
-
TUDU_FILE_KEY => TUDU_FILE,
|
36
|
-
TUDU_TODO_KEY => TUDU_TODOS_FILE,
|
37
|
-
TUDU_DOING_KEY => TUDU_DOINGS_FILE,
|
38
|
-
TUDU_DONE_KEY => TUDU_DONES_FILE
|
39
|
-
}
|
40
|
-
#== task file names
|
41
|
-
TASK_FILES = {
|
42
|
-
TUDU_TODO_KEY => TUDU_TODOS_FILE,
|
43
|
-
TUDU_DOING_KEY => TUDU_DOINGS_FILE,
|
44
|
-
TUDU_DONE_KEY => TUDU_DONES_FILE
|
45
|
-
}
|
46
|
-
|
47
|
-
#== Tudufile file template
|
48
|
-
TUDU_FILE_TEMPLATE =<<-EOS
|
49
|
-
# encoding: utf-8
|
50
|
-
|
51
|
-
# !!!!!!! in tudu ver 0.0.1 this file not using !!!!!!!
|
52
|
-
|
53
|
-
# if you want to use notification, set target type. default => :none
|
54
|
-
# you can set :none, :mail
|
55
|
-
# target_type :mail
|
56
|
-
|
57
|
-
# if you want to use notification, set targets. default => []
|
58
|
-
# if you choose target_type none, you must not set targets.
|
59
|
-
# if you choose mail, you must set target email addresses.
|
60
|
-
# targets ["target1@abcdefg", "target2@abcdefg"]
|
61
|
-
EOS
|
62
|
-
|
63
|
-
#== todo file template
|
64
|
-
TUDU_TODOS_FILE_TEMPLATE = ""
|
65
|
-
#== doing file template
|
66
|
-
TUDU_DOINGS_FILE_TEMPLATE = ""
|
67
|
-
#== done file template
|
68
|
-
TUDU_DONES_FILE_TEMPLATE = ""
|
69
|
-
|
70
|
-
#== template files
|
71
|
-
INIT_FILES_TEMPLATE = {
|
72
|
-
TUDU_FILE_KEY => TUDU_FILE_TEMPLATE,
|
73
|
-
TUDU_TODO_KEY => TUDU_TODOS_FILE_TEMPLATE,
|
74
|
-
TUDU_DOING_KEY => TUDU_DOINGS_FILE_TEMPLATE,
|
75
|
-
TUDU_DONE_KEY => TUDU_DONES_FILE_TEMPLATE
|
76
|
-
}
|
77
|
-
|
78
|
-
#== task type [todo, doing, done]
|
79
|
-
attr_accessor :type
|
80
|
-
#== task name [uniq]
|
81
|
-
attr_accessor :name
|
82
|
-
|
83
|
-
class << self
|
84
|
-
#== add task to todos
|
85
|
-
#=== Params
|
86
|
-
#- task_names : add task name list
|
87
|
-
def add(*task_names)
|
88
|
-
task_names.each do |task_name|
|
89
|
-
if find_tasks(task_name)
|
90
|
-
puts "#{task_name} is already exists."
|
91
|
-
next
|
92
|
-
end
|
93
|
-
File.open(TUDU_TODOS_FILE_PATH, "a:UTF-8") {|f|f.puts task_name}
|
94
|
-
puts "complete add todo '#{task_name}' to tudu/todos"
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
#== remove task to todo
|
99
|
-
#=== Params
|
100
|
-
#- task_names : remove task name list
|
101
|
-
def remove(*task_names)
|
102
|
-
task_names.each do |task_name|
|
103
|
-
can_find = false
|
104
|
-
TASK_FILES.each_value do |rf|
|
105
|
-
tasks = get_tasks_from_file(rf)
|
106
|
-
next unless has_task?(tasks, task_name)
|
107
|
-
remove_task(tasks, task_name, "./#{TUDU_DIR}/#{rf}")
|
108
|
-
can_find = true
|
109
|
-
break
|
110
|
-
end
|
111
|
-
puts "no such todo '#{task_name}'" unless can_find
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
#== choose todo => doing task
|
116
|
-
#=== Params
|
117
|
-
#- task_name : target task name
|
118
|
-
def choose(task_name)
|
119
|
-
if
|
120
|
-
puts "
|
121
|
-
return
|
122
|
-
end
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
#-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
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
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
#-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
tasks
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
tasks
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
tasks
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Tudu
|
4
|
+
#= Tudu::Tasks
|
5
|
+
class Tasks
|
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
|
+
|
17
|
+
#== Tudufile file name
|
18
|
+
TUDU_FILE = "Tudufile"
|
19
|
+
#== Tudufile file name
|
20
|
+
TUDU_DIR = "tudu"
|
21
|
+
#== todo file name
|
22
|
+
TUDU_TODOS_FILE = "todos"
|
23
|
+
#== todo file path
|
24
|
+
TUDU_TODOS_FILE_PATH = "./#{TUDU_DIR}/#{TUDU_TODOS_FILE}"
|
25
|
+
#== doing file name
|
26
|
+
TUDU_DOINGS_FILE = "doings"
|
27
|
+
#== doing file path
|
28
|
+
TUDU_DOINGS_FILE_PATH = "./#{TUDU_DIR}/#{TUDU_DOINGS_FILE}"
|
29
|
+
#== done file name
|
30
|
+
TUDU_DONES_FILE = "dones"
|
31
|
+
#== done file path
|
32
|
+
TUDU_DONES_FILE_PATH = "./#{TUDU_DIR}/#{TUDU_DONES_FILE}"
|
33
|
+
#== file names
|
34
|
+
INIT_FILES = {
|
35
|
+
TUDU_FILE_KEY => TUDU_FILE,
|
36
|
+
TUDU_TODO_KEY => TUDU_TODOS_FILE,
|
37
|
+
TUDU_DOING_KEY => TUDU_DOINGS_FILE,
|
38
|
+
TUDU_DONE_KEY => TUDU_DONES_FILE
|
39
|
+
}
|
40
|
+
#== task file names
|
41
|
+
TASK_FILES = {
|
42
|
+
TUDU_TODO_KEY => TUDU_TODOS_FILE,
|
43
|
+
TUDU_DOING_KEY => TUDU_DOINGS_FILE,
|
44
|
+
TUDU_DONE_KEY => TUDU_DONES_FILE
|
45
|
+
}
|
46
|
+
|
47
|
+
#== Tudufile file template
|
48
|
+
TUDU_FILE_TEMPLATE =<<-EOS
|
49
|
+
# encoding: utf-8
|
50
|
+
|
51
|
+
# !!!!!!! in tudu ver 0.0.1 this file not using !!!!!!!
|
52
|
+
|
53
|
+
# if you want to use notification, set target type. default => :none
|
54
|
+
# you can set :none, :mail
|
55
|
+
# target_type :mail
|
56
|
+
|
57
|
+
# if you want to use notification, set targets. default => []
|
58
|
+
# if you choose target_type none, you must not set targets.
|
59
|
+
# if you choose mail, you must set target email addresses.
|
60
|
+
# targets ["target1@abcdefg", "target2@abcdefg"]
|
61
|
+
EOS
|
62
|
+
|
63
|
+
#== todo file template
|
64
|
+
TUDU_TODOS_FILE_TEMPLATE = ""
|
65
|
+
#== doing file template
|
66
|
+
TUDU_DOINGS_FILE_TEMPLATE = ""
|
67
|
+
#== done file template
|
68
|
+
TUDU_DONES_FILE_TEMPLATE = ""
|
69
|
+
|
70
|
+
#== template files
|
71
|
+
INIT_FILES_TEMPLATE = {
|
72
|
+
TUDU_FILE_KEY => TUDU_FILE_TEMPLATE,
|
73
|
+
TUDU_TODO_KEY => TUDU_TODOS_FILE_TEMPLATE,
|
74
|
+
TUDU_DOING_KEY => TUDU_DOINGS_FILE_TEMPLATE,
|
75
|
+
TUDU_DONE_KEY => TUDU_DONES_FILE_TEMPLATE
|
76
|
+
}
|
77
|
+
|
78
|
+
#== task type [todo, doing, done]
|
79
|
+
attr_accessor :type
|
80
|
+
#== task name [uniq]
|
81
|
+
attr_accessor :name
|
82
|
+
|
83
|
+
class << self
|
84
|
+
#== add task to todos
|
85
|
+
#=== Params
|
86
|
+
#- task_names : add task name list
|
87
|
+
def add(*task_names)
|
88
|
+
task_names.each do |task_name|
|
89
|
+
if find_tasks(task_name)
|
90
|
+
puts "#{task_name} is already exists.";
|
91
|
+
next
|
92
|
+
end
|
93
|
+
File.open(TUDU_TODOS_FILE_PATH, "a:UTF-8") {|f|f.puts task_name}
|
94
|
+
puts "complete add todo '#{task_name}' to tudu/todos"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
#== remove task to todo
|
99
|
+
#=== Params
|
100
|
+
#- task_names : remove task name list
|
101
|
+
def remove(*task_names)
|
102
|
+
task_names.each do |task_name|
|
103
|
+
can_find = false
|
104
|
+
TASK_FILES.each_value do |rf|
|
105
|
+
tasks = get_tasks_from_file(rf)
|
106
|
+
next unless has_task?(tasks, task_name)
|
107
|
+
remove_task(tasks, task_name, "./#{TUDU_DIR}/#{rf}")
|
108
|
+
can_find = true
|
109
|
+
break
|
110
|
+
end
|
111
|
+
puts "no such todo '#{task_name}'" unless can_find
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
#== choose todo => doing task
|
116
|
+
#=== Params
|
117
|
+
#- task_name : target task name
|
118
|
+
def choose(task_name)
|
119
|
+
if get_todos.size == 0
|
120
|
+
puts "todos is empty."
|
121
|
+
return
|
122
|
+
end
|
123
|
+
if get_doings.size > 0
|
124
|
+
puts "before choose, you must done current doings."
|
125
|
+
return
|
126
|
+
end
|
127
|
+
task_name = get_first_todo_name_if_nil_or_empty task_name
|
128
|
+
task = find_tasks(task_name)
|
129
|
+
if task.nil?
|
130
|
+
puts "#{task_name} not exists"
|
131
|
+
return
|
132
|
+
end
|
133
|
+
unless task.todo?
|
134
|
+
puts "#{task_name} is not exists in todos. #{task_name} in #{task.type}"
|
135
|
+
return
|
136
|
+
end
|
137
|
+
remove task_name
|
138
|
+
File.open(TUDU_DOINGS_FILE_PATH, "w:UTF-8") {|f|f.puts task_name}
|
139
|
+
puts "complete add doings '#{task_name}'"
|
140
|
+
end
|
141
|
+
|
142
|
+
#== doing to done
|
143
|
+
#- if doings size == 0, nothing todo.
|
144
|
+
#- after move doing to done, next todo move to doing.
|
145
|
+
def done
|
146
|
+
return unless doings_to_dones
|
147
|
+
todos_to_doings
|
148
|
+
end
|
149
|
+
|
150
|
+
#== get todos type tasks.
|
151
|
+
#=== Returns
|
152
|
+
# return Array[Tasks]
|
153
|
+
def get_todos
|
154
|
+
get_tasks(TUDU_TODOS_FILE)
|
155
|
+
end
|
156
|
+
|
157
|
+
#== get doings type tasks.
|
158
|
+
#=== Returns
|
159
|
+
# return Array[Tasks]
|
160
|
+
def get_doings
|
161
|
+
get_tasks(TUDU_DOINGS_FILE)
|
162
|
+
end
|
163
|
+
|
164
|
+
#== get dones type tasks.
|
165
|
+
#=== Returns
|
166
|
+
# return Array[Tasks]
|
167
|
+
def get_dones
|
168
|
+
get_tasks(TUDU_DONES_FILE)
|
169
|
+
end
|
170
|
+
|
171
|
+
#== get each type tasks.
|
172
|
+
#=== Params
|
173
|
+
#- type : task type.if use nil, you can get all types task.
|
174
|
+
#=== Returns
|
175
|
+
# return Array[Tasks]
|
176
|
+
def get_tasks(type = nil)
|
177
|
+
type.nil? ? get_all_tasks : get_each_tasks(type)
|
178
|
+
end
|
179
|
+
|
180
|
+
#== get each type tasks from file.
|
181
|
+
#=== Params
|
182
|
+
#- type : task type.
|
183
|
+
#=== Returns
|
184
|
+
# return Array[String]
|
185
|
+
def get_tasks_from_file(file_name)
|
186
|
+
File.read("./#{TUDU_DIR}/#{file_name}").split("\n")
|
187
|
+
end
|
188
|
+
|
189
|
+
#== filter tasklist by search_word.
|
190
|
+
#=== Params
|
191
|
+
#- tasks : task list.
|
192
|
+
#- search_word : filtering word.
|
193
|
+
#=== Returns
|
194
|
+
# return filterd task list
|
195
|
+
def filter_tasks(tasks, search_word)
|
196
|
+
return tasks if search_word.nil?
|
197
|
+
tasks.select {|task|task.name.match /.*#{search_word}.*/}
|
198
|
+
end
|
199
|
+
|
200
|
+
#== find task from all tasks.
|
201
|
+
#=== Params
|
202
|
+
#- task_name : task name.
|
203
|
+
#=== Returns
|
204
|
+
# return task
|
205
|
+
def find_tasks(task_name)
|
206
|
+
tasks = get_tasks
|
207
|
+
tasks.select {|task|task.name == task_name}.first
|
208
|
+
end
|
209
|
+
|
210
|
+
private
|
211
|
+
def get_first_todo_name_if_nil_or_empty(task_name)
|
212
|
+
(task_name.nil? || task_name.empty?) ? get_todos.first.name : task_name
|
213
|
+
end
|
214
|
+
|
215
|
+
def get_each_tasks(type)
|
216
|
+
tasks = []
|
217
|
+
get_tasks_from_file(type).each {|task|tasks << Tasks.new(type, task)}
|
218
|
+
tasks
|
219
|
+
end
|
220
|
+
|
221
|
+
def get_all_tasks
|
222
|
+
tasks = []
|
223
|
+
TASK_FILES.each_value {|each_type|tasks += get_each_tasks(each_type)}
|
224
|
+
tasks
|
225
|
+
end
|
226
|
+
|
227
|
+
def has_task?(tasks, task_name)
|
228
|
+
tasks.include? task_name
|
229
|
+
end
|
230
|
+
|
231
|
+
def remove_task(tasks, task_name, file_path)
|
232
|
+
tasks.delete(task_name)
|
233
|
+
contents = tasks.size == 0 ? "" : tasks.join("\n") + "\n"
|
234
|
+
File.open(file_path, "w:UTF-8") {|wf|wf.print contents}
|
235
|
+
puts "complete remove todo '#{task_name}' from #{file_path}"
|
236
|
+
end
|
237
|
+
|
238
|
+
def doings_to_dones
|
239
|
+
_doings = get_doings
|
240
|
+
if _doings.size == 0
|
241
|
+
puts "there is no doing task.before done, you must choose task."
|
242
|
+
return false
|
243
|
+
end
|
244
|
+
File.open(TUDU_DOINGS_FILE_PATH, "w:UTF-8") {|f|f.print ""}
|
245
|
+
File.open(TUDU_DONES_FILE_PATH, "a:UTF-8") {|f|f.puts _doings.first.name}
|
246
|
+
true
|
247
|
+
end
|
248
|
+
|
249
|
+
def todos_to_doings
|
250
|
+
_todos = get_todos
|
251
|
+
if _todos.size == 0
|
252
|
+
puts "All Tasks Finish!!" if get_doings.size == 0
|
253
|
+
return
|
254
|
+
end
|
255
|
+
|
256
|
+
deleted_todos = _todos.dup
|
257
|
+
deleted_todos.delete_at 0
|
258
|
+
File.open(TUDU_TODOS_FILE_PATH, "w:UTF-8") do |f|
|
259
|
+
deleted_todos.each {|task|f.puts task.name}
|
260
|
+
end
|
261
|
+
File.open(TUDU_DOINGS_FILE_PATH, "w:UTF-8") {|f|f.puts _todos.first.name}
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
#== init task with setting task type and task name.
|
266
|
+
def initialize(type, name)
|
267
|
+
@type, @name = type, name
|
268
|
+
end
|
269
|
+
|
270
|
+
def todo?
|
271
|
+
@type == "todos"
|
272
|
+
end
|
273
|
+
|
274
|
+
def doing?
|
275
|
+
@type == "doings"
|
276
|
+
end
|
277
|
+
|
278
|
+
def done?
|
279
|
+
@type == "dones"
|
280
|
+
end
|
281
|
+
|
282
|
+
def ==(other)
|
283
|
+
if self.name == other.name
|
284
|
+
return true if self.type == other.type
|
285
|
+
end
|
286
|
+
false
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
data/lib/tudu/version.rb
CHANGED