my_todo 3.1.0 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/db/todos_development.sqlite3 +0 -0
- data/lib/db/todos_test.sqlite3 +0 -0
- data/lib/my_todo/models/item.rb +2 -0
- data/lib/my_todo/modules/my_todo_actions.rb +21 -6
- data/lib/my_todo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4c70de321e879cf5515fbbd10b78e71f8a69017
|
4
|
+
data.tar.gz: 53acd0ce0b42fe4cd6baf3bfbadd7c272350c739
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 811c02060a4a567ba1528c55152f40d4075387fee2c3d09f810ea685a9f6f577082fabb4f9af87869ad90338d6d880edafb74eac937ba57e58bb409c8f4a21d6
|
7
|
+
data.tar.gz: cd090f60fd4879456d9ce52e3939d8dd344c5e8acaff04e21a41cee1a8f94b01044d02241f7adc54d43388ebeadb809934001f58ed7146d4ef8176cf092f5ea9
|
Binary file
|
data/lib/db/todos_test.sqlite3
CHANGED
Binary file
|
data/lib/my_todo/models/item.rb
CHANGED
@@ -21,6 +21,8 @@ class Item < ActiveRecord::Base
|
|
21
21
|
# ActiveModel validation to ensure body is present
|
22
22
|
validates :body, presence: true
|
23
23
|
|
24
|
+
# Hook to set done boolean based on detailed status
|
25
|
+
#(see #update_done)
|
24
26
|
before_save :update_done
|
25
27
|
|
26
28
|
#set done attribute based on detailed_status set
|
@@ -1,18 +1,33 @@
|
|
1
1
|
module MyTodoActions
|
2
2
|
def ask_status
|
3
3
|
list_statuses
|
4
|
-
@status = ask("Choose a status for item", default:
|
4
|
+
@status = ask("Choose a status for item", default: set_default_status)
|
5
5
|
end
|
6
6
|
|
7
7
|
def create_item(options)
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
@item = Item.new(options.except(:tags))
|
9
|
+
assign_detailed_status
|
10
|
+
@item.save!
|
11
|
+
set_tags
|
11
12
|
end
|
12
13
|
|
13
14
|
def update_item(options)
|
15
|
+
item.assign_attributes(options)
|
16
|
+
@item = item #Find a better way!!!!
|
17
|
+
assign_detailed_status
|
18
|
+
item.save!
|
19
|
+
end
|
20
|
+
|
21
|
+
def assign_detailed_status
|
14
22
|
ask_status
|
15
|
-
|
16
|
-
|
23
|
+
@item.write_attribute(:detailed_status, detailed_statuses[@status.to_i])
|
24
|
+
end
|
25
|
+
|
26
|
+
def set_tags
|
27
|
+
options[:tags].split(' ').each{|tag| @item.tags.create(name: tag) } if options[:tags]
|
28
|
+
end
|
29
|
+
|
30
|
+
def set_default_status
|
31
|
+
@item.detailed_status.nil? ? 1 : detailed_statuses.index(@item.detailed_status)
|
17
32
|
end
|
18
33
|
end
|
data/lib/my_todo/version.rb
CHANGED
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: 3.1.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|