rubyfocus 0.5.6 → 0.5.9
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.
- checksums.yaml +4 -4
- data/HISTORY.md +18 -0
- data/README.md +2 -2
- data/lib/rubyfocus/document.rb +32 -0
- data/lib/rubyfocus/items/project.rb +8 -4
- data/lib/rubyfocus/items/ranked_item.rb +1 -0
- data/lib/rubyfocus/items/task.rb +8 -3
- data/lib/rubyfocus/patch.rb +2 -11
- data/version.txt +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80ef3e4cecd0eadf4c382649ebc6e0bec02f5ef0
|
4
|
+
data.tar.gz: 18d49a1f6c59c97058918fb1d6e9684c131cf467
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 104abdd65cbbf6d662786395c28d0a4ac67febbe1fea637dee88b2f46d3d58006ad59e190e8810a126261816a29c888082995d80090d4c172de767379369e80a
|
7
|
+
data.tar.gz: 04a52e5c3d0cb037c3b93d1d6082e808804045261d6a912710eb562295cdf97fd937063fb03b5b57ef3403fc580591c822d9f66975fc3a8e149b930b9a8594bf
|
data/HISTORY.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
# History
|
2
2
|
|
3
|
+
## 0.5.9 // 2016-09-04
|
4
|
+
|
5
|
+
Further Omnifocus database format changes result in shennanigans with rubyfocus. All fixed.
|
6
|
+
|
7
|
+
* [Fixed] Blank entries in updates are now treated as "no change", rather than "new value is nil".
|
8
|
+
|
9
|
+
## 0.5.8 // 2016-09-02
|
10
|
+
|
11
|
+
Heading off edge cases, again a result of the new Omnifocus database format
|
12
|
+
|
13
|
+
* [Fixed] Projects inside folders were being reported as having no container, due to empty `<task/`> tags. Now fixed.
|
14
|
+
|
15
|
+
## 0.5.7 // 2016-09-02
|
16
|
+
|
17
|
+
A quick fix for the new OF database format
|
18
|
+
|
19
|
+
* [Fixed] Empty `<project/>` tags in a task description will no longer cause Rubyfocus to treat said task as a project.
|
20
|
+
|
3
21
|
## 0.5.6 // 2016-09-01
|
4
22
|
|
5
23
|
* [New] Added `Time.safely_parse`, which will not choke on empty strings or nil values
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Version: 0.5.
|
1
|
+
# Version: 0.5.9
|
2
2
|
|
3
3
|
Rubyfocus is a one-way (read-only) ruby bridge to OmniFocus. Analyse, store, inspect, or play with your projects and tasks in OmniFocus from the comfort and flexibility of ruby!
|
4
4
|
|
@@ -22,7 +22,7 @@ Now build and install it!
|
|
22
22
|
|
23
23
|
```
|
24
24
|
gem build rubyfocus.gemspec
|
25
|
-
gem install rubyfocus-0.5.
|
25
|
+
gem install rubyfocus-0.5.9.gem
|
26
26
|
```
|
27
27
|
|
28
28
|
# Usage
|
data/lib/rubyfocus/document.rb
CHANGED
@@ -135,6 +135,38 @@ class Rubyfocus::Document
|
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
138
|
+
# Update an element in-place by applying xml. This method also takes into account:
|
139
|
+
# * new nodes (i.e. silently creates if required)
|
140
|
+
# * tasks upgraded to projects
|
141
|
+
# * projects downgraded to tasks
|
142
|
+
# Note that unlike add_element, this takes pure XML
|
143
|
+
def update_element(node)
|
144
|
+
element = self[node["id"]]
|
145
|
+
|
146
|
+
# Does element already exist?
|
147
|
+
if element
|
148
|
+
# Quick check: is it a task being upgraded to a project?
|
149
|
+
if element.class == Rubyfocus::Task && Rubyfocus::Project.matches_node?(node)
|
150
|
+
# Upgrade
|
151
|
+
new_node = element.to_project
|
152
|
+
new_node.apply_xml(node)
|
153
|
+
add_element(new_node, overwrite:true)
|
154
|
+
# or is the project being downgraded to a task?
|
155
|
+
elsif element.class == Rubyfocus::Project && !Rubyfocus::Project.matches_node?(node)
|
156
|
+
# Downgrade
|
157
|
+
new_node = element.to_task
|
158
|
+
new_node.apply_xml(node)
|
159
|
+
add_element(new_node, overwrite:true)
|
160
|
+
else
|
161
|
+
# Update in-place
|
162
|
+
element.apply_xml(node)
|
163
|
+
end
|
164
|
+
else
|
165
|
+
# Create a new node and add it
|
166
|
+
Rubyfocus::Parser.parse(self,node)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
138
170
|
#-------------------------------------------------------------------------------
|
139
171
|
# Searchable stuff
|
140
172
|
def elements
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# The project represents an OmniFocus project object.
|
2
2
|
class Rubyfocus::Project < Rubyfocus::Task
|
3
|
-
# It's parseable
|
4
3
|
include Rubyfocus::Parser
|
5
4
|
|
6
5
|
#-------------------------------------------------------------------------------
|
@@ -8,7 +7,11 @@ class Rubyfocus::Project < Rubyfocus::Task
|
|
8
7
|
|
9
8
|
# Projects are <task>s with an interior <project> node
|
10
9
|
def self.matches_node?(node)
|
11
|
-
return (
|
10
|
+
return (
|
11
|
+
node.name == "task" &&
|
12
|
+
(node/"project").size > 0 &&
|
13
|
+
(node/"project").first.children.size > 0
|
14
|
+
)
|
12
15
|
end
|
13
16
|
|
14
17
|
# Singleton: contains one-off tasks
|
@@ -64,10 +67,11 @@ class Rubyfocus::Project < Rubyfocus::Task
|
|
64
67
|
def dropped?; status == :dropped; end
|
65
68
|
|
66
69
|
#---------------------------------------
|
67
|
-
# Convert to a task
|
70
|
+
# Convert to a task. Does not supply a document, as this would overwrite current project
|
68
71
|
def to_task
|
69
|
-
t = Rubyfocus::Task.new(
|
72
|
+
t = Rubyfocus::Task.new(nil)
|
70
73
|
instance_variables.each do |ivar|
|
74
|
+
next if ivar == :"@document"
|
71
75
|
setter = ivar.to_s.gsub(/^@/,"") + "="
|
72
76
|
t.send(setter, self.instance_variable_get(ivar)) if t.respond_to?(setter)
|
73
77
|
end
|
@@ -2,6 +2,7 @@ class Rubyfocus::RankedItem < Rubyfocus::NamedItem
|
|
2
2
|
attr_accessor :rank
|
3
3
|
|
4
4
|
# Ranked items also happen to be contained items
|
5
|
+
# Container setting is handled by subclasses - tasks and folders
|
5
6
|
idref :container
|
6
7
|
|
7
8
|
# Retrieve a full list of the parents of this item. [0] = immediate parent
|
data/lib/rubyfocus/items/task.rb
CHANGED
@@ -25,7 +25,11 @@ class Rubyfocus::Task < Rubyfocus::RankedItem
|
|
25
25
|
|
26
26
|
def apply_xml(n)
|
27
27
|
super(n)
|
28
|
-
|
28
|
+
|
29
|
+
t = n.at_xpath("xmlns:task")
|
30
|
+
f = n.at_xpath("xmlns:project/xmlns:folder")
|
31
|
+
|
32
|
+
conditional_set(:container_id, (t && t["idref"]) || (f && f["idref"])){ |e| e }
|
29
33
|
|
30
34
|
conditional_set(:context_id, n.at_xpath("xmlns:context")) { |e| e["idref"] }
|
31
35
|
conditional_set(:note, n.at_xpath("xmlns:note")) { |e| e.inner_html.strip }
|
@@ -128,10 +132,11 @@ class Rubyfocus::Task < Rubyfocus::RankedItem
|
|
128
132
|
#---------------------------------------
|
129
133
|
# Conversion methods
|
130
134
|
|
131
|
-
# Convert the task to a project
|
135
|
+
# Convert the task to a project. Does not supply a document, as this would overwrite current task
|
132
136
|
def to_project
|
133
|
-
p = Rubyfocus::Project.new(
|
137
|
+
p = Rubyfocus::Project.new(nil)
|
134
138
|
instance_variables.each do |ivar|
|
139
|
+
next if ivar == :"@document"
|
135
140
|
setter = ivar.to_s.gsub(/^@/,"") + "="
|
136
141
|
p.send(setter, self.instance_variable_get(ivar)) if p.respond_to?(setter)
|
137
142
|
end
|
data/lib/rubyfocus/patch.rb
CHANGED
@@ -96,27 +96,18 @@ class Rubyfocus::Patch
|
|
96
96
|
# Apply this patch to a document.
|
97
97
|
def apply_to!(document)
|
98
98
|
# Updates modify elements
|
99
|
-
self.update.each{ |node|
|
99
|
+
self.update.each{ |node| document.update_element(node) }
|
100
100
|
|
101
101
|
# Deletes remove elements
|
102
102
|
self.delete.each{ |node| document.remove_element(node["id"]) }
|
103
103
|
|
104
104
|
# Creates make new elements
|
105
|
-
self.create.each{ |node|
|
105
|
+
self.create.each{ |node| document.update_element(node) }
|
106
106
|
|
107
107
|
# Modify current patch_id to show new value
|
108
108
|
document.patch_id = self.to_id
|
109
109
|
end
|
110
110
|
|
111
|
-
# Atomic node update code
|
112
|
-
def update_node(document, node)
|
113
|
-
# Create new element with correct ID. Then add to document, overwriting previous element(s)
|
114
|
-
new_node = Rubyfocus::Parser.parse(nil, node)
|
115
|
-
if new_node
|
116
|
-
document.add_element(new_node, overwrite: true)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
111
|
# String representation
|
121
112
|
def to_s
|
122
113
|
if from_ids.size == 1
|
data/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.9
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubyfocus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan-Yves Ruzicka
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|