qer 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +23 -0
- data/Manifest.txt +15 -0
- data/README.rdoc +86 -0
- data/Rakefile +31 -0
- data/bin/qer +6 -0
- data/lib/qer.rb +29 -0
- data/lib/qer/todo.rb +194 -0
- data/qer.gemspec +44 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/test/test_helper.rb +6 -0
- data/test/test_qer.rb +251 -0
- data/test/test_queue +2 -0
- data/test/testqueue +1 -0
- metadata +104 -0
data/History.txt
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
== 0.2.2 2010-01-25
|
2
|
+
* 2 bugfixes
|
3
|
+
* Bumping too far back was leaving nil rows
|
4
|
+
* nil rows were raising errors - check for them now
|
5
|
+
|
6
|
+
== 0.2.1 2010-01-11
|
7
|
+
* 1 bugfix:
|
8
|
+
* History was overriding help. Couldn't get to help via command
|
9
|
+
|
10
|
+
== 0.2.0 2009-12-17
|
11
|
+
* 1 major enhancement:
|
12
|
+
* Added the history command to view completed tasks
|
13
|
+
|
14
|
+
== 0.1.0 2009-12-07
|
15
|
+
|
16
|
+
* 1 major enhancement:
|
17
|
+
* Added a bump command to move items in the list
|
18
|
+
|
19
|
+
|
20
|
+
== 0.0.1 2009-10-02
|
21
|
+
|
22
|
+
* 1 major enhancement:
|
23
|
+
* Initial release
|
data/Manifest.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
= qer
|
2
|
+
|
3
|
+
* http://github.com/j05h-qer
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Qer is the friendly easy command-line todo list queueing system.
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
Qer is a really simple command line task manager. You add things into your
|
12
|
+
list, and it stores it for you. You can treat it like a queue or a stack,
|
13
|
+
or both. Whatever you like. Qer keeps track of when you put items into
|
14
|
+
the list so you can know how long they've been there.
|
15
|
+
|
16
|
+
Example Output:
|
17
|
+
$ qer
|
18
|
+
---------------------------> Stuff on the Hopper <--------------------------
|
19
|
+
----------------------------------------------------------------------------
|
20
|
+
(0) Get Groceries from the store. > 31 min ago
|
21
|
+
(1) Call Mom. Its her 60th Birthday on Friday! ~ 5 hours ago
|
22
|
+
(2) Write unit tests. ~ 89 days ago
|
23
|
+
(3) Come up with self-referential documentation joke. ~ 1 day ago
|
24
|
+
(4) Deploy Qer to github. > 15 sec ago
|
25
|
+
----------------------------------------------------------------------------
|
26
|
+
|
27
|
+
== SYNOPSIS:
|
28
|
+
|
29
|
+
Qer supports various operation for manipulating your Todo list.
|
30
|
+
|
31
|
+
Commands:
|
32
|
+
print - Prints out the task list
|
33
|
+
`qer`
|
34
|
+
a(dd) - Adds a task to the end of the list
|
35
|
+
`qer add Stuff to do`
|
36
|
+
r(emove) - Remove the given task number from the list
|
37
|
+
`qer remove 2`
|
38
|
+
pu(sh) - Push a task onto the top of the list
|
39
|
+
`qer push Another boring thing`
|
40
|
+
po(p) - Pops the top item off the list
|
41
|
+
`qer pop`
|
42
|
+
b(ump) - Bumps the given index to the top of the list,
|
43
|
+
or to the specified index
|
44
|
+
`qer bump 3` -> bumps index 3 up to the top
|
45
|
+
`qer bump 5 2` -> bumps index five up to 2
|
46
|
+
clear - Clears the entire list
|
47
|
+
`qer clear`
|
48
|
+
history - displays list of completed tasks
|
49
|
+
`qer history`
|
50
|
+
help - Prints this message
|
51
|
+
`qer help`
|
52
|
+
|
53
|
+
== REQUIREMENTS:
|
54
|
+
|
55
|
+
* Ruby
|
56
|
+
* Ruby Gems (for installation)
|
57
|
+
* Shoulda (to run tests)
|
58
|
+
|
59
|
+
== INSTALL:
|
60
|
+
|
61
|
+
sudo gem install j05h-qer --source http://gems.github.com
|
62
|
+
|
63
|
+
== LICENSE:
|
64
|
+
|
65
|
+
(The MIT License)
|
66
|
+
|
67
|
+
Copyright (c) 2009 Josh Kleinpeter
|
68
|
+
|
69
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
70
|
+
a copy of this software and associated documentation files (the
|
71
|
+
'Software'), to deal in the Software without restriction, including
|
72
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
73
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
74
|
+
permit persons to whom the Software is furnished to do so, subject to
|
75
|
+
the following conditions:
|
76
|
+
|
77
|
+
The above copyright notice and this permission notice shall be
|
78
|
+
included in all copies or substantial portions of the Software.
|
79
|
+
|
80
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
81
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
82
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
83
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
84
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
85
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
86
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
%w[rubygems rake rake/clean fileutils hoe newgem rubigen].each { |f| require f }
|
2
|
+
require File.dirname(__FILE__) + '/lib/qer'
|
3
|
+
|
4
|
+
# Generate all the Rake tasks
|
5
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
6
|
+
$hoe = Hoe.spec('qer') do |p|
|
7
|
+
p.developer('Josh Kleinpeter', 'josh@kleinpeter.org')
|
8
|
+
p.developer('Coby Randquist', 'randquistcp@gmail.com')
|
9
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
10
|
+
p.rubyforge_name = p.name
|
11
|
+
p.description = "Qer is an easy command-line todo list."
|
12
|
+
p.summary = "Just type `qer --help` to get started."
|
13
|
+
p.extra_dev_deps = [
|
14
|
+
['shoulda','= 2.10.1'],
|
15
|
+
['newgem', ">= #{::Newgem::VERSION}"]
|
16
|
+
]
|
17
|
+
|
18
|
+
p.clean_globs |= %w[**/.DS_Store tmp *.log]
|
19
|
+
path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
|
20
|
+
p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
|
21
|
+
p.rsync_args = '-av --delete --ignore-errors'
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'newgem/tasks' # load /tasks/*.rake
|
25
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
26
|
+
|
27
|
+
task :default => [:spec]
|
28
|
+
|
29
|
+
task :rcov do
|
30
|
+
system("rcov -t -x '/.*shoulda.*/|/.*rcov.*/' test/test_qer.rb")
|
31
|
+
end
|
data/bin/qer
ADDED
data/lib/qer.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
2
|
+
|
3
|
+
require 'time'
|
4
|
+
require 'qer/todo'
|
5
|
+
module Qer
|
6
|
+
VERSION = '0.2.2'
|
7
|
+
end
|
8
|
+
|
9
|
+
class Time
|
10
|
+
def self.time_ago(from_time, to_time = Time.now)
|
11
|
+
from_time = from_time.to_time if from_time.respond_to?(:to_time)
|
12
|
+
to_time = to_time.to_time if to_time.respond_to?(:to_time)
|
13
|
+
distance_in_minutes = (((to_time - from_time).abs)/60).round
|
14
|
+
distance_in_seconds = ((to_time - from_time).abs).round
|
15
|
+
|
16
|
+
case distance_in_minutes
|
17
|
+
when 0..1 then "> #{distance_in_seconds} sec ago"
|
18
|
+
when 2..44 then "> #{distance_in_minutes} min ago"
|
19
|
+
when 45..89 then "~ 1 hr ago"
|
20
|
+
when 90..1439 then "~ #{(distance_in_minutes.to_f / 60.0).round} hrs ago"
|
21
|
+
when 1440..2879 then "~ 1 day ago"
|
22
|
+
when 2880..43199 then "~ #{(distance_in_minutes / 1440).round} days ago"
|
23
|
+
when 43200..86399 then "~ 1 month ago"
|
24
|
+
when 86400..525599 then "~ #{(distance_in_minutes / 43200).round} months ago"
|
25
|
+
when 525600..1051199 then "~ 1 year ago"
|
26
|
+
else "> #{(distance_in_minutes / 525600).round} years ago"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/qer/todo.rb
ADDED
@@ -0,0 +1,194 @@
|
|
1
|
+
module Qer
|
2
|
+
class ToDo
|
3
|
+
class << self
|
4
|
+
attr_accessor :quiet
|
5
|
+
end
|
6
|
+
|
7
|
+
attr_accessor :queue
|
8
|
+
attr_accessor :history
|
9
|
+
|
10
|
+
def initialize(filename = File.expand_path("~/.qer-queue"))
|
11
|
+
@filename = filename
|
12
|
+
@history_filename = "#{filename}-history"
|
13
|
+
|
14
|
+
file {|f| self.queue = Marshal.load(f) } rescue self.queue= []
|
15
|
+
history_file {|f| self.history = Marshal.load(f) } rescue self.history= []
|
16
|
+
end
|
17
|
+
|
18
|
+
def add(item)
|
19
|
+
self.queue << [Time.now.to_s, item]
|
20
|
+
write
|
21
|
+
print "Adding: "+item
|
22
|
+
end
|
23
|
+
|
24
|
+
def remove(index)
|
25
|
+
returning(item = self.queue.delete_at(index)) do
|
26
|
+
self.history << [Time.now.to_s, item[0], item[1]]
|
27
|
+
write_history
|
28
|
+
write
|
29
|
+
print "Removed #{item.last}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def clear
|
34
|
+
self.queue = []
|
35
|
+
write
|
36
|
+
print "ToDo list cleared"
|
37
|
+
end
|
38
|
+
|
39
|
+
def pop
|
40
|
+
remove(0)
|
41
|
+
end
|
42
|
+
|
43
|
+
def push(item)
|
44
|
+
self.queue.unshift([Time.now.to_s, item])
|
45
|
+
write
|
46
|
+
print
|
47
|
+
end
|
48
|
+
|
49
|
+
def bump(index, new_index = 0)
|
50
|
+
item = queue.delete_at(index.to_i)
|
51
|
+
self.queue.insert(new_index.to_i, item)
|
52
|
+
self.queue.delete_if {|i| i.nil? }
|
53
|
+
write
|
54
|
+
print "Bumped #{item.last} to position #{new_index}"
|
55
|
+
end
|
56
|
+
|
57
|
+
def print(string = nil)
|
58
|
+
dump self.queue, string
|
59
|
+
end
|
60
|
+
|
61
|
+
def print_history(string = nil)
|
62
|
+
dump self.history, string, history_title
|
63
|
+
end
|
64
|
+
|
65
|
+
def write
|
66
|
+
file("w+") {|f| Marshal.dump(self.queue, f) }
|
67
|
+
end
|
68
|
+
|
69
|
+
def write_history
|
70
|
+
history_file("w+") {|f| Marshal.dump(self.history, f) }
|
71
|
+
end
|
72
|
+
|
73
|
+
def file(mode = "r", &block)
|
74
|
+
File.open(@filename, mode) do |f|
|
75
|
+
yield f
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def history_file(mode = "r", &block)
|
80
|
+
File.open(@history_filename, mode) do |f|
|
81
|
+
yield f
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def size
|
86
|
+
self.queue.size
|
87
|
+
end
|
88
|
+
|
89
|
+
def returning(thing)
|
90
|
+
yield
|
91
|
+
thing
|
92
|
+
end
|
93
|
+
|
94
|
+
def width
|
95
|
+
80
|
96
|
+
end
|
97
|
+
|
98
|
+
def title
|
99
|
+
"> Stuff on the Hopper < ".center(width, '-')
|
100
|
+
end
|
101
|
+
|
102
|
+
def history_title
|
103
|
+
"> Stuff Completed < ".center(width, '-')
|
104
|
+
end
|
105
|
+
|
106
|
+
def hl
|
107
|
+
"".center(width, '-')
|
108
|
+
end
|
109
|
+
|
110
|
+
def tf(t)
|
111
|
+
Time.time_ago(Time.parse(t))
|
112
|
+
end
|
113
|
+
|
114
|
+
def process_line(index, item)
|
115
|
+
return unless item
|
116
|
+
item.size == 2 ? process_queue_line(index,item) : process_history_line(index,item)
|
117
|
+
end
|
118
|
+
|
119
|
+
def process_queue_line(index, item)
|
120
|
+
time, task = item
|
121
|
+
left = "(#{index}) #{task}"
|
122
|
+
right = tf(time).rjust(width - left.length)
|
123
|
+
right.insert(0, left)
|
124
|
+
end
|
125
|
+
|
126
|
+
def process_history_line(index, item)
|
127
|
+
end_time, time, task = item
|
128
|
+
left = "(#{index}) #{task}"
|
129
|
+
right = "#{tf(time)} | #{tf(end_time)}".rjust(width-left.length)
|
130
|
+
right.insert(0, left)
|
131
|
+
end
|
132
|
+
|
133
|
+
def dump(queue, string, label = title)
|
134
|
+
out = []
|
135
|
+
out << string if(string)
|
136
|
+
out << label
|
137
|
+
out << hl
|
138
|
+
if queue.empty?
|
139
|
+
queue.each_with_index do |item, index|
|
140
|
+
out << process_line(index, item)
|
141
|
+
end
|
142
|
+
else
|
143
|
+
out << "Nothing in this queue!"
|
144
|
+
end
|
145
|
+
out << hl
|
146
|
+
puts out.join("\n") unless self.class.quiet
|
147
|
+
end
|
148
|
+
|
149
|
+
def command(args)
|
150
|
+
case(args.shift)
|
151
|
+
when /^a(dd)?/ : self.add(args.join(" ")) # qer add Some task 1
|
152
|
+
when /^r(emove)?/ : self.remove(args.shift.to_i) # qer remove 0
|
153
|
+
when /^pu(sh)?/ : self.push(args.join(" ")) # qer push Some task 2
|
154
|
+
when /^po(p)?/ : self.pop # qer pop
|
155
|
+
when /^b(ump)?/ : self.bump(*args.first(2)) # qer bump
|
156
|
+
when /^clear/ : self.clear # qer clear
|
157
|
+
when /.*help/ : self.help # qer help
|
158
|
+
when /^h(istory)?/ : self.print_history # qer history
|
159
|
+
else self.print # qer
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def help
|
164
|
+
string = <<-EOF
|
165
|
+
#{hl}
|
166
|
+
Help for Qer, the friendly easy todo list queueing system.
|
167
|
+
#{hl}
|
168
|
+
Commands:
|
169
|
+
print - Prints out the task list
|
170
|
+
`qer`
|
171
|
+
a(dd) - Adds a task to the end of the list
|
172
|
+
`qer add Stuff to do`
|
173
|
+
r(emove) - Remove the given task number from the list
|
174
|
+
`qer remove 2`
|
175
|
+
pu(sh) - Push a task onto the top of the list
|
176
|
+
`qer push Another boring thing`
|
177
|
+
po(p) - Pops the top item off the list
|
178
|
+
`qer pop`
|
179
|
+
b(ump) - Bumps the given index to the top of the list,
|
180
|
+
or to the specified index
|
181
|
+
`qer bump 3` -> bumps index 3 up to the top
|
182
|
+
`qer bump 5 2` -> bumps index five up to 2
|
183
|
+
clear - Clears the entire list
|
184
|
+
`qer clear`
|
185
|
+
h(istory) - displays list of completed tasks
|
186
|
+
`qer history`
|
187
|
+
help - Prints this message
|
188
|
+
`qer help`
|
189
|
+
#{hl}
|
190
|
+
EOF
|
191
|
+
puts string unless self.class.quiet
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
data/qer.gemspec
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{qer}
|
5
|
+
s.version = "0.0.2"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Josh Kleinpeter"]
|
9
|
+
s.date = %q{2009-10-08}
|
10
|
+
s.default_executable = %q{qer}
|
11
|
+
s.description = %q{Qer is an easy command-line todo list.}
|
12
|
+
s.email = ["josh@kleinpeter.org"]
|
13
|
+
s.executables = ["qer"]
|
14
|
+
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc"]
|
15
|
+
s.files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "bin/qer", "lib/qer.rb", "lib/qer/todo.rb", "qer.gemspec", "script/console", "script/destroy", "script/generate", "test/test_helper.rb", "test/test_qer.rb", "test/test_queue", "test/testqueue"]
|
16
|
+
s.has_rdoc = true
|
17
|
+
s.homepage = %q{http://github.com/j05h-qer}
|
18
|
+
s.post_install_message = %q{PostInstall.txt}
|
19
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
s.rubyforge_project = %q{qer}
|
22
|
+
s.rubygems_version = %q{1.3.2}
|
23
|
+
s.summary = %q{Just type `qer --help` to get started.}
|
24
|
+
s.test_files = ["test/test_helper.rb", "test/test_qer.rb"]
|
25
|
+
|
26
|
+
if s.respond_to? :specification_version then
|
27
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
28
|
+
s.specification_version = 3
|
29
|
+
|
30
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
31
|
+
s.add_development_dependency(%q<shoulda>, ["= 2.10.1"])
|
32
|
+
s.add_development_dependency(%q<newgem>, [">= 1.3.0"])
|
33
|
+
s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
|
34
|
+
else
|
35
|
+
s.add_dependency(%q<shoulda>, ["= 2.10.1"])
|
36
|
+
s.add_dependency(%q<newgem>, [">= 1.3.0"])
|
37
|
+
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
38
|
+
end
|
39
|
+
else
|
40
|
+
s.add_dependency(%q<shoulda>, ["= 2.10.1"])
|
41
|
+
s.add_dependency(%q<newgem>, [">= 1.3.0"])
|
42
|
+
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
43
|
+
end
|
44
|
+
end
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/qer.rb'}"
|
9
|
+
puts "Loading qer gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/test/test_helper.rb
ADDED
data/test/test_qer.rb
ADDED
@@ -0,0 +1,251 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestQer < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@file = File.join(File.dirname(__FILE__), 'testqueue.tmp')
|
7
|
+
File.delete(@file) if File.exists?(@file)
|
8
|
+
@todo = Qer::ToDo.new(@file)
|
9
|
+
end
|
10
|
+
|
11
|
+
context "push" do
|
12
|
+
setup do
|
13
|
+
@todo.push("Some Task")
|
14
|
+
end
|
15
|
+
|
16
|
+
should "have one item" do
|
17
|
+
assert_equal 1, @todo.size
|
18
|
+
end
|
19
|
+
|
20
|
+
should "have two items" do
|
21
|
+
@todo.push("Some Other Task")
|
22
|
+
assert_equal 2, @todo.size
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "pop" do
|
27
|
+
setup do
|
28
|
+
@todo.push("Some Task")
|
29
|
+
@todo.push("Some Other Task")
|
30
|
+
@item = @todo.pop
|
31
|
+
end
|
32
|
+
|
33
|
+
should "pop the right item" do
|
34
|
+
assert_equal "Some Other Task", @item[1]
|
35
|
+
end
|
36
|
+
|
37
|
+
should "have one item" do
|
38
|
+
assert_equal 1, @todo.size
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "add" do
|
43
|
+
setup do
|
44
|
+
@todo.add("Some Task")
|
45
|
+
end
|
46
|
+
|
47
|
+
should "have one item" do
|
48
|
+
assert_equal 1, @todo.size
|
49
|
+
end
|
50
|
+
|
51
|
+
should "have two items" do
|
52
|
+
@todo.add("Some Other Task")
|
53
|
+
assert_equal 2, @todo.size
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "remove" do
|
58
|
+
setup do
|
59
|
+
@todo.add("Some Task")
|
60
|
+
@todo.add("Some Other Task")
|
61
|
+
@item = @todo.remove(0)
|
62
|
+
end
|
63
|
+
|
64
|
+
should "remove the right item" do
|
65
|
+
assert_equal "Some Task", @item[1]
|
66
|
+
end
|
67
|
+
|
68
|
+
should "have one item" do
|
69
|
+
assert_equal 1, @todo.size
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context "clear" do
|
74
|
+
setup do
|
75
|
+
@todo.add("Some Task")
|
76
|
+
@todo.add("Some Other Task")
|
77
|
+
@todo.clear
|
78
|
+
end
|
79
|
+
|
80
|
+
should "have one item" do
|
81
|
+
assert_equal 0, @todo.size
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
context "bump" do
|
87
|
+
setup do
|
88
|
+
@todo.add("first")
|
89
|
+
@todo.add("second")
|
90
|
+
@todo.add("third")
|
91
|
+
end
|
92
|
+
|
93
|
+
should "be able to bump to the top" do
|
94
|
+
@todo.bump(2)
|
95
|
+
assert_equal "third", @todo.queue.first.last
|
96
|
+
end
|
97
|
+
|
98
|
+
should "be able to bump to a specific location" do
|
99
|
+
@todo.bump(2,1)
|
100
|
+
assert_equal "third", @todo.queue[1].last
|
101
|
+
end
|
102
|
+
|
103
|
+
should "not leave nil rows in if we bump too far back" do
|
104
|
+
@todo.bump(0,100)
|
105
|
+
assert !@todo.queue.include?(nil)
|
106
|
+
assert_equal "first", @todo.queue.last[1]
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
context "read" do
|
113
|
+
setup do
|
114
|
+
@file = File.join(File.dirname(__FILE__), 'test_queue')
|
115
|
+
@todo = Qer::ToDo.new(@file)
|
116
|
+
end
|
117
|
+
|
118
|
+
should "have 5 items" do
|
119
|
+
assert_equal 5, @todo.size
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context "write" do
|
124
|
+
setup do
|
125
|
+
@todo.add("Some Task")
|
126
|
+
@todo.add("Some Other Task")
|
127
|
+
@other_todo = Qer::ToDo.new(@file)
|
128
|
+
end
|
129
|
+
|
130
|
+
should "have 2 items" do
|
131
|
+
assert_equal 2, @todo.size
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
context "command" do
|
136
|
+
setup do
|
137
|
+
@todo.add("Some Task")
|
138
|
+
end
|
139
|
+
|
140
|
+
should "add" do
|
141
|
+
@todo.command(%w(add some stuff))
|
142
|
+
assert_equal 2, @todo.size
|
143
|
+
end
|
144
|
+
|
145
|
+
should "remove" do
|
146
|
+
assert_equal "Some Task", @todo.command(%w(remove 0)).last
|
147
|
+
assert_equal 0, @todo.size
|
148
|
+
end
|
149
|
+
|
150
|
+
should "push" do
|
151
|
+
@todo.command(%w(push some stuff))
|
152
|
+
assert_equal 2, @todo.size
|
153
|
+
end
|
154
|
+
|
155
|
+
should "pop" do
|
156
|
+
assert_equal "Some Task", @todo.command(%w(pop)).last
|
157
|
+
assert_equal 0, @todo.size
|
158
|
+
end
|
159
|
+
|
160
|
+
should "clear" do
|
161
|
+
@todo.command(%w(clear))
|
162
|
+
assert_equal 0, @todo.size
|
163
|
+
end
|
164
|
+
|
165
|
+
should "help" do
|
166
|
+
@todo.command(%w(help))
|
167
|
+
assert_equal 1, @todo.size
|
168
|
+
end
|
169
|
+
|
170
|
+
should "print" do
|
171
|
+
@todo.command([])
|
172
|
+
assert_equal 1, @todo.size
|
173
|
+
end
|
174
|
+
|
175
|
+
should "bump" do
|
176
|
+
@todo.add("second")
|
177
|
+
@todo.command(%w(bump 1))
|
178
|
+
assert_equal "second", @todo.queue.first.last
|
179
|
+
|
180
|
+
@todo.add('third')
|
181
|
+
@todo.command(%w(bump 2 1))
|
182
|
+
assert_equal "third", @todo.queue[1].last
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
|
187
|
+
context "time" do
|
188
|
+
setup do
|
189
|
+
@time = Time.now
|
190
|
+
end
|
191
|
+
|
192
|
+
should "parse time" do
|
193
|
+
@time = @todo.tf("Fri Oct 02 15:04:59 -0700 2009")
|
194
|
+
end
|
195
|
+
|
196
|
+
should "have distance in seconds" do
|
197
|
+
assert_equal "> 1 sec ago", Time.time_ago(@time, @time - 1)
|
198
|
+
end
|
199
|
+
|
200
|
+
should "have distance in minutes" do
|
201
|
+
assert_equal "> 5 min ago", Time.time_ago(@time, @time - 5*60)
|
202
|
+
end
|
203
|
+
|
204
|
+
should "have distance in 1 hour" do
|
205
|
+
assert_equal "~ 1 hr ago", Time.time_ago(@time, @time - 3600)
|
206
|
+
end
|
207
|
+
|
208
|
+
should "have distance in hours" do
|
209
|
+
assert_equal "~ 2 hrs ago", Time.time_ago(@time, @time - 2*3600)
|
210
|
+
end
|
211
|
+
|
212
|
+
should "have distance in 1 day" do
|
213
|
+
assert_equal "~ 1 day ago", Time.time_ago(@time, @time - 86400)
|
214
|
+
end
|
215
|
+
|
216
|
+
should "have distance in days" do
|
217
|
+
assert_equal "~ 7 days ago", Time.time_ago(@time, @time - 7*86400)
|
218
|
+
end
|
219
|
+
|
220
|
+
should "have distance in 1 month" do
|
221
|
+
assert_equal "~ 1 month ago", Time.time_ago(@time, @time - 2592000)
|
222
|
+
end
|
223
|
+
|
224
|
+
should "have distance in months" do
|
225
|
+
assert_equal "~ 3 months ago", Time.time_ago(@time, @time - 3*2592000)
|
226
|
+
end
|
227
|
+
|
228
|
+
should "have distance in 1 year" do
|
229
|
+
assert_equal "~ 1 year ago", Time.time_ago(@time, @time - 31536000)
|
230
|
+
end
|
231
|
+
|
232
|
+
should "have distance in years" do
|
233
|
+
assert_equal "> 99 years ago", Time.time_ago(@time, @time - 99*31536000)
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
context "print" do
|
238
|
+
should "have width" do
|
239
|
+
assert_equal 80, @todo.width
|
240
|
+
end
|
241
|
+
|
242
|
+
should "have a title" do
|
243
|
+
assert_equal @todo.width, @todo.title.size
|
244
|
+
end
|
245
|
+
|
246
|
+
should "have a horizontal line printer" do
|
247
|
+
assert_equal @todo.width, @todo.hl.size
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
end
|
data/test/test_queue
ADDED
data/test/testqueue
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
[["#Fri Oct 02 14:44:48 -0700 2009"Some Task["#Fri Oct 02 14:44:48 -0700 2009"Some Other Task
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: qer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Josh Kleinpeter
|
8
|
+
- Coby Randquist
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2010-01-25 00:00:00 -08:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: shoulda
|
18
|
+
type: :development
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - "="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 2.10.1
|
25
|
+
version:
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: newgem
|
28
|
+
type: :development
|
29
|
+
version_requirement:
|
30
|
+
version_requirements: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.5.2
|
35
|
+
version:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: hoe
|
38
|
+
type: :development
|
39
|
+
version_requirement:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 2.3.3
|
45
|
+
version:
|
46
|
+
description: Qer is an easy command-line todo list.
|
47
|
+
email:
|
48
|
+
- josh@kleinpeter.org
|
49
|
+
- randquistcp@gmail.com
|
50
|
+
executables:
|
51
|
+
- qer
|
52
|
+
extensions: []
|
53
|
+
|
54
|
+
extra_rdoc_files:
|
55
|
+
- History.txt
|
56
|
+
- Manifest.txt
|
57
|
+
files:
|
58
|
+
- History.txt
|
59
|
+
- Manifest.txt
|
60
|
+
- README.rdoc
|
61
|
+
- Rakefile
|
62
|
+
- bin/qer
|
63
|
+
- lib/qer.rb
|
64
|
+
- lib/qer/todo.rb
|
65
|
+
- qer.gemspec
|
66
|
+
- script/console
|
67
|
+
- script/destroy
|
68
|
+
- script/generate
|
69
|
+
- test/test_helper.rb
|
70
|
+
- test/test_qer.rb
|
71
|
+
- test/test_queue
|
72
|
+
- test/testqueue
|
73
|
+
has_rdoc: true
|
74
|
+
homepage:
|
75
|
+
licenses: []
|
76
|
+
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options:
|
79
|
+
- --main
|
80
|
+
- README.txt
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: "0"
|
88
|
+
version:
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: "0"
|
94
|
+
version:
|
95
|
+
requirements: []
|
96
|
+
|
97
|
+
rubyforge_project: qer
|
98
|
+
rubygems_version: 1.3.5
|
99
|
+
signing_key:
|
100
|
+
specification_version: 3
|
101
|
+
summary: Just type `qer --help` to get started.
|
102
|
+
test_files:
|
103
|
+
- test/test_helper.rb
|
104
|
+
- test/test_qer.rb
|