standup_md 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/standup_md.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
-
2
+ require 'yaml'
3
3
  require 'date'
4
4
  require 'fileutils'
5
5
  require_relative 'standup_md/version'
@@ -12,19 +12,17 @@ require_relative 'standup_md/version'
12
12
  class StandupMD
13
13
 
14
14
  ##
15
- # Convenience method for calling +new+ + +load+
15
+ # Convenience method for calling +new+ + +load+. Accepts a +YAML+ config file
16
+ # as an argument, and yields the standup instance if a block is given.
16
17
  #
17
- # @param [Hash] attributes Attributes to set before loading.
18
+ # @param [String] config_file File path to config file.
18
19
  #
19
20
  # @example
20
21
  # su = StandupMD.load(bullet_character: '*')
21
- def self.load(attributes = {})
22
- self.new do |s|
23
- attributes.each do |k, v|
24
- next unless s.respond_to?(k)
25
- s.send("#{k}=", v)
26
- end
27
- end.load
22
+ def self.load(config_file = nil)
23
+ s = new(config_file)
24
+ yield s if block_given?
25
+ s.load
28
26
  end
29
27
 
30
28
  # :section: Attributes that aren't settable by user, but are gettable.
@@ -48,9 +46,10 @@ class StandupMD
48
46
  attr_reader :file
49
47
 
50
48
  ##
51
- # The file that contains previous entries. When last month's file exists, but
52
- # this month's doesn't or is empty, previous_file should equal last month's
53
- # file.
49
+ # The file that contains the previous entry. If previous entry was same month,
50
+ # previous_file will be the same as file. If previous entry was last month,
51
+ # and a file exists for last month, previous_file is last month's file.
52
+ # If neither is true, returns an empty string.
54
53
  #
55
54
  # @return [String]
56
55
  #
@@ -112,6 +111,19 @@ class StandupMD
112
111
 
113
112
  # :section: Attributes that are settable by the user, but have custom setters.
114
113
 
114
+ ##
115
+ # The configuration file. Default is +nil+. If set to a string, and the file
116
+ # exists, it is used to set options.
117
+ #
118
+ # @return [String] file path
119
+ attr_reader :config_file
120
+
121
+ ##
122
+ # The options from +config_file+ as a hash.
123
+ #
124
+ # @return [Hash] Options from +config_file+
125
+ attr_reader :config
126
+
115
127
  ##
116
128
  # The directory where the markdown files are kept.
117
129
  #
@@ -220,17 +232,23 @@ class StandupMD
220
232
  attr_accessor :notes_header
221
233
 
222
234
  ##
223
- # Constructor. Yields the instance so you can pass a block to access setters.
235
+ # Constructor. Takes a path to a +YAML+ configuration file as an argument. If
236
+ # passed, settings from the config file will be set. After +config_file+ is
237
+ # loaded, yields +self+ so you can pass a block to access setters,
238
+ # overwriting settings from +config_file+.
239
+ #
240
+ # @param [String] config_file The config file, if any, to load.
224
241
  #
225
242
  # @return [self]
226
243
  #
227
244
  # @example
228
- # su = StandupMD.new do |s|
245
+ # su = StandupMD.new('~/.standup_md.yml') do |s|
229
246
  # s.directory = @workdir
230
247
  # s.file_name_format = '%y_%m.markdown'
231
248
  # s.bullet_character = '*'
232
249
  # end
233
- def initialize
250
+ def initialize(config_file = nil)
251
+ @config = {}
234
252
  @notes = []
235
253
  @header_depth = 1
236
254
  @sub_header_depth = 2
@@ -245,12 +263,21 @@ class StandupMD
245
263
  @impediments_header = 'Impediments'
246
264
  @notes_header = 'Notes'
247
265
  @sub_header_order = %w[previous current impediments notes]
266
+ @config_file_loaded = false
267
+ @config_file = config_file && File.expand_path(config_file)
268
+
269
+ load_config_file if config_file
248
270
 
249
271
  yield self if block_given?
250
272
  end
251
273
 
252
- # :section: Booleans
253
- # Helper methods for booleans.
274
+ ##
275
+ # Has a config file been loaded?
276
+ #
277
+ # @return [Boolean]
278
+ def config_file_loaded?
279
+ @config_file_loaded
280
+ end
254
281
 
255
282
  ##
256
283
  # Has the file been written since instantiated?
@@ -276,9 +303,6 @@ class StandupMD
276
303
  @entry_previously_added
277
304
  end
278
305
 
279
- # :section: Custom setters
280
- # Setters that required validations.
281
-
282
306
  ##
283
307
  # Setter for current entry tasks.
284
308
  #
@@ -334,6 +358,18 @@ class StandupMD
334
358
  @bullet_character = character
335
359
  end
336
360
 
361
+ ##
362
+ # Setter for directory. Must be expanded in case the user uses `~` for home.
363
+ # If the directory doesn't exist, it will be created. To reset instance
364
+ # variables after changing the directory, you'll need to call load.
365
+ #
366
+ # @param [String] file
367
+ #
368
+ # @return [String]
369
+ def config_file=(config_file)
370
+ @config_file = File.expand_path(config_file)
371
+ end
372
+
337
373
  ##
338
374
  # Setter for directory. Must be expanded in case the user uses `~` for home.
339
375
  # If the directory doesn't exist, it will be created. To reset instance
@@ -343,7 +379,6 @@ class StandupMD
343
379
  #
344
380
  # @return [String]
345
381
  def directory=(directory)
346
- # TODO test this
347
382
  directory = File.expand_path(directory)
348
383
  FileUtils.mkdir_p(directory) unless File.directory?(directory)
349
384
  @directory = directory
@@ -359,7 +394,7 @@ class StandupMD
359
394
  if !depth.between?(1, 5)
360
395
  raise 'Header depth out of bounds (1..5)'
361
396
  elsif depth >= sub_header_depth
362
- raise 'header_depth must be larger than sub_header_depth'
397
+ @sub_header_depth = depth + 1
363
398
  end
364
399
  @header_depth = depth
365
400
  end
@@ -374,7 +409,7 @@ class StandupMD
374
409
  if !depth.between?(2, 6)
375
410
  raise 'Sub-header depth out of bounds (2..6)'
376
411
  elsif depth <= header_depth
377
- raise 'sub_header_depth must be smaller than header_depth'
412
+ @header_depth = depth - 1
378
413
  end
379
414
  @sub_header_depth = depth
380
415
  end
@@ -391,9 +426,6 @@ class StandupMD
391
426
  @sub_header_order = array
392
427
  end
393
428
 
394
- # :section: Misc
395
- # Misc.
396
-
397
429
  ##
398
430
  # Return a copy of the sub-header order so the user can't modify the array.
399
431
  #
@@ -402,6 +434,18 @@ class StandupMD
402
434
  @sub_header_order.dup
403
435
  end
404
436
 
437
+ ##
438
+ # Loads the config file
439
+ #
440
+ # @return [Hash] The config options
441
+ def load_config_file
442
+ raise 'No config file set' if config_file.nil?
443
+ raise "File #{config_file} does not exist" unless File.file?(config_file)
444
+ @config = YAML::load_file(config_file)
445
+ @config_file_loaded = true
446
+ @config.each { |k, v| send("#{k}=", v) }
447
+ end
448
+
405
449
  ##
406
450
  # Writes a new entry to the file if the first entry in the file isn't today.
407
451
  #
@@ -477,11 +521,6 @@ class StandupMD
477
521
  @today
478
522
  end
479
523
 
480
- ##
481
- # The file that contains the previous entry. If previous entry was same month,
482
- # previous_file will be the same as file. If previous entry was last month,
483
- # and a file exists for last month, previous_file is last month's file.
484
- # If neither is true, returns an empty string.
485
524
  def get_previous_file # :nodoc:
486
525
  return file if File.file?(file) && !File.zero?(file)
487
526
  prev_month_file = File.expand_path(File.join(
@@ -1,5 +1,4 @@
1
1
  require 'json'
2
- require 'yaml'
3
2
  require 'optparse'
4
3
  require_relative '../standup_md'
5
4
 
@@ -58,8 +57,13 @@ class StandupMD
58
57
  #
59
58
  # @return [StandupMD]
60
59
  def standup
61
- @standup ||= ::StandupMD.new do |s|
62
- echo 'Runtime options:'
60
+ cf = File.file?(PREFERENCE_FILE) ? PREFERENCE_FILE : nil
61
+ @standup ||= ::StandupMD.new(cf) do |s|
62
+ if s.config.any?
63
+ echo 'Config options:'
64
+ s.config.each { |k, v| echo " #{k} = #{v}" }
65
+ end
66
+ echo 'Runtime options:' if preferences.any?
63
67
  preferences.each do |k, v|
64
68
  echo " #{k} = #{v}"
65
69
  s.send("#{k}=", v)
@@ -134,7 +138,7 @@ class StandupMD
134
138
  ##
135
139
  # Opens the file in an editor. Abandons the script.
136
140
  def edit
137
- echo " Opening file in #{editor}"
141
+ echo "Opening file in #{editor}"
138
142
  exec("#{editor} #{standup.file}")
139
143
  end
140
144
 
@@ -143,7 +147,7 @@ class StandupMD
143
147
  #
144
148
  # @return [Boolean] true if file was written
145
149
  def write_file
146
- echo ' Writing file'
150
+ echo 'Writing file'
147
151
  standup.write
148
152
  end
149
153
 
@@ -295,7 +299,7 @@ class StandupMD
295
299
  end
296
300
  end.parse!(options)
297
301
 
298
- (File.file?(PREFERENCE_FILE) ? YAML.load_file(PREFERENCE_FILE) : {}).merge(prefs)
302
+ prefs
299
303
  end
300
304
  end
301
305
  end
@@ -4,6 +4,6 @@ class StandupMD
4
4
  #
5
5
  # @example
6
6
  # StandupMD::VERSION
7
- # # => '0.1.3'
8
- VERSION = '0.1.3'
7
+ # # => '0.2.0'
8
+ VERSION = '0.2.0'
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standup_md
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Gray
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-01 00:00:00.000000000 Z
11
+ date: 2020-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -69,9 +69,6 @@ files:
69
69
  - doc/README_md.html
70
70
  - doc/StandupMD.html
71
71
  - doc/StandupMD/Cli.html
72
- - doc/TestCli.html
73
- - doc/TestHelper.html
74
- - doc/TestStandupMD.html
75
72
  - doc/created.rid
76
73
  - doc/css/fonts.css
77
74
  - doc/css/rdoc.css
data/doc/TestCli.html DELETED
@@ -1,792 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <meta charset="UTF-8">
6
-
7
- <title>class TestCli - 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">Test::Unit::TestCase
67
-
68
- </div>
69
-
70
- <div id="includes-section" class="nav-section">
71
- <h3>Included Modules</h3>
72
-
73
- <ul class="link-list">
74
-
75
-
76
- <li><a class="include" href="TestHelper.html">TestHelper</a>
77
-
78
-
79
- </ul>
80
- </div>
81
-
82
-
83
- <!-- Method Quickref -->
84
- <div id="method-list-section" class="nav-section">
85
- <h3>Methods</h3>
86
-
87
- <ul class="link-list" role="directory">
88
-
89
- <li ><a href="#method-i-setup">#setup</a>
90
-
91
- <li ><a href="#method-i-should_append-3F">#should_append?</a>
92
-
93
- <li ><a href="#method-i-teardown">#teardown</a>
94
-
95
- <li ><a href="#method-i-test_PREFERENCE_FILE">#test_PREFERENCE_FILE</a>
96
-
97
- <li ><a href="#method-i-test_append_previous-3F">#test_append_previous?</a>
98
-
99
- <li ><a href="#method-i-test_edit-3F">#test_edit?</a>
100
-
101
- <li ><a href="#method-i-test_editor">#test_editor</a>
102
-
103
- <li ><a href="#method-i-test_initialize">#test_initialize</a>
104
-
105
- <li ><a href="#method-i-test_json-3F">#test_json?</a>
106
-
107
- <li ><a href="#method-i-test_options">#test_options</a>
108
-
109
- <li ><a href="#method-i-test_preferences">#test_preferences</a>
110
-
111
- <li ><a href="#method-i-test_print_all_entries-3F">#test_print_all_entries?</a>
112
-
113
- <li ><a href="#method-i-test_print_current_entry-3F">#test_print_current_entry?</a>
114
-
115
- <li ><a href="#method-i-test_self_execute">#test_self_execute</a>
116
-
117
- <li ><a href="#method-i-test_standup">#test_standup</a>
118
-
119
- <li ><a href="#method-i-test_verbose-3F">#test_verbose?</a>
120
-
121
- <li ><a href="#method-i-test_write-3F">#test_write?</a>
122
-
123
- </ul>
124
- </div>
125
-
126
- </div>
127
- </nav>
128
-
129
- <main role="main" aria-labelledby="class-TestCli">
130
- <h1 id="class-TestCli" class="class">
131
- class TestCli
132
- </h1>
133
-
134
- <section class="description">
135
-
136
- <p>The test suite for <code>Cli</code>.</p>
137
-
138
- </section>
139
-
140
-
141
- <section id="5Buntitled-5D" class="documentation-section">
142
-
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
- <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
152
- <header>
153
- <h3>Public Instance Methods</h3>
154
- </header>
155
-
156
-
157
- <div id="method-i-setup" class="method-detail ">
158
-
159
- <div class="method-heading">
160
- <span class="method-name">setup</span><span
161
- class="method-args">()</span>
162
-
163
- <span class="method-click-advice">click to toggle source</span>
164
-
165
- </div>
166
-
167
-
168
- <div class="method-description">
169
-
170
- <p>Set working directory, current month&#39;s file, and last month&#39;s file, which will be created and destroyed for each test.</p>
171
-
172
-
173
-
174
-
175
- <div class="method-source-code" id="setup-source">
176
- <pre><span class="ruby-comment"># File test/standup_md/cli_test.rb, line 12</span>
177
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">setup</span>
178
- <span class="ruby-ivar">@workdir</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">__dir__</span>, <span class="ruby-string">&#39;files&#39;</span>)
179
- <span class="ruby-ivar">@current_test_file</span> =
180
- <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@workdir</span>, <span class="ruby-constant">Date</span>.<span class="ruby-identifier">today</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%Y_%m.md&#39;</span>))
181
- <span class="ruby-ivar">@previous_month_test_file</span> =
182
- <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@workdir</span>, <span class="ruby-constant">Date</span>.<span class="ruby-identifier">today</span>.<span class="ruby-identifier">prev_month</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%Y_%m.md&#39;</span>))
183
- <span class="ruby-ivar">@options</span> = [<span class="ruby-string">&#39;--no-edit&#39;</span>, <span class="ruby-string">&#39;--no-write&#39;</span>, <span class="ruby-node">&quot;--directory=#{@workdir}&quot;</span>]
184
- <span class="ruby-keyword">end</span></pre>
185
- </div>
186
-
187
- </div>
188
-
189
-
190
-
191
-
192
- </div>
193
-
194
-
195
- <div id="method-i-should_append-3F" class="method-detail ">
196
-
197
- <div class="method-heading">
198
- <span class="method-name">should_append?</span><span
199
- class="method-args">()</span>
200
-
201
- <span class="method-click-advice">click to toggle source</span>
202
-
203
- </div>
204
-
205
-
206
- <div class="method-description">
207
-
208
- <p>True only if <code>--no-append</code> and <code>--previous-entry-tasks</code> are passed.</p>
209
-
210
-
211
-
212
-
213
- <div class="method-source-code" id="should_append-3F-source">
214
- <pre><span class="ruby-comment"># File test/standup_md/cli_test.rb, line 161</span>
215
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">should_append?</span>
216
- <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cli</span>
217
- <span class="ruby-identifier">refute</span>(<span class="ruby-identifier">c</span>.<span class="ruby-identifier">should_append?</span>)
218
-
219
- <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cli</span>[<span class="ruby-string">&#39;--no-append&#39;</span>]
220
- <span class="ruby-identifier">refute</span>(<span class="ruby-identifier">c</span>.<span class="ruby-identifier">should_append?</span>)
221
-
222
- <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cli</span>([<span class="ruby-string">&#39;--no-append&#39;</span>, <span class="ruby-string">&#39;--previous-entry-tasks=&quot;test one&quot;,&quot;test two&quot;&#39;</span>])
223
- <span class="ruby-identifier">refute</span>(<span class="ruby-identifier">c</span>.<span class="ruby-identifier">should_append?</span>)
224
-
225
- <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cli</span>([<span class="ruby-string">&#39;--previous-entry-tasks=&quot;test one&quot;,&quot;test two&quot;&#39;</span>])
226
- <span class="ruby-identifier">assert</span>(<span class="ruby-identifier">c</span>.<span class="ruby-identifier">should_append?</span>)
227
- <span class="ruby-keyword">end</span></pre>
228
- </div>
229
-
230
- </div>
231
-
232
-
233
-
234
-
235
- </div>
236
-
237
-
238
- <div id="method-i-teardown" class="method-detail ">
239
-
240
- <div class="method-heading">
241
- <span class="method-name">teardown</span><span
242
- class="method-args">()</span>
243
-
244
- <span class="method-click-advice">click to toggle source</span>
245
-
246
- </div>
247
-
248
-
249
- <div class="method-description">
250
-
251
- <p>Destroy the working directory and its contents.</p>
252
-
253
-
254
-
255
-
256
- <div class="method-source-code" id="teardown-source">
257
- <pre><span class="ruby-comment"># File test/standup_md/cli_test.rb, line 23</span>
258
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">teardown</span>
259
- <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm_r</span>(<span class="ruby-ivar">@workdir</span>) <span class="ruby-keyword">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-ivar">@workdir</span>)
260
- <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm</span>(<span class="ruby-ivar">@current_test_file</span>) <span class="ruby-keyword">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-ivar">@current_test_file</span>)
261
- <span class="ruby-keyword">end</span></pre>
262
- </div>
263
-
264
- </div>
265
-
266
-
267
-
268
-
269
- </div>
270
-
271
-
272
- <div id="method-i-test_PREFERENCE_FILE" class="method-detail ">
273
-
274
- <div class="method-heading">
275
- <span class="method-name">test_PREFERENCE_FILE</span><span
276
- class="method-args">()</span>
277
-
278
- <span class="method-click-advice">click to toggle source</span>
279
-
280
- </div>
281
-
282
-
283
- <div class="method-description">
284
-
285
- <p>The user&#39;s preference file is a string.</p>
286
-
287
-
288
-
289
-
290
- <div class="method-source-code" id="test_PREFERENCE_FILE-source">
291
- <pre><span class="ruby-comment"># File test/standup_md/cli_test.rb, line 30</span>
292
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_PREFERENCE_FILE</span>
293
- <span class="ruby-identifier">assert_equal</span>(
294
- <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;HOME&#39;</span>], <span class="ruby-string">&#39;.standup_md.yml&#39;</span>)),
295
- <span class="ruby-constant">StandupMD</span><span class="ruby-operator">::</span><span class="ruby-constant">Cli</span><span class="ruby-operator">::</span><span class="ruby-constant">PREFERENCE_FILE</span>
296
- )
297
- <span class="ruby-keyword">end</span></pre>
298
- </div>
299
-
300
- </div>
301
-
302
-
303
-
304
-
305
- </div>
306
-
307
-
308
- <div id="method-i-test_append_previous-3F" class="method-detail ">
309
-
310
- <div class="method-heading">
311
- <span class="method-name">test_append_previous?</span><span
312
- class="method-args">()</span>
313
-
314
- <span class="method-click-advice">click to toggle source</span>
315
-
316
- </div>
317
-
318
-
319
- <div class="method-description">
320
-
321
- <p>True by default. False if flag is passed.</p>
322
-
323
-
324
-
325
-
326
- <div class="method-source-code" id="test_append_previous-3F-source">
327
- <pre><span class="ruby-comment"># File test/standup_md/cli_test.rb, line 151</span>
328
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_append_previous?</span>
329
- <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cli</span>
330
- <span class="ruby-identifier">assert</span>(<span class="ruby-identifier">c</span>.<span class="ruby-identifier">append_previous?</span>)
331
-
332
- <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cli</span>([<span class="ruby-string">&#39;--no-append-previous&#39;</span>])
333
- <span class="ruby-identifier">refute</span>(<span class="ruby-identifier">c</span>.<span class="ruby-identifier">append_previous?</span>)
334
- <span class="ruby-keyword">end</span></pre>
335
- </div>
336
-
337
- </div>
338
-
339
-
340
-
341
-
342
- </div>
343
-
344
-
345
- <div id="method-i-test_edit-3F" class="method-detail ">
346
-
347
- <div class="method-heading">
348
- <span class="method-name">test_edit?</span><span
349
- class="method-args">()</span>
350
-
351
- <span class="method-click-advice">click to toggle source</span>
352
-
353
- </div>
354
-
355
-
356
- <div class="method-description">
357
-
358
- <p>True by default. False if flag is passed.</p>
359
-
360
-
361
-
362
-
363
- <div class="method-source-code" id="test_edit-3F-source">
364
- <pre><span class="ruby-comment"># File test/standup_md/cli_test.rb, line 141</span>
365
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_edit?</span>
366
- <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cli</span>
367
- <span class="ruby-identifier">assert</span>(<span class="ruby-identifier">c</span>.<span class="ruby-identifier">edit?</span>)
368
-
369
- <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cli</span>([<span class="ruby-string">&#39;--no-edit&#39;</span>])
370
- <span class="ruby-identifier">refute</span>(<span class="ruby-identifier">c</span>.<span class="ruby-identifier">edit?</span>)
371
- <span class="ruby-keyword">end</span></pre>
372
- </div>
373
-
374
- </div>
375
-
376
-
377
-
378
-
379
- </div>
380
-
381
-
382
- <div id="method-i-test_editor" class="method-detail ">
383
-
384
- <div class="method-heading">
385
- <span class="method-name">test_editor</span><span
386
- class="method-args">()</span>
387
-
388
- <span class="method-click-advice">click to toggle source</span>
389
-
390
- </div>
391
-
392
-
393
- <div class="method-description">
394
-
395
- <p>The editor should be set by preferences, or env, or set to &#39;vim&#39;.</p>
396
-
397
-
398
-
399
-
400
- <div class="method-source-code" id="test_editor-source">
401
- <pre><span class="ruby-comment"># File test/standup_md/cli_test.rb, line 75</span>
402
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_editor</span>
403
- <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cli</span>
404
- <span class="ruby-keyword">if</span> <span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;VISUAL&#39;</span>]
405
- <span class="ruby-identifier">assert_equal</span>(<span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;VISUAL&#39;</span>], <span class="ruby-identifier">c</span>.<span class="ruby-identifier">editor</span>)
406
- <span class="ruby-keyword">elsif</span> <span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;EDITOR&#39;</span>]
407
- <span class="ruby-identifier">assert_equal</span>(<span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;EDITOR&#39;</span>], <span class="ruby-identifier">c</span>.<span class="ruby-identifier">editor</span>)
408
- <span class="ruby-keyword">else</span>
409
- <span class="ruby-identifier">assert_equal</span>(<span class="ruby-string">&#39;vim&#39;</span>, <span class="ruby-identifier">c</span>.<span class="ruby-identifier">editor</span>)
410
- <span class="ruby-keyword">end</span>
411
-
412
- <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cli</span>([<span class="ruby-string">&#39;--editor=mate&#39;</span>])
413
- <span class="ruby-identifier">assert_equal</span>(<span class="ruby-string">&#39;mate&#39;</span>, <span class="ruby-identifier">c</span>.<span class="ruby-identifier">editor</span>)
414
- <span class="ruby-keyword">end</span></pre>
415
- </div>
416
-
417
- </div>
418
-
419
-
420
-
421
-
422
- </div>
423
-
424
-
425
- <div id="method-i-test_initialize" class="method-detail ">
426
-
427
- <div class="method-heading">
428
- <span class="method-name">test_initialize</span><span
429
- class="method-args">()</span>
430
-
431
- <span class="method-click-advice">click to toggle source</span>
432
-
433
- </div>
434
-
435
-
436
- <div class="method-description">
437
-
438
- <p>The <code>initialize</code> method should accept the same parameters as <code>exectute</code>.</p>
439
-
440
-
441
-
442
-
443
- <div class="method-source-code" id="test_initialize-source">
444
- <pre><span class="ruby-comment"># File test/standup_md/cli_test.rb, line 62</span>
445
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_initialize</span>
446
- <span class="ruby-identifier">assert_nothing_raised</span> { <span class="ruby-constant">StandupMD</span><span class="ruby-operator">::</span><span class="ruby-constant">Cli</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@options</span>) }
447
- <span class="ruby-keyword">end</span></pre>
448
- </div>
449
-
450
- </div>
451
-
452
-
453
-
454
-
455
- </div>
456
-
457
-
458
- <div id="method-i-test_json-3F" class="method-detail ">
459
-
460
- <div class="method-heading">
461
- <span class="method-name">test_json?</span><span
462
- class="method-args">()</span>
463
-
464
- <span class="method-click-advice">click to toggle source</span>
465
-
466
- </div>
467
-
468
-
469
- <div class="method-description">
470
-
471
- <p>False by default. True if flag is passed.</p>
472
-
473
-
474
-
475
-
476
- <div class="method-source-code" id="test_json-3F-source">
477
- <pre><span class="ruby-comment"># File test/standup_md/cli_test.rb, line 101</span>
478
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_json?</span>
479
- <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cli</span>
480
- <span class="ruby-identifier">refute</span>(<span class="ruby-identifier">c</span>.<span class="ruby-identifier">json?</span>)
481
-
482
- <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cli</span>([<span class="ruby-string">&#39;-j&#39;</span>])
483
- <span class="ruby-identifier">assert</span>(<span class="ruby-identifier">c</span>.<span class="ruby-identifier">json?</span>)
484
- <span class="ruby-keyword">end</span></pre>
485
- </div>
486
-
487
- </div>
488
-
489
-
490
-
491
-
492
- </div>
493
-
494
-
495
- <div id="method-i-test_options" class="method-detail ">
496
-
497
- <div class="method-heading">
498
- <span class="method-name">test_options</span><span
499
- class="method-args">()</span>
500
-
501
- <span class="method-click-advice">click to toggle source</span>
502
-
503
- </div>
504
-
505
-
506
- <div class="method-description">
507
-
508
- <p>The <code>options</code> should be an array of options passed from the command line.</p>
509
-
510
-
511
-
512
-
513
- <div class="method-source-code" id="test_options-source">
514
- <pre><span class="ruby-comment"># File test/standup_md/cli_test.rb, line 46</span>
515
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_options</span>
516
- <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cli</span>(<span class="ruby-ivar">@options</span>)
517
- <span class="ruby-identifier">assert_equal</span>(<span class="ruby-ivar">@options</span>, <span class="ruby-identifier">c</span>.<span class="ruby-identifier">options</span>)
518
- <span class="ruby-keyword">end</span></pre>
519
- </div>
520
-
521
- </div>
522
-
523
-
524
-
525
-
526
- </div>
527
-
528
-
529
- <div id="method-i-test_preferences" class="method-detail ">
530
-
531
- <div class="method-heading">
532
- <span class="method-name">test_preferences</span><span
533
- class="method-args">()</span>
534
-
535
- <span class="method-click-advice">click to toggle source</span>
536
-
537
- </div>
538
-
539
-
540
- <div class="method-description">
541
-
542
- <p>The <code>preferences</code> are the settings after <code>options</code> are parsed.</p>
543
-
544
-
545
-
546
-
547
- <div class="method-source-code" id="test_preferences-source">
548
- <pre><span class="ruby-comment"># File test/standup_md/cli_test.rb, line 53</span>
549
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_preferences</span>
550
- <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cli</span>(<span class="ruby-ivar">@options</span>)
551
- <span class="ruby-identifier">assert_equal</span>(<span class="ruby-keyword">false</span>, <span class="ruby-identifier">c</span>.<span class="ruby-identifier">instance_variable_get</span>(<span class="ruby-string">&#39;@write&#39;</span>))
552
- <span class="ruby-identifier">assert_equal</span>(<span class="ruby-keyword">false</span>, <span class="ruby-identifier">c</span>.<span class="ruby-identifier">instance_variable_get</span>(<span class="ruby-string">&#39;@edit&#39;</span>))
553
- <span class="ruby-identifier">assert_equal</span>(<span class="ruby-ivar">@workdir</span>, <span class="ruby-identifier">c</span>.<span class="ruby-identifier">preferences</span>[<span class="ruby-string">&#39;directory&#39;</span>])
554
- <span class="ruby-keyword">end</span></pre>
555
- </div>
556
-
557
- </div>
558
-
559
-
560
-
561
-
562
- </div>
563
-
564
-
565
- <div id="method-i-test_print_all_entries-3F" class="method-detail ">
566
-
567
- <div class="method-heading">
568
- <span class="method-name">test_print_all_entries?</span><span
569
- class="method-args">()</span>
570
-
571
- <span class="method-click-advice">click to toggle source</span>
572
-
573
- </div>
574
-
575
-
576
- <div class="method-description">
577
-
578
- <p>False by default. True if flag is passed.</p>
579
-
580
-
581
-
582
-
583
- <div class="method-source-code" id="test_print_all_entries-3F-source">
584
- <pre><span class="ruby-comment"># File test/standup_md/cli_test.rb, line 111</span>
585
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_print_all_entries?</span>
586
- <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cli</span>
587
- <span class="ruby-identifier">refute</span>(<span class="ruby-identifier">c</span>.<span class="ruby-identifier">print_all_entries?</span>)
588
-
589
- <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cli</span>([<span class="ruby-string">&#39;-a&#39;</span>])
590
- <span class="ruby-identifier">assert</span>(<span class="ruby-identifier">c</span>.<span class="ruby-identifier">print_all_entries?</span>)
591
- <span class="ruby-keyword">end</span></pre>
592
- </div>
593
-
594
- </div>
595
-
596
-
597
-
598
-
599
- </div>
600
-
601
-
602
- <div id="method-i-test_print_current_entry-3F" class="method-detail ">
603
-
604
- <div class="method-heading">
605
- <span class="method-name">test_print_current_entry?</span><span
606
- class="method-args">()</span>
607
-
608
- <span class="method-click-advice">click to toggle source</span>
609
-
610
- </div>
611
-
612
-
613
- <div class="method-description">
614
-
615
- <p>False by default. True if flag is passed.</p>
616
-
617
-
618
-
619
-
620
- <div class="method-source-code" id="test_print_current_entry-3F-source">
621
- <pre><span class="ruby-comment"># File test/standup_md/cli_test.rb, line 91</span>
622
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_print_current_entry?</span>
623
- <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cli</span>
624
- <span class="ruby-identifier">refute</span>(<span class="ruby-identifier">c</span>.<span class="ruby-identifier">print_current_entry?</span>)
625
-
626
- <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cli</span>([<span class="ruby-string">&#39;-c&#39;</span>])
627
- <span class="ruby-identifier">assert</span>(<span class="ruby-identifier">c</span>.<span class="ruby-identifier">print_current_entry?</span>)
628
- <span class="ruby-keyword">end</span></pre>
629
- </div>
630
-
631
- </div>
632
-
633
-
634
-
635
-
636
- </div>
637
-
638
-
639
- <div id="method-i-test_self_execute" class="method-detail ">
640
-
641
- <div class="method-heading">
642
- <span class="method-name">test_self_execute</span><span
643
- class="method-args">()</span>
644
-
645
- <span class="method-click-advice">click to toggle source</span>
646
-
647
- </div>
648
-
649
-
650
- <div class="method-description">
651
-
652
- <p>The <code>execute</code> method is the entry point for the Cli. It&#39;s parameter is an array of command-line flags</p>
653
-
654
-
655
-
656
-
657
- <div class="method-source-code" id="test_self_execute-source">
658
- <pre><span class="ruby-comment"># File test/standup_md/cli_test.rb, line 40</span>
659
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_self_execute</span>
660
- <span class="ruby-identifier">assert_nothing_raised</span> { <span class="ruby-constant">StandupMD</span><span class="ruby-operator">::</span><span class="ruby-constant">Cli</span>.<span class="ruby-identifier">execute</span>(<span class="ruby-ivar">@options</span>) }
661
- <span class="ruby-keyword">end</span></pre>
662
- </div>
663
-
664
- </div>
665
-
666
-
667
-
668
-
669
- </div>
670
-
671
-
672
- <div id="method-i-test_standup" class="method-detail ">
673
-
674
- <div class="method-heading">
675
- <span class="method-name">test_standup</span><span
676
- class="method-args">()</span>
677
-
678
- <span class="method-click-advice">click to toggle source</span>
679
-
680
- </div>
681
-
682
-
683
- <div class="method-description">
684
-
685
- <p>Creates the instance of <code>StandupMD</code>.</p>
686
-
687
-
688
-
689
-
690
- <div class="method-source-code" id="test_standup-source">
691
- <pre><span class="ruby-comment"># File test/standup_md/cli_test.rb, line 68</span>
692
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_standup</span>
693
- <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cli</span>
694
- <span class="ruby-identifier">assert_instance_of</span>(<span class="ruby-constant">StandupMD</span>, <span class="ruby-identifier">c</span>.<span class="ruby-identifier">standup</span>)
695
- <span class="ruby-keyword">end</span></pre>
696
- </div>
697
-
698
- </div>
699
-
700
-
701
-
702
-
703
- </div>
704
-
705
-
706
- <div id="method-i-test_verbose-3F" class="method-detail ">
707
-
708
- <div class="method-heading">
709
- <span class="method-name">test_verbose?</span><span
710
- class="method-args">()</span>
711
-
712
- <span class="method-click-advice">click to toggle source</span>
713
-
714
- </div>
715
-
716
-
717
- <div class="method-description">
718
-
719
- <p>False by default. True if flag is passed.</p>
720
-
721
-
722
-
723
-
724
- <div class="method-source-code" id="test_verbose-3F-source">
725
- <pre><span class="ruby-comment"># File test/standup_md/cli_test.rb, line 121</span>
726
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_verbose?</span>
727
- <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cli</span>
728
- <span class="ruby-identifier">refute</span>(<span class="ruby-identifier">c</span>.<span class="ruby-identifier">verbose?</span>)
729
-
730
- <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cli</span>([<span class="ruby-string">&#39;-v&#39;</span>])
731
- <span class="ruby-identifier">assert</span>(<span class="ruby-identifier">c</span>.<span class="ruby-identifier">verbose?</span>)
732
- <span class="ruby-keyword">end</span></pre>
733
- </div>
734
-
735
- </div>
736
-
737
-
738
-
739
-
740
- </div>
741
-
742
-
743
- <div id="method-i-test_write-3F" class="method-detail ">
744
-
745
- <div class="method-heading">
746
- <span class="method-name">test_write?</span><span
747
- class="method-args">()</span>
748
-
749
- <span class="method-click-advice">click to toggle source</span>
750
-
751
- </div>
752
-
753
-
754
- <div class="method-description">
755
-
756
- <p>True by default. False if flag is passed.</p>
757
-
758
-
759
-
760
-
761
- <div class="method-source-code" id="test_write-3F-source">
762
- <pre><span class="ruby-comment"># File test/standup_md/cli_test.rb, line 131</span>
763
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_write?</span>
764
- <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cli</span>
765
- <span class="ruby-identifier">assert</span>(<span class="ruby-identifier">c</span>.<span class="ruby-identifier">write?</span>)
766
-
767
- <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cli</span>([<span class="ruby-string">&#39;--no-write&#39;</span>])
768
- <span class="ruby-identifier">refute</span>(<span class="ruby-identifier">c</span>.<span class="ruby-identifier">write?</span>)
769
- <span class="ruby-keyword">end</span></pre>
770
- </div>
771
-
772
- </div>
773
-
774
-
775
-
776
-
777
- </div>
778
-
779
-
780
- </section>
781
-
782
- </section>
783
-
784
- </main>
785
-
786
-
787
- <footer id="validator-badges" role="contentinfo">
788
- <p><a href="https://validator.w3.org/check/referer">Validate</a>
789
- <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.1.
790
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
791
- </footer>
792
-