rubdo 0.2.4 → 0.2.5
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/lib/rubdo/cli.rb +3 -2
- data/lib/rubdo/list.rb +9 -10
- data/lib/rubdo/version.rb +1 -1
- metadata +2 -2
data/lib/rubdo/cli.rb
CHANGED
@@ -3,7 +3,8 @@ require 'tempfile'
|
|
3
3
|
module Rubdo
|
4
4
|
class CLI
|
5
5
|
def initialize
|
6
|
-
|
6
|
+
todos = List.read(File.expand_path('~/.tasks/Todo.yml'))
|
7
|
+
@list = List.new(todos)
|
7
8
|
@id = ARGV[1].to_i - 1
|
8
9
|
end
|
9
10
|
|
@@ -29,7 +30,7 @@ module Rubdo
|
|
29
30
|
end
|
30
31
|
|
31
32
|
def list
|
32
|
-
@list.
|
33
|
+
@list.to_a.each_with_index { |item, index| puts "#{index + 1}: #{item.description}" }
|
33
34
|
puts "no tasks" if @list.items.empty?
|
34
35
|
end
|
35
36
|
|
data/lib/rubdo/list.rb
CHANGED
@@ -6,11 +6,15 @@ module Rubdo
|
|
6
6
|
class List
|
7
7
|
attr_reader :items, :completed, :storage
|
8
8
|
|
9
|
-
def
|
9
|
+
def self.read(file)
|
10
|
+
return YAML.load_file(file) if File.exists? file
|
11
|
+
[]
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(todos)
|
15
|
+
@items = todos
|
10
16
|
@storage = File.expand_path('~/.tasks/Todo.yml')
|
11
|
-
@items = []
|
12
17
|
FileUtils.mkdir_p File.dirname @storage
|
13
|
-
@items = read(@storage)
|
14
18
|
end
|
15
19
|
|
16
20
|
def add(description)
|
@@ -18,12 +22,7 @@ module Rubdo
|
|
18
22
|
end
|
19
23
|
|
20
24
|
def write
|
21
|
-
File.open(
|
22
|
-
end
|
23
|
-
|
24
|
-
def read(file)
|
25
|
-
return YAML.load_file(file) if File.exists? file
|
26
|
-
[]
|
25
|
+
File.open(self.storage, 'w') { |todos| todos.write(@items.to_yaml) }
|
27
26
|
end
|
28
27
|
|
29
28
|
def done(id)
|
@@ -31,7 +30,7 @@ module Rubdo
|
|
31
30
|
end
|
32
31
|
|
33
32
|
def to_a
|
34
|
-
|
33
|
+
self.items
|
35
34
|
end
|
36
35
|
|
37
36
|
alias_method :<<, :add
|
data/lib/rubdo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubdo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-31 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A quick and dirty todo application
|
15
15
|
email:
|