rubyfocus 0.4.0 → 0.5.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63565e849764d58187bc270c714a509aec780ff5
4
- data.tar.gz: 91c1408da7a1764a625d0ebd1434441dde52cd79
3
+ metadata.gz: 2de36243510c62436694de980a91adeee728d06a
4
+ data.tar.gz: ba5e7631fcab8e3e15b1f29b9ea3aaa631fe1bec
5
5
  SHA512:
6
- metadata.gz: 2f2925e0baae0e08eaf043a7dea9120446ab15b99729f9319c3c47e73feafe7246262879fa409734f0fce6e7566571a3711e3023d56217ec83af77a33ebdaad7
7
- data.tar.gz: 119909f3d146a97f0d4cd7b3fd0c1afff0425220c8acfd235f6635609a3fe2fdfd33f3106bf51cbc85481a65c43dc991a01f68cf1f4d5110e91b5d2421c10166
6
+ metadata.gz: 7ef2f8b0838f15d69405d4905ff88d5c70c13b88d31453afbf67bca75cc881202c4df4b5ca628cec5e95348bf7623f752d911f842fe73be0b1847ce2736a0322
7
+ data.tar.gz: 98c217b5fe2f8adf38a584bb26737b94c4f1b9719af4a8b24831220f13d0d8073930aca00fc7ba8f3169461b9adb3eb5fd3952e12e2a8fe6e82eeeab95300f9e
data/Manifest CHANGED
@@ -2,7 +2,8 @@
2
2
  # INCLUDE lib/**/*
3
3
  # INCLUDE *
4
4
  # EXCLUDE **/.DS_Store
5
- # EXCLUDE .rarity
5
+ # EXCLUDE .*
6
+ # EXCLUDE Manifest
6
7
  # EXCLUDE stage_ofocus.rb
7
8
  # EXCLUDE spec/files/ofocus_staging
8
9
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Version: 0.4.0
1
+ # Version: 0.5.0
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
 
@@ -106,36 +106,4 @@ Rubyfocus makes use of this by fetching and reading OmniFocus' local store on yo
106
106
 
107
107
  `rubyfocus` is a work in progress. In the near future I hope to release a more comprehensive document detailing exactly which details of OmniFocus' projects and tasks are available to the user, and what you can do with them.
108
108
 
109
- Other goals include:
110
-
111
- * Registering with the Omni Sync Server, so you don't need to always delete + reinstantiate the database.
112
- * Determining when you're "detached" from the latest version on the OSS.
113
- * A couple of example projects using rubyfocus (especially a static webpage generator for kanban)
114
-
115
- # History
116
-
117
- ## 0.4.0 // 2016-01-01
118
-
119
- * Happy new year!
120
- * [Modified] Container IDRef is now located on RankedItem, rather than having several on each RankedItem subclass.
121
- * [New] RankedItems can look at their ancestry much more easily, using RankedItem#ancestry and RankedItem#contained_within?
122
- * [New] Documents now forbid elements with duplicate IDs unless Document#allow_duplicate_ids is set to true.
123
- * [New] Patchers now treate CREATE nodes on elements whose IDs already exist in the database as UPDATE nodes
124
- * [Fixed] Patchers will now interpret missing parameters as "default values" e.g. project update without `status` parameter assumed to be active.
125
-
126
- ## 0.3.1 // 2015-12-31
127
-
128
- * [Bugfix] IDRefs will now return +nil+ if the relevant ID is not set.
129
-
130
- ## 0.3.0 // 2015-10-17
131
-
132
- * [New] Now supports remote syncing with the Omni Sync Server!
133
-
134
- ## 0.2.0 // 2015-10-11
135
-
136
- * [Bugfix] Will now turn tasks into projects and projects into tasks if the user has done this in OmniFocus.
137
- * [Bugfix] Rubyfocus::Patch now does patch application, rather than delegating to the Fetcher.
138
-
139
- ## 0.1.0 // 2015-10-10
140
-
141
- * Hello, world!
109
+ My main goal is to register with the Omni Sync Server, so you don't need to always delete + reinstantiate the database.
@@ -38,6 +38,24 @@ class Rubyfocus::Fetcher
38
38
  raise RuntimeError, "Method Fetcher#patch called for abstract class Fetcher."
39
39
  end
40
40
 
41
+ # Returns the latest patch
42
+ def head
43
+ @head ||= patches.sort.last
44
+ end
45
+
46
+ # Can you reach head from the given ID?
47
+ def can_reach_head_from?(id)
48
+ patch_array = patches.select{ |p| p.from_ids.include?(id) }
49
+ until patch_array.empty?
50
+ p = patch_array.first
51
+ return true if p == self.head
52
+
53
+ next_patches = patches.select{ |np| np.from_ids.include? p.to_id }
54
+ patch_array = patch_array[1..-1] + next_patches
55
+ end
56
+ return false
57
+ end
58
+
41
59
  #---------------------------------------
42
60
  # Patching methods
43
61
 
@@ -65,7 +83,7 @@ class Rubyfocus::Fetcher
65
83
  # apply the latest one.
66
84
  def next_patch(document)
67
85
  all_possible_patches = self.patches.select{ |patch| patch.can_patch?(document) }
68
- return all_possible_patches.sort_by(&:time).last
86
+ return all_possible_patches.sort.first
69
87
  end
70
88
 
71
89
 
@@ -6,6 +6,10 @@ class Rubyfocus::NamedItem < Rubyfocus::Item
6
6
  conditional_set(:name, n.at_xpath("xmlns:name"), &:inner_html)
7
7
  end
8
8
 
9
+ def to_s
10
+ @name
11
+ end
12
+
9
13
  private
10
14
  def inspect_properties
11
15
  super + %w(name)
@@ -67,7 +67,7 @@ class Rubyfocus::Task < Rubyfocus::RankedItem
67
67
  # The first non-completed task, determined by order
68
68
  def next_available_task
69
69
  nat_candidate = immediate_tasks.select{ |t| !t.completed? }.sort_by(&:rank).first
70
- if nat_candidate.has_subtasks?
70
+ if nat_candidate && nat_candidate.has_subtasks?
71
71
  nat_candidate.next_available_task
72
72
  else
73
73
  nat_candidate
@@ -1,6 +1,7 @@
1
1
  # The patch class represents a text-file patch, storing update, delete, and creation operations.
2
2
  # It should also be able to apply itself to an existing document.
3
3
  class Rubyfocus::Patch
4
+ include Comparable
4
5
  # The fetcher this patch belongs to. We mainly use this to work out how to fetch content for the patch proper
5
6
  attr_accessor :fetcher
6
7
 
@@ -113,8 +114,6 @@ class Rubyfocus::Patch
113
114
  new_node = Rubyfocus::Parser.parse(nil, node)
114
115
  if new_node
115
116
  document.add_element(new_node, overwrite: true)
116
- else
117
- raise(RuntimeError, "Encountered unparsable XML during patch reading: #{node}.")
118
117
  end
119
118
  end
120
119
 
@@ -126,4 +125,20 @@ class Rubyfocus::Patch
126
125
  "([#{from_ids.join(", ")}] -> #{to_id})"
127
126
  end
128
127
  end
128
+
129
+ def <=> o
130
+ if self.time.nil?
131
+ if o.time.nil?
132
+ 0
133
+ else
134
+ -1
135
+ end
136
+ else
137
+ if o.time.nil?
138
+ 1
139
+ else
140
+ self.time <=> o.time
141
+ end
142
+ end
143
+ end
129
144
  end
data/version.txt CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.5.1
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.4.0
4
+ version: 0.5.1
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-01-17 00:00:00.000000000 Z
11
+ date: 2016-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -112,3 +112,4 @@ signing_key:
112
112
  specification_version: 4
113
113
  summary: Pure ruby bridge to OmniFocus.
114
114
  test_files: []
115
+ has_rdoc: