tudu 0.0.1

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/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tudu.gemspec
4
+ gemspec
5
+ gem "rspec", "~> 2.14.1"
6
+ gem "thor", "~> 0.18.1"
7
+ gem "simplecov", "~> 0.8.2"
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 tbpgr
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,196 @@
1
+ # Tudu
2
+
3
+ Tudu is single person's minimum unit of task manager
4
+
5
+ ## Purpose
6
+ * Manage single person's task.
7
+ * You shuold use this gem by minimun unit task. For example, make spec of Hoge#some_method, implements Hoge#some_method and so on.
8
+ * If you create some framework for user or your team, you can presentation minimum unit task-flow.
9
+ * If you have apprentice, you can presentation task-flow for them.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'tudu'
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install tudu
24
+
25
+ ## Structure
26
+ ~~~
27
+ .
28
+ ┗ tudu
29
+ ┠ todos :todos(0-n task)
30
+ ┠ doings :doing tasks(0-1 task)
31
+ ┠ dones :done tasks(0-n task)
32
+ ┗ Tudufile :in current version, we not use this
33
+ ~~~
34
+
35
+ ## Usage
36
+ ### init
37
+ * generate todos,doings,dones emptyfile
38
+ * generate Tudufile template
39
+
40
+ ~~~
41
+ $ tudu init
42
+ $ tree
43
+ .
44
+ ┗ tudu
45
+ ┠ todos
46
+ ┠ doings
47
+ ┠ dones
48
+ ┗ Tudufile
49
+ ~~~
50
+
51
+ ### add task to todos file.
52
+ * single add
53
+
54
+ ~~~
55
+ $ tudu add hoge
56
+ $ tudu todos
57
+ hoge
58
+ ~~~
59
+
60
+ * multi add
61
+
62
+ ~~~
63
+ $ tudu add hoge foo bar
64
+ $ tudu todos
65
+ hoge
66
+ foo
67
+ bar
68
+ ~~~
69
+
70
+ ### remove task to todos file.
71
+ * single remove
72
+
73
+ ~~~
74
+ $ tudu add hoge hige
75
+ $ tudu remove hoge
76
+ $ tudu todos
77
+ hige
78
+ ~~~
79
+
80
+ * multi remove
81
+
82
+ ~~~
83
+ $ tudu add hoge foo bar hige
84
+ $ tudu remove hoge foo bar
85
+ $ tudu todos
86
+ hige
87
+ ~~~
88
+
89
+ ### choose task from todo to doing
90
+ * choose
91
+
92
+ ~~~
93
+ $ tudu add hoge
94
+ $ tudu choose hoge
95
+ $ tudu todos
96
+ $ tudu doings
97
+ hoge
98
+ ~~~
99
+
100
+ ### done task from doing to done and from first todos to doing
101
+ * done
102
+
103
+ ~~~
104
+ $ tudu add one two three
105
+ $ tudu choose one
106
+ $ done
107
+ $ tudu todos
108
+ three
109
+ $ tudu doings
110
+ two
111
+ $ tudu done
112
+ one
113
+ ~~~
114
+
115
+ ### tasks show all tasks from [todos, doings, dones].
116
+ * tudu tasks
117
+
118
+ ~~~
119
+ $ tudu add one two three
120
+ $ tudu choose one
121
+ $ done
122
+ $ tudu tasks
123
+ three
124
+ two
125
+ one
126
+ ~~~
127
+
128
+ ### show specific tasks from [todos, doings, dones].
129
+ * tudu tasks search_word
130
+
131
+ ~~~
132
+ $ tudu add test tester testest
133
+ $ tudu search teste
134
+ tester
135
+ testest
136
+ ~~~
137
+
138
+ ### todos show all todos tasks.
139
+ * tudu todos
140
+
141
+ ~~~
142
+ $ tudu add hoge hige
143
+ $ tudu choose hoge
144
+ $ tudu todos
145
+ hige
146
+ ~~~
147
+
148
+ ### todos 'search word' show specific todos tasks.
149
+ same as 'tasks search_word'
150
+
151
+ ### doings show all doings tasks.
152
+ You can use doings command's alias 'now'
153
+
154
+ * tudu doings(or now)
155
+
156
+ ~~~
157
+ $ tudu add hoge
158
+ $ tudu choose hoge
159
+ $ tudu doings
160
+ hoge
161
+ ~~~
162
+
163
+ ### doings 'search word' show specific doings tasks.
164
+ same as 'tasks search_word' case
165
+
166
+ ### dones show all dones tasks.
167
+ * tudu dones
168
+
169
+ ~~~
170
+ $ tudu add hoge hige
171
+ $ tudu choose hoge
172
+ $ tudu done
173
+ $ tudu doings
174
+ hige
175
+ $ tudu dones
176
+ hoge
177
+ ~~~
178
+
179
+ ### dones 'search word' show specific dones tasks.
180
+ same as 'tasks search_word' case
181
+
182
+ ### Notes
183
+ if you want to do other operation, edit [todos, doings, dones] directly.
184
+
185
+ it's only plain text, so you can edit freely.
186
+
187
+ ## History
188
+ * version 0.0.1 : first release.
189
+
190
+ ## Contributing
191
+
192
+ 1. Fork it
193
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
194
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
195
+ 4. Push to the branch (`git push origin my-new-feature`)
196
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/tudu ADDED
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ require 'tudu/version'
5
+ require 'tudu_core'
6
+ require "thor"
7
+
8
+ module Tudu
9
+ #= Tudu CLI
10
+ class CLI < Thor
11
+ class_option :help, :type => :boolean, :aliases => '-h', :desc => 'help message.'
12
+ class_option :version, :type => :boolean, :desc => 'version'
13
+
14
+ desc "init", "generate todos,doings,dones files"
15
+ def init
16
+ Tudu::Core.new.init
17
+ end
18
+
19
+ desc "add", "add tasks to todos file"
20
+ def add(*args)
21
+ puts args
22
+ Tudu::Core.new.add *args
23
+ end
24
+
25
+ desc "remove", "remove tasks from todos,doings,dones file"
26
+ def remove(*args)
27
+ Tudu::Core.new.remove *args
28
+ end
29
+
30
+ desc "choose", "choose tasks from todos to doings file"
31
+ def choose(*args)
32
+ Tudu::Core.new.choose args.first
33
+ end
34
+
35
+ desc "done", "done tasks from doings to dones file. and choose task from todos's top task to doings"
36
+ def done
37
+ Tudu::Core.new.done
38
+ end
39
+
40
+ desc "tasks", "tasks search tasks from todos,doings,dones file. no args => get all tasks. set search word args, you get hit tasks"
41
+ def tasks(*args)
42
+ puts Tudu::Core.new.tasks args.first
43
+ end
44
+
45
+ desc "todos", "todos search tasks from todos file. no args => get all tasks. set search word args, you get hit tasks"
46
+ def todos(*args)
47
+ puts Tudu::Core.new.todos args.first
48
+ end
49
+
50
+ desc "doings", "doings search tasks from doings file. no args => get all tasks. set search word args, you get hit tasks"
51
+ def doings(*args)
52
+ puts Tudu::Core.new.doings args.first
53
+ end
54
+
55
+ desc "now", "now search tasks from doings file. no args => get all tasks. set search word args, you get hit tasks"
56
+ def now(*args)
57
+ puts Tudu::Core.new.now args.first
58
+ end
59
+
60
+ desc "dones", "dones search tasks from dones file. no args => get all tasks. set search word args, you get hit tasks"
61
+ def dones(*args)
62
+ puts Tudu::Core.new.dones args.first
63
+ end
64
+
65
+ desc "version", "version"
66
+ def version
67
+ p Tudu::VERSION
68
+ end
69
+ end
70
+ end
71
+ Tudu::CLI.start(ARGV)
data/lib/task.rb ADDED
@@ -0,0 +1,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_doings.size > 0
120
+ puts "before choose, you must done current doings."
121
+ return
122
+ end
123
+
124
+ task = find_tasks(task_name)
125
+
126
+ if task.nil?
127
+ puts "#{task_name} not exists"
128
+ return
129
+ end
130
+
131
+ unless task.todo?
132
+ puts "#{task_name} is not exists in todos. #{task_name} in #{task.type}"
133
+ return
134
+ end
135
+
136
+ remove task_name
137
+ File.open(TUDU_DOINGS_FILE_PATH, "w:UTF-8") {|f|f.puts task_name}
138
+ puts "complete add doings '#{task_name}'"
139
+ end
140
+
141
+ #== doing to done
142
+ #- if doings size == 0, nothing todo.
143
+ #- after move doing to done, next todo move to doing.
144
+ def done
145
+ return unless doings_to_dones
146
+ todos_to_doings
147
+ end
148
+
149
+ #== get todos type tasks.
150
+ #=== Returns
151
+ # return Array[Tasks]
152
+ def get_todos
153
+ get_tasks(TUDU_TODOS_FILE)
154
+ end
155
+
156
+ #== get doings type tasks.
157
+ #=== Returns
158
+ # return Array[Tasks]
159
+ def get_doings
160
+ get_tasks(TUDU_DOINGS_FILE)
161
+ end
162
+
163
+ #== get dones type tasks.
164
+ #=== Returns
165
+ # return Array[Tasks]
166
+ def get_dones
167
+ get_tasks(TUDU_DONES_FILE)
168
+ end
169
+
170
+ #== get each type tasks.
171
+ #=== Params
172
+ #- type : task type.if use nil, you can get all types task.
173
+ #=== Returns
174
+ # return Array[Tasks]
175
+ def get_tasks(type = nil)
176
+ type.nil? ? get_all_tasks : get_each_tasks(type)
177
+ end
178
+
179
+ #== get each type tasks from file.
180
+ #=== Params
181
+ #- type : task type.
182
+ #=== Returns
183
+ # return Array[String]
184
+ def get_tasks_from_file(file_name)
185
+ File.read("./#{TUDU_DIR}/#{file_name}").split("\n")
186
+ end
187
+
188
+ #== filter tasklist by search_word.
189
+ #=== Params
190
+ #- tasks : task list.
191
+ #- search_word : filtering word.
192
+ #=== Returns
193
+ # return filterd task list
194
+ def filter_tasks(tasks, search_word)
195
+ return tasks if search_word.nil?
196
+ tasks.select {|task|task.name.match /.*#{search_word}.*/}
197
+ end
198
+
199
+ #== find task from all tasks.
200
+ #=== Params
201
+ #- task_name : task name.
202
+ #=== Returns
203
+ # return task
204
+ def find_tasks(task_name)
205
+ tasks = get_tasks
206
+ tasks.select {|task|task.name == task_name}.first
207
+ end
208
+
209
+ private
210
+ def get_each_tasks(type)
211
+ tasks = []
212
+ get_tasks_from_file(type).each {|task|tasks << Tasks.new(type, task)}
213
+ tasks
214
+ end
215
+
216
+ def get_all_tasks
217
+ tasks = []
218
+ TASK_FILES.each_value {|each_type|tasks += get_each_tasks(each_type)}
219
+ tasks
220
+ end
221
+
222
+ def has_task?(tasks, task_name)
223
+ tasks.include? task_name
224
+ end
225
+
226
+ def remove_task(tasks, task_name, file_path)
227
+ tasks.delete(task_name)
228
+ File.open(file_path, "w:UTF-8") {|wf|wf.puts tasks.join("\n")}
229
+ puts "complete remove todo '#{task_name}' from #{file_path}"
230
+ end
231
+
232
+ def doings_to_dones
233
+ _doings = get_doings
234
+ if _doings.size == 0
235
+ puts "there is no doing task.before done, you must choose task."
236
+ return false
237
+ end
238
+ File.open(TUDU_DOINGS_FILE_PATH, "w:UTF-8") {|f|f.print ""}
239
+ File.open(TUDU_DONES_FILE_PATH, "a:UTF-8") {|f|f.puts _doings.first.name}
240
+ true
241
+ end
242
+
243
+ def todos_to_doings
244
+ _todos = get_todos
245
+ return if _todos.size == 0
246
+ deleted_todos = _todos.dup
247
+ deleted_todos.delete_at 0
248
+ File.open(TUDU_TODOS_FILE_PATH, "w:UTF-8") do |f|
249
+ deleted_todos.each {|task|f.puts task.name}
250
+ end
251
+ File.open(TUDU_DOINGS_FILE_PATH, "w:UTF-8") {|f|f.puts _todos.first.name}
252
+ end
253
+ end
254
+
255
+ #== init task with setting task type and task name.
256
+ def initialize(type, name)
257
+ @type, @name = type, name
258
+ end
259
+
260
+ def todo?
261
+ @type == "todos"
262
+ end
263
+
264
+ def doing?
265
+ @type == "doings"
266
+ end
267
+
268
+ def done?
269
+ @type == "dones"
270
+ end
271
+
272
+ def ==(other)
273
+ if self.name == other.name
274
+ if self.type == other.type
275
+ return true
276
+ end
277
+ end
278
+ false
279
+ end
280
+ end
281
+ end