standup_md 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +7 -1
- data/README.md +142 -116
- data/bin/standup +1 -1
- data/doc/README_md.html +143 -96
- data/doc/StandupMD.html +96 -1322
- data/doc/StandupMD/Cli.html +124 -479
- data/doc/StandupMD/Cli/Helpers.html +167 -0
- data/doc/StandupMD/Config.html +230 -0
- data/doc/StandupMD/Config/Cli.html +355 -0
- data/doc/StandupMD/Config/Entry.html +284 -0
- data/doc/StandupMD/Config/EntryList.html +197 -0
- data/doc/StandupMD/Config/File.html +609 -0
- data/doc/StandupMD/Entry.html +478 -0
- data/doc/StandupMD/EntryList.html +759 -0
- data/doc/StandupMD/File.html +574 -0
- data/doc/created.rid +15 -5
- data/doc/index.html +153 -94
- data/doc/js/search_index.js +1 -1
- data/doc/js/search_index.js.gz +0 -0
- data/doc/table_of_contents.html +221 -72
- data/lib/standup_md.rb +27 -544
- data/lib/standup_md/cli.rb +63 -246
- data/lib/standup_md/cli/helpers.rb +165 -0
- data/lib/standup_md/config.rb +45 -0
- data/lib/standup_md/config/cli.rb +106 -0
- data/lib/standup_md/config/entry.rb +61 -0
- data/lib/standup_md/config/entry_list.rb +26 -0
- data/lib/standup_md/config/file.rb +199 -0
- data/lib/standup_md/entry.rb +121 -0
- data/lib/standup_md/entry_list.rb +166 -0
- data/lib/standup_md/file.rb +172 -0
- data/lib/standup_md/file/helpers.rb +62 -0
- data/lib/standup_md/version.rb +5 -3
- data/standup_md.gemspec +1 -0
- metadata +35 -2
@@ -0,0 +1,574 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>class StandupMD::File - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "../";
|
11
|
+
var index_rel_prefix = "../";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="../js/navigation.js" defer></script>
|
15
|
+
<script src="../js/search.js" defer></script>
|
16
|
+
<script src="../js/search_index.js" defer></script>
|
17
|
+
<script src="../js/searcher.js" defer></script>
|
18
|
+
<script src="../js/darkfish.js" defer></script>
|
19
|
+
|
20
|
+
<link href="../css/fonts.css" rel="stylesheet">
|
21
|
+
<link href="../css/rdoc.css" rel="stylesheet">
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
<body id="top" role="document" class="class">
|
27
|
+
<nav role="navigation">
|
28
|
+
<div id="project-navigation">
|
29
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
30
|
+
<h2>
|
31
|
+
<a href="../index.html" rel="home">Home</a>
|
32
|
+
</h2>
|
33
|
+
|
34
|
+
<div id="table-of-contents-navigation">
|
35
|
+
<a href="../table_of_contents.html#pages">Pages</a>
|
36
|
+
<a href="../table_of_contents.html#classes">Classes</a>
|
37
|
+
<a href="../table_of_contents.html#methods">Methods</a>
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
42
|
+
<form action="#" method="get" accept-charset="utf-8">
|
43
|
+
<div id="search-field-wrapper">
|
44
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
45
|
+
aria-autocomplete="list" aria-controls="search-results"
|
46
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
47
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
48
|
+
</div>
|
49
|
+
|
50
|
+
<ul id="search-results" aria-label="Search Results"
|
51
|
+
aria-busy="false" aria-expanded="false"
|
52
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
53
|
+
</form>
|
54
|
+
</div>
|
55
|
+
|
56
|
+
</div>
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
<div id="class-metadata">
|
61
|
+
|
62
|
+
<div id="parent-class-section" class="nav-section">
|
63
|
+
<h3>Parent</h3>
|
64
|
+
|
65
|
+
|
66
|
+
<p class="link">Object
|
67
|
+
|
68
|
+
</div>
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
<!-- Method Quickref -->
|
73
|
+
<div id="method-list-section" class="nav-section">
|
74
|
+
<h3>Methods</h3>
|
75
|
+
|
76
|
+
<ul class="link-list" role="directory">
|
77
|
+
|
78
|
+
<li ><a href="#method-c-config">::config</a>
|
79
|
+
|
80
|
+
<li ><a href="#method-c-find">::find</a>
|
81
|
+
|
82
|
+
<li ><a href="#method-c-find_by_date">::find_by_date</a>
|
83
|
+
|
84
|
+
<li ><a href="#method-c-new">::new</a>
|
85
|
+
|
86
|
+
<li ><a href="#method-i-exist-3F">#exist?</a>
|
87
|
+
|
88
|
+
<li ><a href="#method-i-load">#load</a>
|
89
|
+
|
90
|
+
<li ><a href="#method-i-loaded-3F">#loaded?</a>
|
91
|
+
|
92
|
+
<li ><a href="#method-i-new-3F">#new?</a>
|
93
|
+
|
94
|
+
<li ><a href="#method-i-write">#write</a>
|
95
|
+
|
96
|
+
</ul>
|
97
|
+
</div>
|
98
|
+
|
99
|
+
</div>
|
100
|
+
</nav>
|
101
|
+
|
102
|
+
<main role="main" aria-labelledby="class-StandupMD::File">
|
103
|
+
<h1 id="class-StandupMD::File" class="class">
|
104
|
+
class StandupMD::File
|
105
|
+
</h1>
|
106
|
+
|
107
|
+
<section class="description">
|
108
|
+
|
109
|
+
<p>Class for handling reading and writing standup files.</p>
|
110
|
+
|
111
|
+
</section>
|
112
|
+
|
113
|
+
|
114
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
<section class="attribute-method-details" class="method-section">
|
123
|
+
<header>
|
124
|
+
<h3>Attributes</h3>
|
125
|
+
</header>
|
126
|
+
|
127
|
+
|
128
|
+
<div id="attribute-i-entries" class="method-detail">
|
129
|
+
<div class="method-heading attribute-method-heading">
|
130
|
+
<span class="method-name">entries</span><span
|
131
|
+
class="attribute-access-type">[R]</span>
|
132
|
+
</div>
|
133
|
+
|
134
|
+
<div class="method-description">
|
135
|
+
|
136
|
+
<p>The list of entries in the file.</p>
|
137
|
+
|
138
|
+
<p>@return [StandupMP::EntryList]</p>
|
139
|
+
|
140
|
+
</div>
|
141
|
+
</div>
|
142
|
+
|
143
|
+
<div id="attribute-i-name" class="method-detail">
|
144
|
+
<div class="method-heading attribute-method-heading">
|
145
|
+
<span class="method-name">name</span><span
|
146
|
+
class="attribute-access-type">[R]</span>
|
147
|
+
</div>
|
148
|
+
|
149
|
+
<div class="method-description">
|
150
|
+
|
151
|
+
<p>The name of the file.</p>
|
152
|
+
|
153
|
+
<p>@return [String]</p>
|
154
|
+
|
155
|
+
</div>
|
156
|
+
</div>
|
157
|
+
|
158
|
+
</section>
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
163
|
+
<header>
|
164
|
+
<h3>Public Class Methods</h3>
|
165
|
+
</header>
|
166
|
+
|
167
|
+
|
168
|
+
<div id="method-c-config" class="method-detail ">
|
169
|
+
|
170
|
+
<div class="method-heading">
|
171
|
+
<span class="method-name">config</span><span
|
172
|
+
class="method-args">()</span>
|
173
|
+
|
174
|
+
<span class="method-click-advice">click to toggle source</span>
|
175
|
+
|
176
|
+
</div>
|
177
|
+
|
178
|
+
|
179
|
+
<div class="method-description">
|
180
|
+
|
181
|
+
<p>Access to the class's configuration.</p>
|
182
|
+
|
183
|
+
<p>@return [StandupMD::Config::EntryList]</p>
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
<div class="method-source-code" id="config-source">
|
189
|
+
<pre><span class="ruby-comment"># File lib/standup_md/file.rb, line 18</span>
|
190
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">config</span>
|
191
|
+
<span class="ruby-ivar">@config</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">StandupMD</span>.<span class="ruby-identifier">config</span>.<span class="ruby-identifier">file</span>
|
192
|
+
<span class="ruby-keyword">end</span></pre>
|
193
|
+
</div>
|
194
|
+
|
195
|
+
</div>
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
</div>
|
201
|
+
|
202
|
+
|
203
|
+
<div id="method-c-find" class="method-detail ">
|
204
|
+
|
205
|
+
<div class="method-heading">
|
206
|
+
<span class="method-name">find</span><span
|
207
|
+
class="method-args">(file_name)</span>
|
208
|
+
|
209
|
+
<span class="method-click-advice">click to toggle source</span>
|
210
|
+
|
211
|
+
</div>
|
212
|
+
|
213
|
+
|
214
|
+
<div class="method-description">
|
215
|
+
|
216
|
+
<p>Find standup file in directory by file name.</p>
|
217
|
+
|
218
|
+
<p>@param [String] File_naem</p>
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
<div class="method-source-code" id="find-source">
|
224
|
+
<pre><span class="ruby-comment"># File lib/standup_md/file.rb, line 26</span>
|
225
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">find</span>(<span class="ruby-identifier">file_name</span>)
|
226
|
+
<span class="ruby-identifier">file</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">entries</span>(<span class="ruby-identifier">config</span>.<span class="ruby-identifier">directory</span>).<span class="ruby-identifier">bsearch</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">file_name</span> }
|
227
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">file</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">config</span>.<span class="ruby-identifier">create</span>
|
228
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-node">"File #{file_name} not found."</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">config</span>.<span class="ruby-identifier">create</span>
|
229
|
+
<span class="ruby-keyword">end</span>
|
230
|
+
<span class="ruby-identifier">new</span>(<span class="ruby-identifier">file_name</span>)
|
231
|
+
<span class="ruby-keyword">end</span></pre>
|
232
|
+
</div>
|
233
|
+
|
234
|
+
</div>
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
</div>
|
240
|
+
|
241
|
+
|
242
|
+
<div id="method-c-find_by_date" class="method-detail ">
|
243
|
+
|
244
|
+
<div class="method-heading">
|
245
|
+
<span class="method-name">find_by_date</span><span
|
246
|
+
class="method-args">(date)</span>
|
247
|
+
|
248
|
+
<span class="method-click-advice">click to toggle source</span>
|
249
|
+
|
250
|
+
</div>
|
251
|
+
|
252
|
+
|
253
|
+
<div class="method-description">
|
254
|
+
|
255
|
+
<p>Find standup file in directory by Date object.</p>
|
256
|
+
|
257
|
+
<p>@param [Date] date</p>
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
<div class="method-source-code" id="find_by_date-source">
|
263
|
+
<pre><span class="ruby-comment"># File lib/standup_md/file.rb, line 38</span>
|
264
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">find_by_date</span>(<span class="ruby-identifier">date</span>)
|
265
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">date</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Date</span>)
|
266
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">"Argument must be a Date object"</span>
|
267
|
+
<span class="ruby-keyword">end</span>
|
268
|
+
<span class="ruby-identifier">find</span>(<span class="ruby-identifier">date</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-identifier">config</span>.<span class="ruby-identifier">name_format</span>))
|
269
|
+
<span class="ruby-keyword">end</span></pre>
|
270
|
+
</div>
|
271
|
+
|
272
|
+
</div>
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
</div>
|
278
|
+
|
279
|
+
|
280
|
+
<div id="method-c-new" class="method-detail ">
|
281
|
+
|
282
|
+
<div class="method-heading">
|
283
|
+
<span class="method-name">new</span><span
|
284
|
+
class="method-args">(file_name)</span>
|
285
|
+
|
286
|
+
<span class="method-click-advice">click to toggle source</span>
|
287
|
+
|
288
|
+
</div>
|
289
|
+
|
290
|
+
|
291
|
+
<div class="method-description">
|
292
|
+
|
293
|
+
<p>Constructs the instance.</p>
|
294
|
+
|
295
|
+
<p>@param [String] file_name</p>
|
296
|
+
|
297
|
+
<p>@return [StandupMP::File]</p>
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
<div class="method-source-code" id="new-source">
|
303
|
+
<pre><span class="ruby-comment"># File lib/standup_md/file.rb, line 63</span>
|
304
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">file_name</span>)
|
305
|
+
<span class="ruby-ivar">@config</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">config</span>
|
306
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">file_name</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-operator">::</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">SEPARATOR</span>)
|
307
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>,
|
308
|
+
<span class="ruby-node">"#{file_name} contains directory. Please use `StandupMD.config.file.directory=`"</span>
|
309
|
+
<span class="ruby-keyword">end</span>
|
310
|
+
|
311
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-ivar">@config</span>.<span class="ruby-identifier">directory</span>)
|
312
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-node">"Dir #{@config.directory} not found."</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@config</span>.<span class="ruby-identifier">create</span>
|
313
|
+
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>(<span class="ruby-ivar">@config</span>.<span class="ruby-identifier">directory</span>)
|
314
|
+
<span class="ruby-keyword">end</span>
|
315
|
+
|
316
|
+
<span class="ruby-ivar">@name</span> = <span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@config</span>.<span class="ruby-identifier">directory</span>, <span class="ruby-identifier">file_name</span>))
|
317
|
+
|
318
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-ivar">@name</span>)
|
319
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-node">"File #{@name} not found."</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@config</span>.<span class="ruby-identifier">create</span>
|
320
|
+
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-ivar">@name</span>)
|
321
|
+
<span class="ruby-keyword">end</span>
|
322
|
+
|
323
|
+
<span class="ruby-ivar">@new</span> = <span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">zero?</span>(<span class="ruby-ivar">@name</span>)
|
324
|
+
<span class="ruby-ivar">@loaded</span> = <span class="ruby-keyword">false</span>
|
325
|
+
<span class="ruby-keyword">end</span></pre>
|
326
|
+
</div>
|
327
|
+
|
328
|
+
</div>
|
329
|
+
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
</div>
|
334
|
+
|
335
|
+
|
336
|
+
</section>
|
337
|
+
|
338
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
339
|
+
<header>
|
340
|
+
<h3>Public Instance Methods</h3>
|
341
|
+
</header>
|
342
|
+
|
343
|
+
|
344
|
+
<div id="method-i-exist-3F" class="method-detail ">
|
345
|
+
|
346
|
+
<div class="method-heading">
|
347
|
+
<span class="method-name">exist?</span><span
|
348
|
+
class="method-args">()</span>
|
349
|
+
|
350
|
+
<span class="method-click-advice">click to toggle source</span>
|
351
|
+
|
352
|
+
</div>
|
353
|
+
|
354
|
+
|
355
|
+
<div class="method-description">
|
356
|
+
|
357
|
+
<p>Does the file exist?</p>
|
358
|
+
|
359
|
+
<p>@return [Boolean] true if exists</p>
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
|
364
|
+
<div class="method-source-code" id="exist-3F-source">
|
365
|
+
<pre><span class="ruby-comment"># File lib/standup_md/file.rb, line 106</span>
|
366
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">exist?</span>
|
367
|
+
<span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">name</span>)
|
368
|
+
<span class="ruby-keyword">end</span></pre>
|
369
|
+
</div>
|
370
|
+
|
371
|
+
</div>
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
</div>
|
377
|
+
|
378
|
+
|
379
|
+
<div id="method-i-load" class="method-detail ">
|
380
|
+
|
381
|
+
<div class="method-heading">
|
382
|
+
<span class="method-name">load</span><span
|
383
|
+
class="method-args">()</span>
|
384
|
+
|
385
|
+
<span class="method-click-advice">click to toggle source</span>
|
386
|
+
|
387
|
+
</div>
|
388
|
+
|
389
|
+
|
390
|
+
<div class="method-description">
|
391
|
+
|
392
|
+
<p>Loads the file's contents. TODO clean up this method.</p>
|
393
|
+
|
394
|
+
<p>@return [StandupMD::FileList]</p>
|
395
|
+
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
<div class="method-source-code" id="load-source">
|
400
|
+
<pre><span class="ruby-comment"># File lib/standup_md/file.rb, line 115</span>
|
401
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">load</span>
|
402
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-node">"File #{name} does not exist."</span> <span class="ruby-keyword">unless</span> <span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-identifier">name</span>)
|
403
|
+
<span class="ruby-identifier">entry_list</span> = <span class="ruby-constant">EntryList</span>.<span class="ruby-identifier">new</span>
|
404
|
+
<span class="ruby-identifier">record</span> = {}
|
405
|
+
<span class="ruby-identifier">section_type</span> = <span class="ruby-string">''</span>
|
406
|
+
<span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">foreach</span>(<span class="ruby-identifier">name</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
|
407
|
+
<span class="ruby-identifier">line</span>.<span class="ruby-identifier">chomp!</span>
|
408
|
+
<span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">empty?</span>
|
409
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">is_header?</span>(<span class="ruby-identifier">line</span>)
|
410
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">record</span>.<span class="ruby-identifier">empty?</span>
|
411
|
+
<span class="ruby-identifier">entry_list</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">new_entry</span>(<span class="ruby-identifier">record</span>)
|
412
|
+
<span class="ruby-identifier">record</span> = {}
|
413
|
+
<span class="ruby-keyword">end</span>
|
414
|
+
<span class="ruby-identifier">record</span>[<span class="ruby-string">'header'</span>] = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">%r{^\#{#{@config.header_depth}}\s*}</span>, <span class="ruby-string">''</span>)
|
415
|
+
<span class="ruby-identifier">section_type</span> = <span class="ruby-ivar">@config</span>.<span class="ruby-identifier">notes_header</span>
|
416
|
+
<span class="ruby-identifier">record</span>[<span class="ruby-identifier">section_type</span>] = []
|
417
|
+
<span class="ruby-keyword">elsif</span> <span class="ruby-identifier">is_sub_header?</span>(<span class="ruby-identifier">line</span>)
|
418
|
+
<span class="ruby-identifier">section_type</span> = <span class="ruby-identifier">determine_section_type</span>(<span class="ruby-identifier">line</span>)
|
419
|
+
<span class="ruby-identifier">record</span>[<span class="ruby-identifier">section_type</span>] = []
|
420
|
+
<span class="ruby-keyword">else</span>
|
421
|
+
<span class="ruby-identifier">record</span>[<span class="ruby-identifier">section_type</span>] <span class="ruby-operator"><<</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-identifier">bullet_character_regex</span>, <span class="ruby-string">''</span>)
|
422
|
+
<span class="ruby-keyword">end</span>
|
423
|
+
<span class="ruby-keyword">end</span>
|
424
|
+
<span class="ruby-identifier">entry_list</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">new_entry</span>(<span class="ruby-identifier">record</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">record</span>.<span class="ruby-identifier">empty?</span>
|
425
|
+
<span class="ruby-ivar">@loaded</span> = <span class="ruby-keyword">true</span>
|
426
|
+
<span class="ruby-ivar">@entries</span> = <span class="ruby-identifier">entry_list</span>.<span class="ruby-identifier">sort</span>
|
427
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-operator">=></span> <span class="ruby-identifier">e</span>
|
428
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-node">"File malformation: #{e}"</span>
|
429
|
+
<span class="ruby-keyword">end</span></pre>
|
430
|
+
</div>
|
431
|
+
|
432
|
+
</div>
|
433
|
+
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
</div>
|
438
|
+
|
439
|
+
|
440
|
+
<div id="method-i-loaded-3F" class="method-detail ">
|
441
|
+
|
442
|
+
<div class="method-heading">
|
443
|
+
<span class="method-name">loaded?</span><span
|
444
|
+
class="method-args">()</span>
|
445
|
+
|
446
|
+
<span class="method-click-advice">click to toggle source</span>
|
447
|
+
|
448
|
+
</div>
|
449
|
+
|
450
|
+
|
451
|
+
<div class="method-description">
|
452
|
+
|
453
|
+
<p>Has the file been loaded?</p>
|
454
|
+
|
455
|
+
<p>@return [Boolean] true if loaded</p>
|
456
|
+
|
457
|
+
|
458
|
+
|
459
|
+
|
460
|
+
<div class="method-source-code" id="loaded-3F-source">
|
461
|
+
<pre><span class="ruby-comment"># File lib/standup_md/file.rb, line 98</span>
|
462
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">loaded?</span>
|
463
|
+
<span class="ruby-ivar">@loaded</span>
|
464
|
+
<span class="ruby-keyword">end</span></pre>
|
465
|
+
</div>
|
466
|
+
|
467
|
+
</div>
|
468
|
+
|
469
|
+
|
470
|
+
|
471
|
+
|
472
|
+
</div>
|
473
|
+
|
474
|
+
|
475
|
+
<div id="method-i-new-3F" class="method-detail ">
|
476
|
+
|
477
|
+
<div class="method-heading">
|
478
|
+
<span class="method-name">new?</span><span
|
479
|
+
class="method-args">()</span>
|
480
|
+
|
481
|
+
<span class="method-click-advice">click to toggle source</span>
|
482
|
+
|
483
|
+
</div>
|
484
|
+
|
485
|
+
|
486
|
+
<div class="method-description">
|
487
|
+
|
488
|
+
<p>Was the file just now created?</p>
|
489
|
+
|
490
|
+
<p>@return [Boolean] true if new</p>
|
491
|
+
|
492
|
+
|
493
|
+
|
494
|
+
|
495
|
+
<div class="method-source-code" id="new-3F-source">
|
496
|
+
<pre><span class="ruby-comment"># File lib/standup_md/file.rb, line 90</span>
|
497
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">new?</span>
|
498
|
+
<span class="ruby-ivar">@new</span>
|
499
|
+
<span class="ruby-keyword">end</span></pre>
|
500
|
+
</div>
|
501
|
+
|
502
|
+
</div>
|
503
|
+
|
504
|
+
|
505
|
+
|
506
|
+
|
507
|
+
</div>
|
508
|
+
|
509
|
+
|
510
|
+
<div id="method-i-write" class="method-detail ">
|
511
|
+
|
512
|
+
<div class="method-heading">
|
513
|
+
<span class="method-name">write</span><span
|
514
|
+
class="method-args">(dates = {})</span>
|
515
|
+
|
516
|
+
<span class="method-click-advice">click to toggle source</span>
|
517
|
+
|
518
|
+
</div>
|
519
|
+
|
520
|
+
|
521
|
+
<div class="method-description">
|
522
|
+
|
523
|
+
<p>Writes a new entry to the file if the first entry in the file isn't today. This method is destructive; if a file for entries in the date range already exists, it will be clobbered with the entries in the range.</p>
|
524
|
+
|
525
|
+
<p>@param [Hash] start_and_end_date</p>
|
526
|
+
|
527
|
+
<p>@return [Boolean] true if successful</p>
|
528
|
+
|
529
|
+
|
530
|
+
|
531
|
+
|
532
|
+
<div class="method-source-code" id="write-source">
|
533
|
+
<pre><span class="ruby-comment"># File lib/standup_md/file.rb, line 153</span>
|
534
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">write</span>(<span class="ruby-identifier">dates</span> = {})
|
535
|
+
<span class="ruby-identifier">sorted_entries</span> = <span class="ruby-identifier">entries</span>.<span class="ruby-identifier">sort</span>
|
536
|
+
<span class="ruby-identifier">start_date</span> = <span class="ruby-identifier">dates</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:start_date</span>, <span class="ruby-identifier">sorted_entries</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">date</span>)
|
537
|
+
<span class="ruby-identifier">end_date</span> = <span class="ruby-identifier">dates</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:end_date</span>, <span class="ruby-identifier">sorted_entries</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">date</span>)
|
538
|
+
<span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">name</span>, <span class="ruby-string">'w'</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
|
539
|
+
<span class="ruby-identifier">sorted_entries</span>.<span class="ruby-identifier">filter</span>(<span class="ruby-identifier">start_date</span>, <span class="ruby-identifier">end_date</span>).<span class="ruby-identifier">sort_reverse</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">entry</span><span class="ruby-operator">|</span>
|
540
|
+
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">header</span>(<span class="ruby-identifier">entry</span>.<span class="ruby-identifier">date</span>)
|
541
|
+
<span class="ruby-ivar">@config</span>.<span class="ruby-identifier">sub_header_order</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">attr</span><span class="ruby-operator">|</span>
|
542
|
+
<span class="ruby-identifier">tasks</span> = <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">attr</span>)
|
543
|
+
<span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">tasks</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">tasks</span>.<span class="ruby-identifier">empty?</span>
|
544
|
+
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">sub_header</span>(<span class="ruby-ivar">@config</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">"#{attr}_header"</span>).<span class="ruby-identifier">capitalize</span>)
|
545
|
+
<span class="ruby-identifier">tasks</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">task</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">puts</span> <span class="ruby-ivar">@config</span>.<span class="ruby-identifier">bullet_character</span> <span class="ruby-operator">+</span> <span class="ruby-string">' '</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">task</span> }
|
546
|
+
<span class="ruby-keyword">end</span>
|
547
|
+
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">puts</span>
|
548
|
+
<span class="ruby-keyword">end</span>
|
549
|
+
<span class="ruby-keyword">end</span>
|
550
|
+
<span class="ruby-keyword">true</span>
|
551
|
+
<span class="ruby-keyword">end</span></pre>
|
552
|
+
</div>
|
553
|
+
|
554
|
+
</div>
|
555
|
+
|
556
|
+
|
557
|
+
|
558
|
+
|
559
|
+
</div>
|
560
|
+
|
561
|
+
|
562
|
+
</section>
|
563
|
+
|
564
|
+
</section>
|
565
|
+
|
566
|
+
</main>
|
567
|
+
|
568
|
+
|
569
|
+
<footer id="validator-badges" role="contentinfo">
|
570
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
571
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.1.
|
572
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
573
|
+
</footer>
|
574
|
+
|