tdo 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.markdown +8 -0
- data/Rakefile +52 -0
- data/VERSION +1 -0
- data/bin/tdo +49 -0
- data/lib/tdo.rb +115 -0
- data/tdo.gemspec +57 -0
- data/test/helper.rb +10 -0
- data/test/test_tdo.rb +7 -0
- metadata +85 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Joshua Hawxwell
|
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/README.markdown
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "tdo"
|
8
|
+
gem.summary = %Q{Tdo, a simple ruby app to manage your todo list}
|
9
|
+
gem.description = %Q{Tdo is a simple ruby app to add, edit and read your todo list. It stores the list at ~/.todo.txt}
|
10
|
+
gem.email = "m@hawx.me"
|
11
|
+
gem.homepage = "http://github.com/hawx/tdo"
|
12
|
+
gem.authors = ["Joshua Hawxwell"]
|
13
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
Jeweler::GemcutterTasks.new
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'rake/testtask'
|
22
|
+
Rake::TestTask.new(:test) do |test|
|
23
|
+
test.libs << 'lib' << 'test'
|
24
|
+
test.pattern = 'test/**/test_*.rb'
|
25
|
+
test.verbose = true
|
26
|
+
end
|
27
|
+
|
28
|
+
begin
|
29
|
+
require 'rcov/rcovtask'
|
30
|
+
Rcov::RcovTask.new do |test|
|
31
|
+
test.libs << 'test'
|
32
|
+
test.pattern = 'test/**/test_*.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
rescue LoadError
|
36
|
+
task :rcov do
|
37
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
task :test => :check_dependencies
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
begin
|
46
|
+
require 'yard'
|
47
|
+
YARD::Rake::YardocTask.new
|
48
|
+
rescue LoadError
|
49
|
+
task :yardoc do
|
50
|
+
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
|
51
|
+
end
|
52
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
data/bin/tdo
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.join( File.dirname(__FILE__), '..', 'lib', 'tdo' )
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
banner = <<EOS
|
7
|
+
Usage: tdo [options]
|
8
|
+
tdo @group "task"
|
9
|
+
EOS
|
10
|
+
|
11
|
+
opts = OptionParser.new do |opts|
|
12
|
+
opts.banner = banner
|
13
|
+
opts.on("--read [group]", "-r", "Read tasks") do |group|
|
14
|
+
puts Tdo.read_tasks( group )
|
15
|
+
exit 0
|
16
|
+
end
|
17
|
+
|
18
|
+
opts.on("--done", "-d", "Mark item as done, in group (optional)") do
|
19
|
+
if ARGV.size == 2
|
20
|
+
item = ARGV[1].to_i if Float(ARGV[1]) rescue item = ARGV[1]
|
21
|
+
Tdo.mark_done(item, ARGV[0])
|
22
|
+
elsif ARGV.size == 1
|
23
|
+
item = ARGV[0].to_i if Float(ARGV[0]) rescue item = ARGV[0]
|
24
|
+
Tdo.mark_done(item)
|
25
|
+
end
|
26
|
+
exit 0
|
27
|
+
end
|
28
|
+
|
29
|
+
opts.on("--clear", "-c", "Clear done items") do
|
30
|
+
Tdo.clear_done
|
31
|
+
exit 0
|
32
|
+
end
|
33
|
+
|
34
|
+
opts.on("--version", "Show version") do
|
35
|
+
puts "Tdo: #{File.read( File.join(File.dirname(__FILE__), '..', 'VERSION') )}"
|
36
|
+
exit 0
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
opts.parse!
|
41
|
+
|
42
|
+
|
43
|
+
if ARGV.size == 2
|
44
|
+
Tdo.add_task(ARGV[1], ARGV[0][1..-1])
|
45
|
+
elsif ARGV.size == 1
|
46
|
+
Tdo.add_task(ARGV[0])
|
47
|
+
else
|
48
|
+
puts "Run tdo -h for help"
|
49
|
+
end
|
data/lib/tdo.rb
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
|
2
|
+
module Tdo
|
3
|
+
|
4
|
+
TODO_FILE = File.expand_path "~/.todo.txt"
|
5
|
+
|
6
|
+
# Reads the TODO file
|
7
|
+
#
|
8
|
+
# @param [String] group to read tasks from
|
9
|
+
# @return [String] the tasks
|
10
|
+
def self.read_tasks( group=nil )
|
11
|
+
unless group
|
12
|
+
File.new(TODO_FILE, "r").read
|
13
|
+
else
|
14
|
+
t = File.new(TODO_FILE, "r").read
|
15
|
+
to_s( to_hash(t)[ group[1..-1] ] )
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Allows you to add a new task to the file
|
20
|
+
#
|
21
|
+
# @param [String] task to add
|
22
|
+
# @param [String] group to add the task to
|
23
|
+
def self.add_task( task, group='ungrouped' )
|
24
|
+
t = to_hash( self.read_tasks )
|
25
|
+
t[group] ||= [] # need to create new group if it doesn't exist
|
26
|
+
t[group] << task.strip
|
27
|
+
|
28
|
+
f = File.new(TODO_FILE, "w")
|
29
|
+
f.puts to_s(t)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Marks the selected item as done
|
33
|
+
#
|
34
|
+
# @param [String, Integer] task to mark as done
|
35
|
+
# @param [String] group that the task belongs to
|
36
|
+
def self.mark_done( id, group='ungrouped' )
|
37
|
+
group = group[1..-1]
|
38
|
+
|
39
|
+
t = to_hash( self.read_tasks )
|
40
|
+
if id.is_a? String
|
41
|
+
begin
|
42
|
+
t[group].each_with_index do |task, i|
|
43
|
+
if task.include? id
|
44
|
+
t[group][i] += ' #done'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
rescue
|
48
|
+
p "Group, #{group}, does not exist"
|
49
|
+
end
|
50
|
+
elsif id.is_a? Integer
|
51
|
+
t[group][id] += ' #done'
|
52
|
+
end
|
53
|
+
|
54
|
+
f = File.new(TODO_FILE, "w")
|
55
|
+
f.puts to_s(t)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Deletes all items which have been marked done
|
59
|
+
#
|
60
|
+
def self.clear_done
|
61
|
+
t = to_hash( self.read_tasks )
|
62
|
+
t.each do |group, tasks|
|
63
|
+
tasks.delete_if {|i| i.include? ' #done' }
|
64
|
+
end
|
65
|
+
|
66
|
+
f = File.new(TODO_FILE, "w")
|
67
|
+
f.puts to_s(t)
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
# Converts the string read from the file to a hash so it can easily be used
|
72
|
+
#
|
73
|
+
# @param [String] read file string
|
74
|
+
# @return [Hash] the string as a hash
|
75
|
+
def self.to_hash( s )
|
76
|
+
r = {'ungrouped' => []}
|
77
|
+
last_group ||= ''
|
78
|
+
s.split("\n").each do |l|
|
79
|
+
if l[0] == '@'
|
80
|
+
last_group = l[1..-1].strip
|
81
|
+
r[last_group] = []
|
82
|
+
elsif l[1] == '-'
|
83
|
+
r[last_group] << l[2..-1].strip
|
84
|
+
elsif l[0] == '-'
|
85
|
+
r['ungrouped'] << l[1..-1].strip
|
86
|
+
end
|
87
|
+
end
|
88
|
+
r
|
89
|
+
end
|
90
|
+
|
91
|
+
# Converts the given hash to a string which can then be written to a file
|
92
|
+
#
|
93
|
+
# @param [Hash] hash of todo tasks
|
94
|
+
# @return [String] string representation of hash
|
95
|
+
def self.to_s( hash )
|
96
|
+
if !hash.is_a? Hash
|
97
|
+
hash = {'ungrouped' => hash}
|
98
|
+
end
|
99
|
+
r = ""
|
100
|
+
hash.each do |group, tasks|
|
101
|
+
if group == 'ungrouped'
|
102
|
+
tasks.each do |task|
|
103
|
+
r += "- #{task}\n"
|
104
|
+
end
|
105
|
+
else
|
106
|
+
r += "\n@#{group}\n"
|
107
|
+
tasks.each do |task|
|
108
|
+
r += " - #{task}\n"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
r
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
data/tdo.gemspec
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{tdo}
|
8
|
+
s.version = "0.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Joshua Hawxwell"]
|
12
|
+
s.date = %q{2010-06-11}
|
13
|
+
s.default_executable = %q{tdo}
|
14
|
+
s.description = %q{Tdo is a simple ruby app to add, edit and read your todo list. It stores the list at ~/.todo.txt}
|
15
|
+
s.email = %q{m@hawx.me}
|
16
|
+
s.executables = ["tdo"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE",
|
19
|
+
"README.markdown"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".gitignore",
|
24
|
+
"LICENSE",
|
25
|
+
"README.markdown",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"bin/tdo",
|
29
|
+
"lib/tdo.rb",
|
30
|
+
"tdo.gemspec",
|
31
|
+
"test/helper.rb",
|
32
|
+
"test/test_tdo.rb"
|
33
|
+
]
|
34
|
+
s.homepage = %q{http://github.com/hawx/tdo}
|
35
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
s.rubygems_version = %q{1.3.6}
|
38
|
+
s.summary = %q{Tdo, a simple ruby app to manage your todo list}
|
39
|
+
s.test_files = [
|
40
|
+
"test/helper.rb",
|
41
|
+
"test/test_tdo.rb"
|
42
|
+
]
|
43
|
+
|
44
|
+
if s.respond_to? :specification_version then
|
45
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
46
|
+
s.specification_version = 3
|
47
|
+
|
48
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
49
|
+
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
50
|
+
else
|
51
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
52
|
+
end
|
53
|
+
else
|
54
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
data/test/helper.rb
ADDED
data/test/test_tdo.rb
ADDED
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tdo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 0.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Joshua Hawxwell
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-06-11 00:00:00 +01:00
|
18
|
+
default_executable: tdo
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: thoughtbot-shoulda
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :development
|
31
|
+
version_requirements: *id001
|
32
|
+
description: Tdo is a simple ruby app to add, edit and read your todo list. It stores the list at ~/.todo.txt
|
33
|
+
email: m@hawx.me
|
34
|
+
executables:
|
35
|
+
- tdo
|
36
|
+
extensions: []
|
37
|
+
|
38
|
+
extra_rdoc_files:
|
39
|
+
- LICENSE
|
40
|
+
- README.markdown
|
41
|
+
files:
|
42
|
+
- .document
|
43
|
+
- .gitignore
|
44
|
+
- LICENSE
|
45
|
+
- README.markdown
|
46
|
+
- Rakefile
|
47
|
+
- VERSION
|
48
|
+
- bin/tdo
|
49
|
+
- lib/tdo.rb
|
50
|
+
- tdo.gemspec
|
51
|
+
- test/helper.rb
|
52
|
+
- test/test_tdo.rb
|
53
|
+
has_rdoc: true
|
54
|
+
homepage: http://github.com/hawx/tdo
|
55
|
+
licenses: []
|
56
|
+
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options:
|
59
|
+
- --charset=UTF-8
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
version: "0"
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
76
|
+
requirements: []
|
77
|
+
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 1.3.6
|
80
|
+
signing_key:
|
81
|
+
specification_version: 3
|
82
|
+
summary: Tdo, a simple ruby app to manage your todo list
|
83
|
+
test_files:
|
84
|
+
- test/helper.rb
|
85
|
+
- test/test_tdo.rb
|