todoreo 0.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ee96ec6d7989f8e92354248c93b2cbcf69fe1c81
4
+ data.tar.gz: 0c6f67926d2e8208acbeecef5c3ed8f798de79d6
5
+ SHA512:
6
+ metadata.gz: c79cbdce3c65b0d4730127958ce3644ce864b33e6e1ef9d08b337cb88a6f19621d706aa26ea728e13fb8d5dcce419cd95904350d7aaf59de37e502d9a95e155c
7
+ data.tar.gz: 8c72ecb5671e686c8fd50a40d548fdb5776eb3b3816c23f5a702ab443fd921c44024fdffc92ae3038053193b2df2bf25c4a78c2c817b6022632339c0fbc1f693
data/bin/todoreo ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'todoreo'
@@ -0,0 +1,19 @@
1
+ module Todoreo
2
+ class TodoItem
3
+ attr_accessor :todo, :days, :time
4
+
5
+ @@todo_id = 0
6
+ def initialize
7
+ @time_created = Time.now
8
+ @@todo_id += 1
9
+ end
10
+
11
+ def time_created
12
+ @time_created
13
+ end
14
+
15
+ def todo_id
16
+ @@todo_id
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,146 @@
1
+ module Todoreo
2
+ class TodoList
3
+ def initialize
4
+ @todoItems = []
5
+ end
6
+
7
+ def run_program
8
+ puts "Type '--help' to see all of the commands"
9
+ loop do
10
+ input = gets.chomp
11
+ case input
12
+ when 'add'
13
+ add_todo_item
14
+ when 'all'
15
+ show_todos
16
+ when 'dot'
17
+ delete_overlapped_todos
18
+ when 'dst'
19
+ print "Type the id of the todo you want to delete: "
20
+ input = gets.chomp
21
+ delete_specific_todo(input)
22
+ when 'est'
23
+ print "Type the id of the todo you want to edit: "
24
+ input = gets.chomp
25
+ edit_specific_todo(input)
26
+ when 'exit'
27
+ break
28
+ when '--help', '-help', '-h', 'help'
29
+ get_help
30
+ when 'sweet love'
31
+ puts "( ͡° ͜ʖ ͡°)\n Oke"
32
+ end
33
+ end
34
+ end
35
+
36
+ def add_todo_item
37
+ newTodoItem = TodoItem.new
38
+ print "Write your todo: "
39
+ newTodoItem.todo = gets.chomp
40
+ print "How many days do you need to complete it: "
41
+ newTodoItem.days = gets.chomp
42
+ print "At what time of the day should it be complete (example: 12:45): "
43
+ newTodoItem.time = gets.chomp
44
+ @todoItems.push(newTodoItem)
45
+
46
+ puts newTodoItem
47
+ puts newTodoItem.time_created
48
+ end
49
+
50
+ def show_todos
51
+ if @todoItems.count > 0
52
+ puts "------------------------"
53
+ puts "Here is your todo items"
54
+ else
55
+ puts "------------------------"
56
+ puts "You have no todos yet.... Type 'add' to create one"
57
+ end
58
+ todoCounter = 1
59
+
60
+ @todoItems.each do |item|
61
+ time_until_due_date = item.time_created + (60 * 60 * 24 * item.days.to_i)
62
+
63
+ todo_due_date = time_until_due_date.strftime("%Y-%m-%d")
64
+ time_of_the_day = item.time
65
+
66
+ if Time.now < time_until_due_date
67
+ puts "[#{todoCounter}] #{item.todo} - Due at #{todo_due_date} on #{time_of_the_day}"
68
+ else
69
+ puts "[#{todoCounter}] #{item.todo} - Due date overlapped (Type 'dot' to delete all overlapped todos )"
70
+ end
71
+ todoCounter += 1
72
+ end
73
+ end
74
+
75
+ def delete_overlapped_todos
76
+ @todoItems.each do |item|
77
+ time_until_due_date = item.time_created + (60 * 60 * 24 * item.days.to_i)
78
+ if Time.now > time_until_due_date
79
+ @todoItems.delete(item)
80
+ end
81
+ end
82
+
83
+ show_todos()
84
+ end
85
+
86
+ def delete_specific_todo(id)
87
+ todoCounter = 1
88
+ @todoItems.each do |item|
89
+ if id.to_i == todoCounter
90
+ @todoItems.delete(item)
91
+ puts "The todo: '#{item.todo}' was successfully deleted"
92
+ end
93
+
94
+ todoCounter += 1
95
+ end
96
+
97
+ show_todos()
98
+ end
99
+
100
+ def edit_specific_todo(id)
101
+ todoCounter = 1
102
+
103
+ @todoItems.each do |item|
104
+ if id.to_i == todoCounter
105
+ puts "What do you want to edit?"
106
+ puts "'todo' to edit the todo content"
107
+ puts "'days' to edit the days you have left"
108
+ puts "'time' to edit the specific time you have to complete it"
109
+ loop do
110
+ decision = gets.chomp
111
+ case decision
112
+ when 'todo'
113
+ print "Write your new version of that todo: "
114
+ new_version = gets.chomp
115
+ item.todo = new_version
116
+ break
117
+ when 'days'
118
+ print "How many days do you want: "
119
+ new_version = gets.chomp
120
+ item.days = new_version
121
+ break
122
+ when 'time'
123
+ print "What should the new time be?: "
124
+ new_version = gets.chomp
125
+ item.time = new_version
126
+ break
127
+ end
128
+ end
129
+ puts "Successfully updated the todo with id of [#{id}]"
130
+ end
131
+ todoCounter += 1
132
+ end
133
+ end
134
+
135
+ def get_help
136
+ puts "------------------------"
137
+ puts "The help has arrived..."
138
+ puts "Type 'add' to create a new todo"
139
+ puts "Type 'all' to view all todos"
140
+ puts "Type 'dst' to delete a specific todo via their id (1., 2. etc.)"
141
+ puts "Type 'dot' to delete overlapped todos"
142
+ puts "Type 'exit' to exit the application (all data will be saved)"
143
+ end
144
+
145
+ end
146
+ end
@@ -0,0 +1,3 @@
1
+ module Todoreo
2
+ VERSION = "0.1.0"
3
+ end
data/lib/todoreo.rb ADDED
@@ -0,0 +1,9 @@
1
+ require "todoreo/version"
2
+ require "todoreo/todolist"
3
+ require "todoreo/todoitem"
4
+
5
+
6
+ module Todoreo
7
+ newList = TodoList.new
8
+ newList.run_program
9
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: todoreo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - LudvigSoerensen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: This is a small todo application
42
+ email:
43
+ - ludvigsoerensen@gmail.com
44
+ executables:
45
+ - todoreo
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - bin/todoreo
50
+ - lib/todoreo.rb
51
+ - lib/todoreo/todoitem.rb
52
+ - lib/todoreo/todolist.rb
53
+ - lib/todoreo/version.rb
54
+ homepage: https://github.com/Lutski/todoreo
55
+ licenses:
56
+ - MIT
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 2.4.8
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: This is a small todo application
78
+ test_files: []