rubdo 0.0.1 → 0.0.3
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/bin/rubdo +0 -0
- data/lib/rubdo/cli.rb +9 -3
- data/lib/rubdo/list.rb +9 -2
- data/lib/rubdo/version.rb +1 -1
- metadata +1 -1
data/bin/rubdo
CHANGED
File without changes
|
data/lib/rubdo/cli.rb
CHANGED
@@ -6,7 +6,12 @@ module Rubdo
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def add
|
9
|
-
@list.add ARGV[1]
|
9
|
+
@list.add ARGV[1] if ARGV[1]
|
10
|
+
unless ARGV[1]
|
11
|
+
system("$EDITOR /tmp/new_task.txt")
|
12
|
+
@list.add File.read('/tmp/new_task.txt').chomp
|
13
|
+
File.delete("/tmp/new_task.txt")
|
14
|
+
end
|
10
15
|
end
|
11
16
|
|
12
17
|
def done
|
@@ -23,6 +28,7 @@ module Rubdo
|
|
23
28
|
|
24
29
|
def list
|
25
30
|
@list.items.each_with_index { |item, index| puts "#{index + 1}: #{item.description}" }
|
31
|
+
puts "no tasks" if @list.items.empty?
|
26
32
|
end
|
27
33
|
|
28
34
|
def info
|
@@ -47,9 +53,9 @@ module Rubdo
|
|
47
53
|
|
48
54
|
def help(onoe = nil)
|
49
55
|
puts <<-HELP
|
50
|
-
|
56
|
+
Commands for todo:
|
51
57
|
------------------
|
52
|
-
add/a [task description] - Add a new
|
58
|
+
add/a [task description] - Add a new task
|
53
59
|
list/ls - Lists all tasks
|
54
60
|
completed - List all completed tasks
|
55
61
|
done/d [task id] - Complete a task
|
data/lib/rubdo/list.rb
CHANGED
@@ -1,16 +1,19 @@
|
|
1
1
|
require 'time'
|
2
2
|
require 'yaml'
|
3
|
+
require 'fileutils'
|
3
4
|
|
4
5
|
module Rubdo
|
5
6
|
class List
|
6
7
|
attr_reader :items, :completed, :storage, :archive
|
7
8
|
|
8
9
|
def initialize
|
9
|
-
@storage = File.expand_path('~/
|
10
|
-
@archive = File.expand_path('~/
|
10
|
+
@storage = File.expand_path('~/tasks/Todo.yml')
|
11
|
+
@archive = File.expand_path('~/tasks/Archive.yml')
|
11
12
|
@items, @completed = [], []
|
12
13
|
@items = load @storage
|
13
14
|
@completed = load @archive
|
15
|
+
create_directory_for @storage
|
16
|
+
create_directory_for @archive
|
14
17
|
end
|
15
18
|
|
16
19
|
def add(description)
|
@@ -38,6 +41,10 @@ module Rubdo
|
|
38
41
|
@items[id].to_s
|
39
42
|
end
|
40
43
|
|
44
|
+
def create_directory_for(file)
|
45
|
+
FileUtils.mkdir File.dirname(file) unless File.exists? file
|
46
|
+
end
|
47
|
+
|
41
48
|
alias_method :<<, :add
|
42
49
|
end
|
43
50
|
end
|
data/lib/rubdo/version.rb
CHANGED