all_todo 0.3.1 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/all_todo.rb +67 -4
- metadata +23 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e614f169caa9cf9299694cbae2877a94a5bea86
|
4
|
+
data.tar.gz: 18c546ba19151dc0728c091583c907bce8ccecc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b0ffae932f9e7521ce2bc53540628ee6b776c1ecbd92789f27545a97321400eb8b179ceeb6dafdabf6482222d00c4a53e3313045d95a7b4226e07a7644207b1
|
7
|
+
data.tar.gz: b92a0306c04b622aa19bdd664b22b07a82c3698dbbbbd5d1f5f02892612395b237c5f14916ab22752c7c411d2a51a064ce4e84167127277b0c1225ecff1680e1
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/all_todo.rb
CHANGED
@@ -4,13 +4,14 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
require 'px_todo'
|
7
|
+
require 'rexle-diff'
|
7
8
|
|
8
9
|
|
9
10
|
class AllTodo < PxTodo
|
10
11
|
|
11
|
-
def initialize(raw_s)
|
12
|
+
def initialize(raw_s, filepath: '.')
|
12
13
|
|
13
|
-
super(raw_s) do |x|
|
14
|
+
super(raw_s, filepath: filepath) do |x|
|
14
15
|
|
15
16
|
todo = x.title
|
16
17
|
|
@@ -41,6 +42,26 @@ class AllTodo < PxTodo
|
|
41
42
|
|
42
43
|
alias breakdown detail
|
43
44
|
|
45
|
+
# generates the todo_daily.txt file
|
46
|
+
|
47
|
+
def export_today()
|
48
|
+
|
49
|
+
ftxt, fxml, fnoidxml = %w(.txt .xml _noid.xml).map{|x| 'todo_daily' + x}
|
50
|
+
|
51
|
+
File.write File.join(@filepath, ftxt), self.today()
|
52
|
+
|
53
|
+
a = self.to_px.find_all_by_todo_when 'today'
|
54
|
+
|
55
|
+
px = Polyrex.new(schema="items[title]/todo[#{@fields.join(', ')}]")
|
56
|
+
a.each {|x| px.add x }
|
57
|
+
|
58
|
+
File.write File.join(@filepath, fxml), px.to_xml(pretty: true)
|
59
|
+
|
60
|
+
px.xpath('//todo').each {|x| x.attributes.delete :id}
|
61
|
+
File.write File.join(@filepath, fnoidxml), px.to_xml(pretty: true)
|
62
|
+
|
63
|
+
end
|
64
|
+
|
44
65
|
def parse_detail(s)
|
45
66
|
|
46
67
|
lines = s.lines
|
@@ -50,6 +71,11 @@ class AllTodo < PxTodo
|
|
50
71
|
|
51
72
|
end
|
52
73
|
|
74
|
+
def save(filepath=File.join(@filepath, 'all_todo.xml'))
|
75
|
+
|
76
|
+
File.write filepath, @px.to_xml(pretty: true)
|
77
|
+
|
78
|
+
end
|
53
79
|
|
54
80
|
def to_s()
|
55
81
|
|
@@ -99,7 +125,7 @@ class AllTodo < PxTodo
|
|
99
125
|
|
100
126
|
# prints out the to-do list for today
|
101
127
|
|
102
|
-
def today(day='today')
|
128
|
+
def today(day='today', filename: 'todo_daily.txt')
|
103
129
|
|
104
130
|
px = @px
|
105
131
|
|
@@ -133,11 +159,48 @@ class AllTodo < PxTodo
|
|
133
159
|
r << heading.join("\n") << '' << items.map{|x| x[1..-1]}.join("\n") << ''
|
134
160
|
end
|
135
161
|
|
136
|
-
filename = 'todo_daily.txt'
|
137
162
|
([filename, '=' * filename.length, ''] + lines).join("\n")
|
138
163
|
|
139
164
|
end
|
140
165
|
|
166
|
+
def update_today(file='todo_daily.txt')
|
167
|
+
|
168
|
+
# parse the newest todo_daily.txt file
|
169
|
+
pxtodo = PxTodo.new(file, filepath: @filepath)
|
170
|
+
|
171
|
+
# remove the id attributes
|
172
|
+
px2 = pxtodo.to_px
|
173
|
+
px2.xpath('//todo').each {|x| x.attributes.delete :id}
|
174
|
+
|
175
|
+
# read the todo_daily_noid file
|
176
|
+
px1noid = Polyrex.new(File.join(@filepath, 'todo_daily_noid.xml'))
|
177
|
+
|
178
|
+
# compare the 2 documents
|
179
|
+
doc = RexleDiff.new(px1noid.to_xml, px2.to_xml).to_doc
|
180
|
+
|
181
|
+
a = doc.xpath('//todo/summary/status[@created]../.')
|
182
|
+
|
183
|
+
# update the all_todo document
|
184
|
+
# first we need to find the ids
|
185
|
+
|
186
|
+
px1 = Polyrex.new(File.join(@filepath, 'todo_daily.xml'))
|
187
|
+
|
188
|
+
statuses = a.map do |node|
|
189
|
+
|
190
|
+
e = px1.element("//summary[contains(title,'#{node.text('title')}')]")
|
191
|
+
[e.parent.attributes[:id], node.text('status') ]
|
192
|
+
|
193
|
+
end
|
194
|
+
|
195
|
+
statuses.each do |id, status|
|
196
|
+
|
197
|
+
todo = @px.find_by_id id
|
198
|
+
todo.status = status
|
199
|
+
|
200
|
+
end
|
201
|
+
|
202
|
+
end
|
203
|
+
|
141
204
|
private
|
142
205
|
|
143
206
|
def fetch_heading(item, a=[])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: all_todo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
version: '0.1'
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.1.
|
45
|
+
version: 0.1.1
|
46
46
|
type: :runtime
|
47
47
|
prerelease: false
|
48
48
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -52,7 +52,27 @@ dependencies:
|
|
52
52
|
version: '0.1'
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0.1.
|
55
|
+
version: 0.1.1
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rexle-diff
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0.5'
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 0.5.4
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - "~>"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0.5'
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.5.4
|
56
76
|
description:
|
57
77
|
email: james@r0bertson.co.uk
|
58
78
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|