my_todo 2.7.1 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e34470c767f09895747115f0d3b3fe188711a7b
4
- data.tar.gz: 88717583dab1f1967d68586652b825f844974090
3
+ metadata.gz: 18cbf31412cafa361da1286224e29d1582e20bab
4
+ data.tar.gz: 5851503d07bc55819b9cf6e8aa7f32d4cec3dcd8
5
5
  SHA512:
6
- metadata.gz: 44541d49b304415df3d76122d684fbb0ecefb64beca23535aa17983de2f20eab057e2e4c8c71cebc6b7ce0c4d520a03e2a525b7919864ffb13579630dddff689
7
- data.tar.gz: ce9a182b76a060e39fa323f35f3b47c38fc2dcb9c1a7a4f8d8c15f14ab58125de2b30c0b495cdcea176a7d58de6280d75f1b21232567dd112568691e461072df
6
+ metadata.gz: 44a29568efb99789a382022f4d48c3c7900a9a8a4b9bab49aeb3750ba7bd9b342ebbeb8d15a9caaa6214d968a8c17471063f662b89648dcd0eb6686483a0f0b4
7
+ data.tar.gz: d2dd52251018244a1a8420fc3cade88e778ff741b27e14458d46b42f326023d85119db30f597528c77a78ba9f4c0e84c638eba7b8fad033c65761f1743dfd8d0
data/README.md CHANGED
@@ -1,4 +1,9 @@
1
1
  # My Todo
2
+ [![Code Climate](https://codeclimate.com/github/vmcilwain/my_todo/badges/gpa.svg)](https://codeclimate.com/github/vmcilwain/my_todo)
3
+
4
+ [![Test Coverage](https://codeclimate.com/github/vmcilwain/my_todo/badges/coverage.svg)](https://codeclimate.com/github/vmcilwain/my_todo/coverage)
5
+
6
+ [![Issue Count](https://codeclimate.com/github/vmcilwain/my_todo/badges/issue_count.svg)](https://codeclimate.com/github/vmcilwain/my_todo)
2
7
 
3
8
  ## Summary
4
9
  This is yet another simple todo application. This was built because I found myself having to create quick reminders when things came up but needing to switch windows from the terminal to the todo application via the GUI. This application is the result of that one annoyance :). It is still a work in progress but I hope you find it useful.
@@ -0,0 +1,5 @@
1
+ class AddDetailedStatusToItems < ActiveRecord::Migration[5.0]
2
+ def change
3
+ add_column :items, :detailed_status, :string
4
+ end
5
+ end
data/lib/db/schema.rb CHANGED
@@ -10,13 +10,14 @@
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: 20161003121448) do
13
+ ActiveRecord::Schema.define(version: 20161005133023) do
14
14
 
15
15
  create_table "items", force: :cascade do |t|
16
16
  t.string "body"
17
17
  t.boolean "done"
18
- t.datetime "created_at", null: false
19
- t.datetime "updated_at", null: false
18
+ t.datetime "created_at", null: false
19
+ t.datetime "updated_at", null: false
20
+ t.string "detailed_status"
20
21
  end
21
22
 
22
23
  create_table "notes", force: :cascade do |t|
Binary file
Binary file
@@ -1,6 +1,7 @@
1
1
  # @author Lovell McIlwain#
2
2
  # Handles business logic for todo item
3
3
  class Item < ActiveRecord::Base
4
+ DETAILED_STATUSES = ['None', 'In Progress', 'Complete', 'Punted', 'Waiting Feedback']
4
5
  # ActiveRecord association to stubs
5
6
  # @note Item.first.stubs
6
7
  has_many :stubs
@@ -1,9 +1,10 @@
1
1
 
2
- ID: <%= item.id %> | Tags: <%= item.tags.map(&:name).join(', ') %> | Complete: <%= item.done %>
2
+ ID: <%= item.id %> | Created On: <%= item.created_at.strftime("%Y-%m-%d") %> | Tags: <%= item.tags.map(&:name).join(', ') %> | Status: <%= item.detailed_status %> | Complete: <%= item.done %>
3
3
  <%= item.body %>
4
4
  <% if item.notes.any? -%>
5
5
  Notes:
6
6
  <% item.notes.each do |note| -%>
7
- <%= note.id %>: <%= note.body %>
7
+ ID: <%= note.id %> | Created On: <%= note.created_at.strftime("%Y-%m-%d")%>
8
+ <%= note.body %>
8
9
  <% end %>
9
10
  <% end %>
@@ -1,3 +1,3 @@
1
1
  module MyTodo
2
- VERSION = "2.7.1"
2
+ VERSION = "2.8.0"
3
3
  end
data/lib/my_todo.rb CHANGED
@@ -29,19 +29,47 @@ module MyTodo
29
29
  def item
30
30
  @item ||= Item.where(id: options[:id]).first
31
31
  end
32
+
33
+ def detailed_statuses
34
+ @detailed_statuses ||= Item::DETAILED_STATUSES
35
+ end
36
+
37
+ def list_statuses
38
+ detailed_statuses.each_with_index {|status, index| say "#{index}: #{status}"}
39
+ end
40
+
41
+ def ask_status
42
+ list_statuses
43
+ @status = ask("Choose a status for item", default: 1)
44
+ end
45
+
46
+ def all_items(status)
47
+ case status
48
+ when 'all'
49
+ Item.all
50
+ when 'done'
51
+ Item.where(done: true)
52
+ else
53
+ Item.where(done: false)
54
+ end
55
+ end
56
+
57
+ def create_item(options)
58
+ ask_status
59
+ @item = Item.create!(options.merge({detailed_status: detailed_statuses[@status.to_i]}).except(:tags))
60
+ options[:tags].split(' ').each{|tag| item.tags.create(name: tag) }
61
+ end
62
+
63
+ def update_item(options)
64
+ ask_status
65
+ new_status = detailed_statuses[@status.to_i]
66
+ item.detailed_status != new_status ? item.update!(options.merge({detailed_status: new_status})) : item.update!(options)
67
+ end
32
68
  end
33
69
 
34
70
  desc 'list([STATUS])', 'list todos. Default: undone, [all], [done], [undone]'
35
71
  def list(status=nil)
36
- items = case status
37
- when 'all'
38
- Item.all
39
- when 'done'
40
- Item.where(done: true)
41
- else
42
- Item.where(done: false)
43
- end
44
-
72
+ items = all_items(status)
45
73
  say "ToDos FOUND: #{items.count}"
46
74
  items.each {|item| output(item)}
47
75
  end
@@ -53,10 +81,9 @@ module MyTodo
53
81
  option :created_at, default: DateTime.now
54
82
  def create
55
83
  begin
56
- item = Item.create!(options.except(:tags))
57
- options[:tags].split(' ').each{|tag| item.tags.create(name: tag) }
58
84
  say 'ToDo CREATED!'
59
- output item
85
+ create_item(options)
86
+ output @item
60
87
  rescue ActiveRecord::RecordInvalid => e
61
88
  say e.message
62
89
  end
@@ -69,7 +96,7 @@ module MyTodo
69
96
  option :updated_at, default: DateTime.now
70
97
  def update
71
98
  begin
72
- item.update!(options)
99
+ update_item(options)
73
100
  say 'ToDo UPDATED!'
74
101
  output item
75
102
  rescue ActiveRecord::RecordInvalid => e
@@ -84,15 +111,16 @@ module MyTodo
84
111
  output item
85
112
  item.destroy!
86
113
  say 'ToDo DESTROYED!'
87
- rescue Exception => e
114
+ rescue StandardError => e
88
115
  say e.message
89
116
  end
90
117
  end
91
118
 
92
119
  desc 'search(TEXT)', 'search for todo by item body, tag name or note body'
93
120
  def search(text)
94
- items = Item.ransack(body_or_tags_name_or_notes_body_cont: text).result
121
+ items = Item.ransack(body_or_detailed_status_or_tags_name_or_notes_body_cont: text).result
95
122
  say "ToDos FOUND: #{items.count}"
123
+ say "Search based on ransack search: body_or_detailed_status_or_tags_name_or_notes_body_cont"
96
124
  items.each {|item| output item}
97
125
  end
98
126
 
@@ -102,7 +130,8 @@ module MyTodo
102
130
  def tag
103
131
  begin
104
132
  item.tags.create!(name: options[:tag])
105
- rescue Exception => e
133
+ output item.reload
134
+ rescue StandardError => e
106
135
  say e.message
107
136
  end
108
137
  end
@@ -114,7 +143,7 @@ module MyTodo
114
143
  begin
115
144
  item.tags.where(name: options[:tag]).first.destroy!
116
145
  output item.reload
117
- rescue Exception => e
146
+ rescue StandardError => e
118
147
  say e.message
119
148
  end
120
149
  end
@@ -126,7 +155,7 @@ module MyTodo
126
155
  begin
127
156
  item.notes.create(body: options[:body])
128
157
  output item.reload
129
- rescue Exception => e
158
+ rescue StandardError => e
130
159
  say e.message
131
160
  end
132
161
  end
@@ -138,7 +167,7 @@ module MyTodo
138
167
  begin
139
168
  item.notes.where(id: options[:noteid]).first.destroy!
140
169
  output item.reload
141
- rescue Exception => e
170
+ rescue StandardError => e
142
171
  say e.message
143
172
  end
144
173
  end
data/lib/setup.rb CHANGED
@@ -12,7 +12,7 @@ class Setup < Thor
12
12
 
13
13
  desc 'db_config', 'Generate data file structure and configuration files'
14
14
  def db_config
15
- unless File.exists?("#{HOME_DIR}/.my_todo/data")
15
+ unless File.exist?("#{HOME_DIR}/.my_todo/data")
16
16
  `mkdir -p #{HOME_DIR}/.my_todo/data`
17
17
  say "Created .my_todo in #{HOME_DIR}"
18
18
  end
data/my_todo.gemspec CHANGED
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency 'byebug', '~> 9.0.5'
30
30
  spec.add_development_dependency 'yard', '~> 0.9.5'
31
31
  spec.add_development_dependency 'simplecov', '~> 0.12.0'
32
+ spec.add_development_dependency 'codeclimate-test-reporter'
32
33
  spec.add_dependency 'activerecord', '~> 5.0.0.1'
33
34
  spec.add_dependency 'activesupport', '~> 5.0.0.1'
34
35
  spec.add_dependency 'thor', '~> 0.19.1'
@@ -1,9 +1,21 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe MyTodo do
4
+ def shell
5
+ @shell ||= Thor::Shell::Basic.new
6
+ end
7
+
4
8
  describe 'create' do
9
+ before do
10
+ expect(Thor::LineEditor).to receive(:readline).with("Choose a status for item (1) ", {:default=>1}).and_return("")
11
+ end
12
+
5
13
  context 'successful creation' do
6
14
  describe 'creation without tags or setting done attribute' do
15
+ it 'prompts for a detailed status' do
16
+ expect(shell.ask("Choose a status for item", {:default=>1})).to eq(1)
17
+ end
18
+
7
19
  it 'creates a todo item' do
8
20
  expect{MyTodo::Todo.start(%w(create --body=wierdness_of_text))}.to change{Item.count}.by(1)
9
21
  end
@@ -21,7 +33,7 @@ describe MyTodo do
21
33
  end
22
34
 
23
35
  it 'displays the created todo item' do
24
- expect{MyTodo::Todo.start(%w(create --body=wierdness_of_text))}.to output("ToDo CREATED!\n\nID: 1 | Tags: default | Complete: false\nwierdness_of_text\n\n").to_stdout
36
+ expect{MyTodo::Todo.start(%w(create --body=wierdness_of_text))}.to output("ToDo CREATED!\n0: None\n1: In Progress\n2: Complete\n3: Punted\n4: Waiting Feedback\n\nID: 1 | Created On: 2016-10-08 | Tags: default | Status: In Progress | Complete: false\nwierdness_of_text\n\n").to_stdout
25
37
  end
26
38
  end
27
39
 
@@ -31,7 +43,7 @@ describe MyTodo do
31
43
  end
32
44
 
33
45
  it 'displays the created todo item with tag' do
34
- expect{MyTodo::Todo.start(%w(create --body=wierdness_of_text --tags=tag1))}.to output("ToDo CREATED!\n\nID: 1 | Tags: tag1 | Complete: false\nwierdness_of_text\n\n").to_stdout
46
+ expect{MyTodo::Todo.start(%w(create --body=wierdness_of_text --tags=tag1))}.to output("ToDo CREATED!\n0: None\n1: In Progress\n2: Complete\n3: Punted\n4: Waiting Feedback\n\nID: 1 | Created On: 2016-10-08 | Tags: tag1 | Status: In Progress | Complete: false\nwierdness_of_text\n\n").to_stdout
35
47
  end
36
48
  end
37
49
 
@@ -44,14 +56,14 @@ describe MyTodo do
44
56
  end
45
57
 
46
58
  it 'displays the created to item with complete set to true' do
47
- expect{MyTodo::Todo.start(%w[create --body=wierdness_of_text --done=true])}.to output("ToDo CREATED!\n\nID: 1 | Tags: default | Complete: true\nwierdness_of_text\n\n").to_stdout
59
+ expect{MyTodo::Todo.start(%w[create --body=wierdness_of_text --done=true])}.to output("ToDo CREATED!\n0: None\n1: In Progress\n2: Complete\n3: Punted\n4: Waiting Feedback\n\nID: 1 | Created On: 2016-10-08 | Tags: default | Status: In Progress | Complete: true\nwierdness_of_text\n\n").to_stdout
48
60
  end
49
61
  end
50
62
  end
51
63
 
52
64
  context 'unsuccessful creation' do
53
65
  it 'returns error message when body is missing' do
54
- expect{MyTodo::Todo.start(%w(create))}.to output("Validation failed: Body can't be blank\n").to_stdout
66
+ expect{MyTodo::Todo.start(%w(create))}.to output("ToDo CREATED!\n0: None\n1: In Progress\n2: Complete\n3: Punted\n4: Waiting Feedback\nValidation failed: Body can't be blank\n").to_stdout
55
67
  end
56
68
  end
57
69
  end
@@ -14,7 +14,7 @@ describe MyTodo do
14
14
  end
15
15
 
16
16
  it 'displays item with notes' do
17
- expect{MyTodo::Todo.start(%W[note --id=#{@todo.id} --body=note_text])}.to output( "\nID: 1 | Tags: | Complete: \nSome Body\nNotes:\n1: note_text\n\n\n").to_stdout
17
+ expect{MyTodo::Todo.start(%W[note --id=#{@todo.id} --body=note_text])}.to output("\nID: 1 | Created On: 2016-10-08 | Tags: | Status: | Complete: \nSome Body\nNotes:\nID: 1 | Created On: 2016-10-08\nnote_text\n\n\n").to_stdout
18
18
  end
19
19
  end
20
20
 
@@ -11,23 +11,23 @@ describe MyTodo do
11
11
  @todo3.notes.create(body: 'note1')
12
12
  end
13
13
 
14
-
15
14
  it 'finds todo item by body' do
16
- expect{MyTodo::Todo.start( %w[search nfl])}.to output("ToDos FOUND: 1\n\nID: 1 | Tags: tag1 | Complete: \nnfl\n\n").to_stdout
15
+ expect{MyTodo::Todo.start( %w[search nfl])}.to output("ToDos FOUND: 1\nSearch based on ransack search: body_or_detailed_status_or_tags_name_or_notes_body_cont\n\nID: 1 | Created On: 2016-10-08 | Tags: tag1 | Status: | Complete: \nnfl\n\n").to_stdout
17
16
  end
18
17
 
19
18
  it 'finds todo items by associated tag' do
20
- expect{MyTodo::Todo.start( %w[search tag1])}.to output("ToDos FOUND: 1\n\nID: 1 | Tags: tag1 | Complete: \nnfl\n\n").to_stdout
19
+ expect{MyTodo::Todo.start( %w[search tag1])}.to output("ToDos FOUND: 1\nSearch based on ransack search: body_or_detailed_status_or_tags_name_or_notes_body_cont\n\nID: 1 | Created On: 2016-10-08 | Tags: tag1 | Status: | Complete: \nnfl\n\n").to_stdout
21
20
  end
22
21
 
23
- it 'finds todo items by associated notes content' do
24
- expect{MyTodo::Todo.start( %w[search note1])}.to output("ToDos FOUND: 1\n\nID: 3 | Tags: | Complete: \nalways\nNotes:\n1: note1\n\n\n").to_stdout
22
+ it 'finds todo items by detailed status' do
23
+ @todo2.update!(detailed_status: 'None')
24
+ expect{MyTodo::Todo.start( %w[search None])}.to output("ToDos FOUND: 1\nSearch based on ransack search: body_or_detailed_status_or_tags_name_or_notes_body_cont\n\nID: 2 | Created On: 2016-10-08 | Tags: | Status: None | Complete: \nrocks\n\n").to_stdout
25
25
  end
26
26
  end
27
27
 
28
28
  context 'unsuccessful search' do
29
29
  it 'returns no results when searching on invalid body' do
30
- expect{MyTodo::Todo.start( %w(search no_body))}.to output("ToDos FOUND: 0\n").to_stdout
30
+ expect{MyTodo::Todo.start( %w(search no_body))}.to output("ToDos FOUND: 0\nSearch based on ransack search: body_or_detailed_status_or_tags_name_or_notes_body_cont\n").to_stdout
31
31
  end
32
32
  end
33
33
  end
@@ -1,17 +1,25 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe MyTodo do
4
+ def shell
5
+ @shell ||= Thor::Shell::Basic.new
6
+ end
7
+
4
8
  describe 'update' do
5
- before {@todo = FactoryGirl.create(:item)}
9
+ before do
10
+ expect(Thor::LineEditor).to receive(:readline).with("Choose a status for item (1) ", {:default=>1}).and_return("In Progress")
11
+ @todo = FactoryGirl.create(:item)
12
+ end
13
+
6
14
  context 'successful update' do
7
- before {MyTodo::Todo.start(%W(update --id=#{@todo.id} --body=hello))}
8
- subject {@todo.reload.body}
9
- it {is_expected.to eq 'hello'}
15
+ it 'displays the update' do
16
+ expect{MyTodo::Todo.start(%W[update --id=#{@todo.id} --body=hello])}.to output("0: None\n1: In Progress\n2: Complete\n3: Punted\n4: Waiting Feedback\nToDo UPDATED!\n\nID: 1 | Created On: 2016-10-08 | Tags: | Status: None | Complete: \nhello\n\n").to_stdout
17
+ end
10
18
  end
11
19
 
12
20
  context 'unsuccessful update' do
13
21
  it 'returns validation error when body is missing' do
14
- expect{MyTodo::Todo.start(%W(update --id=#{@todo.id} --body=))}.to output("Validation failed: Body can't be blank\n").to_stdout
22
+ expect{MyTodo::Todo.start(%W(update --id=#{@todo.id} --body=))}.to output("0: None\n1: In Progress\n2: Complete\n3: Punted\n4: Waiting Feedback\nValidation failed: Body can't be blank\n").to_stdout
15
23
  end
16
24
  end
17
25
  end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,6 @@
1
+ # code climent must be loaded and started before RAILS_ENV is declared
2
+ require "codeclimate-test-reporter"
3
+ CodeClimate::TestReporter.start
1
4
  ENV["RAILS_ENV"] = 'test'
2
5
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
6
  require 'database_cleaner'
@@ -6,8 +9,10 @@ require 'shoulda-matchers'
6
9
  require 'byebug'
7
10
  require 'my_todo'
8
11
  require 'simplecov'
12
+
9
13
  SimpleCov.start
10
14
 
15
+
11
16
  DatabaseCleaner.strategy = :truncation
12
17
 
13
18
  Shoulda::Matchers.configure do |config|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_todo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.1
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-05 00:00:00.000000000 Z
11
+ date: 2016-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: 0.12.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: codeclimate-test-reporter
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: activerecord
141
155
  requirement: !ruby/object:Gem::Requirement
@@ -243,6 +257,7 @@ files:
243
257
  - lib/db/migrate/20160913134552_create_tags.rb
244
258
  - lib/db/migrate/20160913134610_create_stubs.rb
245
259
  - lib/db/migrate/20161003121448_create_notes.rb
260
+ - lib/db/migrate/20161005133023_add_detailed_status_to_items.rb
246
261
  - lib/db/schema.rb
247
262
  - lib/db/todos_development.sqlite3
248
263
  - lib/db/todos_test.sqlite3