omnifocus 1.1.0 → 1.2.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/History.txt +9 -0
- data/Manifest.txt +1 -0
- data/bin/omnifocus_new +20 -0
- data/lib/omnifocus.rb +61 -11
- metadata +4 -2
data/History.txt
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
=== 1.2.0 / 2009-07-30
|
2
|
+
|
3
|
+
* 3 minor enhancements:
|
4
|
+
|
5
|
+
* Added omnifocus_new so I can create tasks via shell. yay!
|
6
|
+
* Cleaned up a fair amount of appscript calls, mostly negated by changes for OF's model.
|
7
|
+
* Figured out the necessary appscript to navigate OmniFocus' byzantine hierarchical object model.
|
8
|
+
* adding methods: all_{tasks,folders,projects}
|
9
|
+
|
1
10
|
=== 1.1.0 / 2009-07-28
|
2
11
|
|
3
12
|
* 3 minor enhancements:
|
data/Manifest.txt
CHANGED
data/bin/omnifocus_new
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'mechanize'
|
5
|
+
require 'appscript'
|
6
|
+
|
7
|
+
project_name = ARGV.shift
|
8
|
+
title = ($stdin.tty? ? ARGV.join(" ") : $stdin.read).strip
|
9
|
+
|
10
|
+
abort "need project and title" unless project_name && ! title.empty?
|
11
|
+
|
12
|
+
include Appscript
|
13
|
+
|
14
|
+
omnifocus = app('OmniFocus').documents[1]
|
15
|
+
|
16
|
+
projects = omnifocus.sections.projects[its.name.eq(project_name)]
|
17
|
+
project = projects.get.flatten.grep(Appscript::Reference).first
|
18
|
+
project.make :new => :task, :with_properties => {:name => title}
|
19
|
+
|
20
|
+
puts "created task in #{project_name}: #{title}"
|
data/lib/omnifocus.rb
CHANGED
@@ -12,7 +12,7 @@ require 'appscript'
|
|
12
12
|
# bts_id: a string uniquely identifying a task: SYSTEM(-projectname)?#id
|
13
13
|
|
14
14
|
class OmniFocus
|
15
|
-
VERSION = '1.
|
15
|
+
VERSION = '1.2.0'
|
16
16
|
|
17
17
|
##
|
18
18
|
# bug_db = {
|
@@ -62,13 +62,64 @@ class OmniFocus
|
|
62
62
|
Appscript.its
|
63
63
|
end
|
64
64
|
|
65
|
+
def omnifocus
|
66
|
+
unless defined? @omnifocus then
|
67
|
+
@omnifocus = Appscript.app('OmniFocus').documents[1]
|
68
|
+
end
|
69
|
+
@omnifocus
|
70
|
+
end
|
71
|
+
|
72
|
+
def all_folders
|
73
|
+
queue = omnifocus.folders.get
|
74
|
+
folders = []
|
75
|
+
|
76
|
+
until queue.empty? do
|
77
|
+
folder = queue.shift
|
78
|
+
folders << folder
|
79
|
+
subfolders = folder.folders.get
|
80
|
+
queue.push(*subfolders)
|
81
|
+
end
|
82
|
+
|
83
|
+
folders
|
84
|
+
end
|
85
|
+
|
86
|
+
def all_projects
|
87
|
+
all_folders.map { |folder| folder.projects }
|
88
|
+
end
|
89
|
+
|
90
|
+
def all_tasks
|
91
|
+
queue = all_projects.map { |project| project.tasks.get }.flatten
|
92
|
+
tasks = []
|
93
|
+
|
94
|
+
until queue.empty? do
|
95
|
+
task = queue.shift
|
96
|
+
tasks << task
|
97
|
+
subtasks = task.tasks.get
|
98
|
+
queue.push(*subtasks)
|
99
|
+
end
|
100
|
+
|
101
|
+
tasks
|
102
|
+
end
|
103
|
+
|
104
|
+
##
|
105
|
+
# Utility shortcut to make a new thing with a name via appscript.
|
106
|
+
|
107
|
+
def make target, type, name, extra = {}
|
108
|
+
target.make :new => type, :with_properties => { :name => name }.merge(extra)
|
109
|
+
end
|
110
|
+
|
65
111
|
##
|
66
112
|
# Get all projects under the nerd folder
|
67
113
|
|
68
114
|
def nerd_projects
|
69
115
|
unless defined? @nerd_projects then
|
70
|
-
|
71
|
-
|
116
|
+
@nerd_projects = omnifocus.folders["nerd"]
|
117
|
+
|
118
|
+
begin
|
119
|
+
@nerd_projects.get
|
120
|
+
rescue
|
121
|
+
make omnifocus, :folder, "nerd"
|
122
|
+
end
|
72
123
|
end
|
73
124
|
|
74
125
|
@nerd_projects
|
@@ -79,7 +130,10 @@ class OmniFocus
|
|
79
130
|
# bug_db hash if they match a bts_id.
|
80
131
|
|
81
132
|
def prepopulate_existing_tasks
|
82
|
-
of_tasks =
|
133
|
+
of_tasks = all_tasks.find_all { |task|
|
134
|
+
task.name.get =~ /^([A-Z]+(?:-[\w-]+)?\#\d+)/
|
135
|
+
}
|
136
|
+
|
83
137
|
of_tasks.each do |of_task|
|
84
138
|
ticket_id = of_task.name.get[/^([A-Z]+(?:-[\w-]+)?\#\d+)/, 1]
|
85
139
|
project = of_task.containing_project.name.get
|
@@ -103,7 +157,7 @@ class OmniFocus
|
|
103
157
|
(bug_db.keys - nerd_projects.projects.name.get).each do |name|
|
104
158
|
warn "creating project #{name}"
|
105
159
|
next if $DEBUG
|
106
|
-
|
160
|
+
make nerd_projects, :project, name
|
107
161
|
end
|
108
162
|
end
|
109
163
|
|
@@ -114,7 +168,7 @@ class OmniFocus
|
|
114
168
|
|
115
169
|
def update_tasks
|
116
170
|
bug_db.each do |name, tickets|
|
117
|
-
project = nerd_projects.projects[
|
171
|
+
project = nerd_projects.projects[name]
|
118
172
|
|
119
173
|
tickets.each do |bts_id, value|
|
120
174
|
case value
|
@@ -131,11 +185,7 @@ class OmniFocus
|
|
131
185
|
puts "Adding #{name} # #{bts_id}"
|
132
186
|
next if $DEBUG
|
133
187
|
title, url = *value
|
134
|
-
|
135
|
-
:with_properties => {
|
136
|
-
:note => url,
|
137
|
-
:name => title,
|
138
|
-
})
|
188
|
+
make project, :task, title, :note => url
|
139
189
|
else
|
140
190
|
abort "ERROR: Unknown value in bug_db #{bts_id}: #{value.inspect}"
|
141
191
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omnifocus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-07-
|
12
|
+
date: 2009-07-30 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -47,6 +47,7 @@ email:
|
|
47
47
|
- ryand-ruby@zenspider.com
|
48
48
|
executables:
|
49
49
|
- omnifocus
|
50
|
+
- omnifocus_new
|
50
51
|
extensions: []
|
51
52
|
|
52
53
|
extra_rdoc_files:
|
@@ -60,6 +61,7 @@ files:
|
|
60
61
|
- README.txt
|
61
62
|
- Rakefile
|
62
63
|
- bin/omnifocus
|
64
|
+
- bin/omnifocus_new
|
63
65
|
- lib/omnifocus.rb
|
64
66
|
has_rdoc: true
|
65
67
|
homepage: http://rubyforge.org/projects/seattlerb
|