todo-void 0.1.1.pre → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/interactors/todo_interactor.rb +5 -2
- data/lib/todo.rb +2 -1
- data/lib/todo_list.rb +1 -7
- data/lib/todo_store.rb +7 -2
- data/lib/todo_view.rb +4 -1
- data/lib/todo_void.rb +13 -2
- metadata +4 -4
data/lib/todo.rb
CHANGED
@@ -2,11 +2,12 @@ require 'openssl'
|
|
2
2
|
|
3
3
|
class Todo
|
4
4
|
attr_reader :description
|
5
|
-
attr_accessor :status, :finished_at
|
5
|
+
attr_accessor :tags, :status, :finished_at
|
6
6
|
|
7
7
|
def initialize(description)
|
8
8
|
@description = description
|
9
9
|
@status = :pending
|
10
|
+
@tags = []
|
10
11
|
end
|
11
12
|
|
12
13
|
def id
|
data/lib/todo_list.rb
CHANGED
data/lib/todo_store.rb
CHANGED
@@ -13,7 +13,8 @@ class TodoStore
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def update(todo)
|
16
|
-
@list.
|
16
|
+
@list.delete(todo)
|
17
|
+
@list.add(todo)
|
17
18
|
write
|
18
19
|
end
|
19
20
|
|
@@ -37,6 +38,9 @@ class TodoStore
|
|
37
38
|
unless raw_todo[2].nil?
|
38
39
|
todo.finished_at = DateTime.parse(raw_todo[2]).to_time
|
39
40
|
end
|
41
|
+
unless raw_todo[3].nil?
|
42
|
+
todo.tags = raw_todo[3].split('|')
|
43
|
+
end
|
40
44
|
todo.status = raw_todo[1].to_sym
|
41
45
|
todo
|
42
46
|
end
|
@@ -44,7 +48,8 @@ class TodoStore
|
|
44
48
|
def write
|
45
49
|
CSV.open(todo_file, "w") do |csv|
|
46
50
|
@list.each do |todo|
|
47
|
-
|
51
|
+
tags = todo.tags.join('|')
|
52
|
+
csv << [todo.description, todo.status, todo.finished_at, tags]
|
48
53
|
end
|
49
54
|
end
|
50
55
|
end
|
data/lib/todo_view.rb
CHANGED
@@ -6,12 +6,15 @@ class TodoView
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def render
|
9
|
-
if @todo.status == :finished
|
9
|
+
output = if @todo.status == :finished
|
10
10
|
"#{@todo.id} #{@todo.description}".foreground(:black)
|
11
11
|
elsif @todo.status == :started
|
12
12
|
"#{@todo.id.foreground(:green)} #{@todo.description}"
|
13
13
|
else
|
14
14
|
"#{@todo.id.foreground(:yellow)} #{@todo.description}"
|
15
15
|
end
|
16
|
+
|
17
|
+
output += " (#{@todo.tags.join(', ')})".foreground(:green) unless @todo.tags.empty?
|
18
|
+
output
|
16
19
|
end
|
17
20
|
end
|
data/lib/todo_void.rb
CHANGED
@@ -3,7 +3,8 @@ require_relative '../interactors/status_changes_interactor.rb'
|
|
3
3
|
require_relative './todo_list_view'
|
4
4
|
|
5
5
|
class TodoVoid
|
6
|
-
def initialize(args=[])
|
6
|
+
def initialize(args=[], interactor = TodoInteractor.new)
|
7
|
+
@todo_interactor = interactor
|
7
8
|
@args = args
|
8
9
|
@output = ""
|
9
10
|
end
|
@@ -18,7 +19,8 @@ class TodoVoid
|
|
18
19
|
elsif flag?('--help')
|
19
20
|
@output = read_help
|
20
21
|
elsif @args[0]
|
21
|
-
|
22
|
+
tags = extract_tags(@args[1])
|
23
|
+
@todo_interactor.add_todo(@args[0], tags)
|
22
24
|
else
|
23
25
|
todos = TodoInteractor.new.list_all
|
24
26
|
@output = TodoListView.render(todos)
|
@@ -31,6 +33,15 @@ class TodoVoid
|
|
31
33
|
@args[0] == flag
|
32
34
|
end
|
33
35
|
|
36
|
+
def extract_tags(tag_arg)
|
37
|
+
return [] unless tag_arg
|
38
|
+
|
39
|
+
flag, tags = tag_arg.split("=")
|
40
|
+
tags = tags.gsub("'", "")
|
41
|
+
tags = tags.split(',')
|
42
|
+
tags.map! {|tag| tag.strip}
|
43
|
+
end
|
44
|
+
|
34
45
|
def hash
|
35
46
|
@args[1]
|
36
47
|
end
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: todo-void
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.1
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.1
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Robert Curth
|
@@ -108,9 +108,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
108
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
109
|
none: false
|
110
110
|
requirements:
|
111
|
-
- - ! '
|
111
|
+
- - ! '>='
|
112
112
|
- !ruby/object:Gem::Version
|
113
|
-
version:
|
113
|
+
version: '0'
|
114
114
|
requirements: []
|
115
115
|
rubyforge_project:
|
116
116
|
rubygems_version: 1.8.24
|