rudoo 0.0.01
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 +20 -0
- data/bin/rd +179 -0
- data/lib/rudoo.rb +27 -0
- data/lib/rudoo/list.rb +310 -0
- data/lib/rudoo/storage.rb +99 -0
- data/lib/rudoo/task.rb +15 -0
- data/lib/version.rb +3 -0
- data/rudoo.gemspec +17 -0
- data/spec/list_spec.rb +1 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/storage_spec.rb +1 -0
- data/spec/task_spec.rb +38 -0
- metadata +80 -0
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# Rudoo
|
2
|
+
|
3
|
+
Rudoo is a command line tool written in ruby that allows you to manage local, project based todo lists.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Currently, I don't have a gem available for rudoo but that will change soon! I already have the structure ready, I just want to add a few more features before releasing.
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
TO BE ADDED
|
12
|
+
|
13
|
+
## TODO LIST
|
14
|
+
*Items in bold are undone. Items in normal font are already completed*
|
15
|
+
|
16
|
+
* **Create function to allow bulk deletion.**
|
17
|
+
* **Think about ways to add remote hosting... Google Tasks?**
|
18
|
+
* **Create functions to allow holding and resuming of current projects**
|
19
|
+
* **Write tests.**
|
20
|
+
* **Add documentation.**
|
data/bin/rd
ADDED
@@ -0,0 +1,179 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'rudoo.rb'))
|
6
|
+
|
7
|
+
options = {}
|
8
|
+
|
9
|
+
opt_parser = OptionParser.new do |opt|
|
10
|
+
opt.banner = "Usage: rd COMMAND [OPTIONS]"
|
11
|
+
opt.separator ""
|
12
|
+
opt.separator "Commands"
|
13
|
+
opt.separator " init: initialize a new rudoo file architecture"
|
14
|
+
opt.separator ""
|
15
|
+
opt.separator "Options"
|
16
|
+
|
17
|
+
## INIT SPECIFIC ##
|
18
|
+
|
19
|
+
opt.on("--reset","reset the file structure for rudoo") do |reset|
|
20
|
+
options[:reset] = true
|
21
|
+
end
|
22
|
+
|
23
|
+
opt.on("--destroy","remove the file structure for rudoo and do not initialize a new one.") do |destroy|
|
24
|
+
options[:destroy] = true
|
25
|
+
end
|
26
|
+
|
27
|
+
## END ##
|
28
|
+
|
29
|
+
opt.on("-m", "--message MESSAGE", "message for a todo (what needs to be completed)") do |message|
|
30
|
+
options[:message] = message
|
31
|
+
end
|
32
|
+
|
33
|
+
opt.on("--id IDENTIFIER", "specify the id of a task") do |id|
|
34
|
+
options[:id] = id
|
35
|
+
end
|
36
|
+
|
37
|
+
opt.on("-p", "--priority PRIORITY", "specify the priority of a task") do |priority|
|
38
|
+
options[:priority] = priority
|
39
|
+
end
|
40
|
+
|
41
|
+
opt.on("-t", "--type TYPE", "specify the type of task (done, undone, or all)") do |type|
|
42
|
+
options[:type] = type
|
43
|
+
end
|
44
|
+
|
45
|
+
## GIT SPECIFIC ##
|
46
|
+
|
47
|
+
opt.on("--commit", "make a new commit with the current task as the message") do |commit|
|
48
|
+
options[:commit] = true
|
49
|
+
end
|
50
|
+
|
51
|
+
## To-MD SPECIFIC ##
|
52
|
+
|
53
|
+
opt.on("-f", "--file FILE", "destination to file you want to export .md list to") do |file|
|
54
|
+
options[:file] = file
|
55
|
+
end
|
56
|
+
|
57
|
+
## END ##
|
58
|
+
end
|
59
|
+
|
60
|
+
opt_parser.parse!
|
61
|
+
|
62
|
+
reset = options[:reset] || false
|
63
|
+
destroy = options[:destroy] || false
|
64
|
+
message = options[:message] || nil
|
65
|
+
priority = options[:priority] || 0
|
66
|
+
id = options[:id] || nil
|
67
|
+
type = options[:type] || "undone"
|
68
|
+
commit = options[:commit] || false
|
69
|
+
file = options[:file] || false
|
70
|
+
|
71
|
+
case ARGV[0]
|
72
|
+
when "init"
|
73
|
+
Rd.new unless reset || destroy
|
74
|
+
Rd.reset if reset
|
75
|
+
Rd.destroy if destroy
|
76
|
+
|
77
|
+
when "add"
|
78
|
+
if message.nil?
|
79
|
+
puts "ERROR: Message required when adding a new task!"
|
80
|
+
puts ""
|
81
|
+
else
|
82
|
+
added = Rd.list.add(message, priority)
|
83
|
+
|
84
|
+
puts "Task successfully added!" if added.class == Rudoo::Task
|
85
|
+
end
|
86
|
+
|
87
|
+
when "edit"
|
88
|
+
puts "ERROR: At least one modification must be specified!" if message.nil? && priority.nil?
|
89
|
+
|
90
|
+
edit = Rd.list.edit(id, message, priority)
|
91
|
+
|
92
|
+
if edit.class == Rudoo::Task
|
93
|
+
puts "Task successfully edited!"
|
94
|
+
else
|
95
|
+
puts "Unable to find an objective with ID: #{id}"
|
96
|
+
end
|
97
|
+
|
98
|
+
when "list"
|
99
|
+
args = ARGV[1..-1] || []
|
100
|
+
|
101
|
+
Rd.list.gather(args, type)
|
102
|
+
|
103
|
+
when "tags"
|
104
|
+
Rd.list.tags(type)
|
105
|
+
|
106
|
+
when "people"
|
107
|
+
Rd.list.people(type)
|
108
|
+
|
109
|
+
when "promote"
|
110
|
+
if id.nil?
|
111
|
+
puts "ERROR: You must specify a task id to promote!"
|
112
|
+
else
|
113
|
+
puts "Task successfully promoted!" if Rd.list.promote(id)
|
114
|
+
end
|
115
|
+
|
116
|
+
when "demote"
|
117
|
+
if id.nil?
|
118
|
+
puts "ERROR: You must specify a task id to demote!"
|
119
|
+
else
|
120
|
+
puts "Task successfully demoted!" if Rd.list.demote(id)
|
121
|
+
end
|
122
|
+
|
123
|
+
when "projects"
|
124
|
+
Rd.list.projects(type)
|
125
|
+
|
126
|
+
when "complete"
|
127
|
+
if id.nil?
|
128
|
+
puts "ERROR: You must include a task id to mark as complete!"
|
129
|
+
else
|
130
|
+
puts "Task successfully marked as complete!" if Rd.list.complete(id)
|
131
|
+
end
|
132
|
+
|
133
|
+
when "open"
|
134
|
+
if id.nil?
|
135
|
+
puts "ERROR: You must specify a task id to open it!"
|
136
|
+
else
|
137
|
+
open = Rd.list.open(id)
|
138
|
+
|
139
|
+
if open
|
140
|
+
puts "Task successfully opened and marked incomplete!"
|
141
|
+
else
|
142
|
+
puts "ERROR: Unable to find task with id: #{id}!"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
when "current"
|
147
|
+
if id.nil?
|
148
|
+
current = Rd.list.current
|
149
|
+
|
150
|
+
if current == false
|
151
|
+
puts "ERROR: You aren't currently working on anything!"
|
152
|
+
else
|
153
|
+
Rd.list.print_to_screen(current)
|
154
|
+
end
|
155
|
+
else
|
156
|
+
puts "Current task successfully changed!" if Rd.list.set_current(id)
|
157
|
+
end
|
158
|
+
|
159
|
+
when "delete"
|
160
|
+
if id.nil?
|
161
|
+
puts "ERROR: You must specify an id for the task you would like to delete!"
|
162
|
+
else
|
163
|
+
puts "Task successfully deleted!" if Rd.list.delete(id)
|
164
|
+
end
|
165
|
+
|
166
|
+
when "to-md"
|
167
|
+
if file
|
168
|
+
Rd.list.to_md(file, type)
|
169
|
+
else
|
170
|
+
puts "ERROR: No file specified to export to!"
|
171
|
+
end
|
172
|
+
|
173
|
+
when "git"
|
174
|
+
Rd.list.commit if commit
|
175
|
+
else
|
176
|
+
puts "Unknown command. See usage instructions:"
|
177
|
+
puts ""
|
178
|
+
puts opt_parser
|
179
|
+
end
|
data/lib/rudoo.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "yaml"
|
3
|
+
require "fileutils"
|
4
|
+
require "digest/sha1"
|
5
|
+
require "chronic"
|
6
|
+
|
7
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "rudoo", "storage.rb"))
|
8
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "rudoo", "list.rb"))
|
9
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "rudoo", "task.rb"))
|
10
|
+
|
11
|
+
class Rd
|
12
|
+
def initialize
|
13
|
+
Rudoo::Storage.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.reset
|
17
|
+
Rudoo::Storage.reset
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.destroy
|
21
|
+
Rudoo::Storage.destroy
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.list
|
25
|
+
Rudoo::List.new
|
26
|
+
end
|
27
|
+
end
|
data/lib/rudoo/list.rb
ADDED
@@ -0,0 +1,310 @@
|
|
1
|
+
module Rudoo
|
2
|
+
class List
|
3
|
+
|
4
|
+
# create a new list object by loading the yaml file
|
5
|
+
def initialize
|
6
|
+
@list = ".rudoo/list.yml"
|
7
|
+
@config = ".rudoo/config.yml"
|
8
|
+
@tasks = {}
|
9
|
+
load
|
10
|
+
end
|
11
|
+
|
12
|
+
# method for adding task objects to the list
|
13
|
+
def add(todo, priority = 0)
|
14
|
+
if todo.class == Rudoo::Task
|
15
|
+
task = todo
|
16
|
+
else
|
17
|
+
task = Rudoo::Task.new(todo, priority)
|
18
|
+
end
|
19
|
+
|
20
|
+
task = convert_date(task)
|
21
|
+
@tasks[task.id] = task
|
22
|
+
write
|
23
|
+
|
24
|
+
return task
|
25
|
+
end
|
26
|
+
|
27
|
+
# method for deleting task objects from the list
|
28
|
+
def delete(task_id)
|
29
|
+
if @tasks.delete(task_id)
|
30
|
+
write
|
31
|
+
else
|
32
|
+
raise StandardError.new("ERROR: Unable to delete objective from the hash!")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# method for editing existing tasks given their id
|
37
|
+
def edit(task_id, message = nil, priority = nil)
|
38
|
+
old = @tasks[task_id]
|
39
|
+
|
40
|
+
message = old.todo if message.nil?
|
41
|
+
priority = old.priority if priority.nil?
|
42
|
+
|
43
|
+
if old
|
44
|
+
new_task = Task.new(message, priority)
|
45
|
+
delete(task_id)
|
46
|
+
add(new_task)
|
47
|
+
else
|
48
|
+
return false
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# complete an existing task
|
53
|
+
def complete(task_id)
|
54
|
+
previous = @tasks[task_id]
|
55
|
+
previous.todo = previous.todo.gsub(" :wkng", "")
|
56
|
+
previous.todo = previous.todo.gsub(" :done", "")
|
57
|
+
|
58
|
+
edit(task_id, "#{previous.todo} :done")
|
59
|
+
|
60
|
+
return true
|
61
|
+
end
|
62
|
+
|
63
|
+
# re-open a completed task (make it incomplete again)
|
64
|
+
def open(task_id)
|
65
|
+
previous = @tasks[task_id]
|
66
|
+
|
67
|
+
if previous
|
68
|
+
edit(task_id, previous.todo.gsub(" :done", ""))
|
69
|
+
return true
|
70
|
+
else
|
71
|
+
return false
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# check if a task is finished or not
|
76
|
+
def done?(task)
|
77
|
+
task.todo.include?(":done")
|
78
|
+
end
|
79
|
+
|
80
|
+
# returns a list of tasks that match the given argument criteria
|
81
|
+
def gather(args = [], state = "undone")
|
82
|
+
list = {}
|
83
|
+
|
84
|
+
if @tasks.empty?
|
85
|
+
list = {}
|
86
|
+
else
|
87
|
+
case args
|
88
|
+
when []
|
89
|
+
deleteThese = []
|
90
|
+
addThese = []
|
91
|
+
|
92
|
+
@tasks.each do |id, task|
|
93
|
+
if (state == "undone" && !done?(task)) || (state == "done" && done?(task)) || (state == "all")
|
94
|
+
if task.todo.include?("{#{Time.now.strftime('%b/%d/%Y')}}")
|
95
|
+
replacedTask = task.dup
|
96
|
+
replacedTask.todo.gsub("{#{Time.now.strftime('%b/%d/%Y')}}", "#{@tag_token}today")
|
97
|
+
|
98
|
+
addThese << replacedTask
|
99
|
+
deleteThese << id
|
100
|
+
else
|
101
|
+
list[task.id] = task
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
deleteThese.each do |id|
|
106
|
+
delete(id)
|
107
|
+
end
|
108
|
+
|
109
|
+
addThese.each do |task|
|
110
|
+
add(task)
|
111
|
+
list[task.id] = task
|
112
|
+
end
|
113
|
+
when @person_token, @tag_token, @project_token
|
114
|
+
tags = Hash.new(0)
|
115
|
+
|
116
|
+
@tasks.each do |id, task|
|
117
|
+
if (state == "undone" && !done?(task)) || (state == "done" && done?(task)) || (state == "all")
|
118
|
+
task.todo.gsub(/(#{"\\" + args}\w+)/).each do |tag|
|
119
|
+
tags[tag] += 1
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
tags.each {|tag, number| puts "#{tag} (#{number})"}
|
125
|
+
else
|
126
|
+
if args.any? {|arg| arg.downcase.include?("tomorrow")}
|
127
|
+
args << Chronic.parse("tomorrow").strftime('%b/%d/%Y')
|
128
|
+
args.delete("tomorrow")
|
129
|
+
args.delete("#{@tag_token}tomorrow")
|
130
|
+
end
|
131
|
+
|
132
|
+
@tasks.each do |id, task|
|
133
|
+
if (state == "undone" && !done?(task)) || (state == "done" && done?(task)) || (state == "all")
|
134
|
+
args.each do |term|
|
135
|
+
list[task.id] = task if task.todo.downcase.include?(term.downcase)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
print_to_screen list unless list == {}
|
143
|
+
end
|
144
|
+
|
145
|
+
# Method to increase the priority of a task
|
146
|
+
def promote(task_id)
|
147
|
+
previous = @tasks[task_id]
|
148
|
+
previous.priority = previous.priority.to_i + 1
|
149
|
+
write
|
150
|
+
|
151
|
+
return true
|
152
|
+
end
|
153
|
+
|
154
|
+
# Method to decrease the priority of a task
|
155
|
+
def demote(task_id)
|
156
|
+
previous = @tasks[task_id]
|
157
|
+
previous.priority = previous.priority.to_i - 1 unless previous.priority.to_i <= 0
|
158
|
+
write
|
159
|
+
|
160
|
+
return true
|
161
|
+
end
|
162
|
+
|
163
|
+
# returns all of the people mentioned
|
164
|
+
def people(type)
|
165
|
+
gather(@person_token, type)
|
166
|
+
end
|
167
|
+
|
168
|
+
# returns all of the tags
|
169
|
+
def tags(type)
|
170
|
+
gather(@tag_token, type)
|
171
|
+
end
|
172
|
+
|
173
|
+
# returns all of the projects
|
174
|
+
def projects(type)
|
175
|
+
gather(@project_token, type)
|
176
|
+
end
|
177
|
+
|
178
|
+
# returns the task (marked with :wkng)
|
179
|
+
def current
|
180
|
+
current = @tasks.dup.select do |id, task|
|
181
|
+
task.todo.include?(":wkng")
|
182
|
+
end
|
183
|
+
|
184
|
+
if current == {}
|
185
|
+
return false
|
186
|
+
else
|
187
|
+
return current
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
# Method to make a task current given its id
|
192
|
+
def set_current(task_id)
|
193
|
+
previous = @tasks[task_id]
|
194
|
+
|
195
|
+
previous.todo = previous.todo.gsub(" :wkng", "")
|
196
|
+
previous.todo = previous.todo.gsub(" :done", "")
|
197
|
+
|
198
|
+
edit(task_id, "#{previous.todo} :wkng")
|
199
|
+
|
200
|
+
return true
|
201
|
+
end
|
202
|
+
|
203
|
+
def to_md(file, state="undone")
|
204
|
+
file = File.open(File.expand_path(file), "a")
|
205
|
+
|
206
|
+
file.puts ""
|
207
|
+
file.puts ""
|
208
|
+
file.puts "## TODO LIST"
|
209
|
+
file.puts " *Items in bold are undone. Items in normal font are already completed*"
|
210
|
+
file.puts ""
|
211
|
+
|
212
|
+
@tasks.each do |id, task|
|
213
|
+
if (state == "undone" && !done?(task)) || (state == "done" && done?(task)) || (state == "all")
|
214
|
+
todo = strip_tags(task.todo)
|
215
|
+
|
216
|
+
if done?(task)
|
217
|
+
file.puts "* #{todo}"
|
218
|
+
else
|
219
|
+
file.puts "* **#{todo}**"
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
## runs git commit with the current task as the
|
226
|
+
def commit
|
227
|
+
current_todo = strip_tags(current.values[0].todo)
|
228
|
+
|
229
|
+
`git commit -am "#{current_todo}"`
|
230
|
+
end
|
231
|
+
|
232
|
+
# method to order tasks by priority and arrange them in a table
|
233
|
+
def print_to_screen(init_hash)
|
234
|
+
priority_hash = {}
|
235
|
+
hash = {}
|
236
|
+
|
237
|
+
init_hash.values.each do |task|
|
238
|
+
priority_hash[task] = task.priority.to_i
|
239
|
+
end
|
240
|
+
|
241
|
+
priority_hash = priority_hash.sort_by {|k, v| v}.reverse
|
242
|
+
|
243
|
+
priority_hash.each do |task, priority|
|
244
|
+
hash[task.id] = task
|
245
|
+
end
|
246
|
+
|
247
|
+
longest_todo = hash.values.sort_by {|x| x.todo.to_s.length}.reverse[0].todo.length
|
248
|
+
longest_priority = hash.values.sort_by {|x| x.priority.to_s.length}.reverse[0].priority.to_s.length
|
249
|
+
array_length = hash.count
|
250
|
+
|
251
|
+
ids = hash.keys
|
252
|
+
tasks = hash.values
|
253
|
+
|
254
|
+
((array_length*2)+1).times do |x|
|
255
|
+
if x%2 == 0
|
256
|
+
puts "+--------+-#{"-"*longest_todo}-+-#{"-"*longest_priority}-+"
|
257
|
+
else
|
258
|
+
task = tasks[(x-1)/2]
|
259
|
+
puts "| #{ids[(x-1)/2]} | #{task.todo}#{" "*(longest_todo - task.todo.length)} | #{task.priority}#{" "*(longest_priority - task.priority.to_s.length)} |"
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
private
|
265
|
+
|
266
|
+
def strip_tags(todo)
|
267
|
+
todo = todo.gsub(" :done", "")
|
268
|
+
todo = todo.gsub(" :wkng", "")
|
269
|
+
todo = todo.gsub(@tag_token, "")
|
270
|
+
todo = todo.gsub(@person_token, "")
|
271
|
+
todo = todo.gsub(@project_token, "")
|
272
|
+
|
273
|
+
return todo
|
274
|
+
end
|
275
|
+
|
276
|
+
# change tomorrow tags into actual dates
|
277
|
+
def convert_date(task)
|
278
|
+
if task.todo.include?("#{@tag_token}tomorrow")
|
279
|
+
task.todo.gsub!("#{@tag_token}tomorrow", "{#{Chronic.parse("tomorrow").strftime('%b/%d/%Y')}}")
|
280
|
+
task.todo.gsub!(/#{@tag_token}tomorrow/, '')
|
281
|
+
end
|
282
|
+
task
|
283
|
+
end
|
284
|
+
|
285
|
+
# load yaml file
|
286
|
+
def load
|
287
|
+
raise StandardException.new("Unable to find rudoo list storage file.") unless File.exists?(@list)
|
288
|
+
raise StandardException.new("Unable to find rudoo configuration file.") unless File.exists?(@config)
|
289
|
+
|
290
|
+
begin
|
291
|
+
@tasks = YAML.load_file(@list)
|
292
|
+
rescue
|
293
|
+
@tasks = {}
|
294
|
+
end
|
295
|
+
|
296
|
+
config = YAML.load_file(@config)
|
297
|
+
|
298
|
+
config.each do |name, value|
|
299
|
+
instance_variable_set("@#{name}",value)
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
# write to yaml file
|
304
|
+
def write
|
305
|
+
File.open(@list, "w") do |file|
|
306
|
+
file << @tasks.to_yaml
|
307
|
+
end
|
308
|
+
end
|
309
|
+
end
|
310
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module Rudoo
|
2
|
+
class Storage
|
3
|
+
def initialize
|
4
|
+
if self.class.dir_initialized?(".rudoo")
|
5
|
+
puts "File architecture already initialized! Run 'rd init --destroy' to wipe rudoo file sysyem." if self.class.file_initialized?(".rudoo", "list.yml") && self.class.file_initialized?(".rudoo", "config.yml")
|
6
|
+
puts "Corrupted file architecture: Unable to find list file. Please run 'rd init --reset' to reset the file system." unless self.class.file_initialized?(".rudoo", "list.yml")
|
7
|
+
puts "Corrupted file architecture: Unable to find configuration file. Please run 'rd init --reset' to reset the file system." unless self.class.file_initialized?(".rudoo", "config.yml")
|
8
|
+
else
|
9
|
+
self.class.make_folder(".rudoo")
|
10
|
+
|
11
|
+
self.class.make_file(".rudoo", "list.yml")
|
12
|
+
self.class.make_file(".rudoo", "config.yml")
|
13
|
+
|
14
|
+
self.class.generate_config
|
15
|
+
|
16
|
+
puts "Rudoo file system successfully created! You can now run rudoo commands."
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.reset
|
21
|
+
if dir_initialized?(".rudoo")
|
22
|
+
clear_files(".rudoo")
|
23
|
+
|
24
|
+
make_folder(".rudoo")
|
25
|
+
|
26
|
+
make_file(".rudoo", "list.yml")
|
27
|
+
make_file(".rudoo", "config.yml")
|
28
|
+
|
29
|
+
generate_config
|
30
|
+
|
31
|
+
puts "Rudoo file system successfully reset! You can now run rudoo commands."
|
32
|
+
else
|
33
|
+
puts "Rudoo file structure not found. Rudoo must be initialized to reset!"
|
34
|
+
puts ""
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.destroy
|
39
|
+
if dir_initialized?(".rudoo")
|
40
|
+
clear_files(".rudoo")
|
41
|
+
else
|
42
|
+
puts "Rudoo file structure not found. Rudoo must be initialized to destroy!"
|
43
|
+
puts ""
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def self.write_file(contents, destination)
|
50
|
+
File.open(destination, "w") do |file|
|
51
|
+
file << contents.to_yaml
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.generate_config
|
56
|
+
preferences = {
|
57
|
+
:person_token => "@",
|
58
|
+
:tag_token => "^",
|
59
|
+
:project_token => "*"
|
60
|
+
}
|
61
|
+
|
62
|
+
write_file(preferences, ".rudoo/config.yml")
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.clear_files(dir)
|
66
|
+
raise StandardError.new("Unable to delete existing architechture.") unless FileUtils.rm_rf(dir)
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.make_file(dir, file)
|
70
|
+
f = File.new(File.join(dir, file), "w+")
|
71
|
+
|
72
|
+
raise StandardError.new("Unable to create rudoo list storage file: #{file}") unless f
|
73
|
+
|
74
|
+
f.close
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.make_folder(dir)
|
78
|
+
folder = FileUtils.mkdir(dir)
|
79
|
+
|
80
|
+
raise StandardError.new("Unable to create directory: #{dir}.") unless folder
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.dir_initialized?(dir)
|
84
|
+
if File.directory?(dir)
|
85
|
+
return true
|
86
|
+
else
|
87
|
+
return false
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.file_initialized?(dir, file)
|
92
|
+
if File.exists?(File.join(dir, file))
|
93
|
+
return true
|
94
|
+
else
|
95
|
+
return false
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
data/lib/rudoo/task.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Rudoo
|
2
|
+
class Task
|
3
|
+
attr_accessor :todo, :priority
|
4
|
+
|
5
|
+
def initialize(todo, priority = 0)
|
6
|
+
@todo = todo
|
7
|
+
@priority = priority
|
8
|
+
end
|
9
|
+
|
10
|
+
def id
|
11
|
+
return Digest::SHA1.hexdigest(@todo)[0,6] unless @todo.nil?
|
12
|
+
return nil if @todo.nil?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/version.rb
ADDED
data/rudoo.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Tommy Schaefer"]
|
6
|
+
gem.email = ["me@tommyschaefer.net"]
|
7
|
+
gem.description = %q{A ruby program for mannaging project based todo-lists in terminal.}
|
8
|
+
gem.summary = %q{Rudoo is a ruby program made primarilly for developers. It allows you to manage project based todo-lists from the command line. In addition to doing some cool things like tagging, rudoo also has a few features that optamize your workflow.}
|
9
|
+
gem.homepage = "https://github.com/tommyschaefer/rudoo"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "rudoo"
|
15
|
+
gem.version = Rudoo::VERSION
|
16
|
+
gem.add_dependency "chronic"
|
17
|
+
end
|
data/spec/list_spec.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper.rb"))
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "rudoo.rb"))
|
@@ -0,0 +1 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper.rb"))
|
data/spec/task_spec.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper.rb"))
|
2
|
+
|
3
|
+
describe Rudoo::Task do
|
4
|
+
before :each do
|
5
|
+
@task = Rudoo::Task.new("This is my task")
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#initialize" do
|
9
|
+
it "returns a task object" do
|
10
|
+
@task.should be_an_instance_of Rudoo::Task
|
11
|
+
end
|
12
|
+
|
13
|
+
it "assigns the todo accessor" do
|
14
|
+
@task.todo.should == "This is my task"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#id" do
|
19
|
+
it "returns nil if todo is nil" do
|
20
|
+
task = Rudoo::Task.new
|
21
|
+
task.id.should == nil
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns a string otherwise" do
|
25
|
+
@task.id.should be_a String
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns a 6 digit string" do
|
29
|
+
@task.id.length.should == 6
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#get" do
|
34
|
+
it "should return a specific string" do
|
35
|
+
@task.get.should == "(#{@task.id}) #{@task.todo}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rudoo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.01
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Tommy Schaefer
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: chronic
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: A ruby program for mannaging project based todo-lists in terminal.
|
31
|
+
email:
|
32
|
+
- me@tommyschaefer.net
|
33
|
+
executables:
|
34
|
+
- rd
|
35
|
+
extensions: []
|
36
|
+
extra_rdoc_files: []
|
37
|
+
files:
|
38
|
+
- README.md
|
39
|
+
- bin/rd
|
40
|
+
- lib/rudoo.rb
|
41
|
+
- lib/rudoo/list.rb
|
42
|
+
- lib/rudoo/storage.rb
|
43
|
+
- lib/rudoo/task.rb
|
44
|
+
- lib/version.rb
|
45
|
+
- rudoo.gemspec
|
46
|
+
- spec/list_spec.rb
|
47
|
+
- spec/spec_helper.rb
|
48
|
+
- spec/storage_spec.rb
|
49
|
+
- spec/task_spec.rb
|
50
|
+
homepage: https://github.com/tommyschaefer/rudoo
|
51
|
+
licenses: []
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 1.8.24
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: Rudoo is a ruby program made primarilly for developers. It allows you to
|
74
|
+
manage project based todo-lists from the command line. In addition to doing some
|
75
|
+
cool things like tagging, rudoo also has a few features that optamize your workflow.
|
76
|
+
test_files:
|
77
|
+
- spec/list_spec.rb
|
78
|
+
- spec/spec_helper.rb
|
79
|
+
- spec/storage_spec.rb
|
80
|
+
- spec/task_spec.rb
|