all_todo 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 14a238fd842c1ed5bc0895777821fd9c55475f8f
4
- data.tar.gz: 94883c7db7611aaf8d9b81437f4aa7792425e68c
3
+ metadata.gz: 3ed63196b9525d18dd25167a81bbf2b8987e97d0
4
+ data.tar.gz: 2039058b2ecbb269e92d050e2a0bec750740daea
5
5
  SHA512:
6
- metadata.gz: 5d644983654f354f63ab409e03264b12dc15c7164cebfab9f1ee2aa9a78399f0776f44cb8103ca1d372ad4284ab8b0c9fe23338e13e9084b25cc5fc04fc25669
7
- data.tar.gz: eea0a4e9fc9e82949dfa4b2b7b805ed0dcb790636978ef8c1e8bad97e7992652efc77a7131c6676e3656f54c68372b198e4bb0c74208fc6af35b5cba8925b7df
6
+ metadata.gz: d7789bf3507a20d0afe7db1dd1bbd77f26792db4de3ef1fdeda4fc45bfddb2178d51abeb97dabda046e1e82a9280bf60df45f1af0ea25532b53aad3678a537d2
7
+ data.tar.gz: c6bb3184a4ebc46ecf5156f4d7b253b0c0f876b0615d087ce60ca09ef472e702752d3471f6e5938f81000b8d3bae9eb7e5ba8455f7581ff8b386cc25a2dc05ea
checksums.yaml.gz.sig CHANGED
@@ -1 +1,2 @@
1
- nB\>��]5���Z͑��/`��3��a:�W_Ǟ���a���++ H�].m'4�:�{ܯȫ$��@jr�o�!�'�Rw䦧�|gNz��U%$�B��gS;�,ICLMߞ@{ 9�+�N oS�QT<�W�8��~�U���8�VD0��ո��K�kɦ���E��*K�&�
1
+ K59U<�E?7CJ���-mp��������.^M�o1JK��!�"l2L��G~,o��2��v�*��1WmT
2
+ J��R1�-��/��с�r��"�L�0��r~�Y?�<dc��Nk+8)Kc������$c�ʗ ��Ӏ�e� � �]�AFj�oІd�jW.JQ��d|����a�\�� Z�I�j��1�)�)�H䯂�p�J�d�K��tK�[���oÆ�]����NtK}�kK]��&znD *w���7�
data.tar.gz.sig CHANGED
Binary file
data/lib/all_todo.rb CHANGED
@@ -7,6 +7,62 @@ require 'px_todo'
7
7
  require 'rexle-diff'
8
8
 
9
9
 
10
+ =begin
11
+ ## start of code comments ######################################
12
+
13
+ how it should work
14
+ ==================
15
+
16
+ Basic usage
17
+ -----------
18
+
19
+ the user ...
20
+
21
+ * creates the all_todo.txt (see the sample all_todo.txt file)
22
+ * runs AllTodo#to_s to refresh the all_todo.txt file with checkboxes
23
+ * identifies the todo items for that day by prefixing the item with an
24
+ asterisk (*)
25
+ * runs AllTodo#export_today to generate the todo_daily.txt file
26
+ * crosses a few todo item checkboxes in the todo_daily.txt file and
27
+ saves the file
28
+ * runs AllTodo#update_today to update the completed todo items from the
29
+ todo_daily.txt into the all_todo.txt file
30
+ - all_todo_detail.txt and all_todo_detail.xml is automatically updated
31
+
32
+ Syncing from all_todo_detail.txt
33
+ ---------------------------------
34
+
35
+ the user ...
36
+
37
+ * updates a few *when* fields in all_todo_detail.txt file
38
+ * runs AllTodo#sync_detail which updates the *when* fields in all_todo.xml
39
+
40
+ --------------------------------------------------
41
+
42
+ example file
43
+
44
+ all_todo.txt
45
+ ------------
46
+
47
+ # Projects
48
+
49
+ ## all_todo
50
+
51
+ [ ] Implement the secret new feature
52
+ [ ] Add a README file
53
+
54
+ ## liveblog
55
+
56
+ Implement the saving of images from the web locally
57
+
58
+ # volunteering
59
+
60
+ * Meeting at Cafe X
61
+
62
+ ## end of code comments ########################################
63
+ =end
64
+
65
+
10
66
  class AllTodo < PxTodo
11
67
 
12
68
  def initialize(raw_s=nil, filepath: '.')
@@ -68,29 +124,30 @@ class AllTodo < PxTodo
68
124
 
69
125
  end
70
126
 
127
+ # parses the all_todo_detail.txt file
128
+ #
71
129
  def parse_detail(s)
72
130
 
73
131
  lines = s.lines
74
132
  lines.shift 3
75
- pr = PxRowX.new(lines.join)
133
+
134
+ pr = PxRowX.new(lines.join, record_name: 'todo')
76
135
  pr.to_xml pretty: true
77
136
 
78
- end
137
+ end
79
138
 
80
- # parses the all_todo_detail.txt file and updates the all_todo_detail.xml file
81
139
 
82
- def update_detail()
83
-
84
- s = File.read File.join(@filepath, 'all_todo_detail.txt')
140
+ # synchronises the when field
141
+ #
142
+ def sync(px, px2)
85
143
 
86
- px = Polyrex.new parse_detail(s)
87
144
  results = []
88
145
 
89
146
  px.each_recursive do |x, parent|
90
147
 
91
148
  if x.when.length > 0 then
92
149
 
93
- basic_xpath = x.node.backtrack.to_xpath
150
+ basic_xpath = x.node.backtrack(use_attributes: false).to_xpath
94
151
 
95
152
  a = basic_xpath.split('/')
96
153
  a.shift # removes the root node reference
@@ -108,35 +165,45 @@ class AllTodo < PxTodo
108
165
  results << [xpath, x.when]
109
166
  end
110
167
  end
111
-
112
- # open the all_todo_detail.xml file
113
-
114
- xmlfilepath = File.join(@filepath, 'all_todo_detail.xml')
115
-
116
- # if the file doesn't exist save it and return from the method
117
-
118
- unless File.exists? xmlfilepath then
119
- File.write xmlfilepath, px.to_xml(pretty: true)
120
- end
121
-
122
- px2 = Polyrex.new xmlfilepath
123
-
168
+
124
169
  results.each do |xpath, val|
125
170
 
126
171
  r = px2.element(xpath + '/summary/when')
127
172
  r2 = px.element(xpath + '/summary/when')
128
173
  next unless r
129
174
 
130
- a1, a2 = [r.text, val].map {|x| x.split(';').map(&:strip) }
175
+ a1, a2 = [r.text, val].map {|x| x.to_s.split(';').map(&:strip) }
131
176
 
132
177
  # return values which in both a1 and a2
133
- r2.text = (a1 | a2).join('; ')
178
+ r.text = (a1 | a2).join('; ')
134
179
 
135
180
  end
136
181
 
137
- # update the all_todo_detail.xml file
182
+
183
+ end
184
+
185
+
186
+ def sync_all_todo()
187
+
188
+ # given all_todo.txt is loaded
189
+ # load the master copy (all_todo.xml)
138
190
 
139
- File.write xmlfilepath, px.to_xml(pretty: true)
191
+ px = Polyrex.new File.join(@filepath, 'all_todo.xml')
192
+
193
+ sync px, @px
194
+
195
+ end
196
+
197
+
198
+ # synchronises the all_todo_detail.txt file and updates the *when* field in
199
+ # the all_todo.xml file
200
+ #
201
+ def sync_detail()
202
+
203
+ s = File.read File.join(@filepath, 'all_todo_detail.txt')
204
+
205
+ px = Polyrex.new parse_detail(s)
206
+ sync px, @px
140
207
 
141
208
  end
142
209
 
@@ -146,10 +213,9 @@ class AllTodo < PxTodo
146
213
 
147
214
  # also update the all_todo.txt and all_todo_detail.txt
148
215
 
149
- File.write File.join(@filepath, 'all_todo.txt'), self.to_s
150
-
151
- #update_detail()
152
- #File.write File.join(@filepath, 'all_todo_detail.txt'), self.detail
216
+ File.write File.join(@filepath, 'all_todo.txt'), self.to_s
217
+ File.write File.join(@filepath, 'all_todo_detail.txt'), self.detail
218
+
153
219
  'saved'
154
220
 
155
221
  end
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.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  4IWTpx4UfuUB+a/n3zRd7tPzfsCnbjv0WeNaOLxPEdrqrbPxdMp0ULnHMi6/cuMX
32
32
  +/4csIEIHj2yLg==
33
33
  -----END CERTIFICATE-----
34
- date: 2016-12-03 00:00:00.000000000 Z
34
+ date: 2016-12-11 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: px_todo
@@ -42,7 +42,7 @@ dependencies:
42
42
  version: '0.1'
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
- version: 0.1.1
45
+ version: 0.1.3
46
46
  type: :runtime
47
47
  prerelease: false
48
48
  version_requirements: !ruby/object:Gem::Requirement
@@ -52,27 +52,27 @@ dependencies:
52
52
  version: '0.1'
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: 0.1.1
55
+ version: 0.1.3
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: rexle-diff
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '0.5'
62
+ version: '0.6'
63
63
  - - ">="
64
64
  - !ruby/object:Gem::Version
65
- version: 0.5.4
65
+ version: 0.6.1
66
66
  type: :runtime
67
67
  prerelease: false
68
68
  version_requirements: !ruby/object:Gem::Requirement
69
69
  requirements:
70
70
  - - "~>"
71
71
  - !ruby/object:Gem::Version
72
- version: '0.5'
72
+ version: '0.6'
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 0.5.4
75
+ version: 0.6.1
76
76
  description:
77
77
  email: james@r0bertson.co.uk
78
78
  executables: []
metadata.gz.sig CHANGED
Binary file