taskz 0.0.1
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 +7 -0
- data/bin/taskz +2 -0
- data/lib/task.rb +13 -0
- data/lib/taskz.rb +69 -0
- data/lib/todo.rb +47 -0
- metadata +48 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: f464aca8ed92a7369d06a3275312fb194d515a0a
|
|
4
|
+
data.tar.gz: 15a863c497504b882d13b46faf8f71fba0f8109f
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: b1f8bc832f6e736c3f3bc4266576e22c72c820c7cddf63d3c40320dc3fabc51594544af343ccb39bce7782bd0f6bcea71e2701dd97314f37e00ed525254db548
|
|
7
|
+
data.tar.gz: e481aee0c71ea09676adc8c6f0c52bba318d051d7b3a806e39a59f9f754b2049a4d46190b5169250cd2f75df816cec7a0440fdcf8dfb04ea0a22ed9b6886e846
|
data/bin/taskz
ADDED
data/lib/task.rb
ADDED
data/lib/taskz.rb
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'optparse'
|
|
3
|
+
require_relative 'task'
|
|
4
|
+
require_relative 'todo'
|
|
5
|
+
|
|
6
|
+
options = { :do_throughput_measurement => false, :query_string => '', :debug => false }
|
|
7
|
+
|
|
8
|
+
OptionParser.new do|opts|
|
|
9
|
+
opts.banner = "Usage: taskz [options]"
|
|
10
|
+
|
|
11
|
+
opts.on('-n', '--new task_name', 'Create a new task') do |task_name|
|
|
12
|
+
options[:new] = task_name
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
opts.on('-c', '--complete index', 'Complete a task at \'index\'') do |index|
|
|
16
|
+
options[:complete] = index
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
opts.on('-r', '--remove index', 'Remove a task at \'index\'') do |index|
|
|
20
|
+
options[:remove] = index
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
opts.on('-w', '--wipe', 'Remove all tasks') do
|
|
24
|
+
options[:wipe] = true
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
opts.on('-h', '--help', 'Displays help') do
|
|
28
|
+
puts "\n#{opts}"
|
|
29
|
+
puts
|
|
30
|
+
exit
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end.parse!
|
|
34
|
+
|
|
35
|
+
options_not_specified = [options[:new], options[:complete], options[:remove], options[:wipe]].count{ |x| x.nil? }
|
|
36
|
+
|
|
37
|
+
todo = Todo.new
|
|
38
|
+
|
|
39
|
+
if options_not_specified == 4
|
|
40
|
+
puts "\nYour Taskz: "
|
|
41
|
+
puts "-------------"
|
|
42
|
+
puts todo
|
|
43
|
+
puts
|
|
44
|
+
exit
|
|
45
|
+
elsif options_not_specified !=3
|
|
46
|
+
puts "\nError - Ceratin Taskz instructions are mutually exclusive. Use 'taskz --help' for more information.\n\n"
|
|
47
|
+
exit
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
if options[:new]
|
|
51
|
+
task = Task.new(options[:new])
|
|
52
|
+
todo.add(task)
|
|
53
|
+
puts "Task successfully added."
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
if options[:complete]
|
|
57
|
+
todo.remove(options[:complete].to_i - 1)
|
|
58
|
+
puts "Task successfully completed."
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
if options[:remove]
|
|
62
|
+
todo.remove(options[:complete].to_i)
|
|
63
|
+
puts "Task successfully removed."
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
if options[:wipe]
|
|
67
|
+
todo.clear
|
|
68
|
+
puts "Tasks cleared!"
|
|
69
|
+
end
|
data/lib/todo.rb
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require_relative 'task'
|
|
2
|
+
|
|
3
|
+
class Todo
|
|
4
|
+
|
|
5
|
+
def initialize
|
|
6
|
+
@tasks = File.exist?(Dir.home + '/.todo_list') ? Marshal.load(File.read(Dir.home + '/.todo_list')) : []
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
attr_reader :items
|
|
10
|
+
|
|
11
|
+
def add(task)
|
|
12
|
+
raise ArugmentError.new "Expecting add on type Task" unless task.kind_of? Task
|
|
13
|
+
@tasks << task
|
|
14
|
+
save_items
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def remove(index)
|
|
18
|
+
@tasks.delete_at(index - 1)
|
|
19
|
+
save_items
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def clear
|
|
23
|
+
@tasks.clear
|
|
24
|
+
save_items
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def to_s
|
|
28
|
+
if @tasks.empty?
|
|
29
|
+
"No Current Tasks!"
|
|
30
|
+
else
|
|
31
|
+
tasks_string = ""
|
|
32
|
+
@tasks.each_with_index do |item, index|
|
|
33
|
+
tasks_string << " #{index + 1} - #{item}\n"
|
|
34
|
+
end
|
|
35
|
+
return tasks_string
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def save_items
|
|
42
|
+
File.open(Dir.home + '/.todo_list', "w") do |f|
|
|
43
|
+
f.puts Marshal.dump(@tasks)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: taskz
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Joel Scarfone
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-06-26 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: This gem was designed to allow people to not forget stuff.
|
|
14
|
+
email: joel.scarfone@carleton.com
|
|
15
|
+
executables:
|
|
16
|
+
- taskz
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- bin/taskz
|
|
21
|
+
- lib/task.rb
|
|
22
|
+
- lib/taskz.rb
|
|
23
|
+
- lib/todo.rb
|
|
24
|
+
homepage: https://github.com/JoelScarfone/Taskz
|
|
25
|
+
licenses:
|
|
26
|
+
- MIT
|
|
27
|
+
metadata: {}
|
|
28
|
+
post_install_message:
|
|
29
|
+
rdoc_options: []
|
|
30
|
+
require_paths:
|
|
31
|
+
- lib
|
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
33
|
+
requirements:
|
|
34
|
+
- - ">="
|
|
35
|
+
- !ruby/object:Gem::Version
|
|
36
|
+
version: '0'
|
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - ">="
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '0'
|
|
42
|
+
requirements: []
|
|
43
|
+
rubyforge_project:
|
|
44
|
+
rubygems_version: 2.4.5
|
|
45
|
+
signing_key:
|
|
46
|
+
specification_version: 4
|
|
47
|
+
summary: Utility to manage daily tasks.
|
|
48
|
+
test_files: []
|