r2do 0.0.6 → 0.0.7
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 +5 -4
- data/lib/r2do/handlers/handle_category.rb +7 -2
- data/lib/r2do/handlers/handle_task.rb +40 -5
- data/lib/r2do/task.rb +15 -1
- data/lib/r2do/ui.rb +8 -0
- data/lib/r2do/version.rb +1 -1
- data/lib/r2do.rb +5 -2
- data/r2do.gemspec +1 -1
- metadata +4 -5
- data/lib/r2do/handlers/handle_current.rb +0 -22
data/README.md
CHANGED
@@ -63,6 +63,10 @@ To view the information regarding a Task:
|
|
63
63
|
|
64
64
|
r2do task --display
|
65
65
|
|
66
|
+
To edit a Task:
|
67
|
+
|
68
|
+
r2do task --edit
|
69
|
+
|
66
70
|
To complete a Task:
|
67
71
|
|
68
72
|
r2do task --done
|
@@ -91,10 +95,7 @@ To see all the available commands:
|
|
91
95
|
|
92
96
|
There are many features presently missing from r2do, which will be implemented in future versions but there is one thing which must be noted here.
|
93
97
|
|
94
|
-
1) The ability to edit a Category
|
95
|
-
|
96
|
-
If you need to edit a Task you can delete the old one and re-create it.
|
97
|
-
The same goes for a Category, although this is more annoying as you will loose your Tasks when you delete a Category.
|
98
|
+
1) The ability to edit a Category is lacking at present.
|
98
99
|
|
99
100
|
2) The ability to move a Task from one Category to another is also missing.
|
100
101
|
|
@@ -76,7 +76,10 @@ module R2do
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
|
79
|
+
# Creates a new Category or selects an already existing one.
|
80
|
+
#
|
81
|
+
# @param [Array] args the argumets passed to the app by the user.
|
82
|
+
# @return [void]
|
80
83
|
def parse_category(args)
|
81
84
|
extra = ''
|
82
85
|
category_name = args[1]
|
@@ -94,7 +97,9 @@ module R2do
|
|
94
97
|
UI.status("Switched to #{extra}category '#{category_name}'")
|
95
98
|
end
|
96
99
|
|
97
|
-
|
100
|
+
# Ensures that a category is selected.
|
101
|
+
#
|
102
|
+
# @return [void]
|
98
103
|
def require_selected_category()
|
99
104
|
if not @state.current_category
|
100
105
|
raise CategoryNotSelectedError, "This action requires a selected category."
|
@@ -24,6 +24,7 @@ module R2do
|
|
24
24
|
COMPLETED = "--done"
|
25
25
|
DISPLAY = "--display"
|
26
26
|
DELETE = "--delete"
|
27
|
+
EDIT = "--edit"
|
27
28
|
|
28
29
|
# Creates a new task or makes a task current in the current category if a task with the
|
29
30
|
# same name already exists
|
@@ -45,6 +46,9 @@ module R2do
|
|
45
46
|
if option.eql?(DISPLAY)
|
46
47
|
require_selected_task()
|
47
48
|
show_current_task(args)
|
49
|
+
elsif option.eql?(EDIT)
|
50
|
+
require_selected_task()
|
51
|
+
edit_current_task(args)
|
48
52
|
elsif option.eql?(COMPLETED)
|
49
53
|
require_selected_task()
|
50
54
|
mark_as_complete(args)
|
@@ -52,13 +56,35 @@ module R2do
|
|
52
56
|
require_selected_task()
|
53
57
|
delete_task(args)
|
54
58
|
elsif option.start_with?("--")
|
55
|
-
raise InvalidOptionError
|
59
|
+
raise InvalidOptionError, "Invalid argument for the command. See 'r2do -h'."
|
56
60
|
else
|
57
61
|
parse_task(args)
|
58
62
|
end
|
59
63
|
end
|
60
64
|
|
65
|
+
# Edit the current task.
|
66
|
+
#
|
67
|
+
# @param [Array] args the arguments passed to the app by the user.
|
68
|
+
# @return [void]
|
69
|
+
def edit_current_task(args)
|
70
|
+
UI.status("Are you sure you want to edit the task:")
|
71
|
+
UI.status(" #{@state.current_category.current_task.description}")
|
72
|
+
UI.new_line()
|
73
|
+
value = UI.input("Continue? [Yn]")
|
74
|
+
if value == YES
|
75
|
+
desc = UI.input("Enter new description:")
|
76
|
+
task = @state.current_category.current_task
|
77
|
+
task.rename(desc)
|
78
|
+
@modified = true
|
79
|
+
|
80
|
+
UI.status("The task as been modified.")
|
81
|
+
end
|
82
|
+
end
|
61
83
|
|
84
|
+
# Delete the currently selected task.
|
85
|
+
#
|
86
|
+
# @param [Array] args the arguments passed to the app by the user.
|
87
|
+
# @return [void]
|
62
88
|
def delete_task(args)
|
63
89
|
UI.status("Are you sure you want to delete the task:")
|
64
90
|
UI.status(" #{@state.current_category.current_task.description}")
|
@@ -74,15 +100,18 @@ module R2do
|
|
74
100
|
end
|
75
101
|
end
|
76
102
|
|
77
|
-
|
103
|
+
# Displays the information of the currently selected task.
|
104
|
+
#
|
105
|
+
# @param [Array] args the arguments passed to the app by the user.
|
106
|
+
# @return [void]
|
78
107
|
def show_current_task(args)
|
79
108
|
task = @state.current_category.current_task
|
80
109
|
UI.status(task.display())
|
81
110
|
end
|
82
111
|
|
83
|
-
# Marks a task as completed
|
112
|
+
# Marks a task as completed.
|
84
113
|
#
|
85
|
-
# @param [Array] args the arguments passed to the app by the user
|
114
|
+
# @param [Array] args the arguments passed to the app by the user.
|
86
115
|
# @return [void]
|
87
116
|
def mark_as_complete(args)
|
88
117
|
task = @state.current_category.current_task
|
@@ -92,7 +121,10 @@ module R2do
|
|
92
121
|
UI.status("Task '%s' has been marked as completed." % task.description)
|
93
122
|
end
|
94
123
|
|
95
|
-
|
124
|
+
# Creates a new task or select an already existing one.
|
125
|
+
#
|
126
|
+
# @param [Array] args the arguments passed to the app by the user.
|
127
|
+
# @return [void]
|
96
128
|
def parse_task(args)
|
97
129
|
extra = ''
|
98
130
|
task_description = args[1]
|
@@ -111,6 +143,9 @@ module R2do
|
|
111
143
|
UI.status("Selected task '#{task_description}'")
|
112
144
|
end
|
113
145
|
|
146
|
+
# Checks that a task is currently selected.
|
147
|
+
#
|
148
|
+
# @return [void]
|
114
149
|
def require_selected_task()
|
115
150
|
if not @state.current_category.current_task
|
116
151
|
raise TaskNotSelectedError, "This action requires a selected task."
|
data/lib/r2do/task.rb
CHANGED
@@ -34,6 +34,14 @@ module R2do
|
|
34
34
|
@date_done = nil
|
35
35
|
end
|
36
36
|
|
37
|
+
# Renames this Task
|
38
|
+
#
|
39
|
+
# @param [String] description the new value for the task
|
40
|
+
# @return [void]
|
41
|
+
def rename(description)
|
42
|
+
@description = description
|
43
|
+
end
|
44
|
+
|
37
45
|
# Gets the completed status of the specific task.
|
38
46
|
#
|
39
47
|
# @return [bool] true if the task is completed.
|
@@ -64,6 +72,9 @@ module R2do
|
|
64
72
|
return "[%s] %-30s %s" % [completed, @description, date]
|
65
73
|
end
|
66
74
|
|
75
|
+
# Returns information regarding the state of this task.
|
76
|
+
#
|
77
|
+
# @return [String] the metadata for this task.
|
67
78
|
def display()
|
68
79
|
date = format_date(@date_created)
|
69
80
|
|
@@ -82,7 +93,10 @@ module R2do
|
|
82
93
|
return result.string
|
83
94
|
end
|
84
95
|
|
85
|
-
|
96
|
+
# Formats the date
|
97
|
+
#
|
98
|
+
# @param [DateTime] date the date to parse
|
99
|
+
# @return [String] the formatted date
|
86
100
|
def format_date(date)
|
87
101
|
date.strftime('%a %b %e, %Y')
|
88
102
|
end
|
data/lib/r2do/ui.rb
CHANGED
@@ -26,6 +26,14 @@ module R2do
|
|
26
26
|
puts message
|
27
27
|
end
|
28
28
|
|
29
|
+
# Displays a status message to the user
|
30
|
+
#
|
31
|
+
# @param [String] message the message to display to the user
|
32
|
+
# @return [void]
|
33
|
+
def self.rescue(exception)
|
34
|
+
puts "abort: #{exception.message}"
|
35
|
+
end
|
36
|
+
|
29
37
|
# Adds a new empty line on the display
|
30
38
|
#
|
31
39
|
# @return [void]
|
data/lib/r2do/version.rb
CHANGED
data/lib/r2do.rb
CHANGED
@@ -27,7 +27,6 @@ require 'r2do/handlers/handle_category'
|
|
27
27
|
require 'r2do/handlers/handle_task'
|
28
28
|
require 'r2do/handlers/handle_init'
|
29
29
|
require 'r2do/handlers/handle_categories'
|
30
|
-
require 'r2do/handlers/handle_current'
|
31
30
|
require 'r2do/utility'
|
32
31
|
|
33
32
|
|
@@ -58,7 +57,11 @@ module R2do
|
|
58
57
|
if @args.length > 0
|
59
58
|
cmd = find_command(option)
|
60
59
|
if not cmd.nil?
|
61
|
-
|
60
|
+
begin
|
61
|
+
cmd.execute(@args)
|
62
|
+
rescue Exception => e
|
63
|
+
UI.rescue(e)
|
64
|
+
end
|
62
65
|
else
|
63
66
|
invalid_command(option)
|
64
67
|
end
|
data/r2do.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.email = ["christiangiacomi@gmail.com"]
|
7
7
|
gem.description = %q{A simple todo gem}
|
8
8
|
gem.summary = %q{A simple todo gem}
|
9
|
-
gem.homepage = ""
|
9
|
+
gem.homepage = "https://github.com/cgiacomi/r2do"
|
10
10
|
|
11
11
|
gem.add_development_dependency "rspec"
|
12
12
|
gem.add_development_dependency "rake"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: r2do
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -112,7 +112,6 @@ files:
|
|
112
112
|
- lib/r2do/exceptions.rb
|
113
113
|
- lib/r2do/handlers/handle_categories.rb
|
114
114
|
- lib/r2do/handlers/handle_category.rb
|
115
|
-
- lib/r2do/handlers/handle_current.rb
|
116
115
|
- lib/r2do/handlers/handle_init.rb
|
117
116
|
- lib/r2do/handlers/handle_task.rb
|
118
117
|
- lib/r2do/state.rb
|
@@ -127,7 +126,7 @@ files:
|
|
127
126
|
- spec/r2do/r2do_spec.rb
|
128
127
|
- spec/r2do/task_spec.rb
|
129
128
|
- spec/spec_helper.rb
|
130
|
-
homepage:
|
129
|
+
homepage: https://github.com/cgiacomi/r2do
|
131
130
|
licenses: []
|
132
131
|
post_install_message:
|
133
132
|
rdoc_options: []
|
@@ -141,7 +140,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
141
140
|
version: '0'
|
142
141
|
segments:
|
143
142
|
- 0
|
144
|
-
hash: -
|
143
|
+
hash: -972365083019823289
|
145
144
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
145
|
none: false
|
147
146
|
requirements:
|
@@ -150,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
149
|
version: '0'
|
151
150
|
segments:
|
152
151
|
- 0
|
153
|
-
hash: -
|
152
|
+
hash: -972365083019823289
|
154
153
|
requirements: []
|
155
154
|
rubyforge_project:
|
156
155
|
rubygems_version: 1.8.24
|
@@ -1,22 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright 2012 Christian Giacomi http://www.christiangiacomi.com
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
#
|
16
|
-
|
17
|
-
module R2do
|
18
|
-
module Handlers
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|