omnifocus 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/History.txt +12 -0
  2. data/lib/omnifocus.rb +34 -12
  3. metadata +2 -2
data/History.txt CHANGED
@@ -1,3 +1,15 @@
1
+ === 1.1.0 / 2009-07-28
2
+
3
+ * 3 minor enhancements:
4
+
5
+ * Changed bts_id to match /SYSTEM(-project)?#id/ to work with PITA BTSen.
6
+ * Debug mode prints pseudo-actions as well as dumping its knowledge db.
7
+ * run method now extends with plugins before hitting the backend.
8
+
9
+ * 1 bug fix:
10
+
11
+ * Fixed load_plugins from loading both gem and local plugins.
12
+
1
13
  === 1.0.0 / 2009-07-26
2
14
 
3
15
  * 1 major enhancement
data/lib/omnifocus.rb CHANGED
@@ -4,22 +4,30 @@ require 'appscript'
4
4
 
5
5
  ##
6
6
  # Synchronizes bug tracking systems to omnifocus.
7
+ #
8
+ # Some definitions:
9
+ #
10
+ # bts: bug tracking system
11
+ # SYSTEM: a tag uniquely identifying the bts
12
+ # bts_id: a string uniquely identifying a task: SYSTEM(-projectname)?#id
7
13
 
8
14
  class OmniFocus
9
- VERSION = '1.0.0'
15
+ VERSION = '1.1.0'
10
16
 
17
+ ##
11
18
  # bug_db = {
12
19
  # 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
20
+ # bts_id => [task_name, url], # only on BTS = add to OF
21
+ # bts_id => true, # both BTS and OF = don't touch
22
+ # bts_id => false, # only on OF = remove from OF
16
23
  # }
17
24
  # }
18
25
 
19
26
  attr_reader :bug_db
20
27
 
28
+ ##
21
29
  # existing = {
22
- # rf_id => project,
30
+ # bts_id => project,
23
31
  # }
24
32
 
25
33
  attr_reader :existing
@@ -28,8 +36,12 @@ class OmniFocus
28
36
  # Load any file matching "omnifocus/*.rb"
29
37
 
30
38
  def self.load_plugins
39
+ loaded = {}
31
40
  Gem.find_files("omnifocus/*.rb").each do |path|
41
+ name = File.basename path
42
+ next if loaded[name]
32
43
  require path
44
+ loaded[name] = true
33
45
  end
34
46
  end
35
47
 
@@ -64,12 +76,12 @@ class OmniFocus
64
76
 
65
77
  ##
66
78
  # 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.
79
+ # bug_db hash if they match a bts_id.
68
80
 
69
81
  def prepopulate_existing_tasks
70
82
  of_tasks = nerd_projects.projects.tasks[its.name.contains("#")].get.flatten
71
83
  of_tasks.each do |of_task|
72
- ticket_id = of_task.name.get[/^[A-Z]+#(\d+)/, 1].to_i
84
+ ticket_id = of_task.name.get[/^([A-Z]+(?:-[\w-]+)?\#\d+)/, 1]
73
85
  project = of_task.containing_project.name.get
74
86
  existing[ticket_id] = project
75
87
  bug_db[project][ticket_id] = false
@@ -89,6 +101,8 @@ class OmniFocus
89
101
 
90
102
  def create_missing_projects
91
103
  (bug_db.keys - nerd_projects.projects.name.get).each do |name|
104
+ warn "creating project #{name}"
105
+ next if $DEBUG
92
106
  nerd_projects.make :new => :project, :with_properties => { :name => name }
93
107
  end
94
108
  end
@@ -107,13 +121,15 @@ class OmniFocus
107
121
  when true
108
122
  # leave alone
109
123
  when false
110
- project.tasks[its.name.contains("##{bts_id}")].get.each do |task|
124
+ project.tasks[its.name.contains(bts_id)].get.each do |task|
111
125
  next if task.completed.get
112
126
  puts "Removing #{name} # #{bts_id}"
127
+ next if $DEBUG
113
128
  task.completed.set true
114
129
  end
115
130
  when Array
116
131
  puts "Adding #{name} # #{bts_id}"
132
+ next if $DEBUG
117
133
  title, url = *value
118
134
  project.make(:new => :task,
119
135
  :with_properties => {
@@ -135,20 +151,26 @@ class OmniFocus
135
151
  end
136
152
 
137
153
  def run
154
+ # do this all up front so we can REALLY fuck shit up with plugins
155
+ self.class.plugins.each do |plugin|
156
+ extend plugin
157
+ end
158
+
138
159
  prepopulate_existing_tasks
139
160
 
140
161
  self.class.plugins.each do |plugin|
141
- extend plugin
142
162
  name = plugin.name.split(/::/).last.downcase
163
+ warn "scanning #{name}"
143
164
  send "populate_#{name}_tasks"
144
165
  end
145
166
 
146
167
  if $DEBUG then
147
168
  require 'pp'
169
+ pp existing
148
170
  pp bug_db
149
- else
150
- create_missing_projects
151
- update_tasks
152
171
  end
172
+
173
+ create_missing_projects
174
+ update_tasks
153
175
  end
154
176
  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.0.0
4
+ version: 1.1.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-26 00:00:00 -07:00
12
+ date: 2009-07-28 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency