bovem 3.0.5 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -3
- data/.rubocop.yml +82 -0
- data/.travis-gemfile +4 -5
- data/.travis.yml +8 -6
- data/CHANGELOG.md +12 -0
- data/Gemfile +9 -8
- data/README.md +1 -1
- data/Rakefile +22 -6
- data/bovem.gemspec +5 -5
- data/doc/Bovem.html +10 -10
- data/doc/Bovem/Application.html +670 -318
- data/doc/Bovem/Command.html +1447 -1125
- data/doc/Bovem/CommandMethods.html +4 -4
- data/doc/Bovem/CommandMethods/Children.html +173 -179
- data/doc/Bovem/CommandMethods/Help.html +9 -9
- data/doc/Bovem/Configuration.html +239 -24
- data/doc/Bovem/Console.html +267 -128
- data/doc/Bovem/ConsoleMethods.html +4 -4
- data/doc/Bovem/ConsoleMethods/Interactions.html +57 -70
- data/doc/Bovem/ConsoleMethods/Interactions/ClassMethods.html +9 -9
- data/doc/Bovem/ConsoleMethods/Logging.html +258 -298
- data/doc/Bovem/ConsoleMethods/Logging/ClassMethods.html +8 -8
- data/doc/Bovem/ConsoleMethods/Output.html +96 -118
- data/doc/Bovem/ConsoleMethods/StyleHandling.html +8 -8
- data/doc/Bovem/ConsoleMethods/StyleHandling/ClassMethods.html +26 -39
- data/doc/Bovem/Errors.html +4 -4
- data/doc/Bovem/Errors/Error.html +4 -4
- data/doc/Bovem/Errors/InvalidConfiguration.html +4 -4
- data/doc/Bovem/Errors/InvalidLogger.html +4 -4
- data/doc/Bovem/I18n.html +175 -0
- data/doc/Bovem/Logger.html +95 -83
- data/doc/Bovem/Option.html +669 -862
- data/doc/Bovem/Parser.html +10 -10
- data/doc/Bovem/ParserMethods.html +4 -4
- data/doc/Bovem/ParserMethods/General.html +4 -4
- data/doc/Bovem/ParserMethods/General/ClassMethods.html +26 -38
- data/doc/Bovem/Shell.html +169 -48
- data/doc/Bovem/ShellMethods.html +4 -4
- data/doc/Bovem/ShellMethods/Directories.html +46 -62
- data/doc/Bovem/ShellMethods/Execute.html +51 -99
- data/doc/Bovem/ShellMethods/General.html +4 -445
- data/doc/Bovem/ShellMethods/Read.html +56 -61
- data/doc/Bovem/ShellMethods/Write.html +22 -242
- data/doc/Bovem/Version.html +6 -6
- data/doc/_index.html +18 -18
- data/doc/class_list.html +6 -2
- data/doc/css/style.css +1 -0
- data/doc/file.README.html +5 -5
- data/doc/file_list.html +5 -1
- data/doc/frames.html +1 -1
- data/doc/index.html +5 -5
- data/doc/js/full_list.js +4 -1
- data/doc/method_list.html +161 -157
- data/doc/top-level-namespace.html +4 -4
- data/lib/bovem.rb +3 -4
- data/lib/bovem/application.rb +47 -39
- data/lib/bovem/command.rb +175 -193
- data/lib/bovem/configuration.rb +28 -29
- data/lib/bovem/console.rb +244 -171
- data/lib/bovem/errors.rb +1 -1
- data/lib/bovem/i18n.rb +18 -0
- data/lib/bovem/logger.rb +26 -26
- data/lib/bovem/option.rb +49 -58
- data/lib/bovem/parser.rb +174 -222
- data/lib/bovem/shell.rb +272 -320
- data/lib/bovem/version.rb +2 -2
- data/locales/en.yml +39 -38
- data/locales/it.yml +39 -38
- data/spec/bovem/application_spec.rb +6 -5
- data/spec/bovem/command_spec.rb +23 -23
- data/spec/bovem/console_spec.rb +101 -102
- data/spec/bovem/i18n_spec.rb +21 -0
- data/spec/bovem/logger_spec.rb +4 -4
- data/spec/bovem/option_spec.rb +43 -43
- data/spec/bovem/parser_spec.rb +13 -13
- data/spec/bovem/shell_spec.rb +106 -115
- data/spec/spec_helper.rb +19 -6
- metadata +14 -13
- data/doc/Bovem/Localizer.html +0 -376
- data/lib/bovem/localizer.rb +0 -27
- data/spec/coverage_helper.rb +0 -20
data/doc/Bovem/Logger.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Class: Bovem::Logger
|
8
8
|
|
9
|
-
— Documentation by YARD 0.8.7.
|
9
|
+
— Documentation by YARD 0.8.7.6
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -17,7 +17,7 @@
|
|
17
17
|
<script type="text/javascript" charset="utf-8">
|
18
18
|
hasFrames = window.top.frames.main ? true : false;
|
19
19
|
relpath = '../';
|
20
|
-
framesUrl = "../frames.html#!"
|
20
|
+
framesUrl = "../frames.html#!Bovem/Logger.html";
|
21
21
|
</script>
|
22
22
|
|
23
23
|
|
@@ -112,6 +112,28 @@
|
|
112
112
|
|
113
113
|
|
114
114
|
</div>
|
115
|
+
<h2>Constant Summary</h2>
|
116
|
+
|
117
|
+
<dl class="constants">
|
118
|
+
|
119
|
+
<dt id="LEVEL_NAMES-constant" class="">LEVEL_NAMES =
|
120
|
+
<div class="docstring">
|
121
|
+
<div class="discussion">
|
122
|
+
<p>List of valid logger levels.</p>
|
123
|
+
|
124
|
+
|
125
|
+
</div>
|
126
|
+
</div>
|
127
|
+
<div class="tags">
|
128
|
+
|
129
|
+
|
130
|
+
</div>
|
131
|
+
</dt>
|
132
|
+
<dd><pre class="code"><span class='lbrace'>{</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>DEBUG</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='symbol'>:cyan</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>INFO</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='symbol'>:green</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>WARN</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='symbol'>:yellow</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>ERROR</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='symbol'>:red</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>FATAL</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='symbol'>:magenta</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
|
133
|
+
|
134
|
+
</dl>
|
135
|
+
|
136
|
+
|
115
137
|
|
116
138
|
|
117
139
|
|
@@ -162,7 +184,7 @@
|
|
162
184
|
<li class="public ">
|
163
185
|
<span class="summary_signature">
|
164
186
|
|
165
|
-
<a href="#create-class_method" title="create (class method)">+ (Logger) <strong>create</strong>(file = nil, level
|
187
|
+
<a href="#create-class_method" title="create (class method)">+ (Logger) <strong>create</strong>(file = nil, level: Logger::INFO, formatter: nil) </a>
|
166
188
|
|
167
189
|
|
168
190
|
|
@@ -286,7 +308,7 @@
|
|
286
308
|
<li class="public ">
|
287
309
|
<span class="summary_signature">
|
288
310
|
|
289
|
-
<a href="#initialize-instance_method" title="#initialize (instance method)">- (Logger) <strong>initialize</strong>(logdev, shift_age = 0, shift_size =
|
311
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">- (Logger) <strong>initialize</strong>(logdev, shift_age = 0, shift_size = 1_048_576) </a>
|
290
312
|
|
291
313
|
|
292
314
|
|
@@ -318,7 +340,7 @@
|
|
318
340
|
<div class="method_details first">
|
319
341
|
<h3 class="signature first" id="initialize-instance_method">
|
320
342
|
|
321
|
-
- (<tt><span class='object_link'><a href="" title="Bovem::Logger (class)">Logger</a></span></tt>) <strong>initialize</strong>(logdev, shift_age = 0, shift_size =
|
343
|
+
- (<tt><span class='object_link'><a href="" title="Bovem::Logger (class)">Logger</a></span></tt>) <strong>initialize</strong>(logdev, shift_age = 0, shift_size = 1_048_576)
|
322
344
|
|
323
345
|
|
324
346
|
|
@@ -375,7 +397,7 @@
|
|
375
397
|
<span class='type'>(<tt>Fixnum</tt>)</span>
|
376
398
|
|
377
399
|
|
378
|
-
<em class="default">(defaults to: <tt>
|
400
|
+
<em class="default">(defaults to: <tt>1_048_576</tt>)</em>
|
379
401
|
|
380
402
|
|
381
403
|
—
|
@@ -400,15 +422,15 @@
|
|
400
422
|
<pre class="lines">
|
401
423
|
|
402
424
|
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
425
|
+
25
|
426
|
+
26
|
427
|
+
27
|
428
|
+
28</pre>
|
407
429
|
</td>
|
408
430
|
<td>
|
409
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/logger.rb', line
|
431
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/logger.rb', line 25</span>
|
410
432
|
|
411
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_logdev'>logdev</span><span class='comma'>,</span> <span class='id identifier rubyid_shift_age'>shift_age</span> <span class='op'>=</span> <span class='int'>0</span><span class='comma'>,</span> <span class='id identifier rubyid_shift_size'>shift_size</span> <span class='op'>=</span> <span class='int'>
|
433
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_logdev'>logdev</span><span class='comma'>,</span> <span class='id identifier rubyid_shift_age'>shift_age</span> <span class='op'>=</span> <span class='int'>0</span><span class='comma'>,</span> <span class='id identifier rubyid_shift_size'>shift_size</span> <span class='op'>=</span> <span class='int'>1_048_576</span><span class='rparen'>)</span>
|
412
434
|
<span class='ivar'>@device</span> <span class='op'>=</span> <span class='id identifier rubyid_logdev'>logdev</span>
|
413
435
|
<span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_logdev'>logdev</span><span class='comma'>,</span> <span class='id identifier rubyid_shift_age'>shift_age</span><span class='comma'>,</span> <span class='id identifier rubyid_shift_size'>shift_size</span><span class='rparen'>)</span>
|
414
436
|
<span class='kw'>end</span></pre>
|
@@ -547,6 +569,9 @@
|
|
547
569
|
<span class='kw'>class</span> <span class='const'>Logger</span> <span class='op'><</span> <span class='op'>::</span><span class='const'>Logger</span>
|
548
570
|
<span class='id identifier rubyid_attr_reader'>attr_reader</span> <span class='symbol'>:device</span>
|
549
571
|
|
572
|
+
<span class='comment'># List of valid logger levels.
|
573
|
+
</span> <span class='const'>LEVEL_NAMES</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>DEBUG</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='symbol'>:cyan</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>INFO</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='symbol'>:green</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>WARN</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='symbol'>:yellow</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>ERROR</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='symbol'>:red</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>FATAL</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='symbol'>:magenta</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span>
|
574
|
+
|
550
575
|
<span class='comment'># Creates a new logger.
|
551
576
|
</span> <span class='comment'>#
|
552
577
|
</span> <span class='comment'># @see http://www.ruby-doc.org/stdlib-1.9.3/libdoc/logger/rdoc/Logger.html
|
@@ -554,7 +579,7 @@
|
|
554
579
|
</span> <span class='comment'># @param logdev [String|IO] The log device. This is a filename (String) or IO object (typically STDOUT, STDERR, or an open file).
|
555
580
|
</span> <span class='comment'># @param shift_age [Fixnum] Number of old log files to keep, or frequency of rotation (daily, weekly or monthly).
|
556
581
|
</span> <span class='comment'># @param shift_size [Fixnum] Maximum logfile size (only applies when shift_age is a number).
|
557
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_logdev'>logdev</span><span class='comma'>,</span> <span class='id identifier rubyid_shift_age'>shift_age</span> <span class='op'>=</span> <span class='int'>0</span><span class='comma'>,</span> <span class='id identifier rubyid_shift_size'>shift_size</span> <span class='op'>=</span> <span class='int'>
|
582
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_logdev'>logdev</span><span class='comma'>,</span> <span class='id identifier rubyid_shift_age'>shift_age</span> <span class='op'>=</span> <span class='int'>0</span><span class='comma'>,</span> <span class='id identifier rubyid_shift_size'>shift_size</span> <span class='op'>=</span> <span class='int'>1_048_576</span><span class='rparen'>)</span>
|
558
583
|
<span class='ivar'>@device</span> <span class='op'>=</span> <span class='id identifier rubyid_logdev'>logdev</span>
|
559
584
|
<span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_logdev'>logdev</span><span class='comma'>,</span> <span class='id identifier rubyid_shift_age'>shift_age</span><span class='comma'>,</span> <span class='id identifier rubyid_shift_size'>shift_size</span><span class='rparen'>)</span>
|
560
585
|
<span class='kw'>end</span>
|
@@ -565,15 +590,13 @@
|
|
565
590
|
</span> <span class='comment'># @param level [Fixnum] The minimum severity to log. See http://www.ruby-doc.org/stdlib-1.9.3/libdoc/logger/rdoc/Logger.html for valid levels.
|
566
591
|
</span> <span class='comment'># @param formatter [Proc] The formatter to use for logging.
|
567
592
|
</span> <span class='comment'># @return [Logger] The new logger.
|
568
|
-
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_file'>file</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='
|
569
|
-
<span class='
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
<span class='
|
575
|
-
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>InvalidLogger</span>
|
576
|
-
<span class='kw'>end</span>
|
593
|
+
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_file'>file</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>level:</span> <span class='const'>Logger</span><span class='op'>::</span><span class='const'>INFO</span><span class='comma'>,</span> <span class='label'>formatter:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
594
|
+
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_get_real_file'>get_real_file</span><span class='lparen'>(</span><span class='id identifier rubyid_file'>file</span> <span class='op'>||</span> <span class='id identifier rubyid_default_file'>default_file</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
595
|
+
<span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_level'>level</span> <span class='op'>=</span> <span class='id identifier rubyid_level'>level</span><span class='period'>.</span><span class='id identifier rubyid_to_integer'>to_integer</span>
|
596
|
+
<span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_formatter'>formatter</span> <span class='op'>=</span> <span class='id identifier rubyid_formatter'>formatter</span> <span class='op'>||</span> <span class='id identifier rubyid_default_formatter'>default_formatter</span>
|
597
|
+
<span class='id identifier rubyid_rv'>rv</span>
|
598
|
+
<span class='kw'>rescue</span>
|
599
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>InvalidLogger</span>
|
577
600
|
<span class='kw'>end</span>
|
578
601
|
|
579
602
|
<span class='comment'># Translates a file to standard input or standard output in some special cases.
|
@@ -582,9 +605,9 @@
|
|
582
605
|
</span> <span class='comment'># @return [String|IO] The translated file name.
|
583
606
|
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_get_real_file'>get_real_file</span><span class='lparen'>(</span><span class='id identifier rubyid_file'>file</span><span class='rparen'>)</span>
|
584
607
|
<span class='kw'>case</span> <span class='id identifier rubyid_file'>file</span>
|
585
|
-
|
586
|
-
|
587
|
-
|
608
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>STDOUT</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='gvar'>$stdout</span>
|
609
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>STDERR</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='gvar'>$stderr</span>
|
610
|
+
<span class='kw'>else</span> <span class='id identifier rubyid_file'>file</span>
|
588
611
|
<span class='kw'>end</span>
|
589
612
|
<span class='kw'>end</span>
|
590
613
|
|
@@ -597,19 +620,18 @@
|
|
597
620
|
<span class='comment'># The default formatter for logging.
|
598
621
|
</span> <span class='comment'># @return [Proc] The default formatter for logging.
|
599
622
|
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_default_formatter'>default_formatter</span>
|
600
|
-
<span class='ivar'>@default_formatter</span> <span class='op'>||=</span> <span class='op'>::</span><span class='const'>Proc</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='
|
601
|
-
<span class='id identifier rubyid_color'>color</span> <span class='op'>=</span> <span class='
|
602
|
-
|
603
|
-
|
604
|
-
<span class='
|
605
|
-
|
606
|
-
|
607
|
-
<span class='
|
608
|
-
<span class='
|
609
|
-
|
610
|
-
<span class='id identifier
|
611
|
-
|
612
|
-
<span class='rbrace'>}</span>
|
623
|
+
<span class='ivar'>@default_formatter</span> <span class='op'>||=</span> <span class='op'>::</span><span class='const'>Proc</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_severity'>severity</span><span class='comma'>,</span> <span class='id identifier rubyid_datetime'>datetime</span><span class='comma'>,</span> <span class='id identifier rubyid__'>_</span><span class='comma'>,</span> <span class='id identifier rubyid_msg'>msg</span><span class='op'>|</span>
|
624
|
+
<span class='id identifier rubyid_color'>color</span> <span class='op'>=</span> <span class='const'>LEVEL_NAMES</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='id identifier rubyid_severity'>severity</span><span class='comma'>,</span> <span class='symbol'>:white</span><span class='rparen'>)</span>
|
625
|
+
|
626
|
+
<span class='id identifier rubyid_header'>header</span> <span class='op'>=</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Console</span><span class='period'>.</span><span class='id identifier rubyid_replace_markers'>replace_markers</span><span class='lparen'>(</span>
|
627
|
+
<span class='id identifier rubyid_sprintf'>sprintf</span><span class='lparen'>(</span>
|
628
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>{mark=bright-</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_color'>color</span><span class='embexpr_end'>}</span><span class='tstring_content'>}[%s T+%0.5f] %s:{/mark}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_datetime'>datetime</span><span class='period'>.</span><span class='id identifier rubyid_strftime'>strftime</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>%Y/%b/%d %H:%M:%S</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='comma'>,</span>
|
629
|
+
<span class='lbracket'>[</span><span class='id identifier rubyid_datetime'>datetime</span><span class='period'>.</span><span class='id identifier rubyid_to_f'>to_f</span> <span class='op'>-</span> <span class='id identifier rubyid_start_time'>start_time</span><span class='period'>.</span><span class='id identifier rubyid_to_f'>to_f</span><span class='comma'>,</span> <span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span><span class='comma'>,</span> <span class='id identifier rubyid_severity'>severity</span><span class='period'>.</span><span class='id identifier rubyid_rjust'>rjust</span><span class='lparen'>(</span><span class='int'>5</span><span class='rparen'>)</span>
|
630
|
+
<span class='rparen'>)</span>
|
631
|
+
<span class='rparen'>)</span>
|
632
|
+
|
633
|
+
<span class='id identifier rubyid_sprintf'>sprintf</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>%s %s\n</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_header'>header</span><span class='comma'>,</span> <span class='id identifier rubyid_msg'>msg</span><span class='rparen'>)</span>
|
634
|
+
<span class='kw'>end</span>
|
613
635
|
<span class='kw'>end</span>
|
614
636
|
|
615
637
|
<span class='comment'># The log time of the first logger. This allows to show a `T+0.1234` information into the log.
|
@@ -633,7 +655,7 @@
|
|
633
655
|
<div class="method_details first">
|
634
656
|
<h3 class="signature first" id="create-class_method">
|
635
657
|
|
636
|
-
+ (<tt><span class='object_link'><a href="" title="Bovem::Logger (class)">Logger</a></span></tt>) <strong>create</strong>(file = nil, level
|
658
|
+
+ (<tt><span class='object_link'><a href="" title="Bovem::Logger (class)">Logger</a></span></tt>) <strong>create</strong>(file = nil, level: Logger::INFO, formatter: nil)
|
637
659
|
|
638
660
|
|
639
661
|
|
@@ -675,8 +697,6 @@
|
|
675
697
|
<span class='type'>(<tt>Fixnum</tt>)</span>
|
676
698
|
|
677
699
|
|
678
|
-
<em class="default">(defaults to: <tt>Logger::INFO</tt>)</em>
|
679
|
-
|
680
700
|
|
681
701
|
—
|
682
702
|
<div class='inline'><p>The minimum severity to log. See http://www.ruby-doc.org/stdlib-1.9.3/libdoc/logger/rdoc/Logger.html for valid levels.</p>
|
@@ -692,8 +712,6 @@
|
|
692
712
|
<span class='type'>(<tt>Proc</tt>)</span>
|
693
713
|
|
694
714
|
|
695
|
-
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
696
|
-
|
697
715
|
|
698
716
|
—
|
699
717
|
<div class='inline'><p>The formatter to use for logging.</p>
|
@@ -727,29 +745,25 @@
|
|
727
745
|
<pre class="lines">
|
728
746
|
|
729
747
|
|
730
|
-
33
|
731
|
-
34
|
732
|
-
35
|
733
748
|
36
|
734
749
|
37
|
735
750
|
38
|
736
751
|
39
|
737
752
|
40
|
738
753
|
41
|
739
|
-
42
|
754
|
+
42
|
755
|
+
43</pre>
|
740
756
|
</td>
|
741
757
|
<td>
|
742
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/logger.rb', line
|
743
|
-
|
744
|
-
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_file'>file</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='
|
745
|
-
<span class='
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
<span class='
|
751
|
-
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>InvalidLogger</span>
|
752
|
-
<span class='kw'>end</span>
|
758
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/logger.rb', line 36</span>
|
759
|
+
|
760
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_file'>file</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>level:</span> <span class='const'>Logger</span><span class='op'>::</span><span class='const'>INFO</span><span class='comma'>,</span> <span class='label'>formatter:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
761
|
+
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_get_real_file'>get_real_file</span><span class='lparen'>(</span><span class='id identifier rubyid_file'>file</span> <span class='op'>||</span> <span class='id identifier rubyid_default_file'>default_file</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
762
|
+
<span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_level'>level</span> <span class='op'>=</span> <span class='id identifier rubyid_level'>level</span><span class='period'>.</span><span class='id identifier rubyid_to_integer'>to_integer</span>
|
763
|
+
<span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_formatter'>formatter</span> <span class='op'>=</span> <span class='id identifier rubyid_formatter'>formatter</span> <span class='op'>||</span> <span class='id identifier rubyid_default_formatter'>default_formatter</span>
|
764
|
+
<span class='id identifier rubyid_rv'>rv</span>
|
765
|
+
<span class='kw'>rescue</span>
|
766
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>InvalidLogger</span>
|
753
767
|
<span class='kw'>end</span></pre>
|
754
768
|
</td>
|
755
769
|
</tr>
|
@@ -798,12 +812,12 @@
|
|
798
812
|
<pre class="lines">
|
799
813
|
|
800
814
|
|
801
|
-
58
|
802
815
|
59
|
803
|
-
60
|
816
|
+
60
|
817
|
+
61</pre>
|
804
818
|
</td>
|
805
819
|
<td>
|
806
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/logger.rb', line
|
820
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/logger.rb', line 59</span>
|
807
821
|
|
808
822
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_default_file'>default_file</span>
|
809
823
|
<span class='ivar'>@default_file</span> <span class='op'>||=</span> <span class='gvar'>$stdout</span>
|
@@ -855,7 +869,6 @@
|
|
855
869
|
<pre class="lines">
|
856
870
|
|
857
871
|
|
858
|
-
64
|
859
872
|
65
|
860
873
|
66
|
861
874
|
67
|
@@ -872,22 +885,21 @@
|
|
872
885
|
78</pre>
|
873
886
|
</td>
|
874
887
|
<td>
|
875
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/logger.rb', line
|
888
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/logger.rb', line 65</span>
|
876
889
|
|
877
890
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_default_formatter'>default_formatter</span>
|
878
|
-
<span class='ivar'>@default_formatter</span> <span class='op'>||=</span> <span class='op'>::</span><span class='const'>Proc</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='
|
879
|
-
<span class='id identifier rubyid_color'>color</span> <span class='op'>=</span> <span class='
|
880
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>DEBUG</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='symbol'>:cyan</span>
|
881
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>INFO</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='symbol'>:green</span>
|
882
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>WARN</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='symbol'>:yellow</span>
|
883
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>ERROR</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='symbol'>:red</span>
|
884
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>FATAL</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='symbol'>:magenta</span>
|
885
|
-
<span class='kw'>else</span> <span class='symbol'>:white</span>
|
886
|
-
<span class='kw'>end</span>
|
891
|
+
<span class='ivar'>@default_formatter</span> <span class='op'>||=</span> <span class='op'>::</span><span class='const'>Proc</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_severity'>severity</span><span class='comma'>,</span> <span class='id identifier rubyid_datetime'>datetime</span><span class='comma'>,</span> <span class='id identifier rubyid__'>_</span><span class='comma'>,</span> <span class='id identifier rubyid_msg'>msg</span><span class='op'>|</span>
|
892
|
+
<span class='id identifier rubyid_color'>color</span> <span class='op'>=</span> <span class='const'>LEVEL_NAMES</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='id identifier rubyid_severity'>severity</span><span class='comma'>,</span> <span class='symbol'>:white</span><span class='rparen'>)</span>
|
887
893
|
|
888
|
-
<span class='id identifier rubyid_header'>header</span> <span class='op'>=</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Console</span><span class='period'>.</span><span class='id identifier rubyid_replace_markers'>replace_markers</span><span class='lparen'>(</span
|
889
|
-
|
890
|
-
|
894
|
+
<span class='id identifier rubyid_header'>header</span> <span class='op'>=</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Console</span><span class='period'>.</span><span class='id identifier rubyid_replace_markers'>replace_markers</span><span class='lparen'>(</span>
|
895
|
+
<span class='id identifier rubyid_sprintf'>sprintf</span><span class='lparen'>(</span>
|
896
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>{mark=bright-</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_color'>color</span><span class='embexpr_end'>}</span><span class='tstring_content'>}[%s T+%0.5f] %s:{/mark}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_datetime'>datetime</span><span class='period'>.</span><span class='id identifier rubyid_strftime'>strftime</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>%Y/%b/%d %H:%M:%S</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='comma'>,</span>
|
897
|
+
<span class='lbracket'>[</span><span class='id identifier rubyid_datetime'>datetime</span><span class='period'>.</span><span class='id identifier rubyid_to_f'>to_f</span> <span class='op'>-</span> <span class='id identifier rubyid_start_time'>start_time</span><span class='period'>.</span><span class='id identifier rubyid_to_f'>to_f</span><span class='comma'>,</span> <span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span><span class='comma'>,</span> <span class='id identifier rubyid_severity'>severity</span><span class='period'>.</span><span class='id identifier rubyid_rjust'>rjust</span><span class='lparen'>(</span><span class='int'>5</span><span class='rparen'>)</span>
|
898
|
+
<span class='rparen'>)</span>
|
899
|
+
<span class='rparen'>)</span>
|
900
|
+
|
901
|
+
<span class='id identifier rubyid_sprintf'>sprintf</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>%s %s\n</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_header'>header</span><span class='comma'>,</span> <span class='id identifier rubyid_msg'>msg</span><span class='rparen'>)</span>
|
902
|
+
<span class='kw'>end</span>
|
891
903
|
<span class='kw'>end</span></pre>
|
892
904
|
</td>
|
893
905
|
</tr>
|
@@ -955,22 +967,22 @@
|
|
955
967
|
<pre class="lines">
|
956
968
|
|
957
969
|
|
958
|
-
48
|
959
970
|
49
|
960
971
|
50
|
961
972
|
51
|
962
973
|
52
|
963
974
|
53
|
964
|
-
54
|
975
|
+
54
|
976
|
+
55</pre>
|
965
977
|
</td>
|
966
978
|
<td>
|
967
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/logger.rb', line
|
979
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/logger.rb', line 49</span>
|
968
980
|
|
969
981
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_get_real_file'>get_real_file</span><span class='lparen'>(</span><span class='id identifier rubyid_file'>file</span><span class='rparen'>)</span>
|
970
982
|
<span class='kw'>case</span> <span class='id identifier rubyid_file'>file</span>
|
971
|
-
|
972
|
-
|
973
|
-
|
983
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>STDOUT</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='gvar'>$stdout</span>
|
984
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>STDERR</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='gvar'>$stderr</span>
|
985
|
+
<span class='kw'>else</span> <span class='id identifier rubyid_file'>file</span>
|
974
986
|
<span class='kw'>end</span>
|
975
987
|
<span class='kw'>end</span></pre>
|
976
988
|
</td>
|
@@ -1040,9 +1052,9 @@
|
|
1040
1052
|
</div>
|
1041
1053
|
|
1042
1054
|
<div id="footer">
|
1043
|
-
Generated on
|
1055
|
+
Generated on Tue Mar 29 20:43:17 2016 by
|
1044
1056
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1045
|
-
0.8.7.
|
1057
|
+
0.8.7.6 (ruby-2.3.0).
|
1046
1058
|
</div>
|
1047
1059
|
|
1048
1060
|
</body>
|
data/doc/Bovem/Option.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Class: Bovem::Option
|
8
8
|
|
9
|
-
— Documentation by YARD 0.8.7.
|
9
|
+
— Documentation by YARD 0.8.7.6
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -17,7 +17,7 @@
|
|
17
17
|
<script type="text/javascript" charset="utf-8">
|
18
18
|
hasFrames = window.top.frames.main ? true : false;
|
19
19
|
relpath = '../';
|
20
|
-
framesUrl = "../frames.html#!"
|
20
|
+
framesUrl = "../frames.html#!Bovem/Option.html";
|
21
21
|
</script>
|
22
22
|
|
23
23
|
|
@@ -490,7 +490,7 @@
|
|
490
490
|
<li class="public ">
|
491
491
|
<span class="summary_signature">
|
492
492
|
|
493
|
-
<a href="#
|
493
|
+
<a href="#default%3F-instance_method" title="#default? (instance method)">- (Boolean) <strong>default?</strong> </a>
|
494
494
|
|
495
495
|
|
496
496
|
|
@@ -504,7 +504,7 @@
|
|
504
504
|
|
505
505
|
|
506
506
|
|
507
|
-
<span class="summary_desc"><div class='inline'><p>
|
507
|
+
<span class="summary_desc"><div class='inline'><p>Check if the current option has a default value.</p>
|
508
508
|
</div></span>
|
509
509
|
|
510
510
|
</li>
|
@@ -513,7 +513,7 @@
|
|
513
513
|
<li class="public ">
|
514
514
|
<span class="summary_signature">
|
515
515
|
|
516
|
-
<a href="#
|
516
|
+
<a href="#execute_action-instance_method" title="#execute_action (instance method)">- (Object) <strong>execute_action</strong> </a>
|
517
517
|
|
518
518
|
|
519
519
|
|
@@ -527,7 +527,7 @@
|
|
527
527
|
|
528
528
|
|
529
529
|
|
530
|
-
<span class="summary_desc"><div class='inline'><p>
|
530
|
+
<span class="summary_desc"><div class='inline'><p>Executes the action associated to this option.</p>
|
531
531
|
</div></span>
|
532
532
|
|
533
533
|
</li>
|
@@ -536,7 +536,7 @@
|
|
536
536
|
<li class="public ">
|
537
537
|
<span class="summary_signature">
|
538
538
|
|
539
|
-
<a href="#
|
539
|
+
<a href="#help%3F-instance_method" title="#help? (instance method)">- (Boolean) <strong>help?</strong> </a>
|
540
540
|
|
541
541
|
|
542
542
|
|
@@ -772,16 +772,16 @@
|
|
772
772
|
<pre class="lines">
|
773
773
|
|
774
774
|
|
775
|
+
61
|
775
776
|
62
|
776
777
|
63
|
777
778
|
64
|
778
779
|
65
|
779
780
|
66
|
780
|
-
67
|
781
|
-
68</pre>
|
781
|
+
67</pre>
|
782
782
|
</td>
|
783
783
|
<td>
|
784
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line
|
784
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 61</span>
|
785
785
|
|
786
786
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_forms'>forms</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
|
787
787
|
<span class='ivar'>@name</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
|
@@ -844,6 +844,7 @@
|
|
844
844
|
<pre class="lines">
|
845
845
|
|
846
846
|
|
847
|
+
41
|
847
848
|
42
|
848
849
|
43
|
849
850
|
44
|
@@ -1046,19 +1047,10 @@
|
|
1046
1047
|
241
|
1047
1048
|
242
|
1048
1049
|
243
|
1049
|
-
244
|
1050
|
-
245
|
1051
|
-
246
|
1052
|
-
247
|
1053
|
-
248
|
1054
|
-
249
|
1055
|
-
250
|
1056
|
-
251
|
1057
|
-
252
|
1058
|
-
253</pre>
|
1050
|
+
244</pre>
|
1059
1051
|
</td>
|
1060
1052
|
<td>
|
1061
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line
|
1053
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 41</span>
|
1062
1054
|
|
1063
1055
|
<span class='kw'>class</span> <span class='const'>Option</span>
|
1064
1056
|
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:name</span>
|
@@ -1092,7 +1084,7 @@
|
|
1092
1084
|
</span> <span class='comment'>#
|
1093
1085
|
</span> <span class='comment'># @param value [String] The short form of this option.
|
1094
1086
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_short='>short=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
1095
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>
|
1087
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
1096
1088
|
|
1097
1089
|
<span class='comment'># Clean value
|
1098
1090
|
</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}([a-z0-9])(.*)$</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
@@ -1104,7 +1096,7 @@
|
|
1104
1096
|
</span> <span class='comment'>#
|
1105
1097
|
</span> <span class='comment'># @param value [String] The short form of this option.
|
1106
1098
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_long='>long=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
1107
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>
|
1099
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
1108
1100
|
|
1109
1101
|
<span class='comment'># Clean value
|
1110
1102
|
</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}(.+)$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
@@ -1117,7 +1109,7 @@
|
|
1117
1109
|
</span> <span class='comment'># @param value [String] The validator of this option.
|
1118
1110
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_validator='>validator=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
1119
1111
|
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
|
1120
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='
|
1112
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Proc</span><span class='rparen'>)</span>
|
1121
1113
|
<span class='ivar'>@validator</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
1122
1114
|
<span class='kw'>end</span>
|
1123
1115
|
|
@@ -1144,22 +1136,24 @@
|
|
1144
1136
|
|
1145
1137
|
<span class='comment'># Returns the meta argument for this option.
|
1146
1138
|
</span> <span class='comment'>#
|
1147
|
-
</span> <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
|
1139
|
+
</span> <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
|
1140
|
+
</span> <span class='comment'># if this option doesn't require a meta argument.
|
1148
1141
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_meta'>meta</span>
|
1149
|
-
<span class='
|
1142
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
|
1143
|
+
<span class='ivar'>@meta</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='ivar'>@meta</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span>
|
1150
1144
|
<span class='kw'>end</span>
|
1151
1145
|
|
1152
1146
|
<span class='comment'># Get the current default value for this option.
|
1153
1147
|
</span> <span class='comment'>#
|
1154
1148
|
</span> <span class='comment'># @return [Object] The default value for this option.
|
1155
1149
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_default'>default</span>
|
1156
|
-
<span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>OPTION_TYPES</span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span>
|
1150
|
+
<span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>OPTION_TYPES</span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>false</span>
|
1157
1151
|
<span class='kw'>end</span>
|
1158
1152
|
|
1159
1153
|
<span class='comment'># Check if the current option has a default value.
|
1160
1154
|
</span> <span class='comment'>#
|
1161
1155
|
</span> <span class='comment'># @return [Boolean] If the current option has a default value.
|
1162
|
-
</span> <span class='kw'>def</span> <span class='id identifier
|
1156
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
|
1163
1157
|
<span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
1164
1158
|
<span class='kw'>end</span>
|
1165
1159
|
|
@@ -1172,7 +1166,7 @@
|
|
1172
1166
|
<span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
|
1173
1167
|
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>
|
1174
1168
|
|
1175
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
1169
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
1176
1170
|
<span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
1177
1171
|
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
1178
1172
|
<span class='kw'>else</span> <span class='comment'># Validation failed
|
@@ -1185,10 +1179,9 @@
|
|
1185
1179
|
|
1186
1180
|
<span class='comment'># Executes the action associated to this option.
|
1187
1181
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
|
1188
|
-
<span class='kw'>
|
1189
|
-
|
1190
|
-
|
1191
|
-
<span class='kw'>end</span>
|
1182
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
1183
|
+
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
1184
|
+
<span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
|
1192
1185
|
<span class='kw'>end</span>
|
1193
1186
|
|
1194
1187
|
<span class='comment'># Checks if this option requires an argument.
|
@@ -1208,7 +1201,7 @@
|
|
1208
1201
|
<span class='comment'># Check if this command has a help.
|
1209
1202
|
</span> <span class='comment'>#
|
1210
1203
|
</span> <span class='comment'># @return [Boolean] `true` if this command has a help, `false` otherwise.
|
1211
|
-
</span> <span class='kw'>def</span> <span class='id identifier
|
1204
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
|
1212
1205
|
<span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
1213
1206
|
<span class='kw'>end</span>
|
1214
1207
|
|
@@ -1220,57 +1213,48 @@
|
|
1220
1213
|
<span class='kw'>end</span>
|
1221
1214
|
|
1222
1215
|
<span class='id identifier rubyid_private'>private</span>
|
1223
|
-
<span class='comment'># Setups the forms of the this option.
|
1224
|
-
</span> <span class='comment'>#
|
1225
|
-
</span> <span class='comment'># @param forms [Array] An array of short and long forms for this option. Missing forms will be inferred by the name.
|
1226
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
|
1227
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>></span> <span class='int'>0</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
1228
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
|
1229
|
-
<span class='kw'>end</span>
|
1230
1216
|
|
1231
|
-
|
1232
|
-
</span>
|
1233
|
-
</span>
|
1234
|
-
|
1235
|
-
|
1236
|
-
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1237
|
-
<span class='kw'>end</span>
|
1238
|
-
<span class='kw'>end</span>
|
1217
|
+
<span class='comment'># :nodoc:
|
1218
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
|
1219
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
1220
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
|
1221
|
+
<span class='kw'>end</span>
|
1239
1222
|
|
1240
|
-
|
1241
|
-
</span>
|
1242
|
-
</span>
|
1243
|
-
</span>
|
1244
|
-
<span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
|
1223
|
+
<span class='comment'># :nodoc:
|
1224
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
1225
|
+
<span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_option'>option</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
|
1226
|
+
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1245
1227
|
<span class='kw'>end</span>
|
1228
|
+
<span class='kw'>end</span>
|
1246
1229
|
|
1247
|
-
|
1248
|
-
</span>
|
1249
|
-
</span>
|
1250
|
-
|
1251
|
-
|
1230
|
+
<span class='comment'># :nodoc:
|
1231
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
|
1232
|
+
<span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
|
1233
|
+
<span class='kw'>end</span>
|
1234
|
+
|
1235
|
+
<span class='comment'># :nodoc:
|
1236
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
|
1237
|
+
<span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>
|
1252
1238
|
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1239
|
+
<span class='id identifier rubyid_message'>message</span> <span class='op'>=</span>
|
1240
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_vs'>vs</span>
|
1241
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_regexp'>invalid_for_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rparen'>)</span>
|
1242
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_proc'>invalid_for_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='rparen'>)</span>
|
1243
|
+
<span class='kw'>else</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_value'>invalid_value</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_smart_join'>smart_join</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='comma'>,</span> <span class='label'>separator:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>, </span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>last_separator:</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_join_separator'>join_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_html_safe'>html_safe</span><span class='rparen'>)</span>
|
1257
1244
|
<span class='kw'>end</span>
|
1258
1245
|
|
1259
|
-
|
1260
|
-
|
1246
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>Error</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:validation_failed</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
|
1247
|
+
<span class='kw'>end</span>
|
1261
1248
|
|
1262
|
-
|
1263
|
-
</span>
|
1264
|
-
</span>
|
1265
|
-
</span>
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span>
|
1270
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Proc</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span>
|
1271
|
-
<span class='kw'>else</span> <span class='kw'>false</span>
|
1272
|
-
<span class='kw'>end</span>
|
1249
|
+
<span class='comment'># :nodoc:
|
1250
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>
|
1251
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_validator'>validator</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
1252
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Array</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>include?</span><span class='tstring_end'>"</span></span>
|
1253
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span>
|
1254
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Proc</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span>
|
1255
|
+
<span class='kw'>else</span> <span class='kw'>false</span>
|
1273
1256
|
<span class='kw'>end</span>
|
1257
|
+
<span class='kw'>end</span>
|
1274
1258
|
<span class='kw'>end</span></pre>
|
1275
1259
|
</td>
|
1276
1260
|
</tr>
|
@@ -1321,6 +1305,7 @@
|
|
1321
1305
|
<pre class="lines">
|
1322
1306
|
|
1323
1307
|
|
1308
|
+
41
|
1324
1309
|
42
|
1325
1310
|
43
|
1326
1311
|
44
|
@@ -1523,19 +1508,10 @@
|
|
1523
1508
|
241
|
1524
1509
|
242
|
1525
1510
|
243
|
1526
|
-
244
|
1527
|
-
245
|
1528
|
-
246
|
1529
|
-
247
|
1530
|
-
248
|
1531
|
-
249
|
1532
|
-
250
|
1533
|
-
251
|
1534
|
-
252
|
1535
|
-
253</pre>
|
1511
|
+
244</pre>
|
1536
1512
|
</td>
|
1537
1513
|
<td>
|
1538
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line
|
1514
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 41</span>
|
1539
1515
|
|
1540
1516
|
<span class='kw'>class</span> <span class='const'>Option</span>
|
1541
1517
|
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:name</span>
|
@@ -1569,7 +1545,7 @@
|
|
1569
1545
|
</span> <span class='comment'>#
|
1570
1546
|
</span> <span class='comment'># @param value [String] The short form of this option.
|
1571
1547
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_short='>short=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
1572
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>
|
1548
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
1573
1549
|
|
1574
1550
|
<span class='comment'># Clean value
|
1575
1551
|
</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}([a-z0-9])(.*)$</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
@@ -1581,7 +1557,7 @@
|
|
1581
1557
|
</span> <span class='comment'>#
|
1582
1558
|
</span> <span class='comment'># @param value [String] The short form of this option.
|
1583
1559
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_long='>long=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
1584
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>
|
1560
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
1585
1561
|
|
1586
1562
|
<span class='comment'># Clean value
|
1587
1563
|
</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}(.+)$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
@@ -1594,7 +1570,7 @@
|
|
1594
1570
|
</span> <span class='comment'># @param value [String] The validator of this option.
|
1595
1571
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_validator='>validator=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
1596
1572
|
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
|
1597
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='
|
1573
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Proc</span><span class='rparen'>)</span>
|
1598
1574
|
<span class='ivar'>@validator</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
1599
1575
|
<span class='kw'>end</span>
|
1600
1576
|
|
@@ -1621,22 +1597,24 @@
|
|
1621
1597
|
|
1622
1598
|
<span class='comment'># Returns the meta argument for this option.
|
1623
1599
|
</span> <span class='comment'>#
|
1624
|
-
</span> <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
|
1600
|
+
</span> <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
|
1601
|
+
</span> <span class='comment'># if this option doesn't require a meta argument.
|
1625
1602
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_meta'>meta</span>
|
1626
|
-
<span class='
|
1603
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
|
1604
|
+
<span class='ivar'>@meta</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='ivar'>@meta</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span>
|
1627
1605
|
<span class='kw'>end</span>
|
1628
1606
|
|
1629
1607
|
<span class='comment'># Get the current default value for this option.
|
1630
1608
|
</span> <span class='comment'>#
|
1631
1609
|
</span> <span class='comment'># @return [Object] The default value for this option.
|
1632
1610
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_default'>default</span>
|
1633
|
-
<span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>OPTION_TYPES</span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span>
|
1611
|
+
<span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>OPTION_TYPES</span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>false</span>
|
1634
1612
|
<span class='kw'>end</span>
|
1635
1613
|
|
1636
1614
|
<span class='comment'># Check if the current option has a default value.
|
1637
1615
|
</span> <span class='comment'>#
|
1638
1616
|
</span> <span class='comment'># @return [Boolean] If the current option has a default value.
|
1639
|
-
</span> <span class='kw'>def</span> <span class='id identifier
|
1617
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
|
1640
1618
|
<span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
1641
1619
|
<span class='kw'>end</span>
|
1642
1620
|
|
@@ -1649,7 +1627,7 @@
|
|
1649
1627
|
<span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
|
1650
1628
|
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>
|
1651
1629
|
|
1652
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
1630
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
1653
1631
|
<span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
1654
1632
|
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
1655
1633
|
<span class='kw'>else</span> <span class='comment'># Validation failed
|
@@ -1662,10 +1640,9 @@
|
|
1662
1640
|
|
1663
1641
|
<span class='comment'># Executes the action associated to this option.
|
1664
1642
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
|
1665
|
-
<span class='kw'>
|
1666
|
-
|
1667
|
-
|
1668
|
-
<span class='kw'>end</span>
|
1643
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
1644
|
+
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
1645
|
+
<span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
|
1669
1646
|
<span class='kw'>end</span>
|
1670
1647
|
|
1671
1648
|
<span class='comment'># Checks if this option requires an argument.
|
@@ -1685,7 +1662,7 @@
|
|
1685
1662
|
<span class='comment'># Check if this command has a help.
|
1686
1663
|
</span> <span class='comment'>#
|
1687
1664
|
</span> <span class='comment'># @return [Boolean] `true` if this command has a help, `false` otherwise.
|
1688
|
-
</span> <span class='kw'>def</span> <span class='id identifier
|
1665
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
|
1689
1666
|
<span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
1690
1667
|
<span class='kw'>end</span>
|
1691
1668
|
|
@@ -1697,57 +1674,48 @@
|
|
1697
1674
|
<span class='kw'>end</span>
|
1698
1675
|
|
1699
1676
|
<span class='id identifier rubyid_private'>private</span>
|
1700
|
-
<span class='comment'># Setups the forms of the this option.
|
1701
|
-
</span> <span class='comment'>#
|
1702
|
-
</span> <span class='comment'># @param forms [Array] An array of short and long forms for this option. Missing forms will be inferred by the name.
|
1703
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
|
1704
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>></span> <span class='int'>0</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
1705
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
|
1706
|
-
<span class='kw'>end</span>
|
1707
1677
|
|
1708
|
-
|
1709
|
-
</span>
|
1710
|
-
</span>
|
1711
|
-
|
1712
|
-
|
1713
|
-
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1714
|
-
<span class='kw'>end</span>
|
1715
|
-
<span class='kw'>end</span>
|
1678
|
+
<span class='comment'># :nodoc:
|
1679
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
|
1680
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
1681
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
|
1682
|
+
<span class='kw'>end</span>
|
1716
1683
|
|
1717
|
-
|
1718
|
-
</span>
|
1719
|
-
</span>
|
1720
|
-
</span>
|
1721
|
-
<span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
|
1684
|
+
<span class='comment'># :nodoc:
|
1685
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
1686
|
+
<span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_option'>option</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
|
1687
|
+
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1722
1688
|
<span class='kw'>end</span>
|
1689
|
+
<span class='kw'>end</span>
|
1723
1690
|
|
1724
|
-
|
1725
|
-
</span>
|
1726
|
-
</span>
|
1727
|
-
|
1728
|
-
<span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>
|
1691
|
+
<span class='comment'># :nodoc:
|
1692
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
|
1693
|
+
<span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
|
1694
|
+
<span class='kw'>end</span>
|
1729
1695
|
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1696
|
+
<span class='comment'># :nodoc:
|
1697
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
|
1698
|
+
<span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>
|
1699
|
+
|
1700
|
+
<span class='id identifier rubyid_message'>message</span> <span class='op'>=</span>
|
1701
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_vs'>vs</span>
|
1702
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_regexp'>invalid_for_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rparen'>)</span>
|
1703
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_proc'>invalid_for_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='rparen'>)</span>
|
1704
|
+
<span class='kw'>else</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_value'>invalid_value</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_smart_join'>smart_join</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='comma'>,</span> <span class='label'>separator:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>, </span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>last_separator:</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_join_separator'>join_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_html_safe'>html_safe</span><span class='rparen'>)</span>
|
1734
1705
|
<span class='kw'>end</span>
|
1735
1706
|
|
1736
|
-
|
1737
|
-
|
1707
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>Error</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:validation_failed</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
|
1708
|
+
<span class='kw'>end</span>
|
1738
1709
|
|
1739
|
-
|
1740
|
-
</span>
|
1741
|
-
</span>
|
1742
|
-
</span>
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span>
|
1747
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Proc</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span>
|
1748
|
-
<span class='kw'>else</span> <span class='kw'>false</span>
|
1749
|
-
<span class='kw'>end</span>
|
1710
|
+
<span class='comment'># :nodoc:
|
1711
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>
|
1712
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_validator'>validator</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
1713
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Array</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>include?</span><span class='tstring_end'>"</span></span>
|
1714
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span>
|
1715
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Proc</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span>
|
1716
|
+
<span class='kw'>else</span> <span class='kw'>false</span>
|
1750
1717
|
<span class='kw'>end</span>
|
1718
|
+
<span class='kw'>end</span>
|
1751
1719
|
<span class='kw'>end</span></pre>
|
1752
1720
|
</td>
|
1753
1721
|
</tr>
|
@@ -1798,6 +1766,7 @@
|
|
1798
1766
|
<pre class="lines">
|
1799
1767
|
|
1800
1768
|
|
1769
|
+
41
|
1801
1770
|
42
|
1802
1771
|
43
|
1803
1772
|
44
|
@@ -2000,19 +1969,10 @@
|
|
2000
1969
|
241
|
2001
1970
|
242
|
2002
1971
|
243
|
2003
|
-
244
|
2004
|
-
245
|
2005
|
-
246
|
2006
|
-
247
|
2007
|
-
248
|
2008
|
-
249
|
2009
|
-
250
|
2010
|
-
251
|
2011
|
-
252
|
2012
|
-
253</pre>
|
1972
|
+
244</pre>
|
2013
1973
|
</td>
|
2014
1974
|
<td>
|
2015
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line
|
1975
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 41</span>
|
2016
1976
|
|
2017
1977
|
<span class='kw'>class</span> <span class='const'>Option</span>
|
2018
1978
|
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:name</span>
|
@@ -2046,7 +2006,7 @@
|
|
2046
2006
|
</span> <span class='comment'>#
|
2047
2007
|
</span> <span class='comment'># @param value [String] The short form of this option.
|
2048
2008
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_short='>short=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
2049
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>
|
2009
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
2050
2010
|
|
2051
2011
|
<span class='comment'># Clean value
|
2052
2012
|
</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}([a-z0-9])(.*)$</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
@@ -2058,7 +2018,7 @@
|
|
2058
2018
|
</span> <span class='comment'>#
|
2059
2019
|
</span> <span class='comment'># @param value [String] The short form of this option.
|
2060
2020
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_long='>long=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
2061
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>
|
2021
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
2062
2022
|
|
2063
2023
|
<span class='comment'># Clean value
|
2064
2024
|
</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}(.+)$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
@@ -2071,7 +2031,7 @@
|
|
2071
2031
|
</span> <span class='comment'># @param value [String] The validator of this option.
|
2072
2032
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_validator='>validator=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
2073
2033
|
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
|
2074
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='
|
2034
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Proc</span><span class='rparen'>)</span>
|
2075
2035
|
<span class='ivar'>@validator</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
2076
2036
|
<span class='kw'>end</span>
|
2077
2037
|
|
@@ -2098,22 +2058,24 @@
|
|
2098
2058
|
|
2099
2059
|
<span class='comment'># Returns the meta argument for this option.
|
2100
2060
|
</span> <span class='comment'>#
|
2101
|
-
</span> <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
|
2061
|
+
</span> <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
|
2062
|
+
</span> <span class='comment'># if this option doesn't require a meta argument.
|
2102
2063
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_meta'>meta</span>
|
2103
|
-
<span class='
|
2064
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
|
2065
|
+
<span class='ivar'>@meta</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='ivar'>@meta</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span>
|
2104
2066
|
<span class='kw'>end</span>
|
2105
2067
|
|
2106
2068
|
<span class='comment'># Get the current default value for this option.
|
2107
2069
|
</span> <span class='comment'>#
|
2108
2070
|
</span> <span class='comment'># @return [Object] The default value for this option.
|
2109
2071
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_default'>default</span>
|
2110
|
-
<span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>OPTION_TYPES</span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span>
|
2072
|
+
<span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>OPTION_TYPES</span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>false</span>
|
2111
2073
|
<span class='kw'>end</span>
|
2112
2074
|
|
2113
2075
|
<span class='comment'># Check if the current option has a default value.
|
2114
2076
|
</span> <span class='comment'>#
|
2115
2077
|
</span> <span class='comment'># @return [Boolean] If the current option has a default value.
|
2116
|
-
</span> <span class='kw'>def</span> <span class='id identifier
|
2078
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
|
2117
2079
|
<span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
2118
2080
|
<span class='kw'>end</span>
|
2119
2081
|
|
@@ -2126,7 +2088,7 @@
|
|
2126
2088
|
<span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
|
2127
2089
|
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>
|
2128
2090
|
|
2129
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
2091
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
2130
2092
|
<span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
2131
2093
|
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
2132
2094
|
<span class='kw'>else</span> <span class='comment'># Validation failed
|
@@ -2139,10 +2101,9 @@
|
|
2139
2101
|
|
2140
2102
|
<span class='comment'># Executes the action associated to this option.
|
2141
2103
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
|
2142
|
-
<span class='kw'>
|
2143
|
-
|
2144
|
-
|
2145
|
-
<span class='kw'>end</span>
|
2104
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
2105
|
+
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
2106
|
+
<span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
|
2146
2107
|
<span class='kw'>end</span>
|
2147
2108
|
|
2148
2109
|
<span class='comment'># Checks if this option requires an argument.
|
@@ -2162,7 +2123,7 @@
|
|
2162
2123
|
<span class='comment'># Check if this command has a help.
|
2163
2124
|
</span> <span class='comment'>#
|
2164
2125
|
</span> <span class='comment'># @return [Boolean] `true` if this command has a help, `false` otherwise.
|
2165
|
-
</span> <span class='kw'>def</span> <span class='id identifier
|
2126
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
|
2166
2127
|
<span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
2167
2128
|
<span class='kw'>end</span>
|
2168
2129
|
|
@@ -2174,57 +2135,48 @@
|
|
2174
2135
|
<span class='kw'>end</span>
|
2175
2136
|
|
2176
2137
|
<span class='id identifier rubyid_private'>private</span>
|
2177
|
-
<span class='comment'># Setups the forms of the this option.
|
2178
|
-
</span> <span class='comment'>#
|
2179
|
-
</span> <span class='comment'># @param forms [Array] An array of short and long forms for this option. Missing forms will be inferred by the name.
|
2180
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
|
2181
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>></span> <span class='int'>0</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
2182
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
|
2183
|
-
<span class='kw'>end</span>
|
2184
2138
|
|
2185
|
-
|
2186
|
-
</span>
|
2187
|
-
</span>
|
2188
|
-
|
2189
|
-
|
2190
|
-
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
2191
|
-
<span class='kw'>end</span>
|
2192
|
-
<span class='kw'>end</span>
|
2139
|
+
<span class='comment'># :nodoc:
|
2140
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
|
2141
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
2142
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
|
2143
|
+
<span class='kw'>end</span>
|
2193
2144
|
|
2194
|
-
|
2195
|
-
</span>
|
2196
|
-
</span>
|
2197
|
-
</span>
|
2198
|
-
<span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
|
2145
|
+
<span class='comment'># :nodoc:
|
2146
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
2147
|
+
<span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_option'>option</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
|
2148
|
+
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
2199
2149
|
<span class='kw'>end</span>
|
2150
|
+
<span class='kw'>end</span>
|
2151
|
+
|
2152
|
+
<span class='comment'># :nodoc:
|
2153
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
|
2154
|
+
<span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
|
2155
|
+
<span class='kw'>end</span>
|
2200
2156
|
|
2201
|
-
|
2202
|
-
</span>
|
2203
|
-
</span>
|
2204
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
|
2205
|
-
<span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>
|
2157
|
+
<span class='comment'># :nodoc:
|
2158
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
|
2159
|
+
<span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>
|
2206
2160
|
|
2207
|
-
|
2208
|
-
|
2209
|
-
|
2210
|
-
|
2161
|
+
<span class='id identifier rubyid_message'>message</span> <span class='op'>=</span>
|
2162
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_vs'>vs</span>
|
2163
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_regexp'>invalid_for_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rparen'>)</span>
|
2164
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_proc'>invalid_for_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='rparen'>)</span>
|
2165
|
+
<span class='kw'>else</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_value'>invalid_value</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_smart_join'>smart_join</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='comma'>,</span> <span class='label'>separator:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>, </span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>last_separator:</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_join_separator'>join_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_html_safe'>html_safe</span><span class='rparen'>)</span>
|
2211
2166
|
<span class='kw'>end</span>
|
2212
2167
|
|
2213
|
-
|
2214
|
-
|
2168
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>Error</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:validation_failed</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
|
2169
|
+
<span class='kw'>end</span>
|
2215
2170
|
|
2216
|
-
|
2217
|
-
</span>
|
2218
|
-
</span>
|
2219
|
-
</span>
|
2220
|
-
|
2221
|
-
|
2222
|
-
|
2223
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span>
|
2224
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Proc</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span>
|
2225
|
-
<span class='kw'>else</span> <span class='kw'>false</span>
|
2226
|
-
<span class='kw'>end</span>
|
2171
|
+
<span class='comment'># :nodoc:
|
2172
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>
|
2173
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_validator'>validator</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
2174
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Array</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>include?</span><span class='tstring_end'>"</span></span>
|
2175
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span>
|
2176
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Proc</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span>
|
2177
|
+
<span class='kw'>else</span> <span class='kw'>false</span>
|
2227
2178
|
<span class='kw'>end</span>
|
2179
|
+
<span class='kw'>end</span>
|
2228
2180
|
<span class='kw'>end</span></pre>
|
2229
2181
|
</td>
|
2230
2182
|
</tr>
|
@@ -2275,6 +2227,7 @@
|
|
2275
2227
|
<pre class="lines">
|
2276
2228
|
|
2277
2229
|
|
2230
|
+
41
|
2278
2231
|
42
|
2279
2232
|
43
|
2280
2233
|
44
|
@@ -2477,19 +2430,10 @@
|
|
2477
2430
|
241
|
2478
2431
|
242
|
2479
2432
|
243
|
2480
|
-
244
|
2481
|
-
245
|
2482
|
-
246
|
2483
|
-
247
|
2484
|
-
248
|
2485
|
-
249
|
2486
|
-
250
|
2487
|
-
251
|
2488
|
-
252
|
2489
|
-
253</pre>
|
2433
|
+
244</pre>
|
2490
2434
|
</td>
|
2491
2435
|
<td>
|
2492
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line
|
2436
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 41</span>
|
2493
2437
|
|
2494
2438
|
<span class='kw'>class</span> <span class='const'>Option</span>
|
2495
2439
|
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:name</span>
|
@@ -2523,7 +2467,7 @@
|
|
2523
2467
|
</span> <span class='comment'>#
|
2524
2468
|
</span> <span class='comment'># @param value [String] The short form of this option.
|
2525
2469
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_short='>short=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
2526
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>
|
2470
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
2527
2471
|
|
2528
2472
|
<span class='comment'># Clean value
|
2529
2473
|
</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}([a-z0-9])(.*)$</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
@@ -2535,7 +2479,7 @@
|
|
2535
2479
|
</span> <span class='comment'>#
|
2536
2480
|
</span> <span class='comment'># @param value [String] The short form of this option.
|
2537
2481
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_long='>long=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
2538
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>
|
2482
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
2539
2483
|
|
2540
2484
|
<span class='comment'># Clean value
|
2541
2485
|
</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}(.+)$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
@@ -2548,7 +2492,7 @@
|
|
2548
2492
|
</span> <span class='comment'># @param value [String] The validator of this option.
|
2549
2493
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_validator='>validator=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
2550
2494
|
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
|
2551
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='
|
2495
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Proc</span><span class='rparen'>)</span>
|
2552
2496
|
<span class='ivar'>@validator</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
2553
2497
|
<span class='kw'>end</span>
|
2554
2498
|
|
@@ -2575,22 +2519,24 @@
|
|
2575
2519
|
|
2576
2520
|
<span class='comment'># Returns the meta argument for this option.
|
2577
2521
|
</span> <span class='comment'>#
|
2578
|
-
</span> <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
|
2522
|
+
</span> <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
|
2523
|
+
</span> <span class='comment'># if this option doesn't require a meta argument.
|
2579
2524
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_meta'>meta</span>
|
2580
|
-
<span class='
|
2525
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
|
2526
|
+
<span class='ivar'>@meta</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='ivar'>@meta</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span>
|
2581
2527
|
<span class='kw'>end</span>
|
2582
2528
|
|
2583
2529
|
<span class='comment'># Get the current default value for this option.
|
2584
2530
|
</span> <span class='comment'>#
|
2585
2531
|
</span> <span class='comment'># @return [Object] The default value for this option.
|
2586
2532
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_default'>default</span>
|
2587
|
-
<span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>OPTION_TYPES</span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span>
|
2533
|
+
<span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>OPTION_TYPES</span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>false</span>
|
2588
2534
|
<span class='kw'>end</span>
|
2589
2535
|
|
2590
2536
|
<span class='comment'># Check if the current option has a default value.
|
2591
2537
|
</span> <span class='comment'>#
|
2592
2538
|
</span> <span class='comment'># @return [Boolean] If the current option has a default value.
|
2593
|
-
</span> <span class='kw'>def</span> <span class='id identifier
|
2539
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
|
2594
2540
|
<span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
2595
2541
|
<span class='kw'>end</span>
|
2596
2542
|
|
@@ -2603,7 +2549,7 @@
|
|
2603
2549
|
<span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
|
2604
2550
|
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>
|
2605
2551
|
|
2606
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
2552
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
2607
2553
|
<span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
2608
2554
|
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
2609
2555
|
<span class='kw'>else</span> <span class='comment'># Validation failed
|
@@ -2616,10 +2562,9 @@
|
|
2616
2562
|
|
2617
2563
|
<span class='comment'># Executes the action associated to this option.
|
2618
2564
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
|
2619
|
-
<span class='kw'>
|
2620
|
-
|
2621
|
-
|
2622
|
-
<span class='kw'>end</span>
|
2565
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
2566
|
+
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
2567
|
+
<span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
|
2623
2568
|
<span class='kw'>end</span>
|
2624
2569
|
|
2625
2570
|
<span class='comment'># Checks if this option requires an argument.
|
@@ -2639,7 +2584,7 @@
|
|
2639
2584
|
<span class='comment'># Check if this command has a help.
|
2640
2585
|
</span> <span class='comment'>#
|
2641
2586
|
</span> <span class='comment'># @return [Boolean] `true` if this command has a help, `false` otherwise.
|
2642
|
-
</span> <span class='kw'>def</span> <span class='id identifier
|
2587
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
|
2643
2588
|
<span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
2644
2589
|
<span class='kw'>end</span>
|
2645
2590
|
|
@@ -2651,57 +2596,48 @@
|
|
2651
2596
|
<span class='kw'>end</span>
|
2652
2597
|
|
2653
2598
|
<span class='id identifier rubyid_private'>private</span>
|
2654
|
-
<span class='comment'># Setups the forms of the this option.
|
2655
|
-
</span> <span class='comment'>#
|
2656
|
-
</span> <span class='comment'># @param forms [Array] An array of short and long forms for this option. Missing forms will be inferred by the name.
|
2657
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
|
2658
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>></span> <span class='int'>0</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
2659
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
|
2660
|
-
<span class='kw'>end</span>
|
2661
2599
|
|
2662
|
-
|
2663
|
-
</span>
|
2664
|
-
</span>
|
2665
|
-
|
2666
|
-
|
2667
|
-
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
2668
|
-
<span class='kw'>end</span>
|
2669
|
-
<span class='kw'>end</span>
|
2600
|
+
<span class='comment'># :nodoc:
|
2601
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
|
2602
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
2603
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
|
2604
|
+
<span class='kw'>end</span>
|
2670
2605
|
|
2671
|
-
|
2672
|
-
</span>
|
2673
|
-
</span>
|
2674
|
-
</span>
|
2675
|
-
<span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
|
2606
|
+
<span class='comment'># :nodoc:
|
2607
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
2608
|
+
<span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_option'>option</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
|
2609
|
+
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
2676
2610
|
<span class='kw'>end</span>
|
2611
|
+
<span class='kw'>end</span>
|
2612
|
+
|
2613
|
+
<span class='comment'># :nodoc:
|
2614
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
|
2615
|
+
<span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
|
2616
|
+
<span class='kw'>end</span>
|
2677
2617
|
|
2678
|
-
|
2679
|
-
</span>
|
2680
|
-
</span>
|
2681
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
|
2682
|
-
<span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>
|
2618
|
+
<span class='comment'># :nodoc:
|
2619
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
|
2620
|
+
<span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>
|
2683
2621
|
|
2684
|
-
|
2685
|
-
|
2686
|
-
|
2687
|
-
|
2622
|
+
<span class='id identifier rubyid_message'>message</span> <span class='op'>=</span>
|
2623
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_vs'>vs</span>
|
2624
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_regexp'>invalid_for_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rparen'>)</span>
|
2625
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_proc'>invalid_for_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='rparen'>)</span>
|
2626
|
+
<span class='kw'>else</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_value'>invalid_value</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_smart_join'>smart_join</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='comma'>,</span> <span class='label'>separator:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>, </span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>last_separator:</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_join_separator'>join_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_html_safe'>html_safe</span><span class='rparen'>)</span>
|
2688
2627
|
<span class='kw'>end</span>
|
2689
2628
|
|
2690
|
-
|
2691
|
-
|
2629
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>Error</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:validation_failed</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
|
2630
|
+
<span class='kw'>end</span>
|
2692
2631
|
|
2693
|
-
|
2694
|
-
</span>
|
2695
|
-
</span>
|
2696
|
-
</span>
|
2697
|
-
|
2698
|
-
|
2699
|
-
|
2700
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span>
|
2701
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Proc</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span>
|
2702
|
-
<span class='kw'>else</span> <span class='kw'>false</span>
|
2703
|
-
<span class='kw'>end</span>
|
2632
|
+
<span class='comment'># :nodoc:
|
2633
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>
|
2634
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_validator'>validator</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
2635
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Array</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>include?</span><span class='tstring_end'>"</span></span>
|
2636
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span>
|
2637
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Proc</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span>
|
2638
|
+
<span class='kw'>else</span> <span class='kw'>false</span>
|
2704
2639
|
<span class='kw'>end</span>
|
2640
|
+
<span class='kw'>end</span>
|
2705
2641
|
<span class='kw'>end</span></pre>
|
2706
2642
|
</td>
|
2707
2643
|
</tr>
|
@@ -2739,7 +2675,8 @@
|
|
2739
2675
|
|
2740
2676
|
|
2741
2677
|
—
|
2742
|
-
<div class='inline'><p>Returns the current meta argument for this option (the default value is the option name uppercased) or <code>nil</code>,
|
2678
|
+
<div class='inline'><p>Returns the current meta argument for this option (the default value is the option name uppercased) or <code>nil</code>,
|
2679
|
+
if this option doesn’t require a meta argument.</p>
|
2743
2680
|
</div>
|
2744
2681
|
|
2745
2682
|
</li>
|
@@ -2752,6 +2689,7 @@
|
|
2752
2689
|
<pre class="lines">
|
2753
2690
|
|
2754
2691
|
|
2692
|
+
41
|
2755
2693
|
42
|
2756
2694
|
43
|
2757
2695
|
44
|
@@ -2954,19 +2892,10 @@
|
|
2954
2892
|
241
|
2955
2893
|
242
|
2956
2894
|
243
|
2957
|
-
244
|
2958
|
-
245
|
2959
|
-
246
|
2960
|
-
247
|
2961
|
-
248
|
2962
|
-
249
|
2963
|
-
250
|
2964
|
-
251
|
2965
|
-
252
|
2966
|
-
253</pre>
|
2895
|
+
244</pre>
|
2967
2896
|
</td>
|
2968
2897
|
<td>
|
2969
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line
|
2898
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 41</span>
|
2970
2899
|
|
2971
2900
|
<span class='kw'>class</span> <span class='const'>Option</span>
|
2972
2901
|
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:name</span>
|
@@ -3000,7 +2929,7 @@
|
|
3000
2929
|
</span> <span class='comment'>#
|
3001
2930
|
</span> <span class='comment'># @param value [String] The short form of this option.
|
3002
2931
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_short='>short=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
3003
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>
|
2932
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
3004
2933
|
|
3005
2934
|
<span class='comment'># Clean value
|
3006
2935
|
</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}([a-z0-9])(.*)$</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
@@ -3012,7 +2941,7 @@
|
|
3012
2941
|
</span> <span class='comment'>#
|
3013
2942
|
</span> <span class='comment'># @param value [String] The short form of this option.
|
3014
2943
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_long='>long=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
3015
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>
|
2944
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
3016
2945
|
|
3017
2946
|
<span class='comment'># Clean value
|
3018
2947
|
</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}(.+)$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
@@ -3025,7 +2954,7 @@
|
|
3025
2954
|
</span> <span class='comment'># @param value [String] The validator of this option.
|
3026
2955
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_validator='>validator=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
3027
2956
|
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
|
3028
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='
|
2957
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Proc</span><span class='rparen'>)</span>
|
3029
2958
|
<span class='ivar'>@validator</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
3030
2959
|
<span class='kw'>end</span>
|
3031
2960
|
|
@@ -3052,22 +2981,24 @@
|
|
3052
2981
|
|
3053
2982
|
<span class='comment'># Returns the meta argument for this option.
|
3054
2983
|
</span> <span class='comment'>#
|
3055
|
-
</span> <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
|
2984
|
+
</span> <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
|
2985
|
+
</span> <span class='comment'># if this option doesn't require a meta argument.
|
3056
2986
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_meta'>meta</span>
|
3057
|
-
<span class='
|
2987
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
|
2988
|
+
<span class='ivar'>@meta</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='ivar'>@meta</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span>
|
3058
2989
|
<span class='kw'>end</span>
|
3059
2990
|
|
3060
2991
|
<span class='comment'># Get the current default value for this option.
|
3061
2992
|
</span> <span class='comment'>#
|
3062
2993
|
</span> <span class='comment'># @return [Object] The default value for this option.
|
3063
2994
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_default'>default</span>
|
3064
|
-
<span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>OPTION_TYPES</span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span>
|
2995
|
+
<span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>OPTION_TYPES</span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>false</span>
|
3065
2996
|
<span class='kw'>end</span>
|
3066
2997
|
|
3067
2998
|
<span class='comment'># Check if the current option has a default value.
|
3068
2999
|
</span> <span class='comment'>#
|
3069
3000
|
</span> <span class='comment'># @return [Boolean] If the current option has a default value.
|
3070
|
-
</span> <span class='kw'>def</span> <span class='id identifier
|
3001
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
|
3071
3002
|
<span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
3072
3003
|
<span class='kw'>end</span>
|
3073
3004
|
|
@@ -3080,7 +3011,7 @@
|
|
3080
3011
|
<span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
|
3081
3012
|
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>
|
3082
3013
|
|
3083
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
3014
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
3084
3015
|
<span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
3085
3016
|
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
3086
3017
|
<span class='kw'>else</span> <span class='comment'># Validation failed
|
@@ -3093,10 +3024,9 @@
|
|
3093
3024
|
|
3094
3025
|
<span class='comment'># Executes the action associated to this option.
|
3095
3026
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
|
3096
|
-
<span class='kw'>
|
3097
|
-
|
3098
|
-
|
3099
|
-
<span class='kw'>end</span>
|
3027
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
3028
|
+
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
3029
|
+
<span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
|
3100
3030
|
<span class='kw'>end</span>
|
3101
3031
|
|
3102
3032
|
<span class='comment'># Checks if this option requires an argument.
|
@@ -3116,7 +3046,7 @@
|
|
3116
3046
|
<span class='comment'># Check if this command has a help.
|
3117
3047
|
</span> <span class='comment'>#
|
3118
3048
|
</span> <span class='comment'># @return [Boolean] `true` if this command has a help, `false` otherwise.
|
3119
|
-
</span> <span class='kw'>def</span> <span class='id identifier
|
3049
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
|
3120
3050
|
<span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
3121
3051
|
<span class='kw'>end</span>
|
3122
3052
|
|
@@ -3128,57 +3058,48 @@
|
|
3128
3058
|
<span class='kw'>end</span>
|
3129
3059
|
|
3130
3060
|
<span class='id identifier rubyid_private'>private</span>
|
3131
|
-
<span class='comment'># Setups the forms of the this option.
|
3132
|
-
</span> <span class='comment'>#
|
3133
|
-
</span> <span class='comment'># @param forms [Array] An array of short and long forms for this option. Missing forms will be inferred by the name.
|
3134
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
|
3135
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>></span> <span class='int'>0</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
3136
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
|
3137
|
-
<span class='kw'>end</span>
|
3138
3061
|
|
3139
|
-
|
3140
|
-
</span>
|
3141
|
-
</span>
|
3142
|
-
|
3143
|
-
|
3144
|
-
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
3145
|
-
<span class='kw'>end</span>
|
3146
|
-
<span class='kw'>end</span>
|
3062
|
+
<span class='comment'># :nodoc:
|
3063
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
|
3064
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
3065
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
|
3066
|
+
<span class='kw'>end</span>
|
3147
3067
|
|
3148
|
-
|
3149
|
-
</span>
|
3150
|
-
</span>
|
3151
|
-
</span>
|
3152
|
-
<span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
|
3068
|
+
<span class='comment'># :nodoc:
|
3069
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
3070
|
+
<span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_option'>option</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
|
3071
|
+
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
3153
3072
|
<span class='kw'>end</span>
|
3073
|
+
<span class='kw'>end</span>
|
3074
|
+
|
3075
|
+
<span class='comment'># :nodoc:
|
3076
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
|
3077
|
+
<span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
|
3078
|
+
<span class='kw'>end</span>
|
3154
3079
|
|
3155
|
-
|
3156
|
-
</span>
|
3157
|
-
</span>
|
3158
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
|
3159
|
-
<span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>
|
3080
|
+
<span class='comment'># :nodoc:
|
3081
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
|
3082
|
+
<span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>
|
3160
3083
|
|
3161
|
-
|
3162
|
-
|
3163
|
-
|
3164
|
-
|
3084
|
+
<span class='id identifier rubyid_message'>message</span> <span class='op'>=</span>
|
3085
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_vs'>vs</span>
|
3086
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_regexp'>invalid_for_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rparen'>)</span>
|
3087
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_proc'>invalid_for_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='rparen'>)</span>
|
3088
|
+
<span class='kw'>else</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_value'>invalid_value</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_smart_join'>smart_join</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='comma'>,</span> <span class='label'>separator:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>, </span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>last_separator:</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_join_separator'>join_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_html_safe'>html_safe</span><span class='rparen'>)</span>
|
3165
3089
|
<span class='kw'>end</span>
|
3166
3090
|
|
3167
|
-
|
3168
|
-
|
3091
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>Error</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:validation_failed</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
|
3092
|
+
<span class='kw'>end</span>
|
3169
3093
|
|
3170
|
-
|
3171
|
-
</span>
|
3172
|
-
</span>
|
3173
|
-
</span>
|
3174
|
-
|
3175
|
-
|
3176
|
-
|
3177
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span>
|
3178
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Proc</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span>
|
3179
|
-
<span class='kw'>else</span> <span class='kw'>false</span>
|
3180
|
-
<span class='kw'>end</span>
|
3094
|
+
<span class='comment'># :nodoc:
|
3095
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>
|
3096
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_validator'>validator</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
3097
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Array</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>include?</span><span class='tstring_end'>"</span></span>
|
3098
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span>
|
3099
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Proc</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span>
|
3100
|
+
<span class='kw'>else</span> <span class='kw'>false</span>
|
3181
3101
|
<span class='kw'>end</span>
|
3102
|
+
<span class='kw'>end</span>
|
3182
3103
|
<span class='kw'>end</span></pre>
|
3183
3104
|
</td>
|
3184
3105
|
</tr>
|
@@ -3229,6 +3150,7 @@
|
|
3229
3150
|
<pre class="lines">
|
3230
3151
|
|
3231
3152
|
|
3153
|
+
41
|
3232
3154
|
42
|
3233
3155
|
43
|
3234
3156
|
44
|
@@ -3431,19 +3353,10 @@
|
|
3431
3353
|
241
|
3432
3354
|
242
|
3433
3355
|
243
|
3434
|
-
244
|
3435
|
-
245
|
3436
|
-
246
|
3437
|
-
247
|
3438
|
-
248
|
3439
|
-
249
|
3440
|
-
250
|
3441
|
-
251
|
3442
|
-
252
|
3443
|
-
253</pre>
|
3356
|
+
244</pre>
|
3444
3357
|
</td>
|
3445
3358
|
<td>
|
3446
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line
|
3359
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 41</span>
|
3447
3360
|
|
3448
3361
|
<span class='kw'>class</span> <span class='const'>Option</span>
|
3449
3362
|
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:name</span>
|
@@ -3477,7 +3390,7 @@
|
|
3477
3390
|
</span> <span class='comment'>#
|
3478
3391
|
</span> <span class='comment'># @param value [String] The short form of this option.
|
3479
3392
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_short='>short=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
3480
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>
|
3393
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
3481
3394
|
|
3482
3395
|
<span class='comment'># Clean value
|
3483
3396
|
</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}([a-z0-9])(.*)$</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
@@ -3489,7 +3402,7 @@
|
|
3489
3402
|
</span> <span class='comment'>#
|
3490
3403
|
</span> <span class='comment'># @param value [String] The short form of this option.
|
3491
3404
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_long='>long=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
3492
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>
|
3405
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
3493
3406
|
|
3494
3407
|
<span class='comment'># Clean value
|
3495
3408
|
</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}(.+)$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
@@ -3502,7 +3415,7 @@
|
|
3502
3415
|
</span> <span class='comment'># @param value [String] The validator of this option.
|
3503
3416
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_validator='>validator=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
3504
3417
|
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
|
3505
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='
|
3418
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Proc</span><span class='rparen'>)</span>
|
3506
3419
|
<span class='ivar'>@validator</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
3507
3420
|
<span class='kw'>end</span>
|
3508
3421
|
|
@@ -3529,22 +3442,24 @@
|
|
3529
3442
|
|
3530
3443
|
<span class='comment'># Returns the meta argument for this option.
|
3531
3444
|
</span> <span class='comment'>#
|
3532
|
-
</span> <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
|
3445
|
+
</span> <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
|
3446
|
+
</span> <span class='comment'># if this option doesn't require a meta argument.
|
3533
3447
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_meta'>meta</span>
|
3534
|
-
<span class='
|
3448
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
|
3449
|
+
<span class='ivar'>@meta</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='ivar'>@meta</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span>
|
3535
3450
|
<span class='kw'>end</span>
|
3536
3451
|
|
3537
3452
|
<span class='comment'># Get the current default value for this option.
|
3538
3453
|
</span> <span class='comment'>#
|
3539
3454
|
</span> <span class='comment'># @return [Object] The default value for this option.
|
3540
3455
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_default'>default</span>
|
3541
|
-
<span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>OPTION_TYPES</span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span>
|
3456
|
+
<span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>OPTION_TYPES</span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>false</span>
|
3542
3457
|
<span class='kw'>end</span>
|
3543
3458
|
|
3544
3459
|
<span class='comment'># Check if the current option has a default value.
|
3545
3460
|
</span> <span class='comment'>#
|
3546
3461
|
</span> <span class='comment'># @return [Boolean] If the current option has a default value.
|
3547
|
-
</span> <span class='kw'>def</span> <span class='id identifier
|
3462
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
|
3548
3463
|
<span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
3549
3464
|
<span class='kw'>end</span>
|
3550
3465
|
|
@@ -3557,7 +3472,7 @@
|
|
3557
3472
|
<span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
|
3558
3473
|
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>
|
3559
3474
|
|
3560
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
3475
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
3561
3476
|
<span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
3562
3477
|
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
3563
3478
|
<span class='kw'>else</span> <span class='comment'># Validation failed
|
@@ -3570,10 +3485,9 @@
|
|
3570
3485
|
|
3571
3486
|
<span class='comment'># Executes the action associated to this option.
|
3572
3487
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
|
3573
|
-
<span class='kw'>
|
3574
|
-
|
3575
|
-
|
3576
|
-
<span class='kw'>end</span>
|
3488
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
3489
|
+
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
3490
|
+
<span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
|
3577
3491
|
<span class='kw'>end</span>
|
3578
3492
|
|
3579
3493
|
<span class='comment'># Checks if this option requires an argument.
|
@@ -3593,7 +3507,7 @@
|
|
3593
3507
|
<span class='comment'># Check if this command has a help.
|
3594
3508
|
</span> <span class='comment'>#
|
3595
3509
|
</span> <span class='comment'># @return [Boolean] `true` if this command has a help, `false` otherwise.
|
3596
|
-
</span> <span class='kw'>def</span> <span class='id identifier
|
3510
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
|
3597
3511
|
<span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
3598
3512
|
<span class='kw'>end</span>
|
3599
3513
|
|
@@ -3605,57 +3519,48 @@
|
|
3605
3519
|
<span class='kw'>end</span>
|
3606
3520
|
|
3607
3521
|
<span class='id identifier rubyid_private'>private</span>
|
3608
|
-
<span class='comment'># Setups the forms of the this option.
|
3609
|
-
</span> <span class='comment'>#
|
3610
|
-
</span> <span class='comment'># @param forms [Array] An array of short and long forms for this option. Missing forms will be inferred by the name.
|
3611
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
|
3612
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>></span> <span class='int'>0</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
3613
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
|
3614
|
-
<span class='kw'>end</span>
|
3615
3522
|
|
3616
|
-
|
3617
|
-
</span>
|
3618
|
-
</span>
|
3619
|
-
|
3620
|
-
|
3621
|
-
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
3622
|
-
<span class='kw'>end</span>
|
3623
|
-
<span class='kw'>end</span>
|
3523
|
+
<span class='comment'># :nodoc:
|
3524
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
|
3525
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
3526
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
|
3527
|
+
<span class='kw'>end</span>
|
3624
3528
|
|
3625
|
-
|
3626
|
-
</span>
|
3627
|
-
</span>
|
3628
|
-
</span>
|
3629
|
-
<span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
|
3529
|
+
<span class='comment'># :nodoc:
|
3530
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
3531
|
+
<span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_option'>option</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
|
3532
|
+
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
3630
3533
|
<span class='kw'>end</span>
|
3534
|
+
<span class='kw'>end</span>
|
3535
|
+
|
3536
|
+
<span class='comment'># :nodoc:
|
3537
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
|
3538
|
+
<span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
|
3539
|
+
<span class='kw'>end</span>
|
3631
3540
|
|
3632
|
-
|
3633
|
-
</span>
|
3634
|
-
</span>
|
3635
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
|
3636
|
-
<span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>
|
3541
|
+
<span class='comment'># :nodoc:
|
3542
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
|
3543
|
+
<span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>
|
3637
3544
|
|
3638
|
-
|
3639
|
-
|
3640
|
-
|
3641
|
-
|
3545
|
+
<span class='id identifier rubyid_message'>message</span> <span class='op'>=</span>
|
3546
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_vs'>vs</span>
|
3547
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_regexp'>invalid_for_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rparen'>)</span>
|
3548
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_proc'>invalid_for_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='rparen'>)</span>
|
3549
|
+
<span class='kw'>else</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_value'>invalid_value</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_smart_join'>smart_join</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='comma'>,</span> <span class='label'>separator:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>, </span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>last_separator:</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_join_separator'>join_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_html_safe'>html_safe</span><span class='rparen'>)</span>
|
3642
3550
|
<span class='kw'>end</span>
|
3643
3551
|
|
3644
|
-
|
3645
|
-
|
3552
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>Error</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:validation_failed</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
|
3553
|
+
<span class='kw'>end</span>
|
3646
3554
|
|
3647
|
-
|
3648
|
-
</span>
|
3649
|
-
</span>
|
3650
|
-
</span>
|
3651
|
-
|
3652
|
-
|
3653
|
-
|
3654
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span>
|
3655
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Proc</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span>
|
3656
|
-
<span class='kw'>else</span> <span class='kw'>false</span>
|
3657
|
-
<span class='kw'>end</span>
|
3555
|
+
<span class='comment'># :nodoc:
|
3556
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>
|
3557
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_validator'>validator</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
3558
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Array</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>include?</span><span class='tstring_end'>"</span></span>
|
3559
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span>
|
3560
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Proc</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span>
|
3561
|
+
<span class='kw'>else</span> <span class='kw'>false</span>
|
3658
3562
|
<span class='kw'>end</span>
|
3563
|
+
<span class='kw'>end</span>
|
3659
3564
|
<span class='kw'>end</span></pre>
|
3660
3565
|
</td>
|
3661
3566
|
</tr>
|
@@ -3706,6 +3611,7 @@
|
|
3706
3611
|
<pre class="lines">
|
3707
3612
|
|
3708
3613
|
|
3614
|
+
41
|
3709
3615
|
42
|
3710
3616
|
43
|
3711
3617
|
44
|
@@ -3908,19 +3814,10 @@
|
|
3908
3814
|
241
|
3909
3815
|
242
|
3910
3816
|
243
|
3911
|
-
244
|
3912
|
-
245
|
3913
|
-
246
|
3914
|
-
247
|
3915
|
-
248
|
3916
|
-
249
|
3917
|
-
250
|
3918
|
-
251
|
3919
|
-
252
|
3920
|
-
253</pre>
|
3817
|
+
244</pre>
|
3921
3818
|
</td>
|
3922
3819
|
<td>
|
3923
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line
|
3820
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 41</span>
|
3924
3821
|
|
3925
3822
|
<span class='kw'>class</span> <span class='const'>Option</span>
|
3926
3823
|
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:name</span>
|
@@ -3954,7 +3851,7 @@
|
|
3954
3851
|
</span> <span class='comment'>#
|
3955
3852
|
</span> <span class='comment'># @param value [String] The short form of this option.
|
3956
3853
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_short='>short=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
3957
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>
|
3854
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
3958
3855
|
|
3959
3856
|
<span class='comment'># Clean value
|
3960
3857
|
</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}([a-z0-9])(.*)$</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
@@ -3966,7 +3863,7 @@
|
|
3966
3863
|
</span> <span class='comment'>#
|
3967
3864
|
</span> <span class='comment'># @param value [String] The short form of this option.
|
3968
3865
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_long='>long=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
3969
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>
|
3866
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
3970
3867
|
|
3971
3868
|
<span class='comment'># Clean value
|
3972
3869
|
</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}(.+)$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
@@ -3979,7 +3876,7 @@
|
|
3979
3876
|
</span> <span class='comment'># @param value [String] The validator of this option.
|
3980
3877
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_validator='>validator=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
3981
3878
|
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
|
3982
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='
|
3879
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Proc</span><span class='rparen'>)</span>
|
3983
3880
|
<span class='ivar'>@validator</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
3984
3881
|
<span class='kw'>end</span>
|
3985
3882
|
|
@@ -4006,22 +3903,24 @@
|
|
4006
3903
|
|
4007
3904
|
<span class='comment'># Returns the meta argument for this option.
|
4008
3905
|
</span> <span class='comment'>#
|
4009
|
-
</span> <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
|
3906
|
+
</span> <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
|
3907
|
+
</span> <span class='comment'># if this option doesn't require a meta argument.
|
4010
3908
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_meta'>meta</span>
|
4011
|
-
<span class='
|
3909
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
|
3910
|
+
<span class='ivar'>@meta</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='ivar'>@meta</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span>
|
4012
3911
|
<span class='kw'>end</span>
|
4013
3912
|
|
4014
3913
|
<span class='comment'># Get the current default value for this option.
|
4015
3914
|
</span> <span class='comment'>#
|
4016
3915
|
</span> <span class='comment'># @return [Object] The default value for this option.
|
4017
3916
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_default'>default</span>
|
4018
|
-
<span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>OPTION_TYPES</span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span>
|
3917
|
+
<span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>OPTION_TYPES</span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>false</span>
|
4019
3918
|
<span class='kw'>end</span>
|
4020
3919
|
|
4021
3920
|
<span class='comment'># Check if the current option has a default value.
|
4022
3921
|
</span> <span class='comment'>#
|
4023
3922
|
</span> <span class='comment'># @return [Boolean] If the current option has a default value.
|
4024
|
-
</span> <span class='kw'>def</span> <span class='id identifier
|
3923
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
|
4025
3924
|
<span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
4026
3925
|
<span class='kw'>end</span>
|
4027
3926
|
|
@@ -4034,7 +3933,7 @@
|
|
4034
3933
|
<span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
|
4035
3934
|
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>
|
4036
3935
|
|
4037
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
3936
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
4038
3937
|
<span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
4039
3938
|
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
4040
3939
|
<span class='kw'>else</span> <span class='comment'># Validation failed
|
@@ -4047,10 +3946,9 @@
|
|
4047
3946
|
|
4048
3947
|
<span class='comment'># Executes the action associated to this option.
|
4049
3948
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
|
4050
|
-
<span class='kw'>
|
4051
|
-
|
4052
|
-
|
4053
|
-
<span class='kw'>end</span>
|
3949
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
3950
|
+
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
3951
|
+
<span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
|
4054
3952
|
<span class='kw'>end</span>
|
4055
3953
|
|
4056
3954
|
<span class='comment'># Checks if this option requires an argument.
|
@@ -4070,7 +3968,7 @@
|
|
4070
3968
|
<span class='comment'># Check if this command has a help.
|
4071
3969
|
</span> <span class='comment'>#
|
4072
3970
|
</span> <span class='comment'># @return [Boolean] `true` if this command has a help, `false` otherwise.
|
4073
|
-
</span> <span class='kw'>def</span> <span class='id identifier
|
3971
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
|
4074
3972
|
<span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
4075
3973
|
<span class='kw'>end</span>
|
4076
3974
|
|
@@ -4082,57 +3980,48 @@
|
|
4082
3980
|
<span class='kw'>end</span>
|
4083
3981
|
|
4084
3982
|
<span class='id identifier rubyid_private'>private</span>
|
4085
|
-
<span class='comment'># Setups the forms of the this option.
|
4086
|
-
</span> <span class='comment'>#
|
4087
|
-
</span> <span class='comment'># @param forms [Array] An array of short and long forms for this option. Missing forms will be inferred by the name.
|
4088
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
|
4089
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>></span> <span class='int'>0</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
4090
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
|
4091
|
-
<span class='kw'>end</span>
|
4092
3983
|
|
4093
|
-
|
4094
|
-
</span>
|
4095
|
-
</span>
|
4096
|
-
|
4097
|
-
|
4098
|
-
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
4099
|
-
<span class='kw'>end</span>
|
4100
|
-
<span class='kw'>end</span>
|
3984
|
+
<span class='comment'># :nodoc:
|
3985
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
|
3986
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
3987
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
|
3988
|
+
<span class='kw'>end</span>
|
4101
3989
|
|
4102
|
-
|
4103
|
-
</span>
|
4104
|
-
</span>
|
4105
|
-
</span>
|
4106
|
-
<span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
|
3990
|
+
<span class='comment'># :nodoc:
|
3991
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
3992
|
+
<span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_option'>option</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
|
3993
|
+
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
4107
3994
|
<span class='kw'>end</span>
|
3995
|
+
<span class='kw'>end</span>
|
3996
|
+
|
3997
|
+
<span class='comment'># :nodoc:
|
3998
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
|
3999
|
+
<span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
|
4000
|
+
<span class='kw'>end</span>
|
4108
4001
|
|
4109
|
-
|
4110
|
-
</span>
|
4111
|
-
</span>
|
4112
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
|
4113
|
-
<span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>
|
4002
|
+
<span class='comment'># :nodoc:
|
4003
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
|
4004
|
+
<span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>
|
4114
4005
|
|
4115
|
-
|
4116
|
-
|
4117
|
-
|
4118
|
-
|
4006
|
+
<span class='id identifier rubyid_message'>message</span> <span class='op'>=</span>
|
4007
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_vs'>vs</span>
|
4008
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_regexp'>invalid_for_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rparen'>)</span>
|
4009
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_proc'>invalid_for_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='rparen'>)</span>
|
4010
|
+
<span class='kw'>else</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_value'>invalid_value</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_smart_join'>smart_join</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='comma'>,</span> <span class='label'>separator:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>, </span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>last_separator:</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_join_separator'>join_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_html_safe'>html_safe</span><span class='rparen'>)</span>
|
4119
4011
|
<span class='kw'>end</span>
|
4120
4012
|
|
4121
|
-
|
4122
|
-
|
4013
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>Error</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:validation_failed</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
|
4014
|
+
<span class='kw'>end</span>
|
4123
4015
|
|
4124
|
-
|
4125
|
-
</span>
|
4126
|
-
</span>
|
4127
|
-
</span>
|
4128
|
-
|
4129
|
-
|
4130
|
-
|
4131
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span>
|
4132
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Proc</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span>
|
4133
|
-
<span class='kw'>else</span> <span class='kw'>false</span>
|
4134
|
-
<span class='kw'>end</span>
|
4016
|
+
<span class='comment'># :nodoc:
|
4017
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>
|
4018
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_validator'>validator</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
4019
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Array</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>include?</span><span class='tstring_end'>"</span></span>
|
4020
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span>
|
4021
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Proc</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span>
|
4022
|
+
<span class='kw'>else</span> <span class='kw'>false</span>
|
4135
4023
|
<span class='kw'>end</span>
|
4024
|
+
<span class='kw'>end</span>
|
4136
4025
|
<span class='kw'>end</span></pre>
|
4137
4026
|
</td>
|
4138
4027
|
</tr>
|
@@ -4183,6 +4072,7 @@
|
|
4183
4072
|
<pre class="lines">
|
4184
4073
|
|
4185
4074
|
|
4075
|
+
41
|
4186
4076
|
42
|
4187
4077
|
43
|
4188
4078
|
44
|
@@ -4385,19 +4275,10 @@
|
|
4385
4275
|
241
|
4386
4276
|
242
|
4387
4277
|
243
|
4388
|
-
244
|
4389
|
-
245
|
4390
|
-
246
|
4391
|
-
247
|
4392
|
-
248
|
4393
|
-
249
|
4394
|
-
250
|
4395
|
-
251
|
4396
|
-
252
|
4397
|
-
253</pre>
|
4278
|
+
244</pre>
|
4398
4279
|
</td>
|
4399
4280
|
<td>
|
4400
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line
|
4281
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 41</span>
|
4401
4282
|
|
4402
4283
|
<span class='kw'>class</span> <span class='const'>Option</span>
|
4403
4284
|
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:name</span>
|
@@ -4431,7 +4312,7 @@
|
|
4431
4312
|
</span> <span class='comment'>#
|
4432
4313
|
</span> <span class='comment'># @param value [String] The short form of this option.
|
4433
4314
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_short='>short=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
4434
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>
|
4315
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
4435
4316
|
|
4436
4317
|
<span class='comment'># Clean value
|
4437
4318
|
</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}([a-z0-9])(.*)$</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
@@ -4443,7 +4324,7 @@
|
|
4443
4324
|
</span> <span class='comment'>#
|
4444
4325
|
</span> <span class='comment'># @param value [String] The short form of this option.
|
4445
4326
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_long='>long=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
4446
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>
|
4327
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
4447
4328
|
|
4448
4329
|
<span class='comment'># Clean value
|
4449
4330
|
</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}(.+)$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
@@ -4456,7 +4337,7 @@
|
|
4456
4337
|
</span> <span class='comment'># @param value [String] The validator of this option.
|
4457
4338
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_validator='>validator=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
4458
4339
|
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
|
4459
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='
|
4340
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Proc</span><span class='rparen'>)</span>
|
4460
4341
|
<span class='ivar'>@validator</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
4461
4342
|
<span class='kw'>end</span>
|
4462
4343
|
|
@@ -4483,22 +4364,24 @@
|
|
4483
4364
|
|
4484
4365
|
<span class='comment'># Returns the meta argument for this option.
|
4485
4366
|
</span> <span class='comment'>#
|
4486
|
-
</span> <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
|
4367
|
+
</span> <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
|
4368
|
+
</span> <span class='comment'># if this option doesn't require a meta argument.
|
4487
4369
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_meta'>meta</span>
|
4488
|
-
<span class='
|
4370
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
|
4371
|
+
<span class='ivar'>@meta</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='ivar'>@meta</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span>
|
4489
4372
|
<span class='kw'>end</span>
|
4490
4373
|
|
4491
4374
|
<span class='comment'># Get the current default value for this option.
|
4492
4375
|
</span> <span class='comment'>#
|
4493
4376
|
</span> <span class='comment'># @return [Object] The default value for this option.
|
4494
4377
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_default'>default</span>
|
4495
|
-
<span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>OPTION_TYPES</span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span>
|
4378
|
+
<span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>OPTION_TYPES</span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>false</span>
|
4496
4379
|
<span class='kw'>end</span>
|
4497
4380
|
|
4498
4381
|
<span class='comment'># Check if the current option has a default value.
|
4499
4382
|
</span> <span class='comment'>#
|
4500
4383
|
</span> <span class='comment'># @return [Boolean] If the current option has a default value.
|
4501
|
-
</span> <span class='kw'>def</span> <span class='id identifier
|
4384
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
|
4502
4385
|
<span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
4503
4386
|
<span class='kw'>end</span>
|
4504
4387
|
|
@@ -4511,7 +4394,7 @@
|
|
4511
4394
|
<span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
|
4512
4395
|
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>
|
4513
4396
|
|
4514
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
4397
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
4515
4398
|
<span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
4516
4399
|
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
4517
4400
|
<span class='kw'>else</span> <span class='comment'># Validation failed
|
@@ -4524,10 +4407,9 @@
|
|
4524
4407
|
|
4525
4408
|
<span class='comment'># Executes the action associated to this option.
|
4526
4409
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
|
4527
|
-
<span class='kw'>
|
4528
|
-
|
4529
|
-
|
4530
|
-
<span class='kw'>end</span>
|
4410
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
4411
|
+
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
4412
|
+
<span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
|
4531
4413
|
<span class='kw'>end</span>
|
4532
4414
|
|
4533
4415
|
<span class='comment'># Checks if this option requires an argument.
|
@@ -4547,7 +4429,7 @@
|
|
4547
4429
|
<span class='comment'># Check if this command has a help.
|
4548
4430
|
</span> <span class='comment'>#
|
4549
4431
|
</span> <span class='comment'># @return [Boolean] `true` if this command has a help, `false` otherwise.
|
4550
|
-
</span> <span class='kw'>def</span> <span class='id identifier
|
4432
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
|
4551
4433
|
<span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
4552
4434
|
<span class='kw'>end</span>
|
4553
4435
|
|
@@ -4559,57 +4441,48 @@
|
|
4559
4441
|
<span class='kw'>end</span>
|
4560
4442
|
|
4561
4443
|
<span class='id identifier rubyid_private'>private</span>
|
4562
|
-
<span class='comment'># Setups the forms of the this option.
|
4563
|
-
</span> <span class='comment'>#
|
4564
|
-
</span> <span class='comment'># @param forms [Array] An array of short and long forms for this option. Missing forms will be inferred by the name.
|
4565
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
|
4566
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>></span> <span class='int'>0</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
4567
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
|
4568
|
-
<span class='kw'>end</span>
|
4569
4444
|
|
4570
|
-
|
4571
|
-
</span>
|
4572
|
-
</span>
|
4573
|
-
|
4574
|
-
|
4575
|
-
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
4576
|
-
<span class='kw'>end</span>
|
4577
|
-
<span class='kw'>end</span>
|
4445
|
+
<span class='comment'># :nodoc:
|
4446
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
|
4447
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
4448
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
|
4449
|
+
<span class='kw'>end</span>
|
4578
4450
|
|
4579
|
-
|
4580
|
-
</span>
|
4581
|
-
</span>
|
4582
|
-
</span>
|
4583
|
-
<span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
|
4451
|
+
<span class='comment'># :nodoc:
|
4452
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
4453
|
+
<span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_option'>option</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
|
4454
|
+
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
4584
4455
|
<span class='kw'>end</span>
|
4456
|
+
<span class='kw'>end</span>
|
4585
4457
|
|
4586
|
-
|
4587
|
-
</span>
|
4588
|
-
</span>
|
4589
|
-
|
4590
|
-
|
4458
|
+
<span class='comment'># :nodoc:
|
4459
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
|
4460
|
+
<span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
|
4461
|
+
<span class='kw'>end</span>
|
4462
|
+
|
4463
|
+
<span class='comment'># :nodoc:
|
4464
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
|
4465
|
+
<span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>
|
4591
4466
|
|
4592
|
-
|
4593
|
-
|
4594
|
-
|
4595
|
-
|
4467
|
+
<span class='id identifier rubyid_message'>message</span> <span class='op'>=</span>
|
4468
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_vs'>vs</span>
|
4469
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_regexp'>invalid_for_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rparen'>)</span>
|
4470
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_proc'>invalid_for_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='rparen'>)</span>
|
4471
|
+
<span class='kw'>else</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_value'>invalid_value</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_smart_join'>smart_join</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='comma'>,</span> <span class='label'>separator:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>, </span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>last_separator:</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_join_separator'>join_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_html_safe'>html_safe</span><span class='rparen'>)</span>
|
4596
4472
|
<span class='kw'>end</span>
|
4597
4473
|
|
4598
|
-
|
4599
|
-
|
4474
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>Error</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:validation_failed</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
|
4475
|
+
<span class='kw'>end</span>
|
4600
4476
|
|
4601
|
-
|
4602
|
-
</span>
|
4603
|
-
</span>
|
4604
|
-
</span>
|
4605
|
-
|
4606
|
-
|
4607
|
-
|
4608
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span>
|
4609
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Proc</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span>
|
4610
|
-
<span class='kw'>else</span> <span class='kw'>false</span>
|
4611
|
-
<span class='kw'>end</span>
|
4477
|
+
<span class='comment'># :nodoc:
|
4478
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>
|
4479
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_validator'>validator</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
4480
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Array</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>include?</span><span class='tstring_end'>"</span></span>
|
4481
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span>
|
4482
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Proc</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span>
|
4483
|
+
<span class='kw'>else</span> <span class='kw'>false</span>
|
4612
4484
|
<span class='kw'>end</span>
|
4485
|
+
<span class='kw'>end</span>
|
4613
4486
|
<span class='kw'>end</span></pre>
|
4614
4487
|
</td>
|
4615
4488
|
</tr>
|
@@ -4660,6 +4533,7 @@
|
|
4660
4533
|
<pre class="lines">
|
4661
4534
|
|
4662
4535
|
|
4536
|
+
41
|
4663
4537
|
42
|
4664
4538
|
43
|
4665
4539
|
44
|
@@ -4862,19 +4736,10 @@
|
|
4862
4736
|
241
|
4863
4737
|
242
|
4864
4738
|
243
|
4865
|
-
244
|
4866
|
-
245
|
4867
|
-
246
|
4868
|
-
247
|
4869
|
-
248
|
4870
|
-
249
|
4871
|
-
250
|
4872
|
-
251
|
4873
|
-
252
|
4874
|
-
253</pre>
|
4739
|
+
244</pre>
|
4875
4740
|
</td>
|
4876
4741
|
<td>
|
4877
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line
|
4742
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 41</span>
|
4878
4743
|
|
4879
4744
|
<span class='kw'>class</span> <span class='const'>Option</span>
|
4880
4745
|
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:name</span>
|
@@ -4908,7 +4773,7 @@
|
|
4908
4773
|
</span> <span class='comment'>#
|
4909
4774
|
</span> <span class='comment'># @param value [String] The short form of this option.
|
4910
4775
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_short='>short=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
4911
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>
|
4776
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
4912
4777
|
|
4913
4778
|
<span class='comment'># Clean value
|
4914
4779
|
</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}([a-z0-9])(.*)$</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
@@ -4920,7 +4785,7 @@
|
|
4920
4785
|
</span> <span class='comment'>#
|
4921
4786
|
</span> <span class='comment'># @param value [String] The short form of this option.
|
4922
4787
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_long='>long=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
4923
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>
|
4788
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
4924
4789
|
|
4925
4790
|
<span class='comment'># Clean value
|
4926
4791
|
</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}(.+)$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
@@ -4933,7 +4798,7 @@
|
|
4933
4798
|
</span> <span class='comment'># @param value [String] The validator of this option.
|
4934
4799
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_validator='>validator=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
4935
4800
|
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
|
4936
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='
|
4801
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Proc</span><span class='rparen'>)</span>
|
4937
4802
|
<span class='ivar'>@validator</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
4938
4803
|
<span class='kw'>end</span>
|
4939
4804
|
|
@@ -4960,22 +4825,24 @@
|
|
4960
4825
|
|
4961
4826
|
<span class='comment'># Returns the meta argument for this option.
|
4962
4827
|
</span> <span class='comment'>#
|
4963
|
-
</span> <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
|
4828
|
+
</span> <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
|
4829
|
+
</span> <span class='comment'># if this option doesn't require a meta argument.
|
4964
4830
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_meta'>meta</span>
|
4965
|
-
<span class='
|
4831
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
|
4832
|
+
<span class='ivar'>@meta</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='ivar'>@meta</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span>
|
4966
4833
|
<span class='kw'>end</span>
|
4967
4834
|
|
4968
4835
|
<span class='comment'># Get the current default value for this option.
|
4969
4836
|
</span> <span class='comment'>#
|
4970
4837
|
</span> <span class='comment'># @return [Object] The default value for this option.
|
4971
4838
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_default'>default</span>
|
4972
|
-
<span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>OPTION_TYPES</span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span>
|
4839
|
+
<span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>OPTION_TYPES</span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>false</span>
|
4973
4840
|
<span class='kw'>end</span>
|
4974
4841
|
|
4975
4842
|
<span class='comment'># Check if the current option has a default value.
|
4976
4843
|
</span> <span class='comment'>#
|
4977
4844
|
</span> <span class='comment'># @return [Boolean] If the current option has a default value.
|
4978
|
-
</span> <span class='kw'>def</span> <span class='id identifier
|
4845
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
|
4979
4846
|
<span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
4980
4847
|
<span class='kw'>end</span>
|
4981
4848
|
|
@@ -4988,7 +4855,7 @@
|
|
4988
4855
|
<span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
|
4989
4856
|
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>
|
4990
4857
|
|
4991
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
4858
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
4992
4859
|
<span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
4993
4860
|
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
4994
4861
|
<span class='kw'>else</span> <span class='comment'># Validation failed
|
@@ -5001,10 +4868,9 @@
|
|
5001
4868
|
|
5002
4869
|
<span class='comment'># Executes the action associated to this option.
|
5003
4870
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
|
5004
|
-
<span class='kw'>
|
5005
|
-
|
5006
|
-
|
5007
|
-
<span class='kw'>end</span>
|
4871
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
4872
|
+
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
4873
|
+
<span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
|
5008
4874
|
<span class='kw'>end</span>
|
5009
4875
|
|
5010
4876
|
<span class='comment'># Checks if this option requires an argument.
|
@@ -5024,7 +4890,7 @@
|
|
5024
4890
|
<span class='comment'># Check if this command has a help.
|
5025
4891
|
</span> <span class='comment'>#
|
5026
4892
|
</span> <span class='comment'># @return [Boolean] `true` if this command has a help, `false` otherwise.
|
5027
|
-
</span> <span class='kw'>def</span> <span class='id identifier
|
4893
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
|
5028
4894
|
<span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
5029
4895
|
<span class='kw'>end</span>
|
5030
4896
|
|
@@ -5036,57 +4902,48 @@
|
|
5036
4902
|
<span class='kw'>end</span>
|
5037
4903
|
|
5038
4904
|
<span class='id identifier rubyid_private'>private</span>
|
5039
|
-
<span class='comment'># Setups the forms of the this option.
|
5040
|
-
</span> <span class='comment'>#
|
5041
|
-
</span> <span class='comment'># @param forms [Array] An array of short and long forms for this option. Missing forms will be inferred by the name.
|
5042
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
|
5043
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>></span> <span class='int'>0</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
5044
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
|
5045
|
-
<span class='kw'>end</span>
|
5046
4905
|
|
5047
|
-
|
5048
|
-
</span>
|
5049
|
-
</span>
|
5050
|
-
|
5051
|
-
|
5052
|
-
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
5053
|
-
<span class='kw'>end</span>
|
5054
|
-
<span class='kw'>end</span>
|
4906
|
+
<span class='comment'># :nodoc:
|
4907
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
|
4908
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
4909
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
|
4910
|
+
<span class='kw'>end</span>
|
5055
4911
|
|
5056
|
-
|
5057
|
-
</span>
|
5058
|
-
</span>
|
5059
|
-
</span>
|
5060
|
-
<span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
|
4912
|
+
<span class='comment'># :nodoc:
|
4913
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
4914
|
+
<span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_option'>option</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
|
4915
|
+
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
5061
4916
|
<span class='kw'>end</span>
|
4917
|
+
<span class='kw'>end</span>
|
4918
|
+
|
4919
|
+
<span class='comment'># :nodoc:
|
4920
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
|
4921
|
+
<span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
|
4922
|
+
<span class='kw'>end</span>
|
5062
4923
|
|
5063
|
-
|
5064
|
-
</span>
|
5065
|
-
</span>
|
5066
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
|
5067
|
-
<span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>
|
4924
|
+
<span class='comment'># :nodoc:
|
4925
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
|
4926
|
+
<span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>
|
5068
4927
|
|
5069
|
-
|
5070
|
-
|
5071
|
-
|
5072
|
-
|
4928
|
+
<span class='id identifier rubyid_message'>message</span> <span class='op'>=</span>
|
4929
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_vs'>vs</span>
|
4930
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_regexp'>invalid_for_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rparen'>)</span>
|
4931
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_proc'>invalid_for_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='rparen'>)</span>
|
4932
|
+
<span class='kw'>else</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_value'>invalid_value</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_smart_join'>smart_join</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='comma'>,</span> <span class='label'>separator:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>, </span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>last_separator:</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_join_separator'>join_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_html_safe'>html_safe</span><span class='rparen'>)</span>
|
5073
4933
|
<span class='kw'>end</span>
|
5074
4934
|
|
5075
|
-
|
5076
|
-
|
4935
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>Error</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:validation_failed</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
|
4936
|
+
<span class='kw'>end</span>
|
5077
4937
|
|
5078
|
-
|
5079
|
-
</span>
|
5080
|
-
</span>
|
5081
|
-
</span>
|
5082
|
-
|
5083
|
-
|
5084
|
-
|
5085
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span>
|
5086
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Proc</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span>
|
5087
|
-
<span class='kw'>else</span> <span class='kw'>false</span>
|
5088
|
-
<span class='kw'>end</span>
|
4938
|
+
<span class='comment'># :nodoc:
|
4939
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>
|
4940
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_validator'>validator</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
4941
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Array</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>include?</span><span class='tstring_end'>"</span></span>
|
4942
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span>
|
4943
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Proc</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span>
|
4944
|
+
<span class='kw'>else</span> <span class='kw'>false</span>
|
5089
4945
|
<span class='kw'>end</span>
|
4946
|
+
<span class='kw'>end</span>
|
5090
4947
|
<span class='kw'>end</span></pre>
|
5091
4948
|
</td>
|
5092
4949
|
</tr>
|
@@ -5137,6 +4994,7 @@
|
|
5137
4994
|
<pre class="lines">
|
5138
4995
|
|
5139
4996
|
|
4997
|
+
41
|
5140
4998
|
42
|
5141
4999
|
43
|
5142
5000
|
44
|
@@ -5339,19 +5197,10 @@
|
|
5339
5197
|
241
|
5340
5198
|
242
|
5341
5199
|
243
|
5342
|
-
244
|
5343
|
-
245
|
5344
|
-
246
|
5345
|
-
247
|
5346
|
-
248
|
5347
|
-
249
|
5348
|
-
250
|
5349
|
-
251
|
5350
|
-
252
|
5351
|
-
253</pre>
|
5200
|
+
244</pre>
|
5352
5201
|
</td>
|
5353
5202
|
<td>
|
5354
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line
|
5203
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 41</span>
|
5355
5204
|
|
5356
5205
|
<span class='kw'>class</span> <span class='const'>Option</span>
|
5357
5206
|
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:name</span>
|
@@ -5385,7 +5234,7 @@
|
|
5385
5234
|
</span> <span class='comment'>#
|
5386
5235
|
</span> <span class='comment'># @param value [String] The short form of this option.
|
5387
5236
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_short='>short=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
5388
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>
|
5237
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
5389
5238
|
|
5390
5239
|
<span class='comment'># Clean value
|
5391
5240
|
</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}([a-z0-9])(.*)$</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
@@ -5397,7 +5246,7 @@
|
|
5397
5246
|
</span> <span class='comment'>#
|
5398
5247
|
</span> <span class='comment'># @param value [String] The short form of this option.
|
5399
5248
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_long='>long=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
5400
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>
|
5249
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
5401
5250
|
|
5402
5251
|
<span class='comment'># Clean value
|
5403
5252
|
</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}(.+)$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
@@ -5410,7 +5259,7 @@
|
|
5410
5259
|
</span> <span class='comment'># @param value [String] The validator of this option.
|
5411
5260
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_validator='>validator=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
5412
5261
|
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
|
5413
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='
|
5262
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Proc</span><span class='rparen'>)</span>
|
5414
5263
|
<span class='ivar'>@validator</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
5415
5264
|
<span class='kw'>end</span>
|
5416
5265
|
|
@@ -5437,22 +5286,24 @@
|
|
5437
5286
|
|
5438
5287
|
<span class='comment'># Returns the meta argument for this option.
|
5439
5288
|
</span> <span class='comment'>#
|
5440
|
-
</span> <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
|
5289
|
+
</span> <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
|
5290
|
+
</span> <span class='comment'># if this option doesn't require a meta argument.
|
5441
5291
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_meta'>meta</span>
|
5442
|
-
<span class='
|
5292
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
|
5293
|
+
<span class='ivar'>@meta</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='ivar'>@meta</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span>
|
5443
5294
|
<span class='kw'>end</span>
|
5444
5295
|
|
5445
5296
|
<span class='comment'># Get the current default value for this option.
|
5446
5297
|
</span> <span class='comment'>#
|
5447
5298
|
</span> <span class='comment'># @return [Object] The default value for this option.
|
5448
5299
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_default'>default</span>
|
5449
|
-
<span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>OPTION_TYPES</span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span>
|
5300
|
+
<span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>OPTION_TYPES</span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>false</span>
|
5450
5301
|
<span class='kw'>end</span>
|
5451
5302
|
|
5452
5303
|
<span class='comment'># Check if the current option has a default value.
|
5453
5304
|
</span> <span class='comment'>#
|
5454
5305
|
</span> <span class='comment'># @return [Boolean] If the current option has a default value.
|
5455
|
-
</span> <span class='kw'>def</span> <span class='id identifier
|
5306
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
|
5456
5307
|
<span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
5457
5308
|
<span class='kw'>end</span>
|
5458
5309
|
|
@@ -5465,7 +5316,7 @@
|
|
5465
5316
|
<span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
|
5466
5317
|
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>
|
5467
5318
|
|
5468
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
5319
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
5469
5320
|
<span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
5470
5321
|
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
5471
5322
|
<span class='kw'>else</span> <span class='comment'># Validation failed
|
@@ -5478,10 +5329,9 @@
|
|
5478
5329
|
|
5479
5330
|
<span class='comment'># Executes the action associated to this option.
|
5480
5331
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
|
5481
|
-
<span class='kw'>
|
5482
|
-
|
5483
|
-
|
5484
|
-
<span class='kw'>end</span>
|
5332
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
5333
|
+
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
5334
|
+
<span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
|
5485
5335
|
<span class='kw'>end</span>
|
5486
5336
|
|
5487
5337
|
<span class='comment'># Checks if this option requires an argument.
|
@@ -5501,7 +5351,7 @@
|
|
5501
5351
|
<span class='comment'># Check if this command has a help.
|
5502
5352
|
</span> <span class='comment'>#
|
5503
5353
|
</span> <span class='comment'># @return [Boolean] `true` if this command has a help, `false` otherwise.
|
5504
|
-
</span> <span class='kw'>def</span> <span class='id identifier
|
5354
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
|
5505
5355
|
<span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
5506
5356
|
<span class='kw'>end</span>
|
5507
5357
|
|
@@ -5513,57 +5363,48 @@
|
|
5513
5363
|
<span class='kw'>end</span>
|
5514
5364
|
|
5515
5365
|
<span class='id identifier rubyid_private'>private</span>
|
5516
|
-
<span class='comment'># Setups the forms of the this option.
|
5517
|
-
</span> <span class='comment'>#
|
5518
|
-
</span> <span class='comment'># @param forms [Array] An array of short and long forms for this option. Missing forms will be inferred by the name.
|
5519
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
|
5520
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>></span> <span class='int'>0</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
5521
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
|
5522
|
-
<span class='kw'>end</span>
|
5523
5366
|
|
5524
|
-
|
5525
|
-
</span>
|
5526
|
-
</span>
|
5527
|
-
|
5528
|
-
|
5529
|
-
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
5530
|
-
<span class='kw'>end</span>
|
5531
|
-
<span class='kw'>end</span>
|
5367
|
+
<span class='comment'># :nodoc:
|
5368
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
|
5369
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
5370
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
|
5371
|
+
<span class='kw'>end</span>
|
5532
5372
|
|
5533
|
-
|
5534
|
-
</span>
|
5535
|
-
</span>
|
5536
|
-
</span>
|
5537
|
-
<span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
|
5373
|
+
<span class='comment'># :nodoc:
|
5374
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
5375
|
+
<span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_option'>option</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
|
5376
|
+
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
5538
5377
|
<span class='kw'>end</span>
|
5378
|
+
<span class='kw'>end</span>
|
5379
|
+
|
5380
|
+
<span class='comment'># :nodoc:
|
5381
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
|
5382
|
+
<span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
|
5383
|
+
<span class='kw'>end</span>
|
5539
5384
|
|
5540
|
-
|
5541
|
-
</span>
|
5542
|
-
</span>
|
5543
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
|
5544
|
-
<span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>
|
5385
|
+
<span class='comment'># :nodoc:
|
5386
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
|
5387
|
+
<span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>
|
5545
5388
|
|
5546
|
-
|
5547
|
-
|
5548
|
-
|
5549
|
-
|
5389
|
+
<span class='id identifier rubyid_message'>message</span> <span class='op'>=</span>
|
5390
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_vs'>vs</span>
|
5391
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_regexp'>invalid_for_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rparen'>)</span>
|
5392
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_proc'>invalid_for_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='rparen'>)</span>
|
5393
|
+
<span class='kw'>else</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_value'>invalid_value</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_smart_join'>smart_join</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='comma'>,</span> <span class='label'>separator:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>, </span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>last_separator:</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_join_separator'>join_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_html_safe'>html_safe</span><span class='rparen'>)</span>
|
5550
5394
|
<span class='kw'>end</span>
|
5551
5395
|
|
5552
|
-
|
5553
|
-
|
5396
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>Error</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:validation_failed</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
|
5397
|
+
<span class='kw'>end</span>
|
5554
5398
|
|
5555
|
-
|
5556
|
-
</span>
|
5557
|
-
</span>
|
5558
|
-
</span>
|
5559
|
-
|
5560
|
-
|
5561
|
-
|
5562
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span>
|
5563
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Proc</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span>
|
5564
|
-
<span class='kw'>else</span> <span class='kw'>false</span>
|
5565
|
-
<span class='kw'>end</span>
|
5399
|
+
<span class='comment'># :nodoc:
|
5400
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>
|
5401
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_validator'>validator</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
5402
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Array</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>include?</span><span class='tstring_end'>"</span></span>
|
5403
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span>
|
5404
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Proc</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span>
|
5405
|
+
<span class='kw'>else</span> <span class='kw'>false</span>
|
5566
5406
|
<span class='kw'>end</span>
|
5407
|
+
<span class='kw'>end</span>
|
5567
5408
|
<span class='kw'>end</span></pre>
|
5568
5409
|
</td>
|
5569
5410
|
</tr>
|
@@ -5614,6 +5455,7 @@
|
|
5614
5455
|
<pre class="lines">
|
5615
5456
|
|
5616
5457
|
|
5458
|
+
41
|
5617
5459
|
42
|
5618
5460
|
43
|
5619
5461
|
44
|
@@ -5816,19 +5658,10 @@
|
|
5816
5658
|
241
|
5817
5659
|
242
|
5818
5660
|
243
|
5819
|
-
244
|
5820
|
-
245
|
5821
|
-
246
|
5822
|
-
247
|
5823
|
-
248
|
5824
|
-
249
|
5825
|
-
250
|
5826
|
-
251
|
5827
|
-
252
|
5828
|
-
253</pre>
|
5661
|
+
244</pre>
|
5829
5662
|
</td>
|
5830
5663
|
<td>
|
5831
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line
|
5664
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 41</span>
|
5832
5665
|
|
5833
5666
|
<span class='kw'>class</span> <span class='const'>Option</span>
|
5834
5667
|
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:name</span>
|
@@ -5862,7 +5695,7 @@
|
|
5862
5695
|
</span> <span class='comment'>#
|
5863
5696
|
</span> <span class='comment'># @param value [String] The short form of this option.
|
5864
5697
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_short='>short=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
5865
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>
|
5698
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
5866
5699
|
|
5867
5700
|
<span class='comment'># Clean value
|
5868
5701
|
</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}([a-z0-9])(.*)$</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
@@ -5874,7 +5707,7 @@
|
|
5874
5707
|
</span> <span class='comment'>#
|
5875
5708
|
</span> <span class='comment'># @param value [String] The short form of this option.
|
5876
5709
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_long='>long=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
5877
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>
|
5710
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
5878
5711
|
|
5879
5712
|
<span class='comment'># Clean value
|
5880
5713
|
</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}(.+)$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
@@ -5887,7 +5720,7 @@
|
|
5887
5720
|
</span> <span class='comment'># @param value [String] The validator of this option.
|
5888
5721
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_validator='>validator=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
5889
5722
|
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
|
5890
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='
|
5723
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Proc</span><span class='rparen'>)</span>
|
5891
5724
|
<span class='ivar'>@validator</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
5892
5725
|
<span class='kw'>end</span>
|
5893
5726
|
|
@@ -5914,22 +5747,24 @@
|
|
5914
5747
|
|
5915
5748
|
<span class='comment'># Returns the meta argument for this option.
|
5916
5749
|
</span> <span class='comment'>#
|
5917
|
-
</span> <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
|
5750
|
+
</span> <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
|
5751
|
+
</span> <span class='comment'># if this option doesn't require a meta argument.
|
5918
5752
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_meta'>meta</span>
|
5919
|
-
<span class='
|
5753
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
|
5754
|
+
<span class='ivar'>@meta</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='ivar'>@meta</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span>
|
5920
5755
|
<span class='kw'>end</span>
|
5921
5756
|
|
5922
5757
|
<span class='comment'># Get the current default value for this option.
|
5923
5758
|
</span> <span class='comment'>#
|
5924
5759
|
</span> <span class='comment'># @return [Object] The default value for this option.
|
5925
5760
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_default'>default</span>
|
5926
|
-
<span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>OPTION_TYPES</span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span>
|
5761
|
+
<span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>OPTION_TYPES</span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>false</span>
|
5927
5762
|
<span class='kw'>end</span>
|
5928
5763
|
|
5929
5764
|
<span class='comment'># Check if the current option has a default value.
|
5930
5765
|
</span> <span class='comment'>#
|
5931
5766
|
</span> <span class='comment'># @return [Boolean] If the current option has a default value.
|
5932
|
-
</span> <span class='kw'>def</span> <span class='id identifier
|
5767
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
|
5933
5768
|
<span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
5934
5769
|
<span class='kw'>end</span>
|
5935
5770
|
|
@@ -5942,7 +5777,7 @@
|
|
5942
5777
|
<span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
|
5943
5778
|
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>
|
5944
5779
|
|
5945
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
5780
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
5946
5781
|
<span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
5947
5782
|
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
5948
5783
|
<span class='kw'>else</span> <span class='comment'># Validation failed
|
@@ -5955,10 +5790,9 @@
|
|
5955
5790
|
|
5956
5791
|
<span class='comment'># Executes the action associated to this option.
|
5957
5792
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
|
5958
|
-
<span class='kw'>
|
5959
|
-
|
5960
|
-
|
5961
|
-
<span class='kw'>end</span>
|
5793
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
5794
|
+
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
5795
|
+
<span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
|
5962
5796
|
<span class='kw'>end</span>
|
5963
5797
|
|
5964
5798
|
<span class='comment'># Checks if this option requires an argument.
|
@@ -5978,7 +5812,7 @@
|
|
5978
5812
|
<span class='comment'># Check if this command has a help.
|
5979
5813
|
</span> <span class='comment'>#
|
5980
5814
|
</span> <span class='comment'># @return [Boolean] `true` if this command has a help, `false` otherwise.
|
5981
|
-
</span> <span class='kw'>def</span> <span class='id identifier
|
5815
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
|
5982
5816
|
<span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
5983
5817
|
<span class='kw'>end</span>
|
5984
5818
|
|
@@ -5990,57 +5824,48 @@
|
|
5990
5824
|
<span class='kw'>end</span>
|
5991
5825
|
|
5992
5826
|
<span class='id identifier rubyid_private'>private</span>
|
5993
|
-
<span class='comment'># Setups the forms of the this option.
|
5994
|
-
</span> <span class='comment'>#
|
5995
|
-
</span> <span class='comment'># @param forms [Array] An array of short and long forms for this option. Missing forms will be inferred by the name.
|
5996
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
|
5997
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>></span> <span class='int'>0</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
5998
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
|
5999
|
-
<span class='kw'>end</span>
|
6000
5827
|
|
6001
|
-
|
6002
|
-
</span>
|
6003
|
-
</span>
|
6004
|
-
|
6005
|
-
|
6006
|
-
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
6007
|
-
<span class='kw'>end</span>
|
6008
|
-
<span class='kw'>end</span>
|
5828
|
+
<span class='comment'># :nodoc:
|
5829
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
|
5830
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
5831
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
|
5832
|
+
<span class='kw'>end</span>
|
6009
5833
|
|
6010
|
-
|
6011
|
-
</span>
|
6012
|
-
</span>
|
6013
|
-
</span>
|
6014
|
-
<span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
|
5834
|
+
<span class='comment'># :nodoc:
|
5835
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
5836
|
+
<span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_option'>option</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
|
5837
|
+
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
6015
5838
|
<span class='kw'>end</span>
|
5839
|
+
<span class='kw'>end</span>
|
6016
5840
|
|
6017
|
-
|
6018
|
-
</span>
|
6019
|
-
</span>
|
6020
|
-
|
6021
|
-
|
5841
|
+
<span class='comment'># :nodoc:
|
5842
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
|
5843
|
+
<span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
|
5844
|
+
<span class='kw'>end</span>
|
5845
|
+
|
5846
|
+
<span class='comment'># :nodoc:
|
5847
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
|
5848
|
+
<span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>
|
6022
5849
|
|
6023
|
-
|
6024
|
-
|
6025
|
-
|
6026
|
-
|
5850
|
+
<span class='id identifier rubyid_message'>message</span> <span class='op'>=</span>
|
5851
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_vs'>vs</span>
|
5852
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_regexp'>invalid_for_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rparen'>)</span>
|
5853
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_proc'>invalid_for_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='rparen'>)</span>
|
5854
|
+
<span class='kw'>else</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_value'>invalid_value</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_smart_join'>smart_join</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='comma'>,</span> <span class='label'>separator:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>, </span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>last_separator:</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_join_separator'>join_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_html_safe'>html_safe</span><span class='rparen'>)</span>
|
6027
5855
|
<span class='kw'>end</span>
|
6028
5856
|
|
6029
|
-
|
6030
|
-
|
5857
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>Error</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:validation_failed</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
|
5858
|
+
<span class='kw'>end</span>
|
6031
5859
|
|
6032
|
-
|
6033
|
-
</span>
|
6034
|
-
</span>
|
6035
|
-
</span>
|
6036
|
-
|
6037
|
-
|
6038
|
-
|
6039
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span>
|
6040
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Proc</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span>
|
6041
|
-
<span class='kw'>else</span> <span class='kw'>false</span>
|
6042
|
-
<span class='kw'>end</span>
|
5860
|
+
<span class='comment'># :nodoc:
|
5861
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>
|
5862
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_validator'>validator</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
5863
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Array</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>include?</span><span class='tstring_end'>"</span></span>
|
5864
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span>
|
5865
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Proc</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span>
|
5866
|
+
<span class='kw'>else</span> <span class='kw'>false</span>
|
6043
5867
|
<span class='kw'>end</span>
|
5868
|
+
<span class='kw'>end</span>
|
6044
5869
|
<span class='kw'>end</span></pre>
|
6045
5870
|
</td>
|
6046
5871
|
</tr>
|
@@ -6091,6 +5916,7 @@
|
|
6091
5916
|
<pre class="lines">
|
6092
5917
|
|
6093
5918
|
|
5919
|
+
41
|
6094
5920
|
42
|
6095
5921
|
43
|
6096
5922
|
44
|
@@ -6293,19 +6119,10 @@
|
|
6293
6119
|
241
|
6294
6120
|
242
|
6295
6121
|
243
|
6296
|
-
244
|
6297
|
-
245
|
6298
|
-
246
|
6299
|
-
247
|
6300
|
-
248
|
6301
|
-
249
|
6302
|
-
250
|
6303
|
-
251
|
6304
|
-
252
|
6305
|
-
253</pre>
|
6122
|
+
244</pre>
|
6306
6123
|
</td>
|
6307
6124
|
<td>
|
6308
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line
|
6125
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 41</span>
|
6309
6126
|
|
6310
6127
|
<span class='kw'>class</span> <span class='const'>Option</span>
|
6311
6128
|
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:name</span>
|
@@ -6339,7 +6156,7 @@
|
|
6339
6156
|
</span> <span class='comment'>#
|
6340
6157
|
</span> <span class='comment'># @param value [String] The short form of this option.
|
6341
6158
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_short='>short=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
6342
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>
|
6159
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
6343
6160
|
|
6344
6161
|
<span class='comment'># Clean value
|
6345
6162
|
</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}([a-z0-9])(.*)$</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
@@ -6351,7 +6168,7 @@
|
|
6351
6168
|
</span> <span class='comment'>#
|
6352
6169
|
</span> <span class='comment'># @param value [String] The short form of this option.
|
6353
6170
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_long='>long=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
6354
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>
|
6171
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
6355
6172
|
|
6356
6173
|
<span class='comment'># Clean value
|
6357
6174
|
</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}(.+)$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
@@ -6364,7 +6181,7 @@
|
|
6364
6181
|
</span> <span class='comment'># @param value [String] The validator of this option.
|
6365
6182
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_validator='>validator=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
6366
6183
|
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
|
6367
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='
|
6184
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Proc</span><span class='rparen'>)</span>
|
6368
6185
|
<span class='ivar'>@validator</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
6369
6186
|
<span class='kw'>end</span>
|
6370
6187
|
|
@@ -6391,22 +6208,24 @@
|
|
6391
6208
|
|
6392
6209
|
<span class='comment'># Returns the meta argument for this option.
|
6393
6210
|
</span> <span class='comment'>#
|
6394
|
-
</span> <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
|
6211
|
+
</span> <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
|
6212
|
+
</span> <span class='comment'># if this option doesn't require a meta argument.
|
6395
6213
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_meta'>meta</span>
|
6396
|
-
<span class='
|
6214
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
|
6215
|
+
<span class='ivar'>@meta</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='ivar'>@meta</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span>
|
6397
6216
|
<span class='kw'>end</span>
|
6398
6217
|
|
6399
6218
|
<span class='comment'># Get the current default value for this option.
|
6400
6219
|
</span> <span class='comment'>#
|
6401
6220
|
</span> <span class='comment'># @return [Object] The default value for this option.
|
6402
6221
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_default'>default</span>
|
6403
|
-
<span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>OPTION_TYPES</span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span>
|
6222
|
+
<span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>OPTION_TYPES</span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>false</span>
|
6404
6223
|
<span class='kw'>end</span>
|
6405
6224
|
|
6406
6225
|
<span class='comment'># Check if the current option has a default value.
|
6407
6226
|
</span> <span class='comment'>#
|
6408
6227
|
</span> <span class='comment'># @return [Boolean] If the current option has a default value.
|
6409
|
-
</span> <span class='kw'>def</span> <span class='id identifier
|
6228
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
|
6410
6229
|
<span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
6411
6230
|
<span class='kw'>end</span>
|
6412
6231
|
|
@@ -6419,7 +6238,7 @@
|
|
6419
6238
|
<span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
|
6420
6239
|
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>
|
6421
6240
|
|
6422
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
6241
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
6423
6242
|
<span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
6424
6243
|
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
6425
6244
|
<span class='kw'>else</span> <span class='comment'># Validation failed
|
@@ -6432,10 +6251,9 @@
|
|
6432
6251
|
|
6433
6252
|
<span class='comment'># Executes the action associated to this option.
|
6434
6253
|
</span> <span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
|
6435
|
-
<span class='kw'>
|
6436
|
-
|
6437
|
-
|
6438
|
-
<span class='kw'>end</span>
|
6254
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
6255
|
+
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
6256
|
+
<span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
|
6439
6257
|
<span class='kw'>end</span>
|
6440
6258
|
|
6441
6259
|
<span class='comment'># Checks if this option requires an argument.
|
@@ -6455,7 +6273,7 @@
|
|
6455
6273
|
<span class='comment'># Check if this command has a help.
|
6456
6274
|
</span> <span class='comment'>#
|
6457
6275
|
</span> <span class='comment'># @return [Boolean] `true` if this command has a help, `false` otherwise.
|
6458
|
-
</span> <span class='kw'>def</span> <span class='id identifier
|
6276
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
|
6459
6277
|
<span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
6460
6278
|
<span class='kw'>end</span>
|
6461
6279
|
|
@@ -6467,57 +6285,48 @@
|
|
6467
6285
|
<span class='kw'>end</span>
|
6468
6286
|
|
6469
6287
|
<span class='id identifier rubyid_private'>private</span>
|
6470
|
-
<span class='comment'># Setups the forms of the this option.
|
6471
|
-
</span> <span class='comment'>#
|
6472
|
-
</span> <span class='comment'># @param forms [Array] An array of short and long forms for this option. Missing forms will be inferred by the name.
|
6473
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
|
6474
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>></span> <span class='int'>0</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
6475
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
|
6476
|
-
<span class='kw'>end</span>
|
6477
6288
|
|
6478
|
-
|
6479
|
-
</span>
|
6480
|
-
</span>
|
6481
|
-
|
6482
|
-
|
6483
|
-
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
6484
|
-
<span class='kw'>end</span>
|
6485
|
-
<span class='kw'>end</span>
|
6289
|
+
<span class='comment'># :nodoc:
|
6290
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
|
6291
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
6292
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
|
6293
|
+
<span class='kw'>end</span>
|
6486
6294
|
|
6487
|
-
|
6488
|
-
</span>
|
6489
|
-
</span>
|
6490
|
-
</span>
|
6491
|
-
<span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
|
6295
|
+
<span class='comment'># :nodoc:
|
6296
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
6297
|
+
<span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_option'>option</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
|
6298
|
+
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
6492
6299
|
<span class='kw'>end</span>
|
6300
|
+
<span class='kw'>end</span>
|
6301
|
+
|
6302
|
+
<span class='comment'># :nodoc:
|
6303
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
|
6304
|
+
<span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
|
6305
|
+
<span class='kw'>end</span>
|
6493
6306
|
|
6494
|
-
|
6495
|
-
</span>
|
6496
|
-
</span>
|
6497
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
|
6498
|
-
<span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>
|
6307
|
+
<span class='comment'># :nodoc:
|
6308
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
|
6309
|
+
<span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>
|
6499
6310
|
|
6500
|
-
|
6501
|
-
|
6502
|
-
|
6503
|
-
|
6311
|
+
<span class='id identifier rubyid_message'>message</span> <span class='op'>=</span>
|
6312
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_vs'>vs</span>
|
6313
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_regexp'>invalid_for_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rparen'>)</span>
|
6314
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_proc'>invalid_for_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='rparen'>)</span>
|
6315
|
+
<span class='kw'>else</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_value'>invalid_value</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_smart_join'>smart_join</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='comma'>,</span> <span class='label'>separator:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>, </span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>last_separator:</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_join_separator'>join_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_html_safe'>html_safe</span><span class='rparen'>)</span>
|
6504
6316
|
<span class='kw'>end</span>
|
6505
6317
|
|
6506
|
-
|
6507
|
-
|
6318
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>Error</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:validation_failed</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
|
6319
|
+
<span class='kw'>end</span>
|
6508
6320
|
|
6509
|
-
|
6510
|
-
</span>
|
6511
|
-
</span>
|
6512
|
-
</span>
|
6513
|
-
|
6514
|
-
|
6515
|
-
|
6516
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span>
|
6517
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Proc</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span>
|
6518
|
-
<span class='kw'>else</span> <span class='kw'>false</span>
|
6519
|
-
<span class='kw'>end</span>
|
6321
|
+
<span class='comment'># :nodoc:
|
6322
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>
|
6323
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_validator'>validator</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
6324
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Array</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>include?</span><span class='tstring_end'>"</span></span>
|
6325
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>match</span><span class='tstring_end'>"</span></span>
|
6326
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Proc</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>call</span><span class='tstring_end'>"</span></span>
|
6327
|
+
<span class='kw'>else</span> <span class='kw'>false</span>
|
6520
6328
|
<span class='kw'>end</span>
|
6329
|
+
<span class='kw'>end</span>
|
6521
6330
|
<span class='kw'>end</span></pre>
|
6522
6331
|
</td>
|
6523
6332
|
</tr>
|
@@ -6573,12 +6382,12 @@
|
|
6573
6382
|
<pre class="lines">
|
6574
6383
|
|
6575
6384
|
|
6385
|
+
112
|
6576
6386
|
113
|
6577
|
-
114
|
6578
|
-
115</pre>
|
6387
|
+
114</pre>
|
6579
6388
|
</td>
|
6580
6389
|
<td>
|
6581
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line
|
6390
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 112</span>
|
6582
6391
|
|
6583
6392
|
<span class='kw'>def</span> <span class='id identifier rubyid_complete_long'>complete_long</span>
|
6584
6393
|
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>--</span><span class='embexpr_beg'>#{</span><span class='ivar'>@long</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
@@ -6630,12 +6439,12 @@
|
|
6630
6439
|
<pre class="lines">
|
6631
6440
|
|
6632
6441
|
|
6442
|
+
105
|
6633
6443
|
106
|
6634
|
-
107
|
6635
|
-
108</pre>
|
6444
|
+
107</pre>
|
6636
6445
|
</td>
|
6637
6446
|
<td>
|
6638
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line
|
6447
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 105</span>
|
6639
6448
|
|
6640
6449
|
<span class='kw'>def</span> <span class='id identifier rubyid_complete_short'>complete_short</span>
|
6641
6450
|
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>-</span><span class='embexpr_beg'>#{</span><span class='ivar'>@short</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
@@ -6646,9 +6455,9 @@
|
|
6646
6455
|
</div>
|
6647
6456
|
|
6648
6457
|
<div class="method_details ">
|
6649
|
-
<h3 class="signature " id="
|
6458
|
+
<h3 class="signature " id="default?-instance_method">
|
6650
6459
|
|
6651
|
-
- (<tt>
|
6460
|
+
- (<tt>Boolean</tt>) <strong>default?</strong>
|
6652
6461
|
|
6653
6462
|
|
6654
6463
|
|
@@ -6656,13 +6465,30 @@
|
|
6656
6465
|
|
6657
6466
|
</h3><div class="docstring">
|
6658
6467
|
<div class="discussion">
|
6659
|
-
<p>
|
6468
|
+
<p>Check if the current option has a default value.</p>
|
6660
6469
|
|
6661
6470
|
|
6662
6471
|
</div>
|
6663
6472
|
</div>
|
6664
6473
|
<div class="tags">
|
6665
6474
|
|
6475
|
+
<p class="tag_title">Returns:</p>
|
6476
|
+
<ul class="return">
|
6477
|
+
|
6478
|
+
<li>
|
6479
|
+
|
6480
|
+
|
6481
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
6482
|
+
|
6483
|
+
|
6484
|
+
|
6485
|
+
—
|
6486
|
+
<div class='inline'><p>If the current option has a default value.</p>
|
6487
|
+
</div>
|
6488
|
+
|
6489
|
+
</li>
|
6490
|
+
|
6491
|
+
</ul>
|
6666
6492
|
|
6667
6493
|
</div><table class="source_code">
|
6668
6494
|
<tr>
|
@@ -6670,21 +6496,15 @@
|
|
6670
6496
|
<pre class="lines">
|
6671
6497
|
|
6672
6498
|
|
6673
|
-
|
6674
|
-
|
6675
|
-
|
6676
|
-
169
|
6677
|
-
170
|
6678
|
-
171</pre>
|
6499
|
+
142
|
6500
|
+
143
|
6501
|
+
144</pre>
|
6679
6502
|
</td>
|
6680
6503
|
<td>
|
6681
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line
|
6504
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 142</span>
|
6682
6505
|
|
6683
|
-
<span class='kw'>def</span> <span class='id identifier
|
6684
|
-
<span class='
|
6685
|
-
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
6686
|
-
<span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
|
6687
|
-
<span class='kw'>end</span>
|
6506
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
|
6507
|
+
<span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
6688
6508
|
<span class='kw'>end</span></pre>
|
6689
6509
|
</td>
|
6690
6510
|
</tr>
|
@@ -6692,9 +6512,9 @@
|
|
6692
6512
|
</div>
|
6693
6513
|
|
6694
6514
|
<div class="method_details ">
|
6695
|
-
<h3 class="signature " id="
|
6515
|
+
<h3 class="signature " id="execute_action-instance_method">
|
6696
6516
|
|
6697
|
-
- (<tt>
|
6517
|
+
- (<tt>Object</tt>) <strong>execute_action</strong>
|
6698
6518
|
|
6699
6519
|
|
6700
6520
|
|
@@ -6702,30 +6522,13 @@
|
|
6702
6522
|
|
6703
6523
|
</h3><div class="docstring">
|
6704
6524
|
<div class="discussion">
|
6705
|
-
<p>
|
6525
|
+
<p>Executes the action associated to this option.</p>
|
6706
6526
|
|
6707
6527
|
|
6708
6528
|
</div>
|
6709
6529
|
</div>
|
6710
6530
|
<div class="tags">
|
6711
6531
|
|
6712
|
-
<p class="tag_title">Returns:</p>
|
6713
|
-
<ul class="return">
|
6714
|
-
|
6715
|
-
<li>
|
6716
|
-
|
6717
|
-
|
6718
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
6719
|
-
|
6720
|
-
|
6721
|
-
|
6722
|
-
—
|
6723
|
-
<div class='inline'><p>If the current option has a default value.</p>
|
6724
|
-
</div>
|
6725
|
-
|
6726
|
-
</li>
|
6727
|
-
|
6728
|
-
</ul>
|
6729
6532
|
|
6730
6533
|
</div><table class="source_code">
|
6731
6534
|
<tr>
|
@@ -6733,15 +6536,19 @@
|
|
6733
6536
|
<pre class="lines">
|
6734
6537
|
|
6735
6538
|
|
6736
|
-
|
6737
|
-
|
6738
|
-
|
6539
|
+
167
|
6540
|
+
168
|
6541
|
+
169
|
6542
|
+
170
|
6543
|
+
171</pre>
|
6739
6544
|
</td>
|
6740
6545
|
<td>
|
6741
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line
|
6546
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 167</span>
|
6742
6547
|
|
6743
|
-
<span class='kw'>def</span> <span class='id identifier
|
6744
|
-
<span class='
|
6548
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
|
6549
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
6550
|
+
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
6551
|
+
<span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
|
6745
6552
|
<span class='kw'>end</span></pre>
|
6746
6553
|
</td>
|
6747
6554
|
</tr>
|
@@ -6749,9 +6556,9 @@
|
|
6749
6556
|
</div>
|
6750
6557
|
|
6751
6558
|
<div class="method_details ">
|
6752
|
-
<h3 class="signature " id="
|
6559
|
+
<h3 class="signature " id="help?-instance_method">
|
6753
6560
|
|
6754
|
-
- (<tt>Boolean</tt>) <strong>
|
6561
|
+
- (<tt>Boolean</tt>) <strong>help?</strong>
|
6755
6562
|
|
6756
6563
|
|
6757
6564
|
|
@@ -6797,7 +6604,7 @@
|
|
6797
6604
|
<td>
|
6798
6605
|
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 190</span>
|
6799
6606
|
|
6800
|
-
<span class='kw'>def</span> <span class='id identifier
|
6607
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
|
6801
6608
|
<span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
6802
6609
|
<span class='kw'>end</span></pre>
|
6803
6610
|
</td>
|
@@ -6847,12 +6654,12 @@
|
|
6847
6654
|
<pre class="lines">
|
6848
6655
|
|
6849
6656
|
|
6657
|
+
119
|
6850
6658
|
120
|
6851
|
-
121
|
6852
|
-
122</pre>
|
6659
|
+
121</pre>
|
6853
6660
|
</td>
|
6854
6661
|
<td>
|
6855
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line
|
6662
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 119</span>
|
6856
6663
|
|
6857
6664
|
<span class='kw'>def</span> <span class='id identifier rubyid_label'>label</span>
|
6858
6665
|
<span class='lbracket'>[</span><span class='id identifier rubyid_complete_short'>complete_short</span><span class='comma'>,</span> <span class='id identifier rubyid_complete_long'>complete_long</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>/</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
@@ -7054,7 +6861,6 @@
|
|
7054
6861
|
<pre class="lines">
|
7055
6862
|
|
7056
6863
|
|
7057
|
-
150
|
7058
6864
|
151
|
7059
6865
|
152
|
7060
6866
|
153
|
@@ -7067,16 +6873,17 @@
|
|
7067
6873
|
160
|
7068
6874
|
161
|
7069
6875
|
162
|
7070
|
-
163
|
6876
|
+
163
|
6877
|
+
164</pre>
|
7071
6878
|
</td>
|
7072
6879
|
<td>
|
7073
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line
|
6880
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 151</span>
|
7074
6881
|
|
7075
6882
|
<span class='kw'>def</span> <span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_raise_error'>raise_error</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
|
7076
6883
|
<span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
|
7077
6884
|
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>
|
7078
6885
|
|
7079
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
6886
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
|
7080
6887
|
<span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
7081
6888
|
<span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
|
7082
6889
|
<span class='kw'>else</span> <span class='comment'># Validation failed
|
@@ -7096,9 +6903,9 @@
|
|
7096
6903
|
</div>
|
7097
6904
|
|
7098
6905
|
<div id="footer">
|
7099
|
-
Generated on
|
6906
|
+
Generated on Tue Mar 29 20:43:17 2016 by
|
7100
6907
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
7101
|
-
0.8.7.
|
6908
|
+
0.8.7.6 (ruby-2.3.0).
|
7102
6909
|
</div>
|
7103
6910
|
|
7104
6911
|
</body>
|