things-rb 0.3.0 → 0.4.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.
- data/CHANGELOG +6 -0
- data/README.markdown +18 -8
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/bin/things +13 -5
- data/lib/things/document.rb +1 -1
- data/lib/things/focus.rb +4 -0
- data/lib/things/task.rb +20 -5
- data/lib/things/version.rb +1 -1
- data/test/test_focus.rb +11 -0
- data/test/test_helper.rb +2 -1
- data/test/test_task.rb +8 -0
- data/things-rb.gemspec +4 -4
- metadata +25 -9
data/CHANGELOG
CHANGED
data/README.markdown
CHANGED
@@ -15,13 +15,13 @@ There are many reasons why you would use a command line version of Things, inclu
|
|
15
15
|
|
16
16
|
## Install
|
17
17
|
|
18
|
-
$
|
18
|
+
$ gem install things-rb
|
19
19
|
|
20
20
|
If you're on default Mac OS X Leopard and haven't upgraded your RubyGem installation you'll need to to this first:
|
21
21
|
|
22
|
-
$
|
22
|
+
$ gem update --system
|
23
23
|
|
24
|
-
When the upgrade is done, just
|
24
|
+
When the upgrade is done, just run the `gem install ...` command above and you're set.
|
25
25
|
|
26
26
|
|
27
27
|
## Usage
|
@@ -38,8 +38,7 @@ Example usage:
|
|
38
38
|
tasks = things.today.map do |task|
|
39
39
|
tags = "(#{task.tags.join(' ')})" if task.tags?
|
40
40
|
project = "[#{task.parent}]" if task.parent?
|
41
|
-
bullet
|
42
|
-
[bullet, task.title, tags, project].compact.join(" ")
|
41
|
+
[task.bullet, task.title, tags, project].compact.join(" ")
|
43
42
|
end
|
44
43
|
|
45
44
|
puts tasks.compact.sort.join("\n")
|
@@ -71,17 +70,28 @@ Replace `today` with other focus to list the task
|
|
71
70
|
$ things --all next
|
72
71
|
$ things logbook
|
73
72
|
|
73
|
+
To just show tasks with a specific tag, use the `-t` or `--tag` option
|
74
|
+
|
75
|
+
$ things -t errands today
|
76
|
+
|
74
77
|
|
75
78
|
## Testing
|
76
79
|
|
77
|
-
To view test document (`test/fixtures/Database.xml`) in Things, just launch Things
|
80
|
+
To view the test document (`test/fixtures/Database.xml`) in Things, just launch Things with ⌥ (option/alt) down and click "Choose Library" and point it to `things-rb/test/fixtures`.
|
78
81
|
Be sure to disable automatic logging of completed tasks in the Things.app preferences so they won't be moved around in the document.
|
79
82
|
|
83
|
+
To play nice with other package managers than Rubygems, the command line tool (`bin/things`) and the tests `test/test_helper.rb` *don't* `require 'rubygems'` before `require 'hpricot'`. So if hpricot isn't in your path you need to run the tests slightly different.
|
84
|
+
|
85
|
+
`RUBYOPT=rubygems rake` works for me to load hpricot and the other required gems, but still test the local things version (i.e. not the gem).
|
86
|
+
|
87
|
+
Run the local command line tool using `ruby -r rubygems -I lib bin/things`.
|
88
|
+
|
89
|
+
Of course you can just add the require statements in your code in development without committing them.
|
90
|
+
|
80
91
|
|
81
92
|
## TODO
|
82
93
|
- Support "Projects" focus
|
83
94
|
- Optimize test and XML queries
|
84
|
-
- Add tag support to binary
|
85
95
|
- Organize the classes, make internal methods private
|
86
96
|
|
87
97
|
|
@@ -89,7 +99,7 @@ Be sure to disable automatic logging of completed tasks in the Things.app prefer
|
|
89
99
|
|
90
100
|
By [Martin Ström](http://my-domain.se) under the MIT license:
|
91
101
|
|
92
|
-
> Copyright (c) 2009 Martin Ström
|
102
|
+
> Copyright (c) 2009-2010 Martin Ström
|
93
103
|
>
|
94
104
|
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
95
105
|
> of this software and associated documentation files (the "Software"), to deal
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/bin/things
CHANGED
@@ -1,14 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require 'rubygems'
|
3
4
|
require "optparse"
|
5
|
+
|
6
|
+
$: << File.dirname(__FILE__) + '/lib/things'
|
7
|
+
|
4
8
|
require 'things'
|
5
9
|
|
6
10
|
options = { :tasks => { :completed => false } }
|
11
|
+
|
7
12
|
opts = OptionParser.new do |opts|
|
8
13
|
opts.separator ''
|
9
14
|
opts.separator 'Options:'
|
10
|
-
|
11
|
-
opts.banner = "Usage: things [options] today|next|inbox|logbook|trash"
|
15
|
+
opts.banner = "Usage: things [options] today|next|inbox|someday|logbook|trash"
|
12
16
|
|
13
17
|
def opts.show_usage
|
14
18
|
puts self
|
@@ -20,8 +24,9 @@ opts = OptionParser.new do |opts|
|
|
20
24
|
end
|
21
25
|
|
22
26
|
opts.on("-c", "--completed", 'Shows only completed tasks') { options[:tasks] = { :completed => true } }
|
23
|
-
opts.on("-a", "--all", 'Shows all tasks in the focus') {
|
24
|
-
|
27
|
+
opts.on("-a", "--all", 'Shows all tasks in the focus') { options[:tasks].delete(:completed) }
|
28
|
+
opts.on("-t TAG", "--tag TAG", 'Filter tasks by tag') { |f| options[:tasks][:tag] = f }
|
29
|
+
|
25
30
|
opts.on_tail("-h", "--help", "Shows this help message") { opts.show_usage }
|
26
31
|
opts.on_tail("-v", "--version", "Shows version") do
|
27
32
|
puts Things::Version::STRING
|
@@ -48,5 +53,8 @@ tasks = things.focus(options[:focus]).tasks(options[:tasks]).map do |task|
|
|
48
53
|
[task.bullet, task.title, tags, project].compact.join(" ")
|
49
54
|
end
|
50
55
|
|
51
|
-
|
56
|
+
if (sorted = tasks.compact.sort).any?
|
57
|
+
puts sorted.join("\n")
|
58
|
+
end
|
59
|
+
|
52
60
|
|
data/lib/things/document.rb
CHANGED
@@ -19,7 +19,7 @@ module Things
|
|
19
19
|
@focus_cache[name] ||= Focus.new(name, @doc)
|
20
20
|
end
|
21
21
|
|
22
|
-
[:today, :inbox, :trash, :logbook, :next, :scheduled].each do |name|
|
22
|
+
[:today, :inbox, :trash, :logbook, :next, :scheduled, :someday].each do |name|
|
23
23
|
class_eval <<-EOF
|
24
24
|
def #{name}(options = {}) # def inbox(options = {})
|
25
25
|
focus(:#{name}).tasks(options) # focus(:inbox).tasks(options)
|
data/lib/things/focus.rb
CHANGED
data/lib/things/task.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
1
2
|
module Things
|
2
3
|
class Task
|
3
4
|
include Comparable
|
@@ -5,14 +6,21 @@ module Things
|
|
5
6
|
INCOMPLETED = 0
|
6
7
|
CANCELED = 2
|
7
8
|
COMPLETED = 3
|
8
|
-
|
9
|
+
CHECK_MARK = "✓"
|
10
|
+
X_MARK = "×"
|
11
|
+
MINUS_MARK = "-"
|
12
|
+
|
9
13
|
def initialize(task_xml, doc)
|
10
14
|
@doc = doc
|
11
15
|
@xml_node = task_xml
|
12
16
|
end
|
13
17
|
|
14
18
|
def title
|
15
|
-
@xml_node.at("attribute[@name='title']")
|
19
|
+
if n = @xml_node.at("attribute[@name='title']")
|
20
|
+
n.inner_text
|
21
|
+
else
|
22
|
+
"FAIL: [#{@xml_node}]"
|
23
|
+
end
|
16
24
|
end
|
17
25
|
|
18
26
|
alias_method :to_s, :title
|
@@ -44,7 +52,7 @@ module Things
|
|
44
52
|
end
|
45
53
|
|
46
54
|
def tag?(name)
|
47
|
-
tags.
|
55
|
+
tags.any? { |t| t.casecmp(name) == 0 }
|
48
56
|
end
|
49
57
|
|
50
58
|
def parent_id
|
@@ -101,7 +109,7 @@ module Things
|
|
101
109
|
end
|
102
110
|
|
103
111
|
def due?
|
104
|
-
due_date && Time.now > due_date
|
112
|
+
!!due_date && Time.now > due_date
|
105
113
|
end
|
106
114
|
|
107
115
|
def scheduled_date
|
@@ -113,7 +121,14 @@ module Things
|
|
113
121
|
end
|
114
122
|
|
115
123
|
def bullet
|
116
|
-
|
124
|
+
case
|
125
|
+
when completed?
|
126
|
+
CHECK_MARK
|
127
|
+
when canceled?
|
128
|
+
X_MARK
|
129
|
+
else
|
130
|
+
MINUS_MARK
|
131
|
+
end
|
117
132
|
end
|
118
133
|
|
119
134
|
def children_ids
|
data/lib/things/version.rb
CHANGED
data/test/test_focus.rb
CHANGED
@@ -89,6 +89,17 @@ class FocusTest < Test::Unit::TestCase
|
|
89
89
|
assert !canceled.all? { |e| e.title.include?("cancel") }
|
90
90
|
end
|
91
91
|
|
92
|
+
test "should not find canceled nor completed tasks when passing :canceled => false, :completed => false" do
|
93
|
+
tasks = @things.focus(:next).tasks(:canceled => false, :completed => false)
|
94
|
+
assert_equal 0, tasks.select(&:canceled?).length
|
95
|
+
assert_equal 0, tasks.select(&:completed?).length
|
96
|
+
end
|
97
|
+
|
98
|
+
test "should filter tasks by tag" do
|
99
|
+
tasks = @things.focus(:next).tasks(:tag => 'home')
|
100
|
+
assert tasks.all? { |e| e.tag?('home') }
|
101
|
+
end
|
102
|
+
|
92
103
|
test "should not include projects when listing tasks" do
|
93
104
|
with_children = @things.focus(:next).tasks.select(&:children?)
|
94
105
|
assert_equal 0, with_children.length
|
data/test/test_helper.rb
CHANGED
data/test/test_task.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
1
3
|
require 'test_helper'
|
2
4
|
|
3
5
|
class TaskTest < Test::Unit::TestCase
|
@@ -65,6 +67,12 @@ class TaskTest < Test::Unit::TestCase
|
|
65
67
|
assert(!task.tag?("Errand"))
|
66
68
|
end
|
67
69
|
|
70
|
+
test "if the task has a specific tag in other case" do
|
71
|
+
task = find_task(:with_tags)
|
72
|
+
assert task.tag?("HOME")
|
73
|
+
assert !task.tag?("errand")
|
74
|
+
end
|
75
|
+
|
68
76
|
test "should find the tasks parent_id" do
|
69
77
|
task = find_task(:with_parent)
|
70
78
|
assert_equal("z154", task.parent_id)
|
data/things-rb.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{things-rb}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Martin Str\303\266m"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-06-23}
|
13
13
|
s.default_executable = %q{things}
|
14
14
|
s.description = %q{Library and command-line tool for accessing Things.app databases}
|
15
15
|
s.email = %q{name@my-domain.se}
|
@@ -41,7 +41,7 @@ Gem::Specification.new do |s|
|
|
41
41
|
s.homepage = %q{http://github.com/haraldmartin/things-rb}
|
42
42
|
s.rdoc_options = ["--charset=UTF-8"]
|
43
43
|
s.require_paths = ["lib"]
|
44
|
-
s.rubygems_version = %q{1.3.
|
44
|
+
s.rubygems_version = %q{1.3.7}
|
45
45
|
s.summary = %q{Library and command-line tool for accessing Things.app databases}
|
46
46
|
s.test_files = [
|
47
47
|
"test/test_document.rb",
|
@@ -54,7 +54,7 @@ Gem::Specification.new do |s|
|
|
54
54
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
55
55
|
s.specification_version = 3
|
56
56
|
|
57
|
-
if Gem::Version.new(Gem::
|
57
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
58
58
|
s.add_runtime_dependency(%q<hpricot>, [">= 0"])
|
59
59
|
else
|
60
60
|
s.add_dependency(%q<hpricot>, [">= 0"])
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: things-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 15
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 4
|
9
|
+
- 0
|
10
|
+
version: 0.4.0
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- "Martin Str\xC3\xB6m"
|
@@ -9,19 +15,23 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date: 2010-
|
18
|
+
date: 2010-06-23 00:00:00 +02:00
|
13
19
|
default_executable: things
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
22
|
name: hpricot
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
20
26
|
requirements:
|
21
27
|
- - ">="
|
22
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
23
32
|
version: "0"
|
24
|
-
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
25
35
|
description: Library and command-line tool for accessing Things.app databases
|
26
36
|
email: name@my-domain.se
|
27
37
|
executables:
|
@@ -60,21 +70,27 @@ rdoc_options:
|
|
60
70
|
require_paths:
|
61
71
|
- lib
|
62
72
|
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
63
74
|
requirements:
|
64
75
|
- - ">="
|
65
76
|
- !ruby/object:Gem::Version
|
77
|
+
hash: 3
|
78
|
+
segments:
|
79
|
+
- 0
|
66
80
|
version: "0"
|
67
|
-
version:
|
68
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
69
83
|
requirements:
|
70
84
|
- - ">="
|
71
85
|
- !ruby/object:Gem::Version
|
86
|
+
hash: 3
|
87
|
+
segments:
|
88
|
+
- 0
|
72
89
|
version: "0"
|
73
|
-
version:
|
74
90
|
requirements: []
|
75
91
|
|
76
92
|
rubyforge_project:
|
77
|
-
rubygems_version: 1.3.
|
93
|
+
rubygems_version: 1.3.7
|
78
94
|
signing_key:
|
79
95
|
specification_version: 3
|
80
96
|
summary: Library and command-line tool for accessing Things.app databases
|