my_todo 3.1.1 → 4.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +63 -50
- data/Rakefile +3 -0
- data/bin/{my_todo → mytodo} +1 -1
- data/{lib/db → db}/config.yml +3 -3
- data/{lib/db → db}/migrate/20160912172429_create_items.rb +2 -2
- data/{lib/db → db}/migrate/20160913134552_create_tags.rb +1 -1
- data/{lib/db → db}/migrate/20160913134610_create_stubs.rb +1 -1
- data/{lib/db → db}/migrate/20161003121448_create_notes.rb +1 -1
- data/{lib/db → db}/migrate/20161005133023_add_detailed_status_to_items.rb +1 -1
- data/db/migrate/20161220143613_add_default_to_item_done.rb +5 -0
- data/{lib/db → db}/schema.rb +6 -14
- data/lib/my_todo.rb +4 -114
- data/lib/my_todo/ar_base.rb +3 -2
- data/lib/my_todo/models/item.rb +4 -0
- data/lib/my_todo/modules/actions.rb +129 -0
- data/lib/my_todo/modules/finders.rb +5 -3
- data/lib/my_todo/modules/my_todo_actions.rb +7 -6
- data/lib/my_todo/modules/templates.rb +1 -0
- data/lib/my_todo/templates/item.erb +6 -2
- data/lib/my_todo/templates/list.erb +3 -1
- data/lib/my_todo/templates/notes.erb +8 -5
- data/lib/my_todo/templates/results.erb +7 -1
- data/lib/my_todo/templates/standalone_migrations.yml.erb +4 -4
- data/lib/my_todo/version.rb +1 -1
- data/lib/setup.rb +2 -2
- data/my_todo.gemspec +19 -17
- data/spec/actions/create_spec.rb +17 -15
- data/spec/actions/delete_spec.rb +10 -4
- data/spec/actions/list_spec.rb +6 -5
- data/spec/actions/note_spec.rb +9 -7
- data/spec/actions/notes_spec.rb +6 -7
- data/spec/actions/rm_note_spec.rb +7 -8
- data/spec/actions/rm_tag_spec.rb +9 -8
- data/spec/actions/search_spec.rb +12 -13
- data/spec/actions/tag_spec.rb +12 -10
- data/spec/actions/update_spec.rb +5 -6
- data/{lib → spec}/db/todos_test.sqlite3 +0 -0
- data/spec/models/item_spec.rb +1 -1
- data/spec/models/stub_spec.rb +6 -6
- data/spec/spec_helper.rb +19 -5
- metadata +89 -76
- data/.standalone_migrations +0 -6
- data/lib/db/migrate/20161220143613_add_default_to_item_done.rb +0 -5
- data/lib/db/todos_development.sqlite3 +0 -0
- data/lib/my_todo/db/todos_test.sqlite3 +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1ef19ecc95c4315bd6662a9b3b6d6bfd5a684884e5c38492d541990a5860bd41
|
4
|
+
data.tar.gz: b4c7e53d57aec082ef092afebfc2f996de94eabf6953699bd36fa2f314997ca3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73ab785f105b1c338671df021039297f8eec3ccc26e7f215fdf91af12b89fd271027b692bf383ebc1f18e9eb0f92c474659592dba5d6a3e460cab1ea79ff8fdf
|
7
|
+
data.tar.gz: c398d1add1165b0b2152d40c7f2aa24ad9159dd5406ab2559ef0c0617583d46d9cc67b62313a35834147f7729904bac45c04c386a2baa22e8fd0faf9e5e972a5
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# My
|
1
|
+
# My ToDo
|
2
2
|
[![Code Climate](https://codeclimate.com/github/vmcilwain/my_todo/badges/gpa.svg)](https://codeclimate.com/github/vmcilwain/my_todo)
|
3
3
|
|
4
4
|
[![Test Coverage](https://codeclimate.com/github/vmcilwain/my_todo/badges/coverage.svg)](https://codeclimate.com/github/vmcilwain/my_todo/coverage)
|
@@ -6,100 +6,116 @@
|
|
6
6
|
[![Issue Count](https://codeclimate.com/github/vmcilwain/my_todo/badges/issue_count.svg)](https://codeclimate.com/github/vmcilwain/my_todo)
|
7
7
|
|
8
8
|
## Summary
|
9
|
-
|
9
|
+
A CLI todo list / task manager written in Ruby.
|
10
|
+
|
11
|
+
### Explanation
|
12
|
+
|
13
|
+
Often times while coding either at home or at work, I found myself needing to create quick reminders as things came up. While this happens to everyone, I was getting annoyed with having to switch out of the console to go into another application to add it. I didn't need a GUI to manage my lists if I did things right so that set me down the path to building this CLI application. This application will more than likely always be a work in progress but I hope you find it useful should you want to try it.
|
14
|
+
|
15
|
+
## Disclaimer
|
16
|
+
|
17
|
+
This code is provided "as is" and any express or implied warranties, including the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall I or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) sustained by you or a third party, however caused and on any theory of liability, whether in contract, strict liability, or tort arising in any way out of the use of this code, even if advised of the possibility of such damage.
|
10
18
|
|
11
19
|
## Features
|
12
|
-
* SQLIte3 backend (database is located in $HOME/.my_todo)
|
13
|
-
* CRUD actions for todo items (Create, Read, Update & Delete)
|
14
|
-
* Tag / Untag todo items to group / ungroup them.
|
15
|
-
* Search for todo items
|
16
|
-
* Add / Remove additional notes to todo items
|
17
20
|
|
18
|
-
|
21
|
+
* Tagging
|
22
|
+
* Search
|
23
|
+
* Notes
|
24
|
+
|
25
|
+
## Requirements
|
19
26
|
|
20
|
-
|
27
|
+
Ruby 2.2 and above
|
28
|
+
|
29
|
+
## Installation
|
21
30
|
|
22
31
|
```ruby
|
23
32
|
gem install my_todo
|
24
33
|
```
|
25
34
|
|
26
|
-
##
|
27
|
-
Create and migrate the
|
28
|
-
|
29
|
-
`my_todo rake db:migrate`
|
35
|
+
## Setup
|
36
|
+
Create and migrate the database. This should always be done after every version update to ensure proper paths are set at a minium.
|
30
37
|
|
38
|
+
```ruby
|
39
|
+
mytodo rake db:migrate
|
40
|
+
```
|
31
41
|
## Usage
|
32
|
-
Simply type `my_todo` to see a list of commands
|
33
42
|
|
34
|
-
|
43
|
+
Type `mytodo` to see the help text
|
44
|
+
|
45
|
+
### Examples
|
46
|
+
|
47
|
+
#### Creating a todo item
|
35
48
|
|
36
49
|
```ruby
|
37
|
-
|
50
|
+
mytodo create 'hello world'
|
38
51
|
```
|
39
52
|
|
40
|
-
will
|
53
|
+
will then ask if you want to give it an initial status
|
54
|
+
|
55
|
+
```
|
56
|
+
0: None
|
57
|
+
1: In Progress
|
58
|
+
2: Waiting Feedback
|
59
|
+
3: Complete
|
60
|
+
4: Punted
|
41
61
|
|
62
|
+
Choose a status for item (1)
|
42
63
|
```
|
43
|
-
ToDo CREATED!
|
44
64
|
|
65
|
+
`In Progress` is the default (just hit enter to keep going). Setting it to None will leave it blank.
|
45
66
|
|
46
|
-
|
67
|
+
Once selected and `Enter`/`Return` is pressed, something like the following should display:
|
68
|
+
|
69
|
+
```
|
70
|
+
Item Created
|
71
|
+
|
72
|
+
id: 1 notes: 0 tags: Default
|
73
|
+
created: 2018-10-11 status: In Progress (done: No)
|
47
74
|
|
48
75
|
hello world
|
49
|
-
****************************************************************************************************
|
50
76
|
```
|
51
77
|
|
52
|
-
|
78
|
+
#### List pending todo items
|
53
79
|
|
54
80
|
```ruby
|
55
|
-
|
81
|
+
mytodo list
|
56
82
|
```
|
57
83
|
|
58
|
-
will display
|
84
|
+
will display something like
|
59
85
|
|
60
86
|
```
|
61
|
-
|
87
|
+
Items Found: 2
|
62
88
|
|
63
|
-
|
89
|
+
id: 1 notes: 0 tags: Default
|
90
|
+
created: 2018-10-11 status: In Progress (done: No)
|
64
91
|
|
65
92
|
hello world
|
66
93
|
****************************************************************************************************
|
94
|
+
id: 2 notes: 0 tags: Default
|
95
|
+
created: 2018-10-11 status: In Progress (done: No)
|
67
96
|
|
68
|
-
|
69
|
-
|
70
|
-
hello world 2
|
97
|
+
goodbye world
|
71
98
|
****************************************************************************************************
|
72
99
|
```
|
73
100
|
|
74
|
-
|
75
|
-
```
|
76
|
-
#aliases
|
77
|
-
alias m='my_todo'
|
78
|
-
alias mlist='my_todo list'
|
79
|
-
alias mcreate='my_todo create'
|
80
|
-
alias mupdate='my_todo update'
|
81
|
-
alias mdelete='my_todo delete'
|
82
|
-
alias mtag='my_todo tag'
|
83
|
-
alias mrmtag='my_todo rm_tag'
|
84
|
-
alias mnotes='my_todo notes'
|
85
|
-
alias mrmnote='my_todo rm_note'
|
86
|
-
alias msearch='my_todo search'
|
87
|
-
alias mnote='my_todo note'
|
88
|
-
```
|
101
|
+
## Removing the gem and data
|
89
102
|
|
90
|
-
|
103
|
+
Uninstall the gem: `gem uninstall my_todo`
|
104
|
+
|
105
|
+
Delete `$HOME/.my_todo` to remove the data
|
91
106
|
|
92
107
|
## Development
|
93
108
|
|
94
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then `RAILS_ENV=development bin/
|
109
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then `RAILS_ENV=development bin/mytodo rake db:migrate` to create the development DB (in the db directory). You can also run `RAILS_ENV=development bin/console` for an interactive prompt that will allow you to experiment.
|
95
110
|
|
96
|
-
|
111
|
+
##### Note: In development, all commands must be run with the RAILS_ENV included. This is to make sure any data written made go to the right db. Any commands ran without the RAILS_ENV specified will default to production. Example: `RAILS_ENV=development bin/mytodo list`
|
97
112
|
|
98
113
|
## Testing
|
99
114
|
|
100
|
-
Run `RAILS_ENV=test bin/
|
115
|
+
Run `RAILS_ENV=test bin/mytodo rake db:migrate` to create the test db (in spec/db). Then run `bundle exec rake` to run the RSpec tests.
|
101
116
|
|
102
117
|
## Releasing
|
118
|
+
|
103
119
|
To release a new version,
|
104
120
|
* update the version number in `version.rb`
|
105
121
|
* tag the the code `git tag v1.0.0`
|
@@ -107,9 +123,6 @@ To release a new version,
|
|
107
123
|
* then run `bundle exec rake build`
|
108
124
|
* `gem push pkg/my_todo-verion`
|
109
125
|
|
110
|
-
## Removing the gem
|
111
|
-
To remove the gem simply type `gem uninstall my_todo`. Along with this, you will need to remove `$HOME/.my_todo` to remove the database.
|
112
|
-
|
113
126
|
## Contributing
|
114
127
|
|
115
128
|
Bug reports and pull requests are welcome on GitHub at https://github.com/vmcilwain/my_todo. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
data/Rakefile
CHANGED
data/bin/{my_todo → mytodo}
RENAMED
@@ -34,7 +34,7 @@ if exec_type == 'rake'
|
|
34
34
|
# Generate standalone migration file configs for sqlite3
|
35
35
|
if ENV['RAILS_ENV'] == 'production'
|
36
36
|
Setup.start(%w[db_config])
|
37
|
-
Setup.start(%w[standard_migrations_override])
|
37
|
+
# Setup.start(%w[standard_migrations_override])
|
38
38
|
end
|
39
39
|
# Get current working directory
|
40
40
|
pwd=Dir.pwd
|
data/{lib/db → db}/config.yml
RENAMED
@@ -1,18 +1,18 @@
|
|
1
1
|
# To Run: rake db:migrate
|
2
2
|
development:
|
3
3
|
adapter: sqlite3
|
4
|
-
database:
|
4
|
+
database: db/todos_development.sqlite3
|
5
5
|
pool: 5
|
6
6
|
encoding: utf8
|
7
7
|
# To Run: RAILS_ENV=test rake db:migrate
|
8
8
|
test:
|
9
9
|
adapter: sqlite3
|
10
|
-
database:
|
10
|
+
database: spec/db/todos_test.sqlite3
|
11
11
|
pool: 5
|
12
12
|
encoding: utf8
|
13
13
|
# To Run: RAILS_ENV=production rake db:migrate
|
14
14
|
production:
|
15
15
|
adapter: sqlite3
|
16
|
-
database:
|
16
|
+
database: db/todos_production.sqlite3
|
17
17
|
pool: 5
|
18
18
|
encoding: utf8
|
data/{lib/db → db}/schema.rb
RENAMED
@@ -10,27 +10,19 @@
|
|
10
10
|
#
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
12
12
|
|
13
|
-
ActiveRecord::Schema.define(version:
|
13
|
+
ActiveRecord::Schema.define(version: 2016_12_20_143613) do
|
14
14
|
|
15
15
|
create_table "items", force: :cascade do |t|
|
16
|
-
t.string
|
17
|
-
t.boolean
|
18
|
-
t.datetime "created_at", null: false
|
19
|
-
t.datetime "updated_at", null: false
|
20
|
-
t.string "status"
|
21
|
-
t.string "detailed_status"
|
22
|
-
end
|
23
|
-
|
24
|
-
create_table "lists", force: :cascade do |t|
|
25
|
-
t.string "name"
|
26
|
-
t.string "value"
|
16
|
+
t.string "body"
|
17
|
+
t.boolean "done", default: false
|
27
18
|
t.datetime "created_at", null: false
|
28
19
|
t.datetime "updated_at", null: false
|
20
|
+
t.string "detailed_status"
|
29
21
|
end
|
30
22
|
|
31
23
|
create_table "notes", force: :cascade do |t|
|
32
|
-
t.integer
|
33
|
-
t.text
|
24
|
+
t.integer "item_id"
|
25
|
+
t.text "body"
|
34
26
|
t.datetime "created_at", null: false
|
35
27
|
t.datetime "updated_at", null: false
|
36
28
|
t.index ["item_id"], name: "index_notes_on_item_id"
|
data/lib/my_todo.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# @author Lovell McIlwain
|
2
2
|
# Handles running the todo application
|
3
|
-
require "#{__dir__}/my_todo/version"
|
4
3
|
require 'thor'
|
5
4
|
require 'erb'
|
6
5
|
require 'sqlite3'
|
@@ -8,6 +7,7 @@ require 'active_record'
|
|
8
7
|
require 'active_model'
|
9
8
|
require 'yaml'
|
10
9
|
require 'ransack'
|
10
|
+
# require_relative "../lib/my_todo/version"
|
11
11
|
require_relative 'my_todo/ar_base'
|
12
12
|
require_relative 'my_todo/models/item'
|
13
13
|
require_relative 'my_todo/models/stub'
|
@@ -16,129 +16,19 @@ require_relative 'my_todo/models/note'
|
|
16
16
|
require_relative 'my_todo/modules/templates'
|
17
17
|
require_relative 'my_todo/modules/finders'
|
18
18
|
require_relative 'my_todo/modules/my_todo_actions'
|
19
|
+
require_relative 'my_todo/modules/actions'
|
20
|
+
|
19
21
|
module MyTodo
|
20
|
-
# Todo tasks using thor gem
|
21
22
|
class Todo < Thor
|
22
|
-
# Add additional thor tasks
|
23
23
|
include Thor::Actions
|
24
24
|
|
25
|
-
# Private methods
|
26
25
|
no_commands do
|
27
26
|
include Templates
|
28
27
|
include Finders
|
29
28
|
include MyTodoActions
|
30
29
|
end
|
31
30
|
|
32
|
-
|
33
|
-
option :status, default: nil
|
34
|
-
def list
|
35
|
-
say "ToDos FOUND: #{all_items.count}"
|
36
|
-
print_list
|
37
|
-
end
|
38
|
-
|
39
|
-
desc "create --body='some text' [--done=true] [--tags='tag1 tag2']", 'Create a todo'
|
40
|
-
option :body
|
41
|
-
option :tags, default: 'default'
|
42
|
-
def create
|
43
|
-
begin
|
44
|
-
say 'ToDo CREATED!'
|
45
|
-
create_item(options)
|
46
|
-
print_item
|
47
|
-
rescue ActiveRecord::RecordInvalid => e
|
48
|
-
say e.message
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
desc "update --id=TODO_ID --body='some text' [--done=true]", 'Change an existing todo'
|
53
|
-
option :id
|
54
|
-
option :body
|
55
|
-
def update
|
56
|
-
begin
|
57
|
-
update_item(options)
|
58
|
-
say 'ToDo UPDATED!'
|
59
|
-
print_item
|
60
|
-
rescue ActiveRecord::RecordInvalid => e
|
61
|
-
say e.message
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
desc 'delete', 'Destroy a todo'
|
66
|
-
option :id, required: true
|
67
|
-
def delete
|
68
|
-
begin
|
69
|
-
item.destroy!
|
70
|
-
say 'ToDo DESTROYED!'
|
71
|
-
rescue StandardError => e
|
72
|
-
say e.message
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
desc 'search', 'Find a todo by item body, tag name or note body'
|
77
|
-
option :text, required: true
|
78
|
-
def search
|
79
|
-
@items = Item.ransack(body_or_detailed_status_or_tags_name_or_notes_body_cont: options[:text]).result
|
80
|
-
say "ToDos FOUND: #{@items.count}"
|
81
|
-
say "Search based on ransack search: body_or_detailed_status_or_tags_name_or_notes_body_cont"
|
82
|
-
print_search_results
|
83
|
-
end
|
84
|
-
|
85
|
-
desc "tag --id=TODO_ID --tag=TAG_NAME", 'Add a tag to an existing todo'
|
86
|
-
option :id
|
87
|
-
option :tag
|
88
|
-
def tag
|
89
|
-
begin
|
90
|
-
item.tags.create!(name: options[:tag])
|
91
|
-
print_list item.reload
|
92
|
-
rescue StandardError => e
|
93
|
-
say e.message
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
desc 'rm_tag --id=TODO_ID --tag=TAG_NAME', 'Remove tag from an existing todo'
|
98
|
-
option :id
|
99
|
-
option :tag
|
100
|
-
def rm_tag
|
101
|
-
begin
|
102
|
-
item.tags.where(name: options[:tag]).first.destroy!
|
103
|
-
print_list item.reload
|
104
|
-
rescue StandardError => e
|
105
|
-
say e.message
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
desc "note --id=TODO_ID --body='text'", 'Adds note to existing item'
|
110
|
-
option :id
|
111
|
-
option :body
|
112
|
-
def note
|
113
|
-
begin
|
114
|
-
item.notes.create(body: options[:body])
|
115
|
-
print_notes
|
116
|
-
rescue StandardError => e
|
117
|
-
say e.message
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
desc 'rm_note --id=TODO_ID --noteid=NOTE_ID', 'Remove note for exsiting item'
|
122
|
-
option :id
|
123
|
-
option :noteid
|
124
|
-
def rm_note
|
125
|
-
begin
|
126
|
-
item.notes.where(id: options[:noteid]).first.destroy!
|
127
|
-
print_list item.reload
|
128
|
-
rescue StandardError => e
|
129
|
-
say e.message
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
desc 'notes --id=TODO_ID', 'Display notes for a given todo'
|
134
|
-
option :id
|
135
|
-
def notes
|
136
|
-
begin
|
137
|
-
print_notes
|
138
|
-
rescue StandardError => e
|
139
|
-
say e.message
|
140
|
-
end
|
141
|
-
end
|
31
|
+
include MyTodo::Actions
|
142
32
|
end
|
143
33
|
end
|
144
34
|
|