dooby 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +5 -0
- data/Gemfile.lock +18 -0
- data/README.md +82 -15
- data/Rakefile +4 -2
- data/VERSION +1 -1
- data/bin/dooby +133 -60
- data/dooby.gemspec +16 -4
- data/lib/dooby.rb +7 -5
- data/lib/dooby/cli_helper.rb +31 -0
- data/lib/dooby/core_ext.rb +44 -0
- data/lib/dooby/list.rb +40 -15
- data/lib/dooby/task.rb +1 -2
- metadata +56 -6
- data/lib/dooby/readline_helper.rb +0 -13
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
arrayfields (4.7.4)
|
5
|
+
colored (1.2)
|
6
|
+
fattr (2.1.0)
|
7
|
+
highline (1.6.1)
|
8
|
+
main (4.2.0)
|
9
|
+
arrayfields (>= 4.7.4)
|
10
|
+
fattr (>= 2.1.0)
|
11
|
+
|
12
|
+
PLATFORMS
|
13
|
+
ruby
|
14
|
+
|
15
|
+
DEPENDENCIES
|
16
|
+
colored (= 1.2)
|
17
|
+
highline (= 1.6.1)
|
18
|
+
main (= 4.2.0)
|
data/README.md
CHANGED
@@ -16,33 +16,50 @@ I spend a lot of time in the terminal and I didn't really like any of the curren
|
|
16
16
|
How does Dooby works?
|
17
17
|
---------------------
|
18
18
|
|
19
|
+
### A bunch of lists
|
19
20
|
Dooby is directory-based, so you can maintain different to-do/notes lists in every directory you want.
|
20
21
|
|
21
|
-
For instance, I use one to-do list per project, that way I don't have all the tasks in one place
|
22
|
+
For instance, I use one to-do list per project, that way I don't have all the tasks in one place so I can get focused in just one set of tasks, in one context.
|
22
23
|
|
23
|
-
|
24
|
-
|
24
|
+
### Priorities
|
25
|
+
Dooby doesn't like to handle priorities, that's your concern. The main goal of Dooby is to help me to handle my today/tomorrow tasks and to handle my personal notes.
|
25
26
|
|
26
|
-
###
|
27
|
+
### Due dates
|
28
|
+
Due dates for today/tomorrow tasks? well, maybe later.
|
27
29
|
|
28
|
-
|
30
|
+
### #tag #tag and #tag again and tell @jim to #tag everything in his %life as well
|
29
31
|
|
30
|
-
|
32
|
+
Dooby uses some special characters to visually help us to differentiate between things and let us search tasks very easily, the ones that you might recognize are **@** and **#**, I stole the idea from Twitter, but of course they don't behave as in Twitter, the **@** sign is not an username but a character to simply tag a person, that's all, nothing else (so far).
|
31
33
|
|
32
|
-
|
34
|
+
People
|
33
35
|
|
34
|
-
|
36
|
+
@peter, @john, @jim
|
35
37
|
|
36
|
-
|
38
|
+
Contexts (states of mind, mood, places, etc)
|
39
|
+
|
40
|
+
#today, #tomorrow, #urgent
|
41
|
+
|
42
|
+
#work, #home
|
43
|
+
|
44
|
+
#thinking, #sad
|
37
45
|
|
38
|
-
|
46
|
+
Projects
|
39
47
|
|
40
|
-
|
48
|
+
%website, %shoppinglist, %whatever
|
49
|
+
|
50
|
+
Most of these characters are meaningless to Dooby, she (yes, she's a woman) isn't aware of them, Dooby is aware only of some of them:
|
41
51
|
|
42
52
|
#today
|
43
53
|
#urgent
|
44
54
|
#tomorrow
|
45
55
|
|
56
|
+
All the tasks tagged with *#today* and *#urgent* will be shown in a special section every time you list your to-dos/notes.
|
57
|
+
|
58
|
+
All the tasks tagged with *#tomorrow* will be marked with the tag *#today* at the next day.
|
59
|
+
|
60
|
+
Usage
|
61
|
+
-----
|
62
|
+
|
46
63
|
###Creating an alias
|
47
64
|
|
48
65
|
$ alias d='dooby'
|
@@ -65,6 +82,10 @@ This creates a **.dooby/list.yml** file in the current directory. Dooby will sav
|
|
65
82
|
|
66
83
|
$ d l today
|
67
84
|
|
85
|
+
$ d l \#today
|
86
|
+
|
87
|
+
$ d l "#today"
|
88
|
+
|
68
89
|
$ d l %website
|
69
90
|
|
70
91
|
$ d l @
|
@@ -80,7 +101,7 @@ This creates a **.dooby/list.yml** file in the current directory. Dooby will sav
|
|
80
101
|
> #today
|
81
102
|
Showing items containing: #today
|
82
103
|
(b954bf) #fix the email error in %website, talk to @peter #today
|
83
|
-
(9cfbf4) Need to go to the #doctor #today
|
104
|
+
(9cfbf4) Need to go to the #doctor @hendrix #today
|
84
105
|
|
85
106
|
> #doctor
|
86
107
|
Showing items containing: #doctor
|
@@ -92,6 +113,24 @@ This creates a **.dooby/list.yml** file in the current directory. Dooby will sav
|
|
92
113
|
|
93
114
|
**Note:** Dooby uses SHA1 as Task ID.
|
94
115
|
|
116
|
+
#### Listing all the hashtags you have used
|
117
|
+
|
118
|
+
$ d l#
|
119
|
+
#today
|
120
|
+
#doctor
|
121
|
+
#fix
|
122
|
+
|
123
|
+
#### Listing all the people you have tagged
|
124
|
+
|
125
|
+
$ d l@
|
126
|
+
@peter
|
127
|
+
@hendrix
|
128
|
+
|
129
|
+
#### Listing all the projects you have tagged
|
130
|
+
|
131
|
+
$ d l%
|
132
|
+
%website
|
133
|
+
|
95
134
|
### Editing items
|
96
135
|
|
97
136
|
**Dooby** supports autocompletion of task IDs in the *delete* and the *edit* commands, to fire it just do the same as in a bash shell, press TAB TAB.
|
@@ -150,6 +189,27 @@ or
|
|
150
189
|
Showing all items...
|
151
190
|
(521a3d) #fix the email error in %website #today
|
152
191
|
|
192
|
+
### Bulk delete
|
193
|
+
|
194
|
+
If you want to delete all the tasks containing a tag or set of tags this is what bulk delete is useful for. This feature will delete only by tag, not simple text, actually if you enter simple text it will simply ignore it.
|
195
|
+
|
196
|
+
Bulk delete supports auto-completion too. Say you want to delete all the tasks containing @hendrix AND #today.
|
197
|
+
|
198
|
+
$ d bulkdelete
|
199
|
+
|
200
|
+
or
|
201
|
+
|
202
|
+
$ d b
|
203
|
+
What do you want to bulk delete? (@, #, % allowed)
|
204
|
+
_ #TAB TAB
|
205
|
+
#today #doctor
|
206
|
+
|
207
|
+
$ d b
|
208
|
+
What do you want to bulk delete? (@, #, % allowed)
|
209
|
+
#today @hendrix
|
210
|
+
|
211
|
+
That's it
|
212
|
+
|
153
213
|
### Deleting all the items
|
154
214
|
|
155
215
|
$ d flush
|
@@ -193,7 +253,11 @@ You can check the help out using the -h flag
|
|
193
253
|
PARAMETERS
|
194
254
|
what_to_show (-1 ~> what_to_show)
|
195
255
|
--help, -h
|
196
|
-
|
256
|
+
|
257
|
+
Known bugs
|
258
|
+
----------
|
259
|
+
|
260
|
+
* Auto-completion doesn't work with at signs (@)
|
197
261
|
|
198
262
|
Special Thanks
|
199
263
|
--------------
|
@@ -206,7 +270,9 @@ Most of the the ideas to code **dooby** were based on the work of other programm
|
|
206
270
|
|
207
271
|
Thanks all of you!
|
208
272
|
|
209
|
-
|
273
|
+
|
274
|
+
Note on Patches/Pull Requests
|
275
|
+
-----------------------------
|
210
276
|
|
211
277
|
* Fork the project.
|
212
278
|
* Make your feature addition or bug fix.
|
@@ -216,6 +282,7 @@ Thanks all of you!
|
|
216
282
|
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
217
283
|
* Send me a pull request. Bonus points for topic branches.
|
218
284
|
|
219
|
-
|
285
|
+
Copyright
|
286
|
+
---------
|
220
287
|
|
221
288
|
Copyright (c) 2010 Rafael Magana. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -7,13 +7,15 @@ begin
|
|
7
7
|
Jeweler::Tasks.new do |gem|
|
8
8
|
gem.name = "dooby"
|
9
9
|
gem.summary = %Q{A very simplistic command-line to-do list manager in Ruby}
|
10
|
-
gem.description = %Q{
|
10
|
+
gem.description = %Q{With Dooby you can handle your to-do list or your notes in a simple way and through the command-line.}
|
11
11
|
gem.email = "raf.magana@gmail.com"
|
12
12
|
gem.homepage = "http://github.com/rafmagana/dooby"
|
13
13
|
gem.authors = ["Rafael Magaña"]
|
14
14
|
gem.add_development_dependency "shoulda", ">= 2.11.3"
|
15
15
|
gem.add_development_dependency "mocha", ">= 0.9.8"
|
16
|
-
|
16
|
+
gem.add_runtime_dependency('main', ">= 4.2.0")
|
17
|
+
gem.add_runtime_dependency('colored', ">= 1.2")
|
18
|
+
gem.add_runtime_dependency('highline', ">= 1.6.1")
|
17
19
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
20
|
end
|
19
21
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/bin/dooby
CHANGED
@@ -10,49 +10,29 @@ require 'dooby'
|
|
10
10
|
|
11
11
|
ORIGINAL_ARGV = ARGV.dup
|
12
12
|
|
13
|
-
stty_save = `stty -g`.chomp
|
14
|
-
|
15
13
|
Main {
|
16
14
|
|
15
|
+
########################## DEFAULT #############################
|
17
16
|
def run
|
18
|
-
|
17
|
+
list = Dooby.current_list.list.tasks_by_tag(*Dooby::SPLITTABLE_TAGS)
|
18
|
+
if list
|
19
|
+
say 'Showing all items...'.blue_on_white.bold
|
20
|
+
puts list
|
21
|
+
else
|
22
|
+
say 'Nothing found'.red_on_white.bold
|
23
|
+
end
|
24
|
+
|
19
25
|
end
|
20
26
|
|
27
|
+
########################## INIT #################################
|
21
28
|
mode 'init' do
|
22
29
|
description 'Creates .dooby/list.yml file'
|
23
30
|
def run
|
24
31
|
Dooby.init
|
25
32
|
end
|
26
33
|
end
|
27
|
-
|
28
|
-
|
29
|
-
description 'Deletes all the tasks'
|
30
|
-
def run
|
31
|
-
puts "Sure???".red_on_white.bold + " (yes/no)".red.bold
|
32
|
-
sure = STDIN.gets
|
33
|
-
if sure.chomp == 'yes'
|
34
|
-
Dooby.current_list.flush!
|
35
|
-
puts "All the task were deleted!".red.bold
|
36
|
-
else
|
37
|
-
puts "Keep doing things!".green.bold
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
mode 'trash' do
|
43
|
-
description 'Deletes the .dooby directory'
|
44
|
-
def run
|
45
|
-
puts "Sure???".red_on_white.bold + " (yes/no)".red.bold
|
46
|
-
sure = STDIN.gets
|
47
|
-
if sure.chomp == 'yes'
|
48
|
-
Dooby.trash!
|
49
|
-
puts "No more dooby here T_T".red.bold
|
50
|
-
else
|
51
|
-
puts "Keep doing things!".green.bold
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
34
|
+
|
35
|
+
########################## ADD #################################
|
56
36
|
mode 'add' do
|
57
37
|
description 'Creates a new task and adds it to the current todo list'
|
58
38
|
argument 'task_text'
|
@@ -65,14 +45,16 @@ Main {
|
|
65
45
|
puts 'Task added!'
|
66
46
|
end
|
67
47
|
end
|
68
|
-
|
48
|
+
|
49
|
+
########################## LIST ################################
|
69
50
|
mode 'ilist' do
|
70
51
|
description "Interactive Listing"
|
71
52
|
def run
|
72
|
-
|
73
|
-
|
53
|
+
say "input #hashtag, @person, %project, :status or simple text"
|
54
|
+
|
55
|
+
Dooby.cli_helper.keep_asking "> " do |what_to_show|
|
74
56
|
puts
|
75
|
-
puts Dooby.current_list.list
|
57
|
+
puts Dooby.current_list.list(what_to_show.split(' ')).tasks_by_tag(*Dooby::SPLITTABLE_TAGS)
|
76
58
|
puts
|
77
59
|
end
|
78
60
|
end
|
@@ -86,64 +68,155 @@ Main {
|
|
86
68
|
}
|
87
69
|
|
88
70
|
def run
|
89
|
-
|
71
|
+
what_to_show = params[:what_to_show].values
|
72
|
+
list = Dooby.current_list.list(what_to_show).tasks_by_tag(*Dooby::SPLITTABLE_TAGS)
|
73
|
+
if list
|
74
|
+
if what_to_show.empty?
|
75
|
+
say 'Showing all items...'.blue_on_white.bold
|
76
|
+
else
|
77
|
+
say 'Showing items containing:'.blue_on_white.bold + ' ' + what_to_show.join(' and '.blue)
|
78
|
+
end
|
79
|
+
puts list
|
80
|
+
else
|
81
|
+
say 'Nothing found'.red_on_white.bold + ' ' + what_to_show.join(' and '.blue)
|
82
|
+
end
|
90
83
|
end
|
91
84
|
end
|
92
85
|
|
86
|
+
mode 'l@' do
|
87
|
+
def run
|
88
|
+
handle_tag_lists '@', 'You have not tagged people yet.'
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
mode 'l#' do
|
93
|
+
def run
|
94
|
+
handle_tag_lists '#', "You don't have any tags yet."
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
mode 'l%' do
|
99
|
+
def run
|
100
|
+
handle_tag_lists '%', "You don't have any projects yet."
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def handle_tag_lists(tag, error_message)
|
105
|
+
list = Dooby.current_list.list tag
|
106
|
+
if list
|
107
|
+
puts list
|
108
|
+
else
|
109
|
+
puts error_message
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
########################## DELETE ###############################
|
114
|
+
mode 'flush' do
|
115
|
+
description 'Deletes all the tasks'
|
116
|
+
def run
|
117
|
+
if Dooby.cli_helper.flush?
|
118
|
+
Dooby.current_list.flush!
|
119
|
+
say "All the task were deleted!".red.bold
|
120
|
+
else
|
121
|
+
say "Keep doing things!".green.bold
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
mode 'trash' do
|
127
|
+
description 'Deletes the .dooby directory'
|
128
|
+
def run
|
129
|
+
if Dooby.cli_helper.trash?
|
130
|
+
Dooby.trash!
|
131
|
+
puts "No more dooby here T_T".red.bold
|
132
|
+
else
|
133
|
+
puts "Keep doing things!".green.bold
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
93
138
|
mode 'delete' do
|
94
139
|
def run
|
95
|
-
|
140
|
+
unless Dooby.current_list.tasks?
|
96
141
|
puts 'No tasks to delete'.red
|
97
142
|
exit
|
98
143
|
end
|
99
144
|
|
100
|
-
|
145
|
+
autocomp = Dooby.current_list.tasks.keys
|
146
|
+
question = 'Tasky ID '.red.bold + '> '
|
101
147
|
|
102
|
-
|
103
|
-
|
104
|
-
while line = Readline.readline('Task ID '.red.bold + '> ')
|
105
|
-
task_id = line.chomp.strip
|
148
|
+
Dooby.cli_helper.keep_asking question, autocomp do |task_id|
|
149
|
+
|
106
150
|
if Dooby.current_list.delete! task_id
|
107
|
-
|
151
|
+
say task_id + ' deleted...'
|
108
152
|
exit
|
109
153
|
else
|
110
|
-
|
154
|
+
say "Don't try to fool #{'Dooby'.red}, she knows such task doesn't exists"
|
111
155
|
end
|
156
|
+
|
112
157
|
end
|
158
|
+
|
113
159
|
end
|
114
160
|
end
|
115
161
|
|
162
|
+
mode 'bulkdelete' do
|
163
|
+
description "Deletes all the tasks that contains the specified tags.\n $ dooby bulkdelete %mypage @jim \n It will only delete by tag, not by plain text"
|
164
|
+
def run
|
165
|
+
|
166
|
+
unless Dooby.current_list.tasks?
|
167
|
+
puts 'No tasks to delete'.red
|
168
|
+
exit
|
169
|
+
end
|
170
|
+
|
171
|
+
autocomp = Dooby.current_list.all_tags
|
172
|
+
question = "What do you want to bulk delete? (#{Dooby::SPECIAL_TAGS.join(', ')} allowed) \n> "
|
173
|
+
|
174
|
+
Dooby.cli_helper.keep_asking question, autocomp do |tags|
|
175
|
+
unless tags.empty?
|
176
|
+
Dooby.current_list.bulk_delete! tags
|
177
|
+
exit
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
|
184
|
+
########################## EDIT #################################
|
116
185
|
mode 'edit' do
|
117
186
|
def run
|
118
|
-
Dooby.readline_helper.completion_list = Dooby.current_list.tasks.keys
|
119
|
-
|
120
|
-
task_id = ''
|
121
187
|
|
122
|
-
|
123
|
-
|
188
|
+
autocomp = Dooby.current_list.tasks.keys
|
189
|
+
question = 'Tasky ID '.blue.bold + '> '
|
190
|
+
|
191
|
+
current_task_id = ''
|
192
|
+
|
193
|
+
Dooby.cli_helper.keep_asking question, autocomp do |task_id|
|
194
|
+
current_task_id = task_id
|
124
195
|
if Dooby.current_list.tasks.key? task_id
|
125
196
|
todo_to_edit = Dooby.current_list.tasks[task_id].todo
|
126
197
|
Readline::HISTORY.push todo_to_edit
|
127
|
-
|
198
|
+
autocomp = [todo_to_edit]
|
128
199
|
break
|
129
200
|
else
|
130
201
|
puts "Task doesn't exist".red.bold
|
131
202
|
exit
|
132
203
|
end
|
204
|
+
|
133
205
|
end
|
134
206
|
|
135
|
-
|
136
|
-
|
137
|
-
|
207
|
+
question = 'TAB or up arrow to edit '.blue.bold + '> '
|
208
|
+
|
209
|
+
Dooby.cli_helper.keep_asking question, autocomp do |text|
|
210
|
+
if text
|
211
|
+
|
212
|
+
Dooby.current_list.edit! current_task_id do |t|
|
213
|
+
t.todo = text
|
214
|
+
end
|
215
|
+
|
138
216
|
exit
|
139
|
-
end
|
217
|
+
end
|
140
218
|
end
|
141
219
|
|
142
|
-
|
143
|
-
rescue Interrupt
|
144
|
-
system("stty", stty_save)
|
145
|
-
exit
|
146
|
-
|
147
220
|
end
|
148
221
|
end
|
149
222
|
|
data/dooby.gemspec
CHANGED
@@ -5,13 +5,13 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{dooby}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Rafael Maga\303\261a"]
|
12
|
-
s.date = %q{2010-10-
|
12
|
+
s.date = %q{2010-10-28}
|
13
13
|
s.default_executable = %q{dooby}
|
14
|
-
s.description = %q{
|
14
|
+
s.description = %q{With Dooby you can handle your to-do list or your notes in a simple way and through the command-line.}
|
15
15
|
s.email = %q{raf.magana@gmail.com}
|
16
16
|
s.executables = ["dooby"]
|
17
17
|
s.extra_rdoc_files = [
|
@@ -21,6 +21,8 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.files = [
|
22
22
|
".document",
|
23
23
|
".gitignore",
|
24
|
+
"Gemfile",
|
25
|
+
"Gemfile.lock",
|
24
26
|
"LICENSE",
|
25
27
|
"README.md",
|
26
28
|
"Rakefile",
|
@@ -29,10 +31,11 @@ Gem::Specification.new do |s|
|
|
29
31
|
"dooby.gemspec",
|
30
32
|
"lib/dooby.rb",
|
31
33
|
"lib/dooby/base.rb",
|
34
|
+
"lib/dooby/cli_helper.rb",
|
35
|
+
"lib/dooby/core_ext.rb",
|
32
36
|
"lib/dooby/exceptions.rb",
|
33
37
|
"lib/dooby/formatter.rb",
|
34
38
|
"lib/dooby/list.rb",
|
35
|
-
"lib/dooby/readline_helper.rb",
|
36
39
|
"lib/dooby/task.rb",
|
37
40
|
"test/helper.rb",
|
38
41
|
"test/test_dooby.rb"
|
@@ -54,13 +57,22 @@ Gem::Specification.new do |s|
|
|
54
57
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
55
58
|
s.add_development_dependency(%q<shoulda>, [">= 2.11.3"])
|
56
59
|
s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
|
60
|
+
s.add_runtime_dependency(%q<main>, [">= 4.2.0"])
|
61
|
+
s.add_runtime_dependency(%q<colored>, [">= 1.2"])
|
62
|
+
s.add_runtime_dependency(%q<highline>, [">= 1.6.1"])
|
57
63
|
else
|
58
64
|
s.add_dependency(%q<shoulda>, [">= 2.11.3"])
|
59
65
|
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
66
|
+
s.add_dependency(%q<main>, [">= 4.2.0"])
|
67
|
+
s.add_dependency(%q<colored>, [">= 1.2"])
|
68
|
+
s.add_dependency(%q<highline>, [">= 1.6.1"])
|
60
69
|
end
|
61
70
|
else
|
62
71
|
s.add_dependency(%q<shoulda>, [">= 2.11.3"])
|
63
72
|
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
73
|
+
s.add_dependency(%q<main>, [">= 4.2.0"])
|
74
|
+
s.add_dependency(%q<colored>, [">= 1.2"])
|
75
|
+
s.add_dependency(%q<highline>, [">= 1.6.1"])
|
64
76
|
end
|
65
77
|
end
|
66
78
|
|
data/lib/dooby.rb
CHANGED
@@ -1,23 +1,25 @@
|
|
1
1
|
$:.unshift(File.dirname(__FILE__))
|
2
2
|
|
3
|
-
%w[fileutils digest/sha1 colored readline].each { |f| require "#{f}" }
|
3
|
+
%w[fileutils digest/sha1 colored readline highline/import].each { |f| require "#{f}" }
|
4
4
|
|
5
5
|
%w[exceptions
|
6
|
+
core_ext
|
6
7
|
base
|
7
8
|
list
|
8
9
|
formatter
|
9
10
|
task
|
10
|
-
|
11
|
+
cli_helper].each { |f| require "dooby/#{f}" }
|
11
12
|
|
12
13
|
module Dooby
|
13
14
|
|
14
15
|
DOOBY_DIR = '.dooby'
|
15
16
|
CURRENT_TODO_LIST_FILE = "#{DOOBY_DIR}/list.yml"
|
16
17
|
|
17
|
-
DEFAULT_PRIORITY = 5
|
18
18
|
DEFAULT_STATUS = :hold
|
19
19
|
|
20
20
|
AVAILABLE_STATUSES = [:hold, :doing, :done]
|
21
|
+
SPECIAL_TAGS = %w[@ # %]
|
22
|
+
SPLITTABLE_TAGS = %w[#today #urgent]
|
21
23
|
|
22
24
|
def self.init
|
23
25
|
unless File.exist? CURRENT_TODO_LIST_FILE
|
@@ -43,7 +45,7 @@ module Dooby
|
|
43
45
|
current_list
|
44
46
|
end
|
45
47
|
|
46
|
-
def self.
|
47
|
-
|
48
|
+
def self.cli_helper
|
49
|
+
CLIHelper
|
48
50
|
end
|
49
51
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Dooby
|
2
|
+
class CLIHelper
|
3
|
+
|
4
|
+
DEL_TASKS = "Sure you want to delete all the taks???".red_on_white.bold
|
5
|
+
TRASH = "Sure you want to delete the .dooby directory???".red_on_white.bold
|
6
|
+
|
7
|
+
def self.flush?
|
8
|
+
agree DEL_TASKS, true
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.trash?
|
12
|
+
agree TRASH, true
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.keep_asking(question, autocompletion = nil)
|
16
|
+
Readline.completion_append_character = " "
|
17
|
+
Readline.completion_proc = proc { |s| autocompletion.grep( /^#{Regexp.escape(s)}/ ) }
|
18
|
+
|
19
|
+
stty_save = `stty -g`.chomp
|
20
|
+
|
21
|
+
while value = Readline.readline(question, true)
|
22
|
+
yield value.chomp.strip
|
23
|
+
end
|
24
|
+
|
25
|
+
rescue Interrupt
|
26
|
+
system("stty", stty_save)
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class Array
|
2
|
+
def only_tags!(*wanted_tags)
|
3
|
+
replace(only_tags(wanted_tags))
|
4
|
+
end
|
5
|
+
|
6
|
+
def only_tags(*wanted_tags)
|
7
|
+
wanted_tags = '#' if wanted_tags.empty?
|
8
|
+
tags = self.grep(/[#{wanted_tags}]/)
|
9
|
+
tags.flatten
|
10
|
+
end
|
11
|
+
|
12
|
+
def tasks_by_tag(*tags)
|
13
|
+
unless self.empty?
|
14
|
+
tasks = []
|
15
|
+
items = self.dup
|
16
|
+
tags.each do |tag|
|
17
|
+
matches = items.grep(/#{tag}/)
|
18
|
+
items = items - matches
|
19
|
+
unless matches.empty?
|
20
|
+
separator = "\n==================== #{tag[1..-1].upcase} ====================".white_on_red
|
21
|
+
tasks << separator unless tasks.include? separator
|
22
|
+
tasks << matches
|
23
|
+
end
|
24
|
+
end
|
25
|
+
tasks.unshift items
|
26
|
+
tasks.flatten
|
27
|
+
else
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
class String
|
35
|
+
def only_tags(*wanted_tags)
|
36
|
+
split(' ').only_tags(*wanted_tags)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class NilClass
|
41
|
+
def tasks_by_tag(*tags)
|
42
|
+
nil
|
43
|
+
end
|
44
|
+
end
|
data/lib/dooby/list.rb
CHANGED
@@ -3,7 +3,7 @@ module Dooby
|
|
3
3
|
class List
|
4
4
|
|
5
5
|
attr_reader :location
|
6
|
-
|
6
|
+
|
7
7
|
def initialize(location)
|
8
8
|
@location = location
|
9
9
|
@tasks = {}
|
@@ -29,14 +29,29 @@ module Dooby
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
32
|
+
def bulk_delete!(terms)
|
33
|
+
only_tags = terms.only_tags *SPECIAL_TAGS
|
34
|
+
matches = []
|
35
|
+
@tasks.each do |id, task|
|
36
|
+
delete! id if only_tags.all? { |tag| task.todo.include? tag }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def edit!(task_id)
|
33
41
|
old_task = @tasks[task_id]
|
34
|
-
|
35
|
-
|
36
|
-
t
|
37
|
-
t.priority = old_task.priority
|
38
|
-
t.status = old_task.status
|
42
|
+
t = Task.new
|
43
|
+
if old_task
|
44
|
+
yield t
|
39
45
|
end
|
46
|
+
|
47
|
+
t.status = old_task.status
|
48
|
+
|
49
|
+
delete! task_id
|
50
|
+
add t
|
51
|
+
end
|
52
|
+
|
53
|
+
def tasks?
|
54
|
+
!@tasks.empty?
|
40
55
|
end
|
41
56
|
|
42
57
|
def tasks
|
@@ -47,13 +62,19 @@ module Dooby
|
|
47
62
|
list = []
|
48
63
|
|
49
64
|
if @tasks.empty?
|
50
|
-
list =
|
65
|
+
list = nil
|
51
66
|
else
|
52
|
-
|
53
|
-
|
67
|
+
case what_to_show
|
68
|
+
when [] then
|
54
69
|
@tasks.each do |id, task|
|
55
70
|
list << " (#{id.red}) #{task.colorize}"
|
56
71
|
end
|
72
|
+
when *SPECIAL_TAGS then
|
73
|
+
@tasks.each do |id, task|
|
74
|
+
task.todo.gsub(/(#{what_to_show}\w+)/).each do |tag|
|
75
|
+
list << tag.blue unless list.include? tag.blue
|
76
|
+
end
|
77
|
+
end
|
57
78
|
else
|
58
79
|
@tasks.each do |id, task|
|
59
80
|
if what_to_show.all? { |term| task.todo.include? term }
|
@@ -61,17 +82,21 @@ module Dooby
|
|
61
82
|
end
|
62
83
|
end
|
63
84
|
|
64
|
-
if list.empty?
|
65
|
-
list.unshift 'No items found containing:'.red_on_white.bold + ' ' + what_to_show.join(' and '.blue)
|
66
|
-
else
|
67
|
-
list.unshift 'Showing items containing:'.blue_on_white.bold + ' ' + what_to_show.join(' and '.blue)
|
68
|
-
end
|
85
|
+
list = nil if list.empty?
|
69
86
|
end
|
70
87
|
end
|
71
88
|
|
72
89
|
list
|
73
90
|
end
|
74
91
|
|
92
|
+
def all_tags
|
93
|
+
tags = []
|
94
|
+
@tasks.each do |id, task|
|
95
|
+
tags << task.todo.only_tags(*SPECIAL_TAGS)
|
96
|
+
end
|
97
|
+
tags.flatten
|
98
|
+
end
|
99
|
+
|
75
100
|
private
|
76
101
|
def save!
|
77
102
|
File.open( @location, 'w' ) do |f|
|
data/lib/dooby/task.rb
CHANGED
@@ -7,7 +7,6 @@ module Dooby
|
|
7
7
|
def initialize
|
8
8
|
@todo ||= nil
|
9
9
|
@status ||= DEFAULT_STATUS
|
10
|
-
@priority ||= DEFAULT_PRIORITY
|
11
10
|
end
|
12
11
|
|
13
12
|
def id
|
@@ -29,7 +28,7 @@ module Dooby
|
|
29
28
|
def hold!
|
30
29
|
@status = :hold
|
31
30
|
end
|
32
|
-
|
31
|
+
|
33
32
|
def colorize
|
34
33
|
colorized_todo = @todo.dup
|
35
34
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dooby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Rafael Maga\xC3\xB1a"
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-28 00:00:00 -05:00
|
19
19
|
default_executable: dooby
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -50,7 +50,54 @@ dependencies:
|
|
50
50
|
version: 0.9.8
|
51
51
|
type: :development
|
52
52
|
version_requirements: *id002
|
53
|
-
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: main
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 55
|
62
|
+
segments:
|
63
|
+
- 4
|
64
|
+
- 2
|
65
|
+
- 0
|
66
|
+
version: 4.2.0
|
67
|
+
type: :runtime
|
68
|
+
version_requirements: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: colored
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 11
|
78
|
+
segments:
|
79
|
+
- 1
|
80
|
+
- 2
|
81
|
+
version: "1.2"
|
82
|
+
type: :runtime
|
83
|
+
version_requirements: *id004
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: highline
|
86
|
+
prerelease: false
|
87
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
hash: 13
|
93
|
+
segments:
|
94
|
+
- 1
|
95
|
+
- 6
|
96
|
+
- 1
|
97
|
+
version: 1.6.1
|
98
|
+
type: :runtime
|
99
|
+
version_requirements: *id005
|
100
|
+
description: With Dooby you can handle your to-do list or your notes in a simple way and through the command-line.
|
54
101
|
email: raf.magana@gmail.com
|
55
102
|
executables:
|
56
103
|
- dooby
|
@@ -62,6 +109,8 @@ extra_rdoc_files:
|
|
62
109
|
files:
|
63
110
|
- .document
|
64
111
|
- .gitignore
|
112
|
+
- Gemfile
|
113
|
+
- Gemfile.lock
|
65
114
|
- LICENSE
|
66
115
|
- README.md
|
67
116
|
- Rakefile
|
@@ -70,10 +119,11 @@ files:
|
|
70
119
|
- dooby.gemspec
|
71
120
|
- lib/dooby.rb
|
72
121
|
- lib/dooby/base.rb
|
122
|
+
- lib/dooby/cli_helper.rb
|
123
|
+
- lib/dooby/core_ext.rb
|
73
124
|
- lib/dooby/exceptions.rb
|
74
125
|
- lib/dooby/formatter.rb
|
75
126
|
- lib/dooby/list.rb
|
76
|
-
- lib/dooby/readline_helper.rb
|
77
127
|
- lib/dooby/task.rb
|
78
128
|
- test/helper.rb
|
79
129
|
- test/test_dooby.rb
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module Dooby
|
2
|
-
class ReadlineHelper
|
3
|
-
attr_accessor :completion_list
|
4
|
-
|
5
|
-
def initialize
|
6
|
-
@completion_list = ''
|
7
|
-
@completion_proc = proc { |s| @completion_list.grep( /^#{Regexp.escape(s)}/ ) }
|
8
|
-
|
9
|
-
Readline.completion_append_character = " "
|
10
|
-
Readline.completion_proc = @completion_proc
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|