omnifocus 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +24 -0
- data/History.txt +6 -0
- data/Manifest.txt +7 -0
- data/README.txt +57 -0
- data/Rakefile +17 -0
- data/bin/omnifocus +6 -0
- data/lib/omnifocus.rb +154 -0
- metadata +94 -0
data/.autotest
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'autotest/restart'
|
4
|
+
|
5
|
+
Autotest.add_hook :initialize do |at|
|
6
|
+
at.testlib = "minitest/autorun"
|
7
|
+
# at.extra_files << "../some/external/dependency.rb"
|
8
|
+
#
|
9
|
+
# at.libs << ":../some/external"
|
10
|
+
#
|
11
|
+
# at.add_exception 'vendor'
|
12
|
+
#
|
13
|
+
# at.add_mapping(/dependency.rb/) do |f, _|
|
14
|
+
# at.files_matching(/test_.*rb$/)
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# %w(TestA TestB).each do |klass|
|
18
|
+
# at.extra_class_map[klass] = "test/test_misc.rb"
|
19
|
+
# end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Autotest.add_hook :run_command do |at|
|
23
|
+
# system "rake build"
|
24
|
+
# end
|
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
= omnifocus
|
2
|
+
|
3
|
+
* http://rubyforge.org/projects/seattlerb
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Synchronizes bug tracking systems to omnifocus.
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
* Pluggable to work with multiple bug tracking systems (BTS).
|
12
|
+
* Rubyforge plugin included.
|
13
|
+
* Creates projects in omnifocus if needed.
|
14
|
+
* Creates tasks for multiple projects in omnifocus.
|
15
|
+
* Marks tasks complete if they've been closed in the BTS.
|
16
|
+
|
17
|
+
== SYNOPSIS:
|
18
|
+
|
19
|
+
% omnifocus
|
20
|
+
scanning ticket RF#3802
|
21
|
+
removing parsetree # 314159
|
22
|
+
creating parsetree # 3802
|
23
|
+
...
|
24
|
+
|
25
|
+
== REQUIREMENTS:
|
26
|
+
|
27
|
+
* mechanize
|
28
|
+
* rb-appscript
|
29
|
+
|
30
|
+
== INSTALL:
|
31
|
+
|
32
|
+
* sudo gem install omnifocus
|
33
|
+
|
34
|
+
== LICENSE:
|
35
|
+
|
36
|
+
(The MIT License)
|
37
|
+
|
38
|
+
Copyright (c) Ryan Davis, seattle.rb
|
39
|
+
|
40
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
41
|
+
a copy of this software and associated documentation files (the
|
42
|
+
'Software'), to deal in the Software without restriction, including
|
43
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
44
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
45
|
+
permit persons to whom the Software is furnished to do so, subject to
|
46
|
+
the following conditions:
|
47
|
+
|
48
|
+
The above copyright notice and this permission notice shall be
|
49
|
+
included in all copies or substantial portions of the Software.
|
50
|
+
|
51
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
52
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
53
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
54
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
55
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
56
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
57
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
|
6
|
+
Hoe.plugin :seattlerb
|
7
|
+
|
8
|
+
Hoe.spec 'omnifocus' do
|
9
|
+
developer 'Ryan Davis', 'ryand-ruby@zenspider.com'
|
10
|
+
|
11
|
+
extra_deps << "rb-appscript"
|
12
|
+
extra_deps << 'mechanize'
|
13
|
+
|
14
|
+
self.rubyforge_name = 'seattlerb'
|
15
|
+
end
|
16
|
+
|
17
|
+
# vim: syntax=ruby
|
data/bin/omnifocus
ADDED
data/lib/omnifocus.rb
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'mechanize'
|
3
|
+
require 'appscript'
|
4
|
+
|
5
|
+
##
|
6
|
+
# Synchronizes bug tracking systems to omnifocus.
|
7
|
+
|
8
|
+
class OmniFocus
|
9
|
+
VERSION = '1.0.0'
|
10
|
+
|
11
|
+
# bug_db = {
|
12
|
+
# project => {
|
13
|
+
# rf_id => [task_name, url], # only on BTS = add to OF
|
14
|
+
# rf_id => true, # both BTS and OF = don't touch
|
15
|
+
# rf_id => false, # only on OF = remove from OF
|
16
|
+
# }
|
17
|
+
# }
|
18
|
+
|
19
|
+
attr_reader :bug_db
|
20
|
+
|
21
|
+
# existing = {
|
22
|
+
# rf_id => project,
|
23
|
+
# }
|
24
|
+
|
25
|
+
attr_reader :existing
|
26
|
+
|
27
|
+
##
|
28
|
+
# Load any file matching "omnifocus/*.rb"
|
29
|
+
|
30
|
+
def self.load_plugins
|
31
|
+
Gem.find_files("omnifocus/*.rb").each do |path|
|
32
|
+
require path
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
##
|
37
|
+
# Load plugins and then execute the script
|
38
|
+
|
39
|
+
def self.run
|
40
|
+
load_plugins
|
41
|
+
self.new.run
|
42
|
+
end
|
43
|
+
|
44
|
+
def initialize
|
45
|
+
@bug_db = Hash.new { |h,k| h[k] = {} }
|
46
|
+
@existing = {}
|
47
|
+
end
|
48
|
+
|
49
|
+
def its # :nodoc:
|
50
|
+
Appscript.its
|
51
|
+
end
|
52
|
+
|
53
|
+
##
|
54
|
+
# Get all projects under the nerd folder
|
55
|
+
|
56
|
+
def nerd_projects
|
57
|
+
unless defined? @nerd_projects then
|
58
|
+
omnifocus = Appscript.app('OmniFocus').documents[1]
|
59
|
+
@nerd_projects = omnifocus.sections[its.name.eq("nerd")].first
|
60
|
+
end
|
61
|
+
|
62
|
+
@nerd_projects
|
63
|
+
end
|
64
|
+
|
65
|
+
##
|
66
|
+
# Walk all omnifocus tasks under the nerd folder and add them to the
|
67
|
+
# bug_db hash if they have [A-Z]+#\d+ in the subject.
|
68
|
+
|
69
|
+
def prepopulate_existing_tasks
|
70
|
+
of_tasks = nerd_projects.projects.tasks[its.name.contains("#")].get.flatten
|
71
|
+
of_tasks.each do |of_task|
|
72
|
+
ticket_id = of_task.name.get[/^[A-Z]+#(\d+)/, 1].to_i
|
73
|
+
project = of_task.containing_project.name.get
|
74
|
+
existing[ticket_id] = project
|
75
|
+
bug_db[project][ticket_id] = false
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
##
|
80
|
+
# Returns the mechanize agent
|
81
|
+
|
82
|
+
def mechanize
|
83
|
+
@mechanize ||= WWW::Mechanize.new
|
84
|
+
end
|
85
|
+
|
86
|
+
##
|
87
|
+
# Create any projects in bug_db that aren't in omnifocus, add under
|
88
|
+
# the nerd folder.
|
89
|
+
|
90
|
+
def create_missing_projects
|
91
|
+
(bug_db.keys - nerd_projects.projects.name.get).each do |name|
|
92
|
+
nerd_projects.make :new => :project, :with_properties => { :name => name }
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
##
|
97
|
+
# Synchronize the contents of bug_db with omnifocus, creating
|
98
|
+
# missing tasks and marking tasks completed as needed. See the doco
|
99
|
+
# for +bug_db+ for more info on how you should populate it.
|
100
|
+
|
101
|
+
def update_tasks
|
102
|
+
bug_db.each do |name, tickets|
|
103
|
+
project = nerd_projects.projects[its.name.eq(name)].projects[1]
|
104
|
+
|
105
|
+
tickets.each do |bts_id, value|
|
106
|
+
case value
|
107
|
+
when true
|
108
|
+
# leave alone
|
109
|
+
when false
|
110
|
+
project.tasks[its.name.contains("##{bts_id}")].get.each do |task|
|
111
|
+
next if task.completed.get
|
112
|
+
puts "Removing #{name} # #{bts_id}"
|
113
|
+
task.completed.set true
|
114
|
+
end
|
115
|
+
when Array
|
116
|
+
puts "Adding #{name} # #{bts_id}"
|
117
|
+
title, url = *value
|
118
|
+
project.make(:new => :task,
|
119
|
+
:with_properties => {
|
120
|
+
:note => url,
|
121
|
+
:name => title,
|
122
|
+
})
|
123
|
+
else
|
124
|
+
abort "ERROR: Unknown value in bug_db #{bts_id}: #{value.inspect}"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
##
|
131
|
+
# Return all the plugin modules that have been loaded.
|
132
|
+
|
133
|
+
def self.plugins
|
134
|
+
constants.reject { |mod| mod =~ /^[A-Z_]+$/ }.map { |mod| const_get mod }
|
135
|
+
end
|
136
|
+
|
137
|
+
def run
|
138
|
+
prepopulate_existing_tasks
|
139
|
+
|
140
|
+
self.class.plugins.each do |plugin|
|
141
|
+
extend plugin
|
142
|
+
name = plugin.name.split(/::/).last.downcase
|
143
|
+
send "populate_#{name}_tasks"
|
144
|
+
end
|
145
|
+
|
146
|
+
if $DEBUG then
|
147
|
+
require 'pp'
|
148
|
+
pp bug_db
|
149
|
+
else
|
150
|
+
create_missing_projects
|
151
|
+
update_tasks
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omnifocus
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Davis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-26 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rb-appscript
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: mechanize
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: hoe
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 2.3.3
|
44
|
+
version:
|
45
|
+
description: Synchronizes bug tracking systems to omnifocus.
|
46
|
+
email:
|
47
|
+
- ryand-ruby@zenspider.com
|
48
|
+
executables:
|
49
|
+
- omnifocus
|
50
|
+
extensions: []
|
51
|
+
|
52
|
+
extra_rdoc_files:
|
53
|
+
- History.txt
|
54
|
+
- Manifest.txt
|
55
|
+
- README.txt
|
56
|
+
files:
|
57
|
+
- .autotest
|
58
|
+
- History.txt
|
59
|
+
- Manifest.txt
|
60
|
+
- README.txt
|
61
|
+
- Rakefile
|
62
|
+
- bin/omnifocus
|
63
|
+
- lib/omnifocus.rb
|
64
|
+
has_rdoc: true
|
65
|
+
homepage: http://rubyforge.org/projects/seattlerb
|
66
|
+
licenses: []
|
67
|
+
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options:
|
70
|
+
- --main
|
71
|
+
- README.txt
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "0"
|
79
|
+
version:
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: "0"
|
85
|
+
version:
|
86
|
+
requirements: []
|
87
|
+
|
88
|
+
rubyforge_project: seattlerb
|
89
|
+
rubygems_version: 1.3.4
|
90
|
+
signing_key:
|
91
|
+
specification_version: 3
|
92
|
+
summary: Synchronizes bug tracking systems to omnifocus.
|
93
|
+
test_files: []
|
94
|
+
|