todo 0.0.2
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.
- data/History.txt +4 -0
- data/License.txt +20 -0
- data/Manifest.txt +29 -0
- data/PostInstall.txt +7 -0
- data/README.txt +57 -0
- data/Rakefile +4 -0
- data/bin/todo +5 -0
- data/config/hoe.rb +71 -0
- data/config/requirements.rb +15 -0
- data/lib/todo.rb +8 -0
- data/lib/todo/cli.rb +137 -0
- data/lib/todo/list.rb +25 -0
- data/lib/todo/store.rb +26 -0
- data/lib/todo/version.rb +9 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +82 -0
- data/setup.rb +1585 -0
- data/spec/todo_list_specs.rb +63 -0
- data/spec/todo_store_specs.rb +10 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/website/index.html +11 -0
- data/website/index.txt +83 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.html.erb +48 -0
- metadata +114 -0
data/History.txt
ADDED
data/License.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Lakshan Perera
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
History.txt
|
2
|
+
License.txt
|
3
|
+
Manifest.txt
|
4
|
+
PostInstall.txt
|
5
|
+
README.txt
|
6
|
+
Rakefile
|
7
|
+
bin/todo
|
8
|
+
config/hoe.rb
|
9
|
+
config/requirements.rb
|
10
|
+
lib/todo.rb
|
11
|
+
lib/todo/version.rb
|
12
|
+
lib/todo/cli.rb
|
13
|
+
lib/todo/list.rb
|
14
|
+
lib/todo/store.rb
|
15
|
+
script/console
|
16
|
+
script/destroy
|
17
|
+
script/generate
|
18
|
+
script/txt2html
|
19
|
+
setup.rb
|
20
|
+
tasks/deployment.rake
|
21
|
+
tasks/environment.rake
|
22
|
+
tasks/website.rake
|
23
|
+
spec/todo_list_specs.rb
|
24
|
+
spec/todo_store_specs.rb
|
25
|
+
website/index.html
|
26
|
+
website/index.txt
|
27
|
+
website/javascripts/rounded_corners_lite.inc.js
|
28
|
+
website/stylesheets/screen.css
|
29
|
+
website/template.html.erb
|
data/PostInstall.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
= Simple command-line todo list manager
|
2
|
+
|
3
|
+
Really want to get things done? Don't want to juggle with web based todo lists?
|
4
|
+
Get your things done with command-line. No hassle, no distraction - Try out todo ruby gem.
|
5
|
+
|
6
|
+
|
7
|
+
== FEATURES:
|
8
|
+
|
9
|
+
* Uses human readable YAML to store the todo lists (You could edit the todo list manually)
|
10
|
+
* Supportss project specific todo lists. (Just run 'todo create' in your project directory)
|
11
|
+
* Supports tagging.
|
12
|
+
|
13
|
+
== Install
|
14
|
+
|
15
|
+
First make sure you install the dependency gems.
|
16
|
+
sudo gem install main
|
17
|
+
sudo gem install highline
|
18
|
+
|
19
|
+
then;
|
20
|
+
sudo gem install todo
|
21
|
+
|
22
|
+
You can also install from github:
|
23
|
+
gem sources -a http://gems.github.com
|
24
|
+
sudo gem install laktek-todo
|
25
|
+
|
26
|
+
== Example:
|
27
|
+
|
28
|
+
Here is a small sample on how to use todo gem
|
29
|
+
|
30
|
+
#visit your project folder
|
31
|
+
cd projects/newapp
|
32
|
+
|
33
|
+
#create a new todo list for the project
|
34
|
+
todo create
|
35
|
+
|
36
|
+
#add a new task
|
37
|
+
todo add "write the specs"
|
38
|
+
- add tags : important, due:24/08/2008
|
39
|
+
|
40
|
+
#listing all tasks
|
41
|
+
todo list --all
|
42
|
+
|
43
|
+
#listing tasks tagged 'important'
|
44
|
+
todo list --tag important
|
45
|
+
|
46
|
+
#removing a task by name
|
47
|
+
todo remove "write the specs"
|
48
|
+
|
49
|
+
#removing a task by index
|
50
|
+
todo remove -i 1
|
51
|
+
|
52
|
+
== Issues/Improvements
|
53
|
+
|
54
|
+
Todo is still its infant days and have very minimum functionality. If you come across any issues or like to suggest any improvements, please feel free to contact me : lakshan [at] web2media [dot] net
|
55
|
+
|
56
|
+
|
57
|
+
|
data/Rakefile
ADDED
data/bin/todo
ADDED
data/config/hoe.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'todo/version'
|
2
|
+
|
3
|
+
AUTHOR = 'Lakshan Perera' # can also be an array of Authors
|
4
|
+
EMAIL = "lakshan@web2media.net"
|
5
|
+
DESCRIPTION = "simple command line todo list manager"
|
6
|
+
GEM_NAME = 'todo' # what ppl will type to install your gem
|
7
|
+
RUBYFORGE_PROJECT = 'todo' # The unix name for your project
|
8
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
9
|
+
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
10
|
+
EXTRA_DEPENDENCIES = [['main', '>= 2.8.2'], ['highline', '>= 1.4.0']]
|
11
|
+
|
12
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
13
|
+
@config = nil
|
14
|
+
RUBYFORGE_USERNAME = "unknown"
|
15
|
+
def rubyforge_username
|
16
|
+
unless @config
|
17
|
+
begin
|
18
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
19
|
+
rescue
|
20
|
+
puts <<-EOS
|
21
|
+
ERROR: No rubyforge config file found: #{@config_file}
|
22
|
+
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
23
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
24
|
+
EOS
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
end
|
28
|
+
RUBYFORGE_USERNAME.replace @config["username"]
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
REV = nil
|
33
|
+
# UNCOMMENT IF REQUIRED:
|
34
|
+
# REV = YAML.load(`svn info`)['Revision']
|
35
|
+
VERS = Todo::VERSION::STRING + (REV ? ".#{REV}" : "")
|
36
|
+
RDOC_OPTS = ['--quiet', '--title', 'todo documentation',
|
37
|
+
"--opname", "index.html",
|
38
|
+
"--line-numbers",
|
39
|
+
"--main", "README",
|
40
|
+
"--inline-source"]
|
41
|
+
|
42
|
+
class Hoe
|
43
|
+
def extra_deps
|
44
|
+
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
45
|
+
@extra_deps
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Generate all the Rake tasks
|
50
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
51
|
+
$hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
52
|
+
p.developer(AUTHOR, EMAIL)
|
53
|
+
p.description = DESCRIPTION
|
54
|
+
p.summary = DESCRIPTION
|
55
|
+
p.url = HOMEPATH
|
56
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
57
|
+
p.test_globs = ["test/**/test_*.rb"]
|
58
|
+
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
59
|
+
|
60
|
+
# == Optional
|
61
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
62
|
+
p.extra_deps = EXTRA_DEPENDENCIES
|
63
|
+
|
64
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
65
|
+
end
|
66
|
+
|
67
|
+
CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
68
|
+
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
69
|
+
$hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
70
|
+
$hoe.rsync_args = '-av --delete --ignore-errors'
|
71
|
+
$hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
include FileUtils
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
%w[rake hoe newgem rubigen].each do |req_gem|
|
6
|
+
begin
|
7
|
+
require req_gem
|
8
|
+
rescue LoadError
|
9
|
+
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
10
|
+
puts "Installation: gem install #{req_gem} -y"
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
data/lib/todo.rb
ADDED
data/lib/todo/cli.rb
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'main'
|
3
|
+
require 'highline/import'
|
4
|
+
require 'ftools'
|
5
|
+
|
6
|
+
def read_file(environment)
|
7
|
+
file = environment.nil? ? Todo::Store.read('.todo/list.yml') : Todo::Store.read(environment)
|
8
|
+
end
|
9
|
+
|
10
|
+
def write_file(list, environment)
|
11
|
+
file = environment.nil? ? Todo::Store.write(list, '.todo/list.yml') : Todo::Store.write(list, environment)
|
12
|
+
end
|
13
|
+
|
14
|
+
Main {
|
15
|
+
def run
|
16
|
+
puts "todo [command] --help for usage instructions."
|
17
|
+
puts "The available commands are: \n add, remove, list, modify."
|
18
|
+
end
|
19
|
+
|
20
|
+
mode 'create' do
|
21
|
+
description 'Creates a new todo list for this directory'
|
22
|
+
|
23
|
+
def run
|
24
|
+
unless File.exist?(".todo/list.yml")
|
25
|
+
File.makedirs(".todo")
|
26
|
+
newfile = File.new(".todo/list.yml", "w+")
|
27
|
+
say "Created a new todo list inside this directory" if newfile
|
28
|
+
newfile.close
|
29
|
+
else
|
30
|
+
say "Todo list already exists inside this directory"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
mode 'add' do
|
36
|
+
description 'Adds a new todo item'
|
37
|
+
argument('item'){
|
38
|
+
description 'todo item to add'
|
39
|
+
}
|
40
|
+
|
41
|
+
environment('FILE'){
|
42
|
+
synopsis 'export FILE=path'
|
43
|
+
}
|
44
|
+
|
45
|
+
option('notags', 'n'){
|
46
|
+
cast :bool
|
47
|
+
default false
|
48
|
+
}
|
49
|
+
|
50
|
+
def run
|
51
|
+
unless params['notags'].value
|
52
|
+
tags = ask("Enter tags for this item (seperate from commas) ", lambda {|str|
|
53
|
+
str.split(/,\s*/) })
|
54
|
+
end
|
55
|
+
|
56
|
+
#read the YAML file
|
57
|
+
if list=read_file(params['FILE'].value)
|
58
|
+
#add the task
|
59
|
+
list.add(params['item'].value, tags)
|
60
|
+
#write the changes
|
61
|
+
say "Successfully added your task." if write_file(list, params['FILE'].value)
|
62
|
+
else
|
63
|
+
say "Todo list file is invalid or do not exist."
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
mode 'remove' do
|
69
|
+
description 'Removes an item from todo list'
|
70
|
+
|
71
|
+
environment('FILE'){
|
72
|
+
synopsis 'export FILE=path'
|
73
|
+
}
|
74
|
+
|
75
|
+
argument('item'){
|
76
|
+
argument_optional
|
77
|
+
description 'Name of the todo item to remove'
|
78
|
+
}
|
79
|
+
|
80
|
+
option('index', 'i'){
|
81
|
+
cast :int
|
82
|
+
argument :required
|
83
|
+
description 'Index of the todo item to remove (starting from 1). Use instead of item name'
|
84
|
+
}
|
85
|
+
|
86
|
+
def run
|
87
|
+
if list=read_file(params['FILE'].value)
|
88
|
+
if list.remove(params['item'].value || params['index'].value)
|
89
|
+
say "Removed item from the list." if write_file(list, params['FILE'].value)
|
90
|
+
else
|
91
|
+
say "Could not find item to remove."
|
92
|
+
end
|
93
|
+
else
|
94
|
+
say "Todo list file is invalid or do not exist."
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
mode 'list' do
|
100
|
+
description 'Lists todo items'
|
101
|
+
|
102
|
+
environment('FILE'){
|
103
|
+
synopsis 'export barfoo=value'
|
104
|
+
}
|
105
|
+
|
106
|
+
option('tag', 't'){
|
107
|
+
argument_required
|
108
|
+
}
|
109
|
+
|
110
|
+
option('all=[all]', 'a'){ # note shortcut syntax for optional args
|
111
|
+
#argument_optional # we could also use this method
|
112
|
+
cast :bool
|
113
|
+
default false
|
114
|
+
}
|
115
|
+
|
116
|
+
def run
|
117
|
+
if list=read_file(params['FILE'].value)
|
118
|
+
|
119
|
+
if params['tag'].given?
|
120
|
+
title = "Listing todos tagged '#{params['tag'].value}'"
|
121
|
+
tasks = list.tagged(params['tag'].value)
|
122
|
+
else
|
123
|
+
title = "Listing all todos"
|
124
|
+
tasks = list
|
125
|
+
end
|
126
|
+
|
127
|
+
say title
|
128
|
+
tasks.each do |task, tags|
|
129
|
+
tag_string = ("(#{tags.join(", ")})") unless tags.include?(nil)
|
130
|
+
say " - #{task} #{tag_string} \n"
|
131
|
+
end
|
132
|
+
else
|
133
|
+
say "Todo list file is invalid or do not exist."
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
}
|
data/lib/todo/list.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Todo
|
2
|
+
|
3
|
+
class List < Hash
|
4
|
+
|
5
|
+
def tagged(tag)
|
6
|
+
self.reject do |name, tags|
|
7
|
+
not tags.include?(tag)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def add(task, *tags)
|
12
|
+
self.store(task, tags.flatten)
|
13
|
+
self
|
14
|
+
end
|
15
|
+
|
16
|
+
#Returns the list after removing specific item
|
17
|
+
def remove(task)
|
18
|
+
#find key by index
|
19
|
+
task = self.keys[task - 1] if task.instance_of? Fixnum
|
20
|
+
self if self.delete(task)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
data/lib/todo/store.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module Todo
|
5
|
+
class Store
|
6
|
+
def self.read(file)
|
7
|
+
begin
|
8
|
+
loaded_list = YAML::load( File.open( file ) )
|
9
|
+
loaded_list ? List[loaded_list] : List.new
|
10
|
+
rescue
|
11
|
+
nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.write(list, file)
|
16
|
+
begin
|
17
|
+
File.open( file, 'w' ) do |f|
|
18
|
+
f << list.to_yaml
|
19
|
+
end
|
20
|
+
rescue
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
data/lib/todo/version.rb
ADDED
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/todo.rb'}"
|
9
|
+
puts "Loading todo gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|