blackbox 4.0.3 → 4.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +21 -0
- data/.ruby-version +1 -1
- data/Gemfile +1 -0
- data/Guardfile +1 -0
- data/Rakefile +1 -0
- data/blackbox.gemspec +11 -11
- data/coverage/.last_run.json +1 -1
- data/coverage/.resultset.json +15 -12
- data/coverage/index.html +578 -554
- data/lib/blackbox.rb +1 -0
- data/lib/blackbox/crypto.rb +3 -4
- data/lib/blackbox/gem.rb +2 -1
- data/lib/blackbox/hash.rb +1 -0
- data/lib/blackbox/number.rb +8 -7
- data/lib/blackbox/string.rb +1 -0
- data/lib/blackbox/unix.rb +5 -5
- data/lib/blackbox/version.rb +2 -1
- data/spec/blackbox_spec.rb +1 -0
- data/spec/crypto_spec.rb +14 -13
- data/spec/gem_spec.rb +1 -1
- data/spec/hash_spec.rb +1 -0
- data/spec/number_spec.rb +1 -0
- data/spec/spec_helper.rb +2 -1
- data/spec/string_spec.rb +1 -0
- data/spec/unix_spec.rb +1 -0
- metadata +25 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a75dc7b8e492b44ce83849329fbecc8597a8cc49864518f0fbf171e18beddf99
|
4
|
+
data.tar.gz: 5f9974e1a560d5da0530bfbd78d62c5bf174e4a142c08431c897f1d5dba75196
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ba852fa447008259d28621ce7335aa3b4b35e3258ec78946a80b6d4a3cbf20035ce5eb029a2db46946d9887b96a58ddb5a32b8ecaf339db65d8f3143d165b6b
|
7
|
+
data.tar.gz: 4db2790a85ab902c9a608b8bac2517012a9c0758bbc849c5e739e9abde153397405c518954d3edf0f6602b965d224c82230ab1431c6bb3ad756cacb4b0477e17
|
data/.rubocop.yml
CHANGED
@@ -23,3 +23,24 @@ Style/FormatString:
|
|
23
23
|
Performance/RedundantMerge:
|
24
24
|
Exclude:
|
25
25
|
- 'lib/blackbox/gem.rb'
|
26
|
+
|
27
|
+
Metrics/BlockLength:
|
28
|
+
Max: 420
|
29
|
+
|
30
|
+
Naming/UncommunicativeMethodParamName:
|
31
|
+
Exclude:
|
32
|
+
- lib/blackbox/gem.rb
|
33
|
+
- lib/blackbox/crypto.rb
|
34
|
+
|
35
|
+
Performance/Caller:
|
36
|
+
Exclude:
|
37
|
+
- lib/blackbox/gem.rb
|
38
|
+
|
39
|
+
Style/NumericPredicate:
|
40
|
+
Exclude:
|
41
|
+
- lib/blackbox/crypto.rb
|
42
|
+
- lib/blackbox/unix.rb
|
43
|
+
|
44
|
+
Style/CommentedKeyword:
|
45
|
+
Exclude:
|
46
|
+
- lib/blackbox/crypto.rb
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.5.1
|
data/Gemfile
CHANGED
data/Guardfile
CHANGED
data/Rakefile
CHANGED
data/blackbox.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
1
|
# frozen_string_literal: true
|
3
|
-
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
require 'blackbox/version'
|
6
6
|
|
@@ -20,21 +20,21 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.require_paths = ['lib']
|
21
21
|
gem.required_ruby_version = '>= 2.3.0'
|
22
22
|
|
23
|
-
gem.add_development_dependency 'rake'
|
24
|
-
gem.add_development_dependency 'rspec'
|
25
|
-
gem.add_development_dependency 'simplecov'
|
26
|
-
gem.add_development_dependency 'redcarpet'
|
27
|
-
gem.add_development_dependency 'yard'
|
28
23
|
gem.add_development_dependency 'bump'
|
24
|
+
gem.add_development_dependency 'fuubar'
|
29
25
|
gem.add_development_dependency 'guard'
|
30
26
|
gem.add_development_dependency 'guard-rspec'
|
31
|
-
gem.add_development_dependency '
|
32
|
-
gem.add_development_dependency '
|
27
|
+
gem.add_development_dependency 'rake'
|
28
|
+
gem.add_development_dependency 'redcarpet'
|
29
|
+
gem.add_development_dependency 'rspec'
|
33
30
|
gem.add_development_dependency 'rubocop'
|
31
|
+
gem.add_development_dependency 'simplecov'
|
32
|
+
gem.add_development_dependency 'timecop'
|
33
|
+
gem.add_development_dependency 'yard'
|
34
34
|
|
35
|
+
gem.add_dependency 'chronic_duration', '~> 0.10.6'
|
35
36
|
gem.add_dependency 'gem_update_checker', '~> 0.2.0'
|
36
37
|
gem.add_dependency 'lolcat', '~> 90.8.8'
|
37
|
-
gem.add_dependency 'rainbow', '~>
|
38
|
-
gem.add_dependency 'chronic_duration', '~> 0.10.6'
|
38
|
+
gem.add_dependency 'rainbow', '~> 3.0.0'
|
39
39
|
gem.add_dependency 'versionomy', '~> 0.5.0'
|
40
40
|
end
|
data/coverage/.last_run.json
CHANGED
data/coverage/.resultset.json
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
"RSpec": {
|
3
3
|
"coverage": {
|
4
4
|
"/Users/moe/code/busyloop/blackbox/lib/blackbox/crypto.rb": [
|
5
|
+
null,
|
5
6
|
null,
|
6
7
|
1,
|
7
8
|
1,
|
@@ -132,19 +133,18 @@
|
|
132
133
|
3,
|
133
134
|
3,
|
134
135
|
3,
|
135
|
-
|
136
|
+
2,
|
136
137
|
null,
|
137
138
|
null,
|
138
139
|
null,
|
139
140
|
null,
|
140
|
-
2,
|
141
|
-
null,
|
142
141
|
null,
|
143
142
|
null,
|
144
143
|
null,
|
145
144
|
null
|
146
145
|
],
|
147
146
|
"/Users/moe/code/busyloop/blackbox/lib/blackbox/gem.rb": [
|
147
|
+
null,
|
148
148
|
null,
|
149
149
|
1,
|
150
150
|
1,
|
@@ -229,9 +229,9 @@
|
|
229
229
|
null,
|
230
230
|
null,
|
231
231
|
6,
|
232
|
-
|
232
|
+
6,
|
233
233
|
null,
|
234
|
-
|
234
|
+
0,
|
235
235
|
null,
|
236
236
|
null,
|
237
237
|
6,
|
@@ -241,6 +241,7 @@
|
|
241
241
|
null
|
242
242
|
],
|
243
243
|
"/Users/moe/code/busyloop/blackbox/lib/blackbox/hash.rb": [
|
244
|
+
null,
|
244
245
|
null,
|
245
246
|
1,
|
246
247
|
null,
|
@@ -292,6 +293,7 @@
|
|
292
293
|
null
|
293
294
|
],
|
294
295
|
"/Users/moe/code/busyloop/blackbox/lib/blackbox/number.rb": [
|
296
|
+
null,
|
295
297
|
null,
|
296
298
|
1,
|
297
299
|
null,
|
@@ -371,7 +373,7 @@
|
|
371
373
|
null,
|
372
374
|
10,
|
373
375
|
null,
|
374
|
-
|
376
|
+
1,
|
375
377
|
1,
|
376
378
|
null,
|
377
379
|
null,
|
@@ -421,7 +423,7 @@
|
|
421
423
|
12,
|
422
424
|
null,
|
423
425
|
null,
|
424
|
-
|
426
|
+
1,
|
425
427
|
1,
|
426
428
|
null,
|
427
429
|
null,
|
@@ -466,7 +468,7 @@
|
|
466
468
|
16,
|
467
469
|
16,
|
468
470
|
16,
|
469
|
-
|
471
|
+
1,
|
470
472
|
1,
|
471
473
|
null,
|
472
474
|
null,
|
@@ -475,6 +477,7 @@
|
|
475
477
|
null
|
476
478
|
],
|
477
479
|
"/Users/moe/code/busyloop/blackbox/lib/blackbox/string.rb": [
|
480
|
+
null,
|
478
481
|
null,
|
479
482
|
1,
|
480
483
|
null,
|
@@ -495,7 +498,7 @@
|
|
495
498
|
],
|
496
499
|
"/Users/moe/code/busyloop/blackbox/lib/blackbox/unix.rb": [
|
497
500
|
null,
|
498
|
-
|
501
|
+
null,
|
499
502
|
1,
|
500
503
|
1,
|
501
504
|
1,
|
@@ -540,7 +543,7 @@
|
|
540
543
|
0,
|
541
544
|
0,
|
542
545
|
0,
|
543
|
-
|
546
|
+
0,
|
544
547
|
0,
|
545
548
|
0,
|
546
549
|
0,
|
@@ -560,7 +563,7 @@
|
|
560
563
|
0,
|
561
564
|
null,
|
562
565
|
null,
|
563
|
-
|
566
|
+
null,
|
564
567
|
null,
|
565
568
|
0,
|
566
569
|
0,
|
@@ -609,6 +612,6 @@
|
|
609
612
|
null
|
610
613
|
]
|
611
614
|
},
|
612
|
-
"timestamp":
|
615
|
+
"timestamp": 1534561738
|
613
616
|
}
|
614
617
|
}
|
data/coverage/index.html
CHANGED
@@ -3,38 +3,38 @@
|
|
3
3
|
<head>
|
4
4
|
<title>Code coverage for Blackbox</title>
|
5
5
|
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
6
|
-
<script src='./assets/0.10.
|
7
|
-
<link href='./assets/0.10.
|
8
|
-
<link rel="shortcut icon" type="image/png" href="./assets/0.10.
|
9
|
-
<link rel="icon" type="image/png" href="./assets/0.10.
|
6
|
+
<script src='./assets/0.10.2/application.js' type='text/javascript'></script>
|
7
|
+
<link href='./assets/0.10.2/application.css' media='screen, projection, print' rel='stylesheet' type='text/css'>
|
8
|
+
<link rel="shortcut icon" type="image/png" href="./assets/0.10.2/favicon_yellow.png" />
|
9
|
+
<link rel="icon" type="image/png" href="./assets/0.10.2/favicon.png" />
|
10
10
|
</head>
|
11
11
|
|
12
12
|
<body>
|
13
13
|
<div id="loading">
|
14
|
-
<img src="./assets/0.10.
|
14
|
+
<img src="./assets/0.10.2/loading.gif" alt="loading"/>
|
15
15
|
</div>
|
16
16
|
<div id="wrapper" style="display:none;">
|
17
|
-
<div class="timestamp">Generated <abbr class="timeago" title="
|
17
|
+
<div class="timestamp">Generated <abbr class="timeago" title="2018-08-18T05:08:58+02:00">2018-08-18T05:08:58+02:00</abbr></div>
|
18
18
|
<ul class="group_tabs"></ul>
|
19
19
|
|
20
20
|
<div id="content">
|
21
21
|
<div class="file_list_container" id="AllFiles">
|
22
22
|
<h2>
|
23
23
|
<span class="group_name">All Files</span>
|
24
|
-
(<span class="covered_percent"><span class="yellow">82.
|
24
|
+
(<span class="covered_percent"><span class="yellow">82.22%</span></span>
|
25
25
|
covered at
|
26
26
|
<span class="covered_strength">
|
27
27
|
<span class="green">
|
28
|
-
38.
|
28
|
+
38.26
|
29
29
|
</span>
|
30
30
|
</span> hits/line)
|
31
31
|
</h2>
|
32
32
|
<a name="AllFiles"></a>
|
33
33
|
<div>
|
34
34
|
<b>6</b> files in total.
|
35
|
-
<b>
|
35
|
+
<b>225</b> relevant lines.
|
36
36
|
<span class="green"><b>185</b> lines covered</span> and
|
37
|
-
<span class="red"><b>
|
37
|
+
<span class="red"><b>40</b> lines missed </span>
|
38
38
|
</div>
|
39
39
|
<table class="file_list">
|
40
40
|
<thead>
|
@@ -53,27 +53,27 @@
|
|
53
53
|
<tr>
|
54
54
|
<td class="strong"><a href="#f65d5c5fcad29642ef7df71c31f708bfebe1c731" class="src_link" title="lib/blackbox/crypto.rb">lib/blackbox/crypto.rb</a></td>
|
55
55
|
<td class="green strong">100.0 %</td>
|
56
|
-
<td>
|
57
|
-
<td>
|
58
|
-
<td>
|
56
|
+
<td>140</td>
|
57
|
+
<td>47</td>
|
58
|
+
<td>47</td>
|
59
59
|
<td>0</td>
|
60
|
-
<td>
|
60
|
+
<td>160.1</td>
|
61
61
|
</tr>
|
62
62
|
|
63
63
|
<tr>
|
64
64
|
<td class="strong"><a href="#192e300fd7769b750c82567439ee016f85516f3d" class="src_link" title="lib/blackbox/gem.rb">lib/blackbox/gem.rb</a></td>
|
65
|
-
<td class="green strong">
|
66
|
-
<td>
|
67
|
-
<td>34</td>
|
65
|
+
<td class="green strong">97.06 %</td>
|
66
|
+
<td>95</td>
|
68
67
|
<td>34</td>
|
69
|
-
<td>
|
68
|
+
<td>33</td>
|
69
|
+
<td>1</td>
|
70
70
|
<td>8.1</td>
|
71
71
|
</tr>
|
72
72
|
|
73
73
|
<tr>
|
74
74
|
<td class="strong"><a href="#636c073a27c86cd147d7b0f717311b3b9eded478" class="src_link" title="lib/blackbox/hash.rb">lib/blackbox/hash.rb</a></td>
|
75
75
|
<td class="green strong">100.0 %</td>
|
76
|
-
<td>
|
76
|
+
<td>50</td>
|
77
77
|
<td>13</td>
|
78
78
|
<td>13</td>
|
79
79
|
<td>0</td>
|
@@ -83,17 +83,17 @@
|
|
83
83
|
<tr>
|
84
84
|
<td class="strong"><a href="#09e4da465507022615e91e2292a827cde0e5535c" class="src_link" title="lib/blackbox/number.rb">lib/blackbox/number.rb</a></td>
|
85
85
|
<td class="green strong">100.0 %</td>
|
86
|
-
<td>
|
87
|
-
<td>
|
88
|
-
<td>
|
86
|
+
<td>182</td>
|
87
|
+
<td>55</td>
|
88
|
+
<td>55</td>
|
89
89
|
<td>0</td>
|
90
|
-
<td>9.
|
90
|
+
<td>9.0</td>
|
91
91
|
</tr>
|
92
92
|
|
93
93
|
<tr>
|
94
94
|
<td class="strong"><a href="#1503164dbfa2b2b494fd2100a9b38b04be306a6e" class="src_link" title="lib/blackbox/string.rb">lib/blackbox/string.rb</a></td>
|
95
95
|
<td class="green strong">100.0 %</td>
|
96
|
-
<td>
|
96
|
+
<td>18</td>
|
97
97
|
<td>5</td>
|
98
98
|
<td>5</td>
|
99
99
|
<td>0</td>
|
@@ -102,10 +102,10 @@
|
|
102
102
|
|
103
103
|
<tr>
|
104
104
|
<td class="strong"><a href="#ef107940f0bb318164d36d5de1cd48192edb65f2" class="src_link" title="lib/blackbox/unix.rb">lib/blackbox/unix.rb</a></td>
|
105
|
-
<td class="red strong">45.
|
105
|
+
<td class="red strong">45.07 %</td>
|
106
106
|
<td>113</td>
|
107
|
-
<td>
|
108
|
-
<td>
|
107
|
+
<td>71</td>
|
108
|
+
<td>32</td>
|
109
109
|
<td>39</td>
|
110
110
|
<td>1.5</td>
|
111
111
|
</tr>
|
@@ -119,8 +119,8 @@
|
|
119
119
|
</div>
|
120
120
|
|
121
121
|
<div id="footer">
|
122
|
-
Generated by <a href="http://github.com/colszowka/simplecov">simplecov</a> v0.
|
123
|
-
and simplecov-html v0.10.
|
122
|
+
Generated by <a href="http://github.com/colszowka/simplecov">simplecov</a> v0.16.1
|
123
|
+
and simplecov-html v0.10.2<br/>
|
124
124
|
using RSpec
|
125
125
|
</div>
|
126
126
|
|
@@ -131,8 +131,8 @@
|
|
131
131
|
<h3>lib/blackbox/crypto.rb</h3>
|
132
132
|
<h4><span class="green">100.0 %</span> covered</h4>
|
133
133
|
<div>
|
134
|
-
<b>
|
135
|
-
<span class="green"><b>
|
134
|
+
<b>47</b> relevant lines.
|
135
|
+
<span class="green"><b>47</b> lines covered</span> and
|
136
136
|
<span class="red"><b>0</b> lines missed.</span>
|
137
137
|
</div>
|
138
138
|
</div>
|
@@ -146,841 +146,835 @@
|
|
146
146
|
<code class="ruby"># frozen_string_literal: true</code>
|
147
147
|
</li>
|
148
148
|
|
149
|
-
<li class="
|
149
|
+
<li class="never" data-hits="" data-linenumber="2">
|
150
|
+
|
151
|
+
|
152
|
+
<code class="ruby"></code>
|
153
|
+
</li>
|
154
|
+
|
155
|
+
<li class="covered" data-hits="1" data-linenumber="3">
|
150
156
|
<span class="hits">1</span>
|
151
157
|
|
152
158
|
<code class="ruby">require 'openssl'</code>
|
153
159
|
</li>
|
154
160
|
|
155
|
-
<li class="covered" data-hits="1" data-linenumber="
|
161
|
+
<li class="covered" data-hits="1" data-linenumber="4">
|
156
162
|
<span class="hits">1</span>
|
157
163
|
|
158
164
|
<code class="ruby">require 'base64'</code>
|
159
165
|
</li>
|
160
166
|
|
161
|
-
<li class="covered" data-hits="1" data-linenumber="
|
167
|
+
<li class="covered" data-hits="1" data-linenumber="5">
|
162
168
|
<span class="hits">1</span>
|
163
169
|
|
164
170
|
<code class="ruby">require 'chronic_duration'</code>
|
165
171
|
</li>
|
166
172
|
|
167
|
-
<li class="never" data-hits="" data-linenumber="
|
173
|
+
<li class="never" data-hits="" data-linenumber="6">
|
168
174
|
|
169
175
|
|
170
176
|
<code class="ruby"></code>
|
171
177
|
</li>
|
172
178
|
|
173
|
-
<li class="covered" data-hits="1" data-linenumber="
|
179
|
+
<li class="covered" data-hits="1" data-linenumber="7">
|
174
180
|
<span class="hits">1</span>
|
175
181
|
|
176
182
|
<code class="ruby">module BB</code>
|
177
183
|
</li>
|
178
184
|
|
179
|
-
<li class="never" data-hits="" data-linenumber="
|
185
|
+
<li class="never" data-hits="" data-linenumber="8">
|
180
186
|
|
181
187
|
|
182
188
|
<code class="ruby"> # Crypto utilities.</code>
|
183
189
|
</li>
|
184
190
|
|
185
|
-
<li class="covered" data-hits="1" data-linenumber="
|
191
|
+
<li class="covered" data-hits="1" data-linenumber="9">
|
186
192
|
<span class="hits">1</span>
|
187
193
|
|
188
194
|
<code class="ruby"> module Crypto</code>
|
189
195
|
</li>
|
190
196
|
|
191
|
-
<li class="covered" data-hits="1" data-linenumber="
|
197
|
+
<li class="covered" data-hits="1" data-linenumber="10">
|
192
198
|
<span class="hits">1</span>
|
193
199
|
|
194
200
|
<code class="ruby"> class << self</code>
|
195
201
|
</li>
|
196
202
|
|
197
|
-
<li class="never" data-hits="" data-linenumber="
|
203
|
+
<li class="never" data-hits="" data-linenumber="11">
|
198
204
|
|
199
205
|
|
200
206
|
<code class="ruby"> # Encrypt a String.</code>
|
201
207
|
</li>
|
202
208
|
|
203
|
-
<li class="never" data-hits="" data-linenumber="
|
209
|
+
<li class="never" data-hits="" data-linenumber="12">
|
204
210
|
|
205
211
|
|
206
212
|
<code class="ruby"> #</code>
|
207
213
|
</li>
|
208
214
|
|
209
|
-
<li class="never" data-hits="" data-linenumber="
|
215
|
+
<li class="never" data-hits="" data-linenumber="13">
|
210
216
|
|
211
217
|
|
212
218
|
<code class="ruby"> # @param [String] plaintext Input String (plaintext)</code>
|
213
219
|
</li>
|
214
220
|
|
215
|
-
<li class="never" data-hits="" data-linenumber="
|
221
|
+
<li class="never" data-hits="" data-linenumber="14">
|
216
222
|
|
217
223
|
|
218
224
|
<code class="ruby"> # @param [String] key Encryption key</code>
|
219
225
|
</li>
|
220
226
|
|
221
|
-
<li class="never" data-hits="" data-linenumber="
|
227
|
+
<li class="never" data-hits="" data-linenumber="15">
|
222
228
|
|
223
229
|
|
224
230
|
<code class="ruby"> # @param [String] cipher_type OpenSSL cipher</code>
|
225
231
|
</li>
|
226
232
|
|
227
|
-
<li class="never" data-hits="" data-linenumber="
|
233
|
+
<li class="never" data-hits="" data-linenumber="16">
|
228
234
|
|
229
235
|
|
230
236
|
<code class="ruby"> # @param [String] iv Initialization vector</code>
|
231
237
|
</li>
|
232
238
|
|
233
|
-
<li class="never" data-hits="" data-linenumber="
|
239
|
+
<li class="never" data-hits="" data-linenumber="17">
|
234
240
|
|
235
241
|
|
236
242
|
<code class="ruby"> # @return [String] When iv == nil: iv_length+iv+ciphertext</code>
|
237
243
|
</li>
|
238
244
|
|
239
|
-
<li class="never" data-hits="" data-linenumber="
|
245
|
+
<li class="never" data-hits="" data-linenumber="18">
|
240
246
|
|
241
247
|
|
242
248
|
<code class="ruby"> # @return [String] When iv != nil: ciphertext</code>
|
243
249
|
</li>
|
244
250
|
|
245
|
-
<li class="covered" data-hits="1" data-linenumber="
|
251
|
+
<li class="covered" data-hits="1" data-linenumber="19">
|
246
252
|
<span class="hits">1</span>
|
247
253
|
|
248
254
|
<code class="ruby"> def encrypt(plaintext, key, cipher_type = 'aes-256-cbc', iv = nil)</code>
|
249
255
|
</li>
|
250
256
|
|
251
|
-
<li class="covered" data-hits="702" data-linenumber="
|
257
|
+
<li class="covered" data-hits="702" data-linenumber="20">
|
252
258
|
<span class="hits">702</span>
|
253
259
|
|
254
260
|
<code class="ruby"> cipher = OpenSSL::Cipher.new(cipher_type)</code>
|
255
261
|
</li>
|
256
262
|
|
257
|
-
<li class="covered" data-hits="702" data-linenumber="
|
263
|
+
<li class="covered" data-hits="702" data-linenumber="21">
|
258
264
|
<span class="hits">702</span>
|
259
265
|
|
260
266
|
<code class="ruby"> cipher.encrypt</code>
|
261
267
|
</li>
|
262
268
|
|
263
|
-
<li class="covered" data-hits="702" data-linenumber="
|
269
|
+
<li class="covered" data-hits="702" data-linenumber="22">
|
264
270
|
<span class="hits">702</span>
|
265
271
|
|
266
272
|
<code class="ruby"> cipher.key = key</code>
|
267
273
|
</li>
|
268
274
|
|
269
|
-
<li class="covered" data-hits="700" data-linenumber="
|
275
|
+
<li class="covered" data-hits="700" data-linenumber="23">
|
270
276
|
<span class="hits">700</span>
|
271
277
|
|
272
278
|
<code class="ruby"> if iv.nil?</code>
|
273
279
|
</li>
|
274
280
|
|
275
|
-
<li class="covered" data-hits="430" data-linenumber="
|
281
|
+
<li class="covered" data-hits="430" data-linenumber="24">
|
276
282
|
<span class="hits">430</span>
|
277
283
|
|
278
284
|
<code class="ruby"> iv = cipher.random_iv</code>
|
279
285
|
</li>
|
280
286
|
|
281
|
-
<li class="covered" data-hits="430" data-linenumber="
|
287
|
+
<li class="covered" data-hits="430" data-linenumber="25">
|
282
288
|
<span class="hits">430</span>
|
283
289
|
|
284
290
|
<code class="ruby"> [iv.length].pack('C') + iv + cipher.update(plaintext) + cipher.final</code>
|
285
291
|
</li>
|
286
292
|
|
287
|
-
<li class="never" data-hits="" data-linenumber="
|
293
|
+
<li class="never" data-hits="" data-linenumber="26">
|
288
294
|
|
289
295
|
|
290
296
|
<code class="ruby"> else</code>
|
291
297
|
</li>
|
292
298
|
|
293
|
-
<li class="covered" data-hits="270" data-linenumber="
|
299
|
+
<li class="covered" data-hits="270" data-linenumber="27">
|
294
300
|
<span class="hits">270</span>
|
295
301
|
|
296
302
|
<code class="ruby"> cipher.iv = iv</code>
|
297
303
|
</li>
|
298
304
|
|
299
|
-
<li class="covered" data-hits="270" data-linenumber="
|
305
|
+
<li class="covered" data-hits="270" data-linenumber="28">
|
300
306
|
<span class="hits">270</span>
|
301
307
|
|
302
308
|
<code class="ruby"> cipher.update(plaintext) + cipher.final</code>
|
303
309
|
</li>
|
304
310
|
|
305
|
-
<li class="never" data-hits="" data-linenumber="
|
311
|
+
<li class="never" data-hits="" data-linenumber="29">
|
306
312
|
|
307
313
|
|
308
314
|
<code class="ruby"> end</code>
|
309
315
|
</li>
|
310
316
|
|
311
|
-
<li class="never" data-hits="" data-linenumber="
|
317
|
+
<li class="never" data-hits="" data-linenumber="30">
|
312
318
|
|
313
319
|
|
314
320
|
<code class="ruby"> end</code>
|
315
321
|
</li>
|
316
322
|
|
317
|
-
<li class="never" data-hits="" data-linenumber="
|
323
|
+
<li class="never" data-hits="" data-linenumber="31">
|
318
324
|
|
319
325
|
|
320
326
|
<code class="ruby"></code>
|
321
327
|
</li>
|
322
328
|
|
323
|
-
<li class="never" data-hits="" data-linenumber="
|
329
|
+
<li class="never" data-hits="" data-linenumber="32">
|
324
330
|
|
325
331
|
|
326
332
|
<code class="ruby"> # Decrypt a String.</code>
|
327
333
|
</li>
|
328
334
|
|
329
|
-
<li class="never" data-hits="" data-linenumber="
|
335
|
+
<li class="never" data-hits="" data-linenumber="33">
|
330
336
|
|
331
337
|
|
332
338
|
<code class="ruby"> #</code>
|
333
339
|
</li>
|
334
340
|
|
335
|
-
<li class="never" data-hits="" data-linenumber="
|
341
|
+
<li class="never" data-hits="" data-linenumber="34">
|
336
342
|
|
337
343
|
|
338
344
|
<code class="ruby"> # @param [String] ciphertext Input String (ciphertext)</code>
|
339
345
|
</li>
|
340
346
|
|
341
|
-
<li class="never" data-hits="" data-linenumber="
|
347
|
+
<li class="never" data-hits="" data-linenumber="35">
|
342
348
|
|
343
349
|
|
344
350
|
<code class="ruby"> # @param [String] key Encryption key</code>
|
345
351
|
</li>
|
346
352
|
|
347
|
-
<li class="never" data-hits="" data-linenumber="
|
353
|
+
<li class="never" data-hits="" data-linenumber="36">
|
348
354
|
|
349
355
|
|
350
356
|
<code class="ruby"> # @param [String] cipher_type OpenSSL cipher</code>
|
351
357
|
</li>
|
352
358
|
|
353
|
-
<li class="never" data-hits="" data-linenumber="
|
359
|
+
<li class="never" data-hits="" data-linenumber="37">
|
354
360
|
|
355
361
|
|
356
362
|
<code class="ruby"> # @param [String] iv Initialization vector</code>
|
357
363
|
</li>
|
358
364
|
|
359
|
-
<li class="never" data-hits="" data-linenumber="
|
365
|
+
<li class="never" data-hits="" data-linenumber="38">
|
360
366
|
|
361
367
|
|
362
368
|
<code class="ruby"> # @return [String] Plaintext</code>
|
363
369
|
</li>
|
364
370
|
|
365
|
-
<li class="covered" data-hits="1" data-linenumber="
|
371
|
+
<li class="covered" data-hits="1" data-linenumber="39">
|
366
372
|
<span class="hits">1</span>
|
367
373
|
|
368
374
|
<code class="ruby"> def decrypt(ciphertext, key, cipher_type = 'aes-256-cbc', iv = nil)</code>
|
369
375
|
</li>
|
370
376
|
|
371
|
-
<li class="covered" data-hits="372" data-linenumber="
|
377
|
+
<li class="covered" data-hits="372" data-linenumber="40">
|
372
378
|
<span class="hits">372</span>
|
373
379
|
|
374
380
|
<code class="ruby"> cipher = OpenSSL::Cipher.new(cipher_type)</code>
|
375
381
|
</li>
|
376
382
|
|
377
|
-
<li class="covered" data-hits="372" data-linenumber="
|
383
|
+
<li class="covered" data-hits="372" data-linenumber="41">
|
378
384
|
<span class="hits">372</span>
|
379
385
|
|
380
386
|
<code class="ruby"> cipher.decrypt</code>
|
381
387
|
</li>
|
382
388
|
|
383
|
-
<li class="covered" data-hits="372" data-linenumber="
|
389
|
+
<li class="covered" data-hits="372" data-linenumber="42">
|
384
390
|
<span class="hits">372</span>
|
385
391
|
|
386
392
|
<code class="ruby"> cipher.key = key</code>
|
387
393
|
</li>
|
388
394
|
|
389
|
-
<li class="covered" data-hits="372" data-linenumber="
|
395
|
+
<li class="covered" data-hits="372" data-linenumber="43">
|
390
396
|
<span class="hits">372</span>
|
391
397
|
|
392
398
|
<code class="ruby"> if iv.nil?</code>
|
393
399
|
</li>
|
394
400
|
|
395
|
-
<li class="covered" data-hits="282" data-linenumber="
|
401
|
+
<li class="covered" data-hits="282" data-linenumber="44">
|
396
402
|
<span class="hits">282</span>
|
397
403
|
|
398
404
|
<code class="ruby"> iv_len = ciphertext.slice!(0).unpack('C')[0]</code>
|
399
405
|
</li>
|
400
406
|
|
401
|
-
<li class="covered" data-hits="282" data-linenumber="
|
407
|
+
<li class="covered" data-hits="282" data-linenumber="45">
|
402
408
|
<span class="hits">282</span>
|
403
409
|
|
404
|
-
<code class="ruby"> cipher.iv = ciphertext.slice!(0..iv_len - 1) unless
|
410
|
+
<code class="ruby"> cipher.iv = ciphertext.slice!(0..iv_len - 1) unless iv_len == 0</code>
|
405
411
|
</li>
|
406
412
|
|
407
|
-
<li class="never" data-hits="" data-linenumber="
|
413
|
+
<li class="never" data-hits="" data-linenumber="46">
|
408
414
|
|
409
415
|
|
410
416
|
<code class="ruby"> else</code>
|
411
417
|
</li>
|
412
418
|
|
413
|
-
<li class="covered" data-hits="90" data-linenumber="
|
419
|
+
<li class="covered" data-hits="90" data-linenumber="47">
|
414
420
|
<span class="hits">90</span>
|
415
421
|
|
416
422
|
<code class="ruby"> cipher.iv = iv</code>
|
417
423
|
</li>
|
418
424
|
|
419
|
-
<li class="never" data-hits="" data-linenumber="
|
425
|
+
<li class="never" data-hits="" data-linenumber="48">
|
420
426
|
|
421
427
|
|
422
428
|
<code class="ruby"> end</code>
|
423
429
|
</li>
|
424
430
|
|
425
|
-
<li class="covered" data-hits="372" data-linenumber="
|
431
|
+
<li class="covered" data-hits="372" data-linenumber="49">
|
426
432
|
<span class="hits">372</span>
|
427
433
|
|
428
434
|
<code class="ruby"> cipher.update(ciphertext) + cipher.final</code>
|
429
435
|
</li>
|
430
436
|
|
431
|
-
<li class="never" data-hits="" data-linenumber="
|
437
|
+
<li class="never" data-hits="" data-linenumber="50">
|
432
438
|
|
433
439
|
|
434
440
|
<code class="ruby"> end</code>
|
435
441
|
</li>
|
436
442
|
|
437
|
-
<li class="never" data-hits="" data-linenumber="
|
443
|
+
<li class="never" data-hits="" data-linenumber="51">
|
438
444
|
|
439
445
|
|
440
446
|
<code class="ruby"></code>
|
441
447
|
</li>
|
442
448
|
|
443
|
-
<li class="never" data-hits="" data-linenumber="
|
449
|
+
<li class="never" data-hits="" data-linenumber="52">
|
444
450
|
|
445
451
|
|
446
452
|
<code class="ruby"> # Encrypt a String and encode the resulting ciphertext to Base64.</code>
|
447
453
|
</li>
|
448
454
|
|
449
|
-
<li class="never" data-hits="" data-linenumber="
|
455
|
+
<li class="never" data-hits="" data-linenumber="53">
|
450
456
|
|
451
457
|
|
452
458
|
<code class="ruby"> #</code>
|
453
459
|
</li>
|
454
460
|
|
455
|
-
<li class="never" data-hits="" data-linenumber="
|
461
|
+
<li class="never" data-hits="" data-linenumber="54">
|
456
462
|
|
457
463
|
|
458
464
|
<code class="ruby"> # @param [String] plaintext Input String (plaintext)</code>
|
459
465
|
</li>
|
460
466
|
|
461
|
-
<li class="never" data-hits="" data-linenumber="
|
467
|
+
<li class="never" data-hits="" data-linenumber="55">
|
462
468
|
|
463
469
|
|
464
470
|
<code class="ruby"> # @param [String] key Encryption key</code>
|
465
471
|
</li>
|
466
472
|
|
467
|
-
<li class="never" data-hits="" data-linenumber="
|
473
|
+
<li class="never" data-hits="" data-linenumber="56">
|
468
474
|
|
469
475
|
|
470
476
|
<code class="ruby"> # @param [String] cipher_type OpenSSL cipher</code>
|
471
477
|
</li>
|
472
478
|
|
473
|
-
<li class="never" data-hits="" data-linenumber="
|
479
|
+
<li class="never" data-hits="" data-linenumber="57">
|
474
480
|
|
475
481
|
|
476
482
|
<code class="ruby"> # @param [String] iv Initialization vector</code>
|
477
483
|
</li>
|
478
484
|
|
479
|
-
<li class="never" data-hits="" data-linenumber="
|
485
|
+
<li class="never" data-hits="" data-linenumber="58">
|
480
486
|
|
481
487
|
|
482
488
|
<code class="ruby"> # @return [String] When iv == nil: base64(iv_length+iv+ciphertext)</code>
|
483
489
|
</li>
|
484
490
|
|
485
|
-
<li class="never" data-hits="" data-linenumber="
|
491
|
+
<li class="never" data-hits="" data-linenumber="59">
|
486
492
|
|
487
493
|
|
488
494
|
<code class="ruby"> # @return [String] When iv != nil: base64(ciphertext)</code>
|
489
495
|
</li>
|
490
496
|
|
491
|
-
<li class="covered" data-hits="1" data-linenumber="
|
497
|
+
<li class="covered" data-hits="1" data-linenumber="60">
|
492
498
|
<span class="hits">1</span>
|
493
499
|
|
494
500
|
<code class="ruby"> def encrypt_base64(plaintext, key, cipher_type = 'aes-256-cbc', iv = nil)</code>
|
495
501
|
</li>
|
496
502
|
|
497
|
-
<li class="covered" data-hits="246" data-linenumber="
|
503
|
+
<li class="covered" data-hits="246" data-linenumber="61">
|
498
504
|
<span class="hits">246</span>
|
499
505
|
|
500
506
|
<code class="ruby"> Base64.strict_encode64(encrypt(plaintext, key, cipher_type, iv))</code>
|
501
507
|
</li>
|
502
508
|
|
503
|
-
<li class="never" data-hits="" data-linenumber="
|
509
|
+
<li class="never" data-hits="" data-linenumber="62">
|
504
510
|
|
505
511
|
|
506
512
|
<code class="ruby"> end</code>
|
507
513
|
</li>
|
508
514
|
|
509
|
-
<li class="never" data-hits="" data-linenumber="
|
515
|
+
<li class="never" data-hits="" data-linenumber="63">
|
510
516
|
|
511
517
|
|
512
518
|
<code class="ruby"></code>
|
513
519
|
</li>
|
514
520
|
|
515
|
-
<li class="never" data-hits="" data-linenumber="
|
521
|
+
<li class="never" data-hits="" data-linenumber="64">
|
516
522
|
|
517
523
|
|
518
524
|
<code class="ruby"> # Decode and Decrypt a Base64-String.</code>
|
519
525
|
</li>
|
520
526
|
|
521
|
-
<li class="never" data-hits="" data-linenumber="
|
527
|
+
<li class="never" data-hits="" data-linenumber="65">
|
522
528
|
|
523
529
|
|
524
530
|
<code class="ruby"> #</code>
|
525
531
|
</li>
|
526
532
|
|
527
|
-
<li class="never" data-hits="" data-linenumber="
|
533
|
+
<li class="never" data-hits="" data-linenumber="66">
|
528
534
|
|
529
535
|
|
530
536
|
<code class="ruby"> # @param [String] ciphertext Input String (base64(ciphertext))</code>
|
531
537
|
</li>
|
532
538
|
|
533
|
-
<li class="never" data-hits="" data-linenumber="
|
539
|
+
<li class="never" data-hits="" data-linenumber="67">
|
534
540
|
|
535
541
|
|
536
542
|
<code class="ruby"> # @param [String] key Encryption key</code>
|
537
543
|
</li>
|
538
544
|
|
539
|
-
<li class="never" data-hits="" data-linenumber="
|
545
|
+
<li class="never" data-hits="" data-linenumber="68">
|
540
546
|
|
541
547
|
|
542
548
|
<code class="ruby"> # @param [String] cipher_type OpenSSL cipher</code>
|
543
549
|
</li>
|
544
550
|
|
545
|
-
<li class="never" data-hits="" data-linenumber="
|
551
|
+
<li class="never" data-hits="" data-linenumber="69">
|
546
552
|
|
547
553
|
|
548
554
|
<code class="ruby"> # @param [String] iv Initialization vector</code>
|
549
555
|
</li>
|
550
556
|
|
551
|
-
<li class="never" data-hits="" data-linenumber="
|
557
|
+
<li class="never" data-hits="" data-linenumber="70">
|
552
558
|
|
553
559
|
|
554
560
|
<code class="ruby"> # @return [String] Plaintext</code>
|
555
561
|
</li>
|
556
562
|
|
557
|
-
<li class="covered" data-hits="1" data-linenumber="
|
563
|
+
<li class="covered" data-hits="1" data-linenumber="71">
|
558
564
|
<span class="hits">1</span>
|
559
565
|
|
560
566
|
<code class="ruby"> def decrypt_base64(ciphertext, key, cipher_type = 'aes-256-cbc', iv = nil)</code>
|
561
567
|
</li>
|
562
568
|
|
563
|
-
<li class="covered" data-hits="123" data-linenumber="
|
569
|
+
<li class="covered" data-hits="123" data-linenumber="72">
|
564
570
|
<span class="hits">123</span>
|
565
571
|
|
566
572
|
<code class="ruby"> decrypt(Base64.decode64(ciphertext), key, cipher_type, iv)</code>
|
567
573
|
</li>
|
568
574
|
|
569
|
-
<li class="never" data-hits="" data-linenumber="
|
575
|
+
<li class="never" data-hits="" data-linenumber="73">
|
570
576
|
|
571
577
|
|
572
578
|
<code class="ruby"> end</code>
|
573
579
|
</li>
|
574
580
|
|
575
|
-
<li class="never" data-hits="" data-linenumber="
|
581
|
+
<li class="never" data-hits="" data-linenumber="74">
|
576
582
|
|
577
583
|
|
578
584
|
<code class="ruby"></code>
|
579
585
|
</li>
|
580
586
|
|
581
|
-
<li class="never" data-hits="" data-linenumber="
|
587
|
+
<li class="never" data-hits="" data-linenumber="75">
|
582
588
|
|
583
589
|
|
584
590
|
<code class="ruby"> # Encrypt a String and encode the resulting ciphertext to urlsafe Base64.</code>
|
585
591
|
</li>
|
586
592
|
|
587
|
-
<li class="never" data-hits="" data-linenumber="
|
593
|
+
<li class="never" data-hits="" data-linenumber="76">
|
588
594
|
|
589
595
|
|
590
596
|
<code class="ruby"> #</code>
|
591
597
|
</li>
|
592
598
|
|
593
|
-
<li class="never" data-hits="" data-linenumber="
|
599
|
+
<li class="never" data-hits="" data-linenumber="77">
|
594
600
|
|
595
601
|
|
596
602
|
<code class="ruby"> # @param [String] plaintext Input String (plaintext)</code>
|
597
603
|
</li>
|
598
604
|
|
599
|
-
<li class="never" data-hits="" data-linenumber="
|
605
|
+
<li class="never" data-hits="" data-linenumber="78">
|
600
606
|
|
601
607
|
|
602
608
|
<code class="ruby"> # @param [String] key Encryption key</code>
|
603
609
|
</li>
|
604
610
|
|
605
|
-
<li class="never" data-hits="" data-linenumber="
|
611
|
+
<li class="never" data-hits="" data-linenumber="79">
|
606
612
|
|
607
613
|
|
608
614
|
<code class="ruby"> # @param [String] cipher_type OpenSSL cipher</code>
|
609
615
|
</li>
|
610
616
|
|
611
|
-
<li class="never" data-hits="" data-linenumber="
|
617
|
+
<li class="never" data-hits="" data-linenumber="80">
|
612
618
|
|
613
619
|
|
614
620
|
<code class="ruby"> # @param [String] iv Initialization vector</code>
|
615
621
|
</li>
|
616
622
|
|
617
|
-
<li class="never" data-hits="" data-linenumber="
|
623
|
+
<li class="never" data-hits="" data-linenumber="81">
|
618
624
|
|
619
625
|
|
620
626
|
<code class="ruby"> # @return [String] When iv == nil: urlsafe_base64(iv_length+iv+ciphertext)</code>
|
621
627
|
</li>
|
622
628
|
|
623
|
-
<li class="never" data-hits="" data-linenumber="
|
629
|
+
<li class="never" data-hits="" data-linenumber="82">
|
624
630
|
|
625
631
|
|
626
632
|
<code class="ruby"> # @return [String] When iv != nil: urlsafe_base64(ciphertext)</code>
|
627
633
|
</li>
|
628
634
|
|
629
|
-
<li class="covered" data-hits="1" data-linenumber="
|
635
|
+
<li class="covered" data-hits="1" data-linenumber="83">
|
630
636
|
<span class="hits">1</span>
|
631
637
|
|
632
638
|
<code class="ruby"> def encrypt_urlsafe_base64(plaintext, key, cipher_type = 'aes-256-cbc', iv = nil)</code>
|
633
639
|
</li>
|
634
640
|
|
635
|
-
<li class="covered" data-hits="251" data-linenumber="
|
641
|
+
<li class="covered" data-hits="251" data-linenumber="84">
|
636
642
|
<span class="hits">251</span>
|
637
643
|
|
638
644
|
<code class="ruby"> Base64.urlsafe_encode64(encrypt(plaintext, key, cipher_type, iv))</code>
|
639
645
|
</li>
|
640
646
|
|
641
|
-
<li class="never" data-hits="" data-linenumber="
|
647
|
+
<li class="never" data-hits="" data-linenumber="85">
|
642
648
|
|
643
649
|
|
644
650
|
<code class="ruby"> end</code>
|
645
651
|
</li>
|
646
652
|
|
647
|
-
<li class="never" data-hits="" data-linenumber="
|
653
|
+
<li class="never" data-hits="" data-linenumber="86">
|
648
654
|
|
649
655
|
|
650
656
|
<code class="ruby"></code>
|
651
657
|
</li>
|
652
658
|
|
653
|
-
<li class="never" data-hits="" data-linenumber="
|
659
|
+
<li class="never" data-hits="" data-linenumber="87">
|
654
660
|
|
655
661
|
|
656
662
|
<code class="ruby"> # Decode and Decrypt an urlsafe Base64-String.</code>
|
657
663
|
</li>
|
658
664
|
|
659
|
-
<li class="never" data-hits="" data-linenumber="
|
665
|
+
<li class="never" data-hits="" data-linenumber="88">
|
660
666
|
|
661
667
|
|
662
668
|
<code class="ruby"> #</code>
|
663
669
|
</li>
|
664
670
|
|
665
|
-
<li class="never" data-hits="" data-linenumber="
|
671
|
+
<li class="never" data-hits="" data-linenumber="89">
|
666
672
|
|
667
673
|
|
668
674
|
<code class="ruby"> # @param [String] ciphertext Input String (urlsafe_base64(ciphertext))</code>
|
669
675
|
</li>
|
670
676
|
|
671
|
-
<li class="never" data-hits="" data-linenumber="
|
677
|
+
<li class="never" data-hits="" data-linenumber="90">
|
672
678
|
|
673
679
|
|
674
680
|
<code class="ruby"> # @param [String] key Encryption key</code>
|
675
681
|
</li>
|
676
682
|
|
677
|
-
<li class="never" data-hits="" data-linenumber="
|
683
|
+
<li class="never" data-hits="" data-linenumber="91">
|
678
684
|
|
679
685
|
|
680
686
|
<code class="ruby"> # @param [String] cipher_type OpenSSL cipher</code>
|
681
687
|
</li>
|
682
688
|
|
683
|
-
<li class="never" data-hits="" data-linenumber="
|
689
|
+
<li class="never" data-hits="" data-linenumber="92">
|
684
690
|
|
685
691
|
|
686
692
|
<code class="ruby"> # @param [String] iv Initialization vector</code>
|
687
693
|
</li>
|
688
694
|
|
689
|
-
<li class="never" data-hits="" data-linenumber="
|
695
|
+
<li class="never" data-hits="" data-linenumber="93">
|
690
696
|
|
691
697
|
|
692
698
|
<code class="ruby"> # @return [String] Plaintext</code>
|
693
699
|
</li>
|
694
700
|
|
695
|
-
<li class="covered" data-hits="1" data-linenumber="
|
701
|
+
<li class="covered" data-hits="1" data-linenumber="94">
|
696
702
|
<span class="hits">1</span>
|
697
703
|
|
698
704
|
<code class="ruby"> def decrypt_urlsafe_base64(ciphertext, key, cipher_type = 'aes-256-cbc', iv = nil)</code>
|
699
705
|
</li>
|
700
706
|
|
701
|
-
<li class="covered" data-hits="126" data-linenumber="
|
707
|
+
<li class="covered" data-hits="126" data-linenumber="95">
|
702
708
|
<span class="hits">126</span>
|
703
709
|
|
704
710
|
<code class="ruby"> decrypt(Base64.urlsafe_decode64(ciphertext), key, cipher_type, iv)</code>
|
705
711
|
</li>
|
706
712
|
|
707
|
-
<li class="never" data-hits="" data-linenumber="
|
713
|
+
<li class="never" data-hits="" data-linenumber="96">
|
708
714
|
|
709
715
|
|
710
716
|
<code class="ruby"> end</code>
|
711
717
|
</li>
|
712
718
|
|
713
|
-
<li class="never" data-hits="" data-linenumber="
|
719
|
+
<li class="never" data-hits="" data-linenumber="97">
|
714
720
|
|
715
721
|
|
716
722
|
<code class="ruby"> end</code>
|
717
723
|
</li>
|
718
724
|
|
719
|
-
<li class="never" data-hits="" data-linenumber="
|
725
|
+
<li class="never" data-hits="" data-linenumber="98">
|
720
726
|
|
721
727
|
|
722
728
|
<code class="ruby"></code>
|
723
729
|
</li>
|
724
730
|
|
725
|
-
<li class="never" data-hits="" data-linenumber="
|
731
|
+
<li class="never" data-hits="" data-linenumber="99">
|
726
732
|
|
727
733
|
|
728
734
|
<code class="ruby"> # Secure Control Token.</code>
|
729
735
|
</li>
|
730
736
|
|
731
|
-
<li class="covered" data-hits="1" data-linenumber="
|
737
|
+
<li class="covered" data-hits="1" data-linenumber="100">
|
732
738
|
<span class="hits">1</span>
|
733
739
|
|
734
740
|
<code class="ruby"> class ControlToken</code>
|
735
741
|
</li>
|
736
742
|
|
737
|
-
<li class="covered" data-hits="1" data-linenumber="
|
743
|
+
<li class="covered" data-hits="1" data-linenumber="101">
|
738
744
|
<span class="hits">1</span>
|
739
745
|
|
740
746
|
<code class="ruby"> class << self</code>
|
741
747
|
</li>
|
742
748
|
|
743
|
-
<li class="never" data-hits="" data-linenumber="
|
749
|
+
<li class="never" data-hits="" data-linenumber="102">
|
744
750
|
|
745
751
|
|
746
752
|
<code class="ruby"> # Encode and encrypt an urlsafe ControlToken.</code>
|
747
753
|
</li>
|
748
754
|
|
749
|
-
<li class="never" data-hits="" data-linenumber="
|
755
|
+
<li class="never" data-hits="" data-linenumber="103">
|
750
756
|
|
751
757
|
|
752
758
|
<code class="ruby"> #</code>
|
753
759
|
</li>
|
754
760
|
|
755
|
-
<li class="never" data-hits="" data-linenumber="
|
761
|
+
<li class="never" data-hits="" data-linenumber="104">
|
756
762
|
|
757
763
|
|
758
764
|
<code class="ruby"> # @param [String] op Operation id</code>
|
759
765
|
</li>
|
760
766
|
|
761
|
-
<li class="never" data-hits="" data-linenumber="
|
767
|
+
<li class="never" data-hits="" data-linenumber="105">
|
762
768
|
|
763
769
|
|
764
770
|
<code class="ruby"> # @param [Array] args Arguments (Strings)</code>
|
765
771
|
</li>
|
766
772
|
|
767
|
-
<li class="never" data-hits="" data-linenumber="
|
773
|
+
<li class="never" data-hits="" data-linenumber="106">
|
768
774
|
|
769
775
|
|
770
776
|
<code class="ruby"> # @param [Fixnum] expire_in</code>
|
771
777
|
</li>
|
772
778
|
|
773
|
-
<li class="never" data-hits="" data-linenumber="
|
779
|
+
<li class="never" data-hits="" data-linenumber="107">
|
774
780
|
|
775
781
|
|
776
782
|
<code class="ruby"> # @param [String] key Encryption key</code>
|
777
783
|
</li>
|
778
784
|
|
779
|
-
<li class="never" data-hits="" data-linenumber="
|
785
|
+
<li class="never" data-hits="" data-linenumber="108">
|
780
786
|
|
781
787
|
|
782
788
|
<code class="ruby"> # @param [String] cipher_type OpenSSL cipher</code>
|
783
789
|
</li>
|
784
790
|
|
785
|
-
<li class="never" data-hits="" data-linenumber="
|
791
|
+
<li class="never" data-hits="" data-linenumber="109">
|
786
792
|
|
787
793
|
|
788
794
|
<code class="ruby"> # @return [String] ControlToken (urlsafe base64)</code>
|
789
795
|
</li>
|
790
796
|
|
791
|
-
<li class="covered" data-hits="1" data-linenumber="
|
797
|
+
<li class="covered" data-hits="1" data-linenumber="110">
|
792
798
|
<span class="hits">1</span>
|
793
799
|
|
794
800
|
<code class="ruby"> def create(op, args, expire_in = 900, key = ENV['CONTROLTOKEN_SECRET'], cipher_type = 'aes-256-cbc')</code>
|
795
801
|
</li>
|
796
802
|
|
797
|
-
<li class="covered" data-hits="6" data-linenumber="
|
803
|
+
<li class="covered" data-hits="6" data-linenumber="111">
|
798
804
|
<span class="hits">6</span>
|
799
805
|
|
800
806
|
<code class="ruby"> raise ArgumentError, 'key can not be blank' if key.nil? || key.empty?</code>
|
801
807
|
</li>
|
802
808
|
|
803
|
-
<li class="never" data-hits="" data-linenumber="
|
809
|
+
<li class="never" data-hits="" data-linenumber="112">
|
804
810
|
|
805
811
|
|
806
812
|
<code class="ruby"> # If you're reading this in the year 2038: Hi there! :-)</code>
|
807
813
|
</li>
|
808
814
|
|
809
|
-
<li class="covered" data-hits="5" data-linenumber="
|
815
|
+
<li class="covered" data-hits="5" data-linenumber="113">
|
810
816
|
<span class="hits">5</span>
|
811
817
|
|
812
818
|
<code class="ruby"> [Time.now.to_i + expire_in].pack('l<')</code>
|
813
819
|
</li>
|
814
820
|
|
815
|
-
<li class="covered" data-hits="5" data-linenumber="
|
821
|
+
<li class="covered" data-hits="5" data-linenumber="114">
|
816
822
|
<span class="hits">5</span>
|
817
823
|
|
818
824
|
<code class="ruby"> body = ([[Time.now.to_i + expire_in].pack('l<'), op] + args).join("\x00")</code>
|
819
825
|
</li>
|
820
826
|
|
821
|
-
<li class="covered" data-hits="5" data-linenumber="
|
827
|
+
<li class="covered" data-hits="5" data-linenumber="115">
|
822
828
|
<span class="hits">5</span>
|
823
829
|
|
824
830
|
<code class="ruby"> BB::Crypto.encrypt_urlsafe_base64(body, key, cipher_type)</code>
|
825
831
|
</li>
|
826
832
|
|
827
|
-
<li class="never" data-hits="" data-linenumber="
|
833
|
+
<li class="never" data-hits="" data-linenumber="116">
|
828
834
|
|
829
835
|
|
830
836
|
<code class="ruby"> end</code>
|
831
837
|
</li>
|
832
838
|
|
833
|
-
<li class="never" data-hits="" data-linenumber="
|
839
|
+
<li class="never" data-hits="" data-linenumber="117">
|
834
840
|
|
835
841
|
|
836
842
|
<code class="ruby"></code>
|
837
843
|
</li>
|
838
844
|
|
839
|
-
<li class="never" data-hits="" data-linenumber="
|
845
|
+
<li class="never" data-hits="" data-linenumber="118">
|
840
846
|
|
841
847
|
|
842
848
|
<code class="ruby"> # Decrypt and parse an urlsafe ControlToken.</code>
|
843
849
|
</li>
|
844
850
|
|
845
|
-
<li class="never" data-hits="" data-linenumber="
|
851
|
+
<li class="never" data-hits="" data-linenumber="119">
|
846
852
|
|
847
853
|
|
848
854
|
<code class="ruby"> #</code>
|
849
855
|
</li>
|
850
856
|
|
851
|
-
<li class="never" data-hits="" data-linenumber="
|
857
|
+
<li class="never" data-hits="" data-linenumber="120">
|
852
858
|
|
853
859
|
|
854
860
|
<code class="ruby"> # @param [String] token Input String (urlsafe base64)</code>
|
855
861
|
</li>
|
856
862
|
|
857
|
-
<li class="never" data-hits="" data-linenumber="
|
863
|
+
<li class="never" data-hits="" data-linenumber="121">
|
858
864
|
|
859
865
|
|
860
866
|
<code class="ruby"> # @param [String] key Encryption key</code>
|
861
867
|
</li>
|
862
868
|
|
863
|
-
<li class="never" data-hits="" data-linenumber="
|
869
|
+
<li class="never" data-hits="" data-linenumber="122">
|
864
870
|
|
865
871
|
|
866
872
|
<code class="ruby"> # @param [Boolean] force Decode expired token (suppress ArgumentError)</code>
|
867
873
|
</li>
|
868
874
|
|
869
|
-
<li class="never" data-hits="" data-linenumber="
|
875
|
+
<li class="never" data-hits="" data-linenumber="123">
|
870
876
|
|
871
877
|
|
872
878
|
<code class="ruby"> # @param [String] cipher_type OpenSSL cipher</code>
|
873
879
|
</li>
|
874
880
|
|
875
|
-
<li class="never" data-hits="" data-linenumber="
|
881
|
+
<li class="never" data-hits="" data-linenumber="124">
|
876
882
|
|
877
883
|
|
878
884
|
<code class="ruby"> # @return [Hash] Token payload</code>
|
879
885
|
</li>
|
880
886
|
|
881
|
-
<li class="covered" data-hits="1" data-linenumber="
|
887
|
+
<li class="covered" data-hits="1" data-linenumber="125">
|
882
888
|
<span class="hits">1</span>
|
883
889
|
|
884
890
|
<code class="ruby"> def parse(token, key = ENV['CONTROLTOKEN_SECRET'], force = false, cipher_type = 'aes-256-cbc')</code>
|
885
891
|
</li>
|
886
892
|
|
887
|
-
<li class="covered" data-hits="3" data-linenumber="
|
893
|
+
<li class="covered" data-hits="3" data-linenumber="126">
|
888
894
|
<span class="hits">3</span>
|
889
895
|
|
890
896
|
<code class="ruby"> raise ArgumentError, 'key can not be blank' if key.nil? || key.empty?</code>
|
891
897
|
</li>
|
892
898
|
|
893
|
-
<li class="covered" data-hits="3" data-linenumber="
|
899
|
+
<li class="covered" data-hits="3" data-linenumber="127">
|
894
900
|
<span class="hits">3</span>
|
895
901
|
|
896
902
|
<code class="ruby"> body = BB::Crypto.decrypt_urlsafe_base64(token, key, cipher_type)</code>
|
897
903
|
</li>
|
898
904
|
|
899
|
-
<li class="covered" data-hits="3" data-linenumber="
|
905
|
+
<li class="covered" data-hits="3" data-linenumber="128">
|
900
906
|
<span class="hits">3</span>
|
901
907
|
|
902
908
|
<code class="ruby"> valid_until, op, *args = body.split("\x00")</code>
|
903
909
|
</li>
|
904
910
|
|
905
|
-
<li class="covered" data-hits="3" data-linenumber="
|
911
|
+
<li class="covered" data-hits="3" data-linenumber="129">
|
906
912
|
<span class="hits">3</span>
|
907
913
|
|
908
914
|
<code class="ruby"> valid_until = valid_until.unpack('l<')[0]</code>
|
909
915
|
</li>
|
910
916
|
|
911
|
-
<li class="covered" data-hits="3" data-linenumber="
|
917
|
+
<li class="covered" data-hits="3" data-linenumber="130">
|
912
918
|
<span class="hits">3</span>
|
913
919
|
|
914
920
|
<code class="ruby"> expired = Time.now.to_i > valid_until</code>
|
915
921
|
</li>
|
916
922
|
|
917
|
-
<li class="covered" data-hits="3" data-linenumber="
|
923
|
+
<li class="covered" data-hits="3" data-linenumber="131">
|
918
924
|
<span class="hits">3</span>
|
919
925
|
|
920
|
-
<code class="ruby"> if expired && !force</code>
|
921
|
-
</li>
|
922
|
-
|
923
|
-
<li class="covered" data-hits="1" data-linenumber="131">
|
924
|
-
<span class="hits">1</span>
|
925
|
-
|
926
|
-
<code class="ruby"> raise ArgumentError, "Token expired at #{Time.at(valid_until)} (#{ChronicDuration.output(Time.now.to_i - valid_until)} ago)"</code>
|
926
|
+
<code class="ruby"> raise ArgumentError, "Token expired at #{Time.at(valid_until)} (#{ChronicDuration.output(Time.now.to_i - valid_until)} ago)" if expired && !force</code>
|
927
927
|
</li>
|
928
928
|
|
929
|
-
<li class="
|
930
|
-
|
929
|
+
<li class="covered" data-hits="2" data-linenumber="132">
|
930
|
+
<span class="hits">2</span>
|
931
931
|
|
932
|
-
<code class="ruby">
|
932
|
+
<code class="ruby"> { valid_until: valid_until,</code>
|
933
933
|
</li>
|
934
934
|
|
935
935
|
<li class="never" data-hits="" data-linenumber="133">
|
936
936
|
|
937
937
|
|
938
|
-
<code class="ruby">
|
938
|
+
<code class="ruby"> op: op,</code>
|
939
939
|
</li>
|
940
940
|
|
941
941
|
<li class="never" data-hits="" data-linenumber="134">
|
942
942
|
|
943
943
|
|
944
|
-
<code class="ruby">
|
944
|
+
<code class="ruby"> args: args,</code>
|
945
945
|
</li>
|
946
946
|
|
947
947
|
<li class="never" data-hits="" data-linenumber="135">
|
948
948
|
|
949
949
|
|
950
|
-
<code class="ruby"> args: args,</code>
|
951
|
-
</li>
|
952
|
-
|
953
|
-
<li class="covered" data-hits="2" data-linenumber="136">
|
954
|
-
<span class="hits">2</span>
|
955
|
-
|
956
950
|
<code class="ruby"> expired: expired }</code>
|
957
951
|
</li>
|
958
952
|
|
959
|
-
<li class="never" data-hits="" data-linenumber="
|
953
|
+
<li class="never" data-hits="" data-linenumber="136">
|
960
954
|
|
961
955
|
|
962
956
|
<code class="ruby"> end</code>
|
963
957
|
</li>
|
964
958
|
|
965
|
-
<li class="never" data-hits="" data-linenumber="
|
959
|
+
<li class="never" data-hits="" data-linenumber="137">
|
966
960
|
|
967
961
|
|
968
962
|
<code class="ruby"> end</code>
|
969
963
|
</li>
|
970
964
|
|
971
|
-
<li class="never" data-hits="" data-linenumber="
|
965
|
+
<li class="never" data-hits="" data-linenumber="138">
|
972
966
|
|
973
967
|
|
974
968
|
<code class="ruby"> end # /BB::Crypto::Token</code>
|
975
969
|
</li>
|
976
970
|
|
977
|
-
<li class="never" data-hits="" data-linenumber="
|
971
|
+
<li class="never" data-hits="" data-linenumber="139">
|
978
972
|
|
979
973
|
|
980
974
|
<code class="ruby"> end # /BB::Crypto</code>
|
981
975
|
</li>
|
982
976
|
|
983
|
-
<li class="never" data-hits="" data-linenumber="
|
977
|
+
<li class="never" data-hits="" data-linenumber="140">
|
984
978
|
|
985
979
|
|
986
980
|
<code class="ruby">end</code>
|
@@ -989,15 +983,16 @@
|
|
989
983
|
</ol>
|
990
984
|
</pre>
|
991
985
|
</div>
|
986
|
+
|
992
987
|
|
993
988
|
<div class="source_table" id="192e300fd7769b750c82567439ee016f85516f3d">
|
994
989
|
<div class="header">
|
995
990
|
<h3>lib/blackbox/gem.rb</h3>
|
996
|
-
<h4><span class="green">
|
991
|
+
<h4><span class="green">97.06 %</span> covered</h4>
|
997
992
|
<div>
|
998
993
|
<b>34</b> relevant lines.
|
999
|
-
<span class="green"><b>
|
1000
|
-
<span class="red"><b>
|
994
|
+
<span class="green"><b>33</b> lines covered</span> and
|
995
|
+
<span class="red"><b>1</b> lines missed.</span>
|
1001
996
|
</div>
|
1002
997
|
</div>
|
1003
998
|
|
@@ -1010,559 +1005,565 @@
|
|
1010
1005
|
<code class="ruby"># frozen_string_literal: true</code>
|
1011
1006
|
</li>
|
1012
1007
|
|
1013
|
-
<li class="
|
1014
|
-
<span class="hits">1</span>
|
1008
|
+
<li class="never" data-hits="" data-linenumber="2">
|
1015
1009
|
|
1016
|
-
|
1010
|
+
|
1011
|
+
<code class="ruby"></code>
|
1017
1012
|
</li>
|
1018
1013
|
|
1019
1014
|
<li class="covered" data-hits="1" data-linenumber="3">
|
1020
1015
|
<span class="hits">1</span>
|
1021
1016
|
|
1022
|
-
<code class="ruby">
|
1017
|
+
<code class="ruby">require 'versionomy'</code>
|
1023
1018
|
</li>
|
1024
1019
|
|
1025
|
-
<li class="
|
1020
|
+
<li class="covered" data-hits="1" data-linenumber="4">
|
1021
|
+
<span class="hits">1</span>
|
1022
|
+
|
1023
|
+
<code class="ruby">module BB</code>
|
1024
|
+
</li>
|
1025
|
+
|
1026
|
+
<li class="never" data-hits="" data-linenumber="5">
|
1026
1027
|
|
1027
1028
|
|
1028
1029
|
<code class="ruby"> # Gem utilities.</code>
|
1029
1030
|
</li>
|
1030
1031
|
|
1031
|
-
<li class="covered" data-hits="1" data-linenumber="
|
1032
|
+
<li class="covered" data-hits="1" data-linenumber="6">
|
1032
1033
|
<span class="hits">1</span>
|
1033
1034
|
|
1034
1035
|
<code class="ruby"> module Gem</code>
|
1035
1036
|
</li>
|
1036
1037
|
|
1037
|
-
<li class="covered" data-hits="1" data-linenumber="
|
1038
|
+
<li class="covered" data-hits="1" data-linenumber="7">
|
1038
1039
|
<span class="hits">1</span>
|
1039
1040
|
|
1040
1041
|
<code class="ruby"> class << self</code>
|
1041
1042
|
</li>
|
1042
1043
|
|
1043
|
-
<li class="never" data-hits="" data-linenumber="
|
1044
|
+
<li class="never" data-hits="" data-linenumber="8">
|
1044
1045
|
|
1045
1046
|
|
1046
1047
|
<code class="ruby"> # Return information about the currently installed gem</code>
|
1047
1048
|
</li>
|
1048
1049
|
|
1049
|
-
<li class="never" data-hits="" data-linenumber="
|
1050
|
+
<li class="never" data-hits="" data-linenumber="9">
|
1050
1051
|
|
1051
1052
|
|
1052
1053
|
<code class="ruby"> # version and the latest available version on rubygems.org.</code>
|
1053
1054
|
</li>
|
1054
1055
|
|
1055
|
-
<li class="never" data-hits="" data-linenumber="
|
1056
|
+
<li class="never" data-hits="" data-linenumber="10">
|
1056
1057
|
|
1057
1058
|
|
1058
1059
|
<code class="ruby"> #</code>
|
1059
1060
|
</li>
|
1060
1061
|
|
1061
|
-
<li class="never" data-hits="" data-linenumber="
|
1062
|
+
<li class="never" data-hits="" data-linenumber="11">
|
1062
1063
|
|
1063
1064
|
|
1064
1065
|
<code class="ruby"> # @param [Hash] opts the options to create a message with.</code>
|
1065
1066
|
</li>
|
1066
1067
|
|
1067
|
-
<li class="never" data-hits="" data-linenumber="
|
1068
|
+
<li class="never" data-hits="" data-linenumber="12">
|
1068
1069
|
|
1069
1070
|
|
1070
1071
|
<code class="ruby"> # @option opts [Fixnum] :check_interval how frequently to query rubygems.org (default: 3600)</code>
|
1071
1072
|
</li>
|
1072
1073
|
|
1073
|
-
<li class="never" data-hits="" data-linenumber="
|
1074
|
+
<li class="never" data-hits="" data-linenumber="13">
|
1074
1075
|
|
1075
1076
|
|
1076
1077
|
<code class="ruby"> # @option opts [String] :disabling_env_var (default: #{GEMNAME}_DISABLE_VERSION_CHECK)</code>
|
1077
1078
|
</li>
|
1078
1079
|
|
1079
|
-
<li class="never" data-hits="" data-linenumber="
|
1080
|
+
<li class="never" data-hits="" data-linenumber="14">
|
1080
1081
|
|
1081
1082
|
|
1082
1083
|
<code class="ruby"> # @option opts [] :from ('nobody') From address</code>
|
1083
1084
|
</li>
|
1084
1085
|
|
1085
|
-
<li class="never" data-hits="" data-linenumber="
|
1086
|
+
<li class="never" data-hits="" data-linenumber="15">
|
1086
1087
|
|
1087
1088
|
|
1088
1089
|
<code class="ruby"> # @return [Hash] result</code>
|
1089
1090
|
</li>
|
1090
1091
|
|
1091
|
-
<li class="never" data-hits="" data-linenumber="
|
1092
|
+
<li class="never" data-hits="" data-linenumber="16">
|
1092
1093
|
|
1093
1094
|
|
1094
1095
|
<code class="ruby"> # * :gem_name => name of current gem</code>
|
1095
1096
|
</li>
|
1096
1097
|
|
1097
|
-
<li class="never" data-hits="" data-linenumber="
|
1098
|
+
<li class="never" data-hits="" data-linenumber="17">
|
1098
1099
|
|
1099
1100
|
|
1100
1101
|
<code class="ruby"> # * :gem_installed_version => installed version</code>
|
1101
1102
|
</li>
|
1102
1103
|
|
1103
|
-
<li class="never" data-hits="" data-linenumber="
|
1104
|
+
<li class="never" data-hits="" data-linenumber="18">
|
1104
1105
|
|
1105
1106
|
|
1106
1107
|
<code class="ruby"> # * :gem_latest_version => latest version on rubygems.org</code>
|
1107
1108
|
</li>
|
1108
1109
|
|
1109
|
-
<li class="never" data-hits="" data-linenumber="
|
1110
|
+
<li class="never" data-hits="" data-linenumber="19">
|
1110
1111
|
|
1111
1112
|
|
1112
1113
|
<code class="ruby"> # * :last_checked_for_update => timestamp of last query to rubygems.org</code>
|
1113
1114
|
</li>
|
1114
1115
|
|
1115
|
-
<li class="never" data-hits="" data-linenumber="
|
1116
|
+
<li class="never" data-hits="" data-linenumber="20">
|
1116
1117
|
|
1117
1118
|
|
1118
1119
|
<code class="ruby"> # * :next_check_for_update => timestamp of next query to rubygems.org</code>
|
1119
1120
|
</li>
|
1120
1121
|
|
1121
|
-
<li class="never" data-hits="" data-linenumber="
|
1122
|
+
<li class="never" data-hits="" data-linenumber="21">
|
1122
1123
|
|
1123
1124
|
|
1124
1125
|
<code class="ruby"> # * :gem_update_available => update available?</code>
|
1125
1126
|
</li>
|
1126
1127
|
|
1127
|
-
<li class="never" data-hits="" data-linenumber="
|
1128
|
+
<li class="never" data-hits="" data-linenumber="22">
|
1128
1129
|
|
1129
1130
|
|
1130
1131
|
<code class="ruby"> # * :installed_is_latest => is installed version == latest available version?</code>
|
1131
1132
|
</li>
|
1132
1133
|
|
1133
|
-
<li class="covered" data-hits="1" data-linenumber="
|
1134
|
+
<li class="covered" data-hits="1" data-linenumber="23">
|
1134
1135
|
<span class="hits">1</span>
|
1135
1136
|
|
1136
1137
|
<code class="ruby"> def version_info(*_, **opts)</code>
|
1137
1138
|
</li>
|
1138
1139
|
|
1139
|
-
<li class="covered" data-hits="8" data-linenumber="
|
1140
|
+
<li class="covered" data-hits="8" data-linenumber="24">
|
1140
1141
|
<span class="hits">8</span>
|
1141
1142
|
|
1142
1143
|
<code class="ruby"> ret = {</code>
|
1143
1144
|
</li>
|
1144
1145
|
|
1145
|
-
<li class="never" data-hits="" data-linenumber="
|
1146
|
+
<li class="never" data-hits="" data-linenumber="25">
|
1146
1147
|
|
1147
1148
|
|
1148
1149
|
<code class="ruby"> gem_name: :unknown,</code>
|
1149
1150
|
</li>
|
1150
1151
|
|
1151
|
-
<li class="never" data-hits="" data-linenumber="
|
1152
|
+
<li class="never" data-hits="" data-linenumber="26">
|
1152
1153
|
|
1153
1154
|
|
1154
1155
|
<code class="ruby"> gem_installed_version: :unknown,</code>
|
1155
1156
|
</li>
|
1156
1157
|
|
1157
|
-
<li class="never" data-hits="" data-linenumber="
|
1158
|
+
<li class="never" data-hits="" data-linenumber="27">
|
1158
1159
|
|
1159
1160
|
|
1160
1161
|
<code class="ruby"> gem_latest_version: :unknown,</code>
|
1161
1162
|
</li>
|
1162
1163
|
|
1163
|
-
<li class="never" data-hits="" data-linenumber="
|
1164
|
+
<li class="never" data-hits="" data-linenumber="28">
|
1164
1165
|
|
1165
1166
|
|
1166
1167
|
<code class="ruby"> gem_update_available: false,</code>
|
1167
1168
|
</li>
|
1168
1169
|
|
1169
|
-
<li class="never" data-hits="" data-linenumber="
|
1170
|
+
<li class="never" data-hits="" data-linenumber="29">
|
1170
1171
|
|
1171
1172
|
|
1172
1173
|
<code class="ruby"> last_checked_for_update: :unknown,</code>
|
1173
1174
|
</li>
|
1174
1175
|
|
1175
|
-
<li class="never" data-hits="" data-linenumber="
|
1176
|
+
<li class="never" data-hits="" data-linenumber="30">
|
1176
1177
|
|
1177
1178
|
|
1178
1179
|
<code class="ruby"> next_check_for_update: :unknown,</code>
|
1179
1180
|
</li>
|
1180
1181
|
|
1181
|
-
<li class="never" data-hits="" data-linenumber="
|
1182
|
+
<li class="never" data-hits="" data-linenumber="31">
|
1182
1183
|
|
1183
1184
|
|
1184
1185
|
<code class="ruby"> installed_is_latest: true</code>
|
1185
1186
|
</li>
|
1186
1187
|
|
1187
|
-
<li class="never" data-hits="" data-linenumber="
|
1188
|
+
<li class="never" data-hits="" data-linenumber="32">
|
1188
1189
|
|
1189
1190
|
|
1190
1191
|
<code class="ruby"> }</code>
|
1191
1192
|
</li>
|
1192
1193
|
|
1193
|
-
<li class="never" data-hits="" data-linenumber="
|
1194
|
+
<li class="never" data-hits="" data-linenumber="33">
|
1194
1195
|
|
1195
1196
|
|
1196
1197
|
<code class="ruby"></code>
|
1197
1198
|
</li>
|
1198
1199
|
|
1199
|
-
<li class="covered" data-hits="8" data-linenumber="
|
1200
|
+
<li class="covered" data-hits="8" data-linenumber="34">
|
1200
1201
|
<span class="hits">8</span>
|
1201
1202
|
|
1202
1203
|
<code class="ruby"> calling_file = caller[0].split(':')[0]</code>
|
1203
1204
|
</li>
|
1204
1205
|
|
1205
|
-
<li class="covered" data-hits="8" data-linenumber="
|
1206
|
+
<li class="covered" data-hits="8" data-linenumber="35">
|
1206
1207
|
<span class="hits">8</span>
|
1207
1208
|
|
1208
1209
|
<code class="ruby"> spec = ::Gem::Specification.find do |s|</code>
|
1209
1210
|
</li>
|
1210
1211
|
|
1211
|
-
<li class="covered" data-hits="96" data-linenumber="
|
1212
|
+
<li class="covered" data-hits="96" data-linenumber="36">
|
1212
1213
|
<span class="hits">96</span>
|
1213
1214
|
|
1214
1215
|
<code class="ruby"> File.fnmatch(File.join(s.full_gem_path, '*'), calling_file)</code>
|
1215
1216
|
</li>
|
1216
1217
|
|
1217
|
-
<li class="never" data-hits="" data-linenumber="
|
1218
|
+
<li class="never" data-hits="" data-linenumber="37">
|
1218
1219
|
|
1219
1220
|
|
1220
1221
|
<code class="ruby"> end</code>
|
1221
1222
|
</li>
|
1222
1223
|
|
1223
|
-
<li class="never" data-hits="" data-linenumber="
|
1224
|
+
<li class="never" data-hits="" data-linenumber="38">
|
1224
1225
|
|
1225
1226
|
|
1226
1227
|
<code class="ruby"></code>
|
1227
1228
|
</li>
|
1228
1229
|
|
1229
|
-
<li class="covered" data-hits="8" data-linenumber="
|
1230
|
+
<li class="covered" data-hits="8" data-linenumber="39">
|
1230
1231
|
<span class="hits">8</span>
|
1231
1232
|
|
1232
1233
|
<code class="ruby"> ret[:gem_installed_version] = spec&.version&.to_s || :unknown</code>
|
1233
1234
|
</li>
|
1234
1235
|
|
1235
|
-
<li class="covered" data-hits="8" data-linenumber="
|
1236
|
+
<li class="covered" data-hits="8" data-linenumber="40">
|
1236
1237
|
<span class="hits">8</span>
|
1237
1238
|
|
1238
1239
|
<code class="ruby"> ret[:gem_name] = spec&.name || :unknown</code>
|
1239
1240
|
</li>
|
1240
1241
|
|
1241
|
-
<li class="never" data-hits="" data-linenumber="
|
1242
|
+
<li class="never" data-hits="" data-linenumber="41">
|
1242
1243
|
|
1243
1244
|
|
1244
1245
|
<code class="ruby"></code>
|
1245
1246
|
</li>
|
1246
1247
|
|
1247
|
-
<li class="covered" data-hits="8" data-linenumber="
|
1248
|
+
<li class="covered" data-hits="8" data-linenumber="42">
|
1248
1249
|
<span class="hits">8</span>
|
1249
1250
|
|
1250
1251
|
<code class="ruby"> opts = { # defaults</code>
|
1251
1252
|
</li>
|
1252
1253
|
|
1253
|
-
<li class="never" data-hits="" data-linenumber="
|
1254
|
+
<li class="never" data-hits="" data-linenumber="43">
|
1254
1255
|
|
1255
1256
|
|
1256
1257
|
<code class="ruby"> check_interval: 3600,</code>
|
1257
1258
|
</li>
|
1258
1259
|
|
1259
|
-
<li class="never" data-hits="" data-linenumber="
|
1260
|
+
<li class="never" data-hits="" data-linenumber="44">
|
1260
1261
|
|
1261
1262
|
|
1262
1263
|
<code class="ruby"> disabling_env_var: "#{ret[:gem_name].upcase}_DISABLE_VERSION_CHECK"</code>
|
1263
1264
|
</li>
|
1264
1265
|
|
1265
|
-
<li class="never" data-hits="" data-linenumber="
|
1266
|
+
<li class="never" data-hits="" data-linenumber="45">
|
1266
1267
|
|
1267
1268
|
|
1268
1269
|
<code class="ruby"> }.merge(opts)</code>
|
1269
1270
|
</li>
|
1270
1271
|
|
1271
|
-
<li class="never" data-hits="" data-linenumber="
|
1272
|
+
<li class="never" data-hits="" data-linenumber="46">
|
1272
1273
|
|
1273
1274
|
|
1274
1275
|
<code class="ruby"></code>
|
1275
1276
|
</li>
|
1276
1277
|
|
1277
|
-
<li class="covered" data-hits="8" data-linenumber="
|
1278
|
+
<li class="covered" data-hits="8" data-linenumber="47">
|
1278
1279
|
<span class="hits">8</span>
|
1279
1280
|
|
1280
1281
|
<code class="ruby"> return ret if ret[:gem_name] == :unknown</code>
|
1281
1282
|
</li>
|
1282
1283
|
|
1283
|
-
<li class="covered" data-hits="8" data-linenumber="
|
1284
|
+
<li class="covered" data-hits="8" data-linenumber="48">
|
1284
1285
|
<span class="hits">8</span>
|
1285
1286
|
|
1286
1287
|
<code class="ruby"> return ret if ret[:gem_installed_version] == :unknown</code>
|
1287
1288
|
</li>
|
1288
1289
|
|
1289
|
-
<li class="covered" data-hits="8" data-linenumber="
|
1290
|
+
<li class="covered" data-hits="8" data-linenumber="49">
|
1290
1291
|
<span class="hits">8</span>
|
1291
1292
|
|
1292
1293
|
<code class="ruby"> if opts[:disabling_env_var] && ENV.include?(opts[:disabling_env_var])</code>
|
1293
1294
|
</li>
|
1294
1295
|
|
1295
|
-
<li class="covered" data-hits="1" data-linenumber="
|
1296
|
+
<li class="covered" data-hits="1" data-linenumber="50">
|
1296
1297
|
<span class="hits">1</span>
|
1297
1298
|
|
1298
1299
|
<code class="ruby"> ret[:next_check_for_update] = :never</code>
|
1299
1300
|
</li>
|
1300
1301
|
|
1301
|
-
<li class="covered" data-hits="1" data-linenumber="
|
1302
|
+
<li class="covered" data-hits="1" data-linenumber="51">
|
1302
1303
|
<span class="hits">1</span>
|
1303
1304
|
|
1304
1305
|
<code class="ruby"> return ret</code>
|
1305
1306
|
</li>
|
1306
1307
|
|
1307
|
-
<li class="never" data-hits="" data-linenumber="
|
1308
|
+
<li class="never" data-hits="" data-linenumber="52">
|
1308
1309
|
|
1309
1310
|
|
1310
1311
|
<code class="ruby"> end</code>
|
1311
1312
|
</li>
|
1312
1313
|
|
1313
|
-
<li class="never" data-hits="" data-linenumber="
|
1314
|
+
<li class="never" data-hits="" data-linenumber="53">
|
1314
1315
|
|
1315
1316
|
|
1316
1317
|
<code class="ruby"></code>
|
1317
1318
|
</li>
|
1318
1319
|
|
1319
|
-
<li class="covered" data-hits="7" data-linenumber="
|
1320
|
+
<li class="covered" data-hits="7" data-linenumber="54">
|
1320
1321
|
<span class="hits">7</span>
|
1321
1322
|
|
1322
1323
|
<code class="ruby"> require 'gem_update_checker'</code>
|
1323
1324
|
</li>
|
1324
1325
|
|
1325
|
-
<li class="covered" data-hits="7" data-linenumber="
|
1326
|
+
<li class="covered" data-hits="7" data-linenumber="55">
|
1326
1327
|
<span class="hits">7</span>
|
1327
1328
|
|
1328
1329
|
<code class="ruby"> require 'tmpdir'</code>
|
1329
1330
|
</li>
|
1330
1331
|
|
1331
|
-
<li class="covered" data-hits="7" data-linenumber="
|
1332
|
+
<li class="covered" data-hits="7" data-linenumber="56">
|
1332
1333
|
<span class="hits">7</span>
|
1333
1334
|
|
1334
1335
|
<code class="ruby"> require 'fileutils'</code>
|
1335
1336
|
</li>
|
1336
1337
|
|
1337
|
-
<li class="never" data-hits="" data-linenumber="
|
1338
|
+
<li class="never" data-hits="" data-linenumber="57">
|
1338
1339
|
|
1339
1340
|
|
1340
1341
|
<code class="ruby"></code>
|
1341
1342
|
</li>
|
1342
1343
|
|
1343
|
-
<li class="covered" data-hits="7" data-linenumber="
|
1344
|
+
<li class="covered" data-hits="7" data-linenumber="58">
|
1344
1345
|
<span class="hits">7</span>
|
1345
1346
|
|
1346
1347
|
<code class="ruby"> statefile_path = File.join(Dir.tmpdir, "#{ret[:gem_name]}-#{ret[:gem_installed_version]}.last_update_check")</code>
|
1347
1348
|
</li>
|
1348
1349
|
|
1349
|
-
<li class="never" data-hits="" data-linenumber="
|
1350
|
+
<li class="never" data-hits="" data-linenumber="59">
|
1350
1351
|
|
1351
1352
|
|
1352
1353
|
<code class="ruby"></code>
|
1353
1354
|
</li>
|
1354
1355
|
|
1355
|
-
<li class="covered" data-hits="7" data-linenumber="
|
1356
|
+
<li class="covered" data-hits="7" data-linenumber="60">
|
1356
1357
|
<span class="hits">7</span>
|
1357
1358
|
|
1358
1359
|
<code class="ruby"> last_check_at = nil</code>
|
1359
1360
|
</li>
|
1360
1361
|
|
1361
|
-
<li class="covered" data-hits="7" data-linenumber="
|
1362
|
+
<li class="covered" data-hits="7" data-linenumber="61">
|
1362
1363
|
<span class="hits">7</span>
|
1363
1364
|
|
1364
1365
|
<code class="ruby"> begin</code>
|
1365
1366
|
</li>
|
1366
1367
|
|
1367
|
-
<li class="covered" data-hits="7" data-linenumber="
|
1368
|
+
<li class="covered" data-hits="7" data-linenumber="62">
|
1368
1369
|
<span class="hits">7</span>
|
1369
1370
|
|
1370
1371
|
<code class="ruby"> last_check_at = File.stat(statefile_path).mtime</code>
|
1371
1372
|
</li>
|
1372
1373
|
|
1373
|
-
<li class="never" data-hits="" data-linenumber="
|
1374
|
+
<li class="never" data-hits="" data-linenumber="63">
|
1374
1375
|
|
1375
1376
|
|
1376
|
-
<code class="ruby"> rescue</code>
|
1377
|
+
<code class="ruby"> rescue StandardError</code>
|
1377
1378
|
</li>
|
1378
1379
|
|
1379
|
-
<li class="covered" data-hits="1" data-linenumber="
|
1380
|
+
<li class="covered" data-hits="1" data-linenumber="64">
|
1380
1381
|
<span class="hits">1</span>
|
1381
1382
|
|
1382
1383
|
<code class="ruby"> last_check_at = Time.at(0)</code>
|
1383
1384
|
</li>
|
1384
1385
|
|
1385
|
-
<li class="never" data-hits="" data-linenumber="
|
1386
|
+
<li class="never" data-hits="" data-linenumber="65">
|
1386
1387
|
|
1387
1388
|
|
1388
1389
|
<code class="ruby"> end</code>
|
1389
1390
|
</li>
|
1390
1391
|
|
1391
|
-
<li class="never" data-hits="" data-linenumber="
|
1392
|
+
<li class="never" data-hits="" data-linenumber="66">
|
1392
1393
|
|
1393
1394
|
|
1394
1395
|
<code class="ruby"></code>
|
1395
1396
|
</li>
|
1396
1397
|
|
1397
|
-
<li class="covered" data-hits="7" data-linenumber="
|
1398
|
+
<li class="covered" data-hits="7" data-linenumber="67">
|
1398
1399
|
<span class="hits">7</span>
|
1399
1400
|
|
1400
1401
|
<code class="ruby"> ret.merge!(</code>
|
1401
1402
|
</li>
|
1402
1403
|
|
1403
|
-
<li class="never" data-hits="" data-linenumber="
|
1404
|
+
<li class="never" data-hits="" data-linenumber="68">
|
1404
1405
|
|
1405
1406
|
|
1406
1407
|
<code class="ruby"> last_checked_for_update: last_check_at,</code>
|
1407
1408
|
</li>
|
1408
1409
|
|
1409
|
-
<li class="never" data-hits="" data-linenumber="
|
1410
|
+
<li class="never" data-hits="" data-linenumber="69">
|
1410
1411
|
|
1411
1412
|
|
1412
1413
|
<code class="ruby"> next_check_for_update: last_check_at + opts[:check_interval]</code>
|
1413
1414
|
</li>
|
1414
1415
|
|
1415
|
-
<li class="never" data-hits="" data-linenumber="
|
1416
|
+
<li class="never" data-hits="" data-linenumber="70">
|
1416
1417
|
|
1417
1418
|
|
1418
1419
|
<code class="ruby"> )</code>
|
1419
1420
|
</li>
|
1420
1421
|
|
1421
|
-
<li class="never" data-hits="" data-linenumber="
|
1422
|
+
<li class="never" data-hits="" data-linenumber="71">
|
1422
1423
|
|
1423
1424
|
|
1424
1425
|
<code class="ruby"></code>
|
1425
1426
|
</li>
|
1426
1427
|
|
1427
|
-
<li class="covered" data-hits="7" data-linenumber="
|
1428
|
+
<li class="covered" data-hits="7" data-linenumber="72">
|
1428
1429
|
<span class="hits">7</span>
|
1429
1430
|
|
1430
1431
|
<code class="ruby"> return ret if last_check_at + opts[:check_interval] > Time.now && !opts[:force_check]</code>
|
1431
1432
|
</li>
|
1432
1433
|
|
1433
|
-
<li class="never" data-hits="" data-linenumber="
|
1434
|
+
<li class="never" data-hits="" data-linenumber="73">
|
1434
1435
|
|
1435
1436
|
|
1436
1437
|
<code class="ruby"></code>
|
1437
1438
|
</li>
|
1438
1439
|
|
1439
|
-
<li class="covered" data-hits="6" data-linenumber="
|
1440
|
+
<li class="covered" data-hits="6" data-linenumber="74">
|
1440
1441
|
<span class="hits">6</span>
|
1441
1442
|
|
1442
1443
|
<code class="ruby"> checker = GemUpdateChecker::Client.new(ret[:gem_name], ret[:gem_installed_version])</code>
|
1443
1444
|
</li>
|
1444
1445
|
|
1445
|
-
<li class="covered" data-hits="6" data-linenumber="
|
1446
|
+
<li class="covered" data-hits="6" data-linenumber="75">
|
1446
1447
|
<span class="hits">6</span>
|
1447
1448
|
|
1448
1449
|
<code class="ruby"> last_check_at = Time.now</code>
|
1449
1450
|
</li>
|
1450
1451
|
|
1451
|
-
<li class="never" data-hits="" data-linenumber="
|
1452
|
+
<li class="never" data-hits="" data-linenumber="76">
|
1452
1453
|
|
1453
1454
|
|
1454
1455
|
<code class="ruby"></code>
|
1455
1456
|
</li>
|
1456
1457
|
|
1457
|
-
<li class="covered" data-hits="6" data-linenumber="
|
1458
|
+
<li class="covered" data-hits="6" data-linenumber="77">
|
1458
1459
|
<span class="hits">6</span>
|
1459
1460
|
|
1460
1461
|
<code class="ruby"> ret.merge!(</code>
|
1461
1462
|
</li>
|
1462
1463
|
|
1463
|
-
<li class="never" data-hits="" data-linenumber="
|
1464
|
+
<li class="never" data-hits="" data-linenumber="78">
|
1464
1465
|
|
1465
1466
|
|
1466
1467
|
<code class="ruby"> gem_latest_version: checker.latest_version,</code>
|
1467
1468
|
</li>
|
1468
1469
|
|
1469
|
-
<li class="never" data-hits="" data-linenumber="
|
1470
|
+
<li class="never" data-hits="" data-linenumber="79">
|
1470
1471
|
|
1471
1472
|
|
1472
1473
|
<code class="ruby"> last_checked_for_update: last_check_at,</code>
|
1473
1474
|
</li>
|
1474
1475
|
|
1475
|
-
<li class="never" data-hits="" data-linenumber="
|
1476
|
+
<li class="never" data-hits="" data-linenumber="80">
|
1476
1477
|
|
1477
1478
|
|
1478
1479
|
<code class="ruby"> next_check_for_update: last_check_at + opts[:check_interval],</code>
|
1479
1480
|
</li>
|
1480
1481
|
|
1481
|
-
<li class="never" data-hits="" data-linenumber="
|
1482
|
+
<li class="never" data-hits="" data-linenumber="81">
|
1482
1483
|
|
1483
1484
|
|
1484
1485
|
<code class="ruby"> installed_is_latest: ret[:gem_installed_version] == checker.latest_version,</code>
|
1485
1486
|
</li>
|
1486
1487
|
|
1487
|
-
<li class="never" data-hits="" data-linenumber="
|
1488
|
+
<li class="never" data-hits="" data-linenumber="82">
|
1488
1489
|
|
1489
1490
|
|
1490
1491
|
<code class="ruby"> gem_update_available: Versionomy.parse(ret[:gem_installed_version]) < Versionomy.parse(checker.latest_version)</code>
|
1491
1492
|
</li>
|
1492
1493
|
|
1493
|
-
<li class="never" data-hits="" data-linenumber="
|
1494
|
+
<li class="never" data-hits="" data-linenumber="83">
|
1494
1495
|
|
1495
1496
|
|
1496
1497
|
<code class="ruby"> )</code>
|
1497
1498
|
</li>
|
1498
1499
|
|
1499
|
-
<li class="never" data-hits="" data-linenumber="
|
1500
|
+
<li class="never" data-hits="" data-linenumber="84">
|
1500
1501
|
|
1501
1502
|
|
1502
1503
|
<code class="ruby"></code>
|
1503
1504
|
</li>
|
1504
1505
|
|
1505
|
-
<li class="covered" data-hits="6" data-linenumber="
|
1506
|
+
<li class="covered" data-hits="6" data-linenumber="85">
|
1506
1507
|
<span class="hits">6</span>
|
1507
1508
|
|
1508
1509
|
<code class="ruby"> if ret[:installed_is_latest] || opts[:force_check]</code>
|
1509
1510
|
</li>
|
1510
1511
|
|
1511
|
-
<li class="covered" data-hits="
|
1512
|
-
<span class="hits">
|
1512
|
+
<li class="covered" data-hits="6" data-linenumber="86">
|
1513
|
+
<span class="hits">6</span>
|
1513
1514
|
|
1514
1515
|
<code class="ruby"> FileUtils.touch(statefile_path, mtime: Time.now)</code>
|
1515
1516
|
</li>
|
1516
1517
|
|
1517
|
-
<li class="never" data-hits="" data-linenumber="
|
1518
|
+
<li class="never" data-hits="" data-linenumber="87">
|
1518
1519
|
|
1519
1520
|
|
1520
1521
|
<code class="ruby"> else</code>
|
1521
1522
|
</li>
|
1522
1523
|
|
1523
|
-
<li class="
|
1524
|
-
|
1524
|
+
<li class="missed" data-hits="0" data-linenumber="88">
|
1525
|
+
|
1525
1526
|
|
1526
1527
|
<code class="ruby"> ret[:next_check_for_update] = Time.now</code>
|
1527
1528
|
</li>
|
1528
1529
|
|
1529
|
-
<li class="never" data-hits="" data-linenumber="
|
1530
|
+
<li class="never" data-hits="" data-linenumber="89">
|
1530
1531
|
|
1531
1532
|
|
1532
1533
|
<code class="ruby"> end</code>
|
1533
1534
|
</li>
|
1534
1535
|
|
1535
|
-
<li class="never" data-hits="" data-linenumber="
|
1536
|
+
<li class="never" data-hits="" data-linenumber="90">
|
1536
1537
|
|
1537
1538
|
|
1538
1539
|
<code class="ruby"></code>
|
1539
1540
|
</li>
|
1540
1541
|
|
1541
|
-
<li class="covered" data-hits="6" data-linenumber="
|
1542
|
+
<li class="covered" data-hits="6" data-linenumber="91">
|
1542
1543
|
<span class="hits">6</span>
|
1543
1544
|
|
1544
1545
|
<code class="ruby"> ret</code>
|
1545
1546
|
</li>
|
1546
1547
|
|
1547
|
-
<li class="never" data-hits="" data-linenumber="
|
1548
|
+
<li class="never" data-hits="" data-linenumber="92">
|
1548
1549
|
|
1549
1550
|
|
1550
1551
|
<code class="ruby"> end</code>
|
1551
1552
|
</li>
|
1552
1553
|
|
1553
|
-
<li class="never" data-hits="" data-linenumber="
|
1554
|
+
<li class="never" data-hits="" data-linenumber="93">
|
1554
1555
|
|
1555
1556
|
|
1556
1557
|
<code class="ruby"> end</code>
|
1557
1558
|
</li>
|
1558
1559
|
|
1559
|
-
<li class="never" data-hits="" data-linenumber="
|
1560
|
+
<li class="never" data-hits="" data-linenumber="94">
|
1560
1561
|
|
1561
1562
|
|
1562
1563
|
<code class="ruby"> end</code>
|
1563
1564
|
</li>
|
1564
1565
|
|
1565
|
-
<li class="never" data-hits="" data-linenumber="
|
1566
|
+
<li class="never" data-hits="" data-linenumber="95">
|
1566
1567
|
|
1567
1568
|
|
1568
1569
|
<code class="ruby">end</code>
|
@@ -1571,6 +1572,7 @@
|
|
1571
1572
|
</ol>
|
1572
1573
|
</pre>
|
1573
1574
|
</div>
|
1575
|
+
|
1574
1576
|
|
1575
1577
|
<div class="source_table" id="636c073a27c86cd147d7b0f717311b3b9eded478">
|
1576
1578
|
<div class="header">
|
@@ -1592,289 +1594,295 @@
|
|
1592
1594
|
<code class="ruby"># frozen_string_literal: true</code>
|
1593
1595
|
</li>
|
1594
1596
|
|
1595
|
-
<li class="
|
1597
|
+
<li class="never" data-hits="" data-linenumber="2">
|
1598
|
+
|
1599
|
+
|
1600
|
+
<code class="ruby"></code>
|
1601
|
+
</li>
|
1602
|
+
|
1603
|
+
<li class="covered" data-hits="1" data-linenumber="3">
|
1596
1604
|
<span class="hits">1</span>
|
1597
1605
|
|
1598
1606
|
<code class="ruby">module BB</code>
|
1599
1607
|
</li>
|
1600
1608
|
|
1601
|
-
<li class="never" data-hits="" data-linenumber="
|
1609
|
+
<li class="never" data-hits="" data-linenumber="4">
|
1602
1610
|
|
1603
1611
|
|
1604
1612
|
<code class="ruby"> # Hash utilities.</code>
|
1605
1613
|
</li>
|
1606
1614
|
|
1607
|
-
<li class="covered" data-hits="1" data-linenumber="
|
1615
|
+
<li class="covered" data-hits="1" data-linenumber="5">
|
1608
1616
|
<span class="hits">1</span>
|
1609
1617
|
|
1610
1618
|
<code class="ruby"> module Hash</code>
|
1611
1619
|
</li>
|
1612
1620
|
|
1613
|
-
<li class="covered" data-hits="1" data-linenumber="
|
1621
|
+
<li class="covered" data-hits="1" data-linenumber="6">
|
1614
1622
|
<span class="hits">1</span>
|
1615
1623
|
|
1616
1624
|
<code class="ruby"> class << self</code>
|
1617
1625
|
</li>
|
1618
1626
|
|
1619
|
-
<li class="never" data-hits="" data-linenumber="
|
1627
|
+
<li class="never" data-hits="" data-linenumber="7">
|
1620
1628
|
|
1621
1629
|
|
1622
1630
|
<code class="ruby"> # Symbolize all top level keys.</code>
|
1623
1631
|
</li>
|
1624
1632
|
|
1625
|
-
<li class="never" data-hits="" data-linenumber="
|
1633
|
+
<li class="never" data-hits="" data-linenumber="8">
|
1626
1634
|
|
1627
1635
|
|
1628
1636
|
<code class="ruby"> #</code>
|
1629
1637
|
</li>
|
1630
1638
|
|
1631
|
-
<li class="never" data-hits="" data-linenumber="
|
1639
|
+
<li class="never" data-hits="" data-linenumber="9">
|
1632
1640
|
|
1633
1641
|
|
1634
1642
|
<code class="ruby"> # @param [Hash] hash Input hash</code>
|
1635
1643
|
</li>
|
1636
1644
|
|
1637
|
-
<li class="never" data-hits="" data-linenumber="
|
1645
|
+
<li class="never" data-hits="" data-linenumber="10">
|
1638
1646
|
|
1639
1647
|
|
1640
1648
|
<code class="ruby"> # @return [Hash] Output hash (with symbolized keys)</code>
|
1641
1649
|
</li>
|
1642
1650
|
|
1643
|
-
<li class="covered" data-hits="1" data-linenumber="
|
1651
|
+
<li class="covered" data-hits="1" data-linenumber="11">
|
1644
1652
|
<span class="hits">1</span>
|
1645
1653
|
|
1646
1654
|
<code class="ruby"> def symbolize_keys(hash)</code>
|
1647
1655
|
</li>
|
1648
1656
|
|
1649
|
-
<li class="covered" data-hits="112" data-linenumber="
|
1657
|
+
<li class="covered" data-hits="112" data-linenumber="12">
|
1650
1658
|
<span class="hits">112</span>
|
1651
1659
|
|
1652
1660
|
<code class="ruby"> hash.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }</code>
|
1653
1661
|
</li>
|
1654
1662
|
|
1655
|
-
<li class="never" data-hits="" data-linenumber="
|
1663
|
+
<li class="never" data-hits="" data-linenumber="13">
|
1656
1664
|
|
1657
1665
|
|
1658
1666
|
<code class="ruby"> end</code>
|
1659
1667
|
</li>
|
1660
1668
|
|
1661
|
-
<li class="never" data-hits="" data-linenumber="
|
1669
|
+
<li class="never" data-hits="" data-linenumber="14">
|
1662
1670
|
|
1663
1671
|
|
1664
1672
|
<code class="ruby"></code>
|
1665
1673
|
</li>
|
1666
1674
|
|
1667
|
-
<li class="never" data-hits="" data-linenumber="
|
1675
|
+
<li class="never" data-hits="" data-linenumber="15">
|
1668
1676
|
|
1669
1677
|
|
1670
1678
|
<code class="ruby"> # Recursively flatten a hash to property-style format.</code>
|
1671
1679
|
</li>
|
1672
1680
|
|
1673
|
-
<li class="never" data-hits="" data-linenumber="
|
1681
|
+
<li class="never" data-hits="" data-linenumber="16">
|
1674
1682
|
|
1675
1683
|
|
1676
1684
|
<code class="ruby"> # This is a lossy conversion and should only be used for display-purposes.</code>
|
1677
1685
|
</li>
|
1678
1686
|
|
1679
|
-
<li class="never" data-hits="" data-linenumber="
|
1687
|
+
<li class="never" data-hits="" data-linenumber="17">
|
1680
1688
|
|
1681
1689
|
|
1682
1690
|
<code class="ruby"> #</code>
|
1683
1691
|
</li>
|
1684
1692
|
|
1685
|
-
<li class="never" data-hits="" data-linenumber="
|
1693
|
+
<li class="never" data-hits="" data-linenumber="18">
|
1686
1694
|
|
1687
1695
|
|
1688
1696
|
<code class="ruby"> # @example</code>
|
1689
1697
|
</li>
|
1690
1698
|
|
1691
|
-
<li class="never" data-hits="" data-linenumber="
|
1699
|
+
<li class="never" data-hits="" data-linenumber="19">
|
1692
1700
|
|
1693
1701
|
|
1694
1702
|
<code class="ruby"> # input = { :a => { :b => :c } }</code>
|
1695
1703
|
</li>
|
1696
1704
|
|
1697
|
-
<li class="never" data-hits="" data-linenumber="
|
1705
|
+
<li class="never" data-hits="" data-linenumber="20">
|
1698
1706
|
|
1699
1707
|
|
1700
1708
|
<code class="ruby"> # BB::Hash.flatten_prop_style(input)</code>
|
1701
1709
|
</li>
|
1702
1710
|
|
1703
|
-
<li class="never" data-hits="" data-linenumber="
|
1711
|
+
<li class="never" data-hits="" data-linenumber="21">
|
1704
1712
|
|
1705
1713
|
|
1706
1714
|
<code class="ruby"> # => {"a.b"=>:c}</code>
|
1707
1715
|
</li>
|
1708
1716
|
|
1709
|
-
<li class="never" data-hits="" data-linenumber="
|
1717
|
+
<li class="never" data-hits="" data-linenumber="22">
|
1710
1718
|
|
1711
1719
|
|
1712
1720
|
<code class="ruby"> #</code>
|
1713
1721
|
</li>
|
1714
1722
|
|
1715
|
-
<li class="never" data-hits="" data-linenumber="
|
1723
|
+
<li class="never" data-hits="" data-linenumber="23">
|
1716
1724
|
|
1717
1725
|
|
1718
1726
|
<code class="ruby"> # @example</code>
|
1719
1727
|
</li>
|
1720
1728
|
|
1721
|
-
<li class="never" data-hits="" data-linenumber="
|
1729
|
+
<li class="never" data-hits="" data-linenumber="24">
|
1722
1730
|
|
1723
1731
|
|
1724
1732
|
<code class="ruby"> # input = { :a => { :b => [:c, :d, :e] } }</code>
|
1725
1733
|
</li>
|
1726
1734
|
|
1727
|
-
<li class="never" data-hits="" data-linenumber="
|
1735
|
+
<li class="never" data-hits="" data-linenumber="25">
|
1728
1736
|
|
1729
1737
|
|
1730
1738
|
<code class="ruby"> # BB::Hash.flatten_prop_style(input)</code>
|
1731
1739
|
</li>
|
1732
1740
|
|
1733
|
-
<li class="never" data-hits="" data-linenumber="
|
1741
|
+
<li class="never" data-hits="" data-linenumber="26">
|
1734
1742
|
|
1735
1743
|
|
1736
1744
|
<code class="ruby"> # => {"a.b"=>"c,d,e"}</code>
|
1737
1745
|
</li>
|
1738
1746
|
|
1739
|
-
<li class="never" data-hits="" data-linenumber="
|
1747
|
+
<li class="never" data-hits="" data-linenumber="27">
|
1740
1748
|
|
1741
1749
|
|
1742
1750
|
<code class="ruby"> #</code>
|
1743
1751
|
</li>
|
1744
1752
|
|
1745
|
-
<li class="never" data-hits="" data-linenumber="
|
1753
|
+
<li class="never" data-hits="" data-linenumber="28">
|
1746
1754
|
|
1747
1755
|
|
1748
1756
|
<code class="ruby"> # @param [Hash] input Input hash</code>
|
1749
1757
|
</li>
|
1750
1758
|
|
1751
|
-
<li class="never" data-hits="" data-linenumber="
|
1759
|
+
<li class="never" data-hits="" data-linenumber="29">
|
1752
1760
|
|
1753
1761
|
|
1754
1762
|
<code class="ruby"> # @param [Hash] opts Options</code>
|
1755
1763
|
</li>
|
1756
1764
|
|
1757
|
-
<li class="never" data-hits="" data-linenumber="
|
1765
|
+
<li class="never" data-hits="" data-linenumber="30">
|
1758
1766
|
|
1759
1767
|
|
1760
1768
|
<code class="ruby"> # @option opts [String] :delimiter</code>
|
1761
1769
|
</li>
|
1762
1770
|
|
1763
|
-
<li class="never" data-hits="" data-linenumber="
|
1771
|
+
<li class="never" data-hits="" data-linenumber="31">
|
1764
1772
|
|
1765
1773
|
|
1766
1774
|
<code class="ruby"> # Key delimiter (Default: '.')</code>
|
1767
1775
|
</li>
|
1768
1776
|
|
1769
|
-
<li class="never" data-hits="" data-linenumber="
|
1777
|
+
<li class="never" data-hits="" data-linenumber="32">
|
1770
1778
|
|
1771
1779
|
|
1772
1780
|
<code class="ruby"> # @param [Hash] output (leave this blank)</code>
|
1773
1781
|
</li>
|
1774
1782
|
|
1775
|
-
<li class="never" data-hits="" data-linenumber="
|
1783
|
+
<li class="never" data-hits="" data-linenumber="33">
|
1776
1784
|
|
1777
1785
|
|
1778
1786
|
<code class="ruby"> # @return [Hash] Output hash (flattened)</code>
|
1779
1787
|
</li>
|
1780
1788
|
|
1781
|
-
<li class="covered" data-hits="1" data-linenumber="
|
1789
|
+
<li class="covered" data-hits="1" data-linenumber="34">
|
1782
1790
|
<span class="hits">1</span>
|
1783
1791
|
|
1784
1792
|
<code class="ruby"> def flatten_prop_style(input = {}, opts = {}, output = {})</code>
|
1785
1793
|
</li>
|
1786
1794
|
|
1787
|
-
<li class="covered" data-hits="10" data-linenumber="
|
1795
|
+
<li class="covered" data-hits="10" data-linenumber="35">
|
1788
1796
|
<span class="hits">10</span>
|
1789
1797
|
|
1790
1798
|
<code class="ruby"> input.each do |key, value|</code>
|
1791
1799
|
</li>
|
1792
1800
|
|
1793
|
-
<li class="covered" data-hits="22" data-linenumber="
|
1801
|
+
<li class="covered" data-hits="22" data-linenumber="36">
|
1794
1802
|
<span class="hits">22</span>
|
1795
1803
|
|
1796
1804
|
<code class="ruby"> key = opts[:prefix].nil? ? key.to_s : "#{opts[:prefix]}#{opts[:delimiter] || '.'}#{key}"</code>
|
1797
1805
|
</li>
|
1798
1806
|
|
1799
|
-
<li class="covered" data-hits="22" data-linenumber="
|
1807
|
+
<li class="covered" data-hits="22" data-linenumber="37">
|
1800
1808
|
<span class="hits">22</span>
|
1801
1809
|
|
1802
1810
|
<code class="ruby"> case value</code>
|
1803
1811
|
</li>
|
1804
1812
|
|
1805
|
-
<li class="never" data-hits="" data-linenumber="
|
1813
|
+
<li class="never" data-hits="" data-linenumber="38">
|
1806
1814
|
|
1807
1815
|
|
1808
1816
|
<code class="ruby"> when ::Hash</code>
|
1809
1817
|
</li>
|
1810
1818
|
|
1811
|
-
<li class="covered" data-hits="9" data-linenumber="
|
1819
|
+
<li class="covered" data-hits="9" data-linenumber="39">
|
1812
1820
|
<span class="hits">9</span>
|
1813
1821
|
|
1814
1822
|
<code class="ruby"> flatten_prop_style(value, opts.merge(prefix: key), output)</code>
|
1815
1823
|
</li>
|
1816
1824
|
|
1817
|
-
<li class="never" data-hits="" data-linenumber="
|
1825
|
+
<li class="never" data-hits="" data-linenumber="40">
|
1818
1826
|
|
1819
1827
|
|
1820
1828
|
<code class="ruby"> when Array</code>
|
1821
1829
|
</li>
|
1822
1830
|
|
1823
|
-
<li class="covered" data-hits="4" data-linenumber="
|
1831
|
+
<li class="covered" data-hits="4" data-linenumber="41">
|
1824
1832
|
<span class="hits">4</span>
|
1825
1833
|
|
1826
1834
|
<code class="ruby"> output[key] = value.join(',')</code>
|
1827
1835
|
</li>
|
1828
1836
|
|
1829
|
-
<li class="never" data-hits="" data-linenumber="
|
1837
|
+
<li class="never" data-hits="" data-linenumber="42">
|
1830
1838
|
|
1831
1839
|
|
1832
1840
|
<code class="ruby"> else</code>
|
1833
1841
|
</li>
|
1834
1842
|
|
1835
|
-
<li class="covered" data-hits="9" data-linenumber="
|
1843
|
+
<li class="covered" data-hits="9" data-linenumber="43">
|
1836
1844
|
<span class="hits">9</span>
|
1837
1845
|
|
1838
1846
|
<code class="ruby"> output[key] = value</code>
|
1839
1847
|
</li>
|
1840
1848
|
|
1841
|
-
<li class="never" data-hits="" data-linenumber="
|
1849
|
+
<li class="never" data-hits="" data-linenumber="44">
|
1842
1850
|
|
1843
1851
|
|
1844
1852
|
<code class="ruby"> end</code>
|
1845
1853
|
</li>
|
1846
1854
|
|
1847
|
-
<li class="never" data-hits="" data-linenumber="
|
1855
|
+
<li class="never" data-hits="" data-linenumber="45">
|
1848
1856
|
|
1849
1857
|
|
1850
1858
|
<code class="ruby"> end</code>
|
1851
1859
|
</li>
|
1852
1860
|
|
1853
|
-
<li class="covered" data-hits="10" data-linenumber="
|
1861
|
+
<li class="covered" data-hits="10" data-linenumber="46">
|
1854
1862
|
<span class="hits">10</span>
|
1855
1863
|
|
1856
1864
|
<code class="ruby"> output</code>
|
1857
1865
|
</li>
|
1858
1866
|
|
1859
|
-
<li class="never" data-hits="" data-linenumber="
|
1867
|
+
<li class="never" data-hits="" data-linenumber="47">
|
1860
1868
|
|
1861
1869
|
|
1862
1870
|
<code class="ruby"> end</code>
|
1863
1871
|
</li>
|
1864
1872
|
|
1865
|
-
<li class="never" data-hits="" data-linenumber="
|
1873
|
+
<li class="never" data-hits="" data-linenumber="48">
|
1866
1874
|
|
1867
1875
|
|
1868
1876
|
<code class="ruby"> end</code>
|
1869
1877
|
</li>
|
1870
1878
|
|
1871
|
-
<li class="never" data-hits="" data-linenumber="
|
1879
|
+
<li class="never" data-hits="" data-linenumber="49">
|
1872
1880
|
|
1873
1881
|
|
1874
1882
|
<code class="ruby"> end</code>
|
1875
1883
|
</li>
|
1876
1884
|
|
1877
|
-
<li class="never" data-hits="" data-linenumber="
|
1885
|
+
<li class="never" data-hits="" data-linenumber="50">
|
1878
1886
|
|
1879
1887
|
|
1880
1888
|
<code class="ruby">end</code>
|
@@ -1883,14 +1891,15 @@
|
|
1883
1891
|
</ol>
|
1884
1892
|
</pre>
|
1885
1893
|
</div>
|
1894
|
+
|
1886
1895
|
|
1887
1896
|
<div class="source_table" id="09e4da465507022615e91e2292a827cde0e5535c">
|
1888
1897
|
<div class="header">
|
1889
1898
|
<h3>lib/blackbox/number.rb</h3>
|
1890
1899
|
<h4><span class="green">100.0 %</span> covered</h4>
|
1891
1900
|
<div>
|
1892
|
-
<b>
|
1893
|
-
<span class="green"><b>
|
1901
|
+
<b>55</b> relevant lines.
|
1902
|
+
<span class="green"><b>55</b> lines covered</span> and
|
1894
1903
|
<span class="red"><b>0</b> lines missed.</span>
|
1895
1904
|
</div>
|
1896
1905
|
</div>
|
@@ -1904,1081 +1913,1087 @@
|
|
1904
1913
|
<code class="ruby"># frozen_string_literal: true</code>
|
1905
1914
|
</li>
|
1906
1915
|
|
1907
|
-
<li class="
|
1916
|
+
<li class="never" data-hits="" data-linenumber="2">
|
1917
|
+
|
1918
|
+
|
1919
|
+
<code class="ruby"></code>
|
1920
|
+
</li>
|
1921
|
+
|
1922
|
+
<li class="covered" data-hits="1" data-linenumber="3">
|
1908
1923
|
<span class="hits">1</span>
|
1909
1924
|
|
1910
1925
|
<code class="ruby">require 'blackbox/hash'</code>
|
1911
1926
|
</li>
|
1912
1927
|
|
1913
|
-
<li class="never" data-hits="" data-linenumber="
|
1928
|
+
<li class="never" data-hits="" data-linenumber="4">
|
1914
1929
|
|
1915
1930
|
|
1916
1931
|
<code class="ruby"></code>
|
1917
1932
|
</li>
|
1918
1933
|
|
1919
|
-
<li class="covered" data-hits="1" data-linenumber="
|
1934
|
+
<li class="covered" data-hits="1" data-linenumber="5">
|
1920
1935
|
<span class="hits">1</span>
|
1921
1936
|
|
1922
1937
|
<code class="ruby">module BB</code>
|
1923
1938
|
</li>
|
1924
1939
|
|
1925
|
-
<li class="never" data-hits="" data-linenumber="
|
1940
|
+
<li class="never" data-hits="" data-linenumber="6">
|
1926
1941
|
|
1927
1942
|
|
1928
1943
|
<code class="ruby"> # String utilities.</code>
|
1929
1944
|
</li>
|
1930
1945
|
|
1931
|
-
<li class="covered" data-hits="1" data-linenumber="
|
1946
|
+
<li class="covered" data-hits="1" data-linenumber="7">
|
1932
1947
|
<span class="hits">1</span>
|
1933
1948
|
|
1934
1949
|
<code class="ruby"> module Number</code>
|
1935
1950
|
</li>
|
1936
1951
|
|
1937
|
-
<li class="covered" data-hits="1" data-linenumber="
|
1952
|
+
<li class="covered" data-hits="1" data-linenumber="8">
|
1938
1953
|
<span class="hits">1</span>
|
1939
1954
|
|
1940
1955
|
<code class="ruby"> class << self</code>
|
1941
1956
|
</li>
|
1942
1957
|
|
1943
|
-
<li class="covered" data-hits="1" data-linenumber="
|
1958
|
+
<li class="covered" data-hits="1" data-linenumber="9">
|
1944
1959
|
<span class="hits">1</span>
|
1945
1960
|
|
1946
|
-
<code class="ruby"> STORAGE_UNITS = %w
|
1961
|
+
<code class="ruby"> STORAGE_UNITS = %w[byte k M G T P E Z Y].freeze</code>
|
1947
1962
|
</li>
|
1948
1963
|
|
1949
|
-
<li class="never" data-hits="" data-linenumber="
|
1964
|
+
<li class="never" data-hits="" data-linenumber="10">
|
1950
1965
|
|
1951
1966
|
|
1952
1967
|
<code class="ruby"></code>
|
1953
1968
|
</li>
|
1954
1969
|
|
1955
|
-
<li class="never" data-hits="" data-linenumber="
|
1970
|
+
<li class="never" data-hits="" data-linenumber="11">
|
1956
1971
|
|
1957
1972
|
|
1958
1973
|
<code class="ruby"> ##</code>
|
1959
1974
|
</li>
|
1960
1975
|
|
1961
|
-
<li class="never" data-hits="" data-linenumber="
|
1976
|
+
<li class="never" data-hits="" data-linenumber="12">
|
1962
1977
|
|
1963
1978
|
|
1964
1979
|
<code class="ruby"> # Formats the bytes in +number+ into a more understandable representation</code>
|
1965
1980
|
</li>
|
1966
1981
|
|
1967
|
-
<li class="never" data-hits="" data-linenumber="
|
1982
|
+
<li class="never" data-hits="" data-linenumber="13">
|
1968
1983
|
|
1969
1984
|
|
1970
1985
|
<code class="ruby"> # (e.g., giving it 1500 yields 1.5k). This method is useful for</code>
|
1971
1986
|
</li>
|
1972
1987
|
|
1973
|
-
<li class="never" data-hits="" data-linenumber="
|
1988
|
+
<li class="never" data-hits="" data-linenumber="14">
|
1974
1989
|
|
1975
1990
|
|
1976
1991
|
<code class="ruby"> # reporting file sizes to users. This method returns nil if</code>
|
1977
1992
|
</li>
|
1978
1993
|
|
1979
|
-
<li class="never" data-hits="" data-linenumber="
|
1994
|
+
<li class="never" data-hits="" data-linenumber="15">
|
1980
1995
|
|
1981
1996
|
|
1982
1997
|
<code class="ruby"> # +number+ cannot be converted into a number. You can customize the</code>
|
1983
1998
|
</li>
|
1984
1999
|
|
1985
|
-
<li class="never" data-hits="" data-linenumber="
|
2000
|
+
<li class="never" data-hits="" data-linenumber="16">
|
1986
2001
|
|
1987
2002
|
|
1988
2003
|
<code class="ruby"> # format in the +options+ hash.</code>
|
1989
2004
|
</li>
|
1990
2005
|
|
1991
|
-
<li class="never" data-hits="" data-linenumber="
|
2006
|
+
<li class="never" data-hits="" data-linenumber="17">
|
1992
2007
|
|
1993
2008
|
|
1994
2009
|
<code class="ruby"> #</code>
|
1995
2010
|
</li>
|
1996
2011
|
|
1997
|
-
<li class="never" data-hits="" data-linenumber="
|
2012
|
+
<li class="never" data-hits="" data-linenumber="18">
|
1998
2013
|
|
1999
2014
|
|
2000
2015
|
<code class="ruby"> # @overload to_human_size(number, options={})</code>
|
2001
2016
|
</li>
|
2002
2017
|
|
2003
|
-
<li class="never" data-hits="" data-linenumber="
|
2018
|
+
<li class="never" data-hits="" data-linenumber="19">
|
2004
2019
|
|
2005
2020
|
|
2006
2021
|
<code class="ruby"> # @param [Fixnum] number</code>
|
2007
2022
|
</li>
|
2008
2023
|
|
2009
|
-
<li class="never" data-hits="" data-linenumber="
|
2024
|
+
<li class="never" data-hits="" data-linenumber="20">
|
2010
2025
|
|
2011
2026
|
|
2012
2027
|
<code class="ruby"> # Number value to format.</code>
|
2013
2028
|
</li>
|
2014
2029
|
|
2015
|
-
<li class="never" data-hits="" data-linenumber="
|
2030
|
+
<li class="never" data-hits="" data-linenumber="21">
|
2016
2031
|
|
2017
2032
|
|
2018
2033
|
<code class="ruby"> # @param [Hash] options</code>
|
2019
2034
|
</li>
|
2020
2035
|
|
2021
|
-
<li class="never" data-hits="" data-linenumber="
|
2036
|
+
<li class="never" data-hits="" data-linenumber="22">
|
2022
2037
|
|
2023
2038
|
|
2024
2039
|
<code class="ruby"> # Options for formatter.</code>
|
2025
2040
|
</li>
|
2026
2041
|
|
2027
|
-
<li class="never" data-hits="" data-linenumber="
|
2042
|
+
<li class="never" data-hits="" data-linenumber="23">
|
2028
2043
|
|
2029
2044
|
|
2030
2045
|
<code class="ruby"> # @option options [Fixnum] :precision (1)</code>
|
2031
2046
|
</li>
|
2032
2047
|
|
2033
|
-
<li class="never" data-hits="" data-linenumber="
|
2048
|
+
<li class="never" data-hits="" data-linenumber="24">
|
2034
2049
|
|
2035
2050
|
|
2036
2051
|
<code class="ruby"> # Sets the level of precision.</code>
|
2037
2052
|
</li>
|
2038
2053
|
|
2039
|
-
<li class="never" data-hits="" data-linenumber="
|
2054
|
+
<li class="never" data-hits="" data-linenumber="25">
|
2040
2055
|
|
2041
2056
|
|
2042
2057
|
<code class="ruby"> # @option options [String] :separator (".")</code>
|
2043
2058
|
</li>
|
2044
2059
|
|
2045
|
-
<li class="never" data-hits="" data-linenumber="
|
2060
|
+
<li class="never" data-hits="" data-linenumber="26">
|
2046
2061
|
|
2047
2062
|
|
2048
2063
|
<code class="ruby"> # Sets the separator between the units.</code>
|
2049
2064
|
</li>
|
2050
2065
|
|
2051
|
-
<li class="never" data-hits="" data-linenumber="
|
2066
|
+
<li class="never" data-hits="" data-linenumber="27">
|
2052
2067
|
|
2053
2068
|
|
2054
2069
|
<code class="ruby"> # @option options [String] :delimiter ("")</code>
|
2055
2070
|
</li>
|
2056
2071
|
|
2057
|
-
<li class="never" data-hits="" data-linenumber="
|
2072
|
+
<li class="never" data-hits="" data-linenumber="28">
|
2058
2073
|
|
2059
2074
|
|
2060
2075
|
<code class="ruby"> # Sets the thousands delimiter.</code>
|
2061
2076
|
</li>
|
2062
2077
|
|
2063
|
-
<li class="never" data-hits="" data-linenumber="
|
2078
|
+
<li class="never" data-hits="" data-linenumber="29">
|
2064
2079
|
|
2065
2080
|
|
2066
2081
|
<code class="ruby"> # @option options [String] :kilo (1024)</code>
|
2067
2082
|
</li>
|
2068
2083
|
|
2069
|
-
<li class="never" data-hits="" data-linenumber="
|
2084
|
+
<li class="never" data-hits="" data-linenumber="30">
|
2070
2085
|
|
2071
2086
|
|
2072
2087
|
<code class="ruby"> # Sets the number of bytes in a kilobyte.</code>
|
2073
2088
|
</li>
|
2074
2089
|
|
2075
|
-
<li class="never" data-hits="" data-linenumber="
|
2090
|
+
<li class="never" data-hits="" data-linenumber="31">
|
2076
2091
|
|
2077
2092
|
|
2078
2093
|
<code class="ruby"> # @option options [String] :format ("%n%u")</code>
|
2079
2094
|
</li>
|
2080
2095
|
|
2081
|
-
<li class="never" data-hits="" data-linenumber="
|
2096
|
+
<li class="never" data-hits="" data-linenumber="32">
|
2082
2097
|
|
2083
2098
|
|
2084
2099
|
<code class="ruby"> # Sets the display format.</code>
|
2085
2100
|
</li>
|
2086
2101
|
|
2087
|
-
<li class="never" data-hits="" data-linenumber="
|
2102
|
+
<li class="never" data-hits="" data-linenumber="33">
|
2088
2103
|
|
2089
2104
|
|
2090
2105
|
<code class="ruby"> #</code>
|
2091
2106
|
</li>
|
2092
2107
|
|
2093
|
-
<li class="never" data-hits="" data-linenumber="
|
2108
|
+
<li class="never" data-hits="" data-linenumber="34">
|
2094
2109
|
|
2095
2110
|
|
2096
2111
|
<code class="ruby"> # @return [String] The formatted representation of bytes</code>
|
2097
2112
|
</li>
|
2098
2113
|
|
2099
|
-
<li class="never" data-hits="" data-linenumber="
|
2114
|
+
<li class="never" data-hits="" data-linenumber="35">
|
2100
2115
|
|
2101
2116
|
|
2102
2117
|
<code class="ruby"> #</code>
|
2103
2118
|
</li>
|
2104
2119
|
|
2105
|
-
<li class="never" data-hits="" data-linenumber="
|
2120
|
+
<li class="never" data-hits="" data-linenumber="36">
|
2106
2121
|
|
2107
2122
|
|
2108
2123
|
<code class="ruby"> # @example</code>
|
2109
2124
|
</li>
|
2110
2125
|
|
2111
|
-
<li class="never" data-hits="" data-linenumber="
|
2126
|
+
<li class="never" data-hits="" data-linenumber="37">
|
2112
2127
|
|
2113
2128
|
|
2114
2129
|
<code class="ruby"> # to_human_size(123) # => 123</code>
|
2115
2130
|
</li>
|
2116
2131
|
|
2117
|
-
<li class="never" data-hits="" data-linenumber="
|
2132
|
+
<li class="never" data-hits="" data-linenumber="38">
|
2118
2133
|
|
2119
2134
|
|
2120
2135
|
<code class="ruby"> # to_human_size(1234) # => 1.2k</code>
|
2121
2136
|
</li>
|
2122
2137
|
|
2123
|
-
<li class="never" data-hits="" data-linenumber="
|
2138
|
+
<li class="never" data-hits="" data-linenumber="39">
|
2124
2139
|
|
2125
2140
|
|
2126
2141
|
<code class="ruby"> # to_human_size(12345) # => 12.1k</code>
|
2127
2142
|
</li>
|
2128
2143
|
|
2129
|
-
<li class="never" data-hits="" data-linenumber="
|
2144
|
+
<li class="never" data-hits="" data-linenumber="40">
|
2130
2145
|
|
2131
2146
|
|
2132
2147
|
<code class="ruby"> # to_human_size(1234567) # => 1.2M</code>
|
2133
2148
|
</li>
|
2134
2149
|
|
2135
|
-
<li class="never" data-hits="" data-linenumber="
|
2150
|
+
<li class="never" data-hits="" data-linenumber="41">
|
2136
2151
|
|
2137
2152
|
|
2138
2153
|
<code class="ruby"> # to_human_size(1234567890) # => 1.1G</code>
|
2139
2154
|
</li>
|
2140
2155
|
|
2141
|
-
<li class="never" data-hits="" data-linenumber="
|
2156
|
+
<li class="never" data-hits="" data-linenumber="42">
|
2142
2157
|
|
2143
2158
|
|
2144
2159
|
<code class="ruby"> # to_human_size(1234567890123) # => 1.1T</code>
|
2145
2160
|
</li>
|
2146
2161
|
|
2147
|
-
<li class="never" data-hits="" data-linenumber="
|
2162
|
+
<li class="never" data-hits="" data-linenumber="43">
|
2148
2163
|
|
2149
2164
|
|
2150
2165
|
<code class="ruby"> # to_human_size(1234567, :precision => 2) # => 1.18M</code>
|
2151
2166
|
</li>
|
2152
2167
|
|
2153
|
-
<li class="never" data-hits="" data-linenumber="
|
2168
|
+
<li class="never" data-hits="" data-linenumber="44">
|
2154
2169
|
|
2155
2170
|
|
2156
2171
|
<code class="ruby"> # to_human_size(483989, :precision => 0) # => 473k</code>
|
2157
2172
|
</li>
|
2158
2173
|
|
2159
|
-
<li class="never" data-hits="" data-linenumber="
|
2174
|
+
<li class="never" data-hits="" data-linenumber="45">
|
2160
2175
|
|
2161
2176
|
|
2162
2177
|
<code class="ruby"> # to_human_size(1234567, :precision => 2, :separator => ',') # => 1,18M</code>
|
2163
2178
|
</li>
|
2164
2179
|
|
2165
|
-
<li class="never" data-hits="" data-linenumber="
|
2180
|
+
<li class="never" data-hits="" data-linenumber="46">
|
2166
2181
|
|
2167
2182
|
|
2168
2183
|
<code class="ruby"> #</code>
|
2169
2184
|
</li>
|
2170
2185
|
|
2171
|
-
<li class="covered" data-hits="1" data-linenumber="
|
2186
|
+
<li class="covered" data-hits="1" data-linenumber="47">
|
2172
2187
|
<span class="hits">1</span>
|
2173
2188
|
|
2174
2189
|
<code class="ruby"> def to_human_size(number, args = {})</code>
|
2175
2190
|
</li>
|
2176
2191
|
|
2177
|
-
<li class="covered" data-hits="13" data-linenumber="
|
2192
|
+
<li class="covered" data-hits="13" data-linenumber="48">
|
2178
2193
|
<span class="hits">13</span>
|
2179
2194
|
|
2180
2195
|
<code class="ruby"> begin</code>
|
2181
2196
|
</li>
|
2182
2197
|
|
2183
|
-
<li class="covered" data-hits="13" data-linenumber="
|
2198
|
+
<li class="covered" data-hits="13" data-linenumber="49">
|
2184
2199
|
<span class="hits">13</span>
|
2185
2200
|
|
2186
2201
|
<code class="ruby"> Float(number)</code>
|
2187
2202
|
</li>
|
2188
2203
|
|
2189
|
-
<li class="never" data-hits="" data-linenumber="
|
2204
|
+
<li class="never" data-hits="" data-linenumber="50">
|
2190
2205
|
|
2191
2206
|
|
2192
|
-
<code class="ruby"> rescue</code>
|
2207
|
+
<code class="ruby"> rescue StandardError</code>
|
2193
2208
|
</li>
|
2194
2209
|
|
2195
|
-
<li class="covered" data-hits="1" data-linenumber="
|
2210
|
+
<li class="covered" data-hits="1" data-linenumber="51">
|
2196
2211
|
<span class="hits">1</span>
|
2197
2212
|
|
2198
2213
|
<code class="ruby"> return nil</code>
|
2199
2214
|
</li>
|
2200
2215
|
|
2201
|
-
<li class="never" data-hits="" data-linenumber="
|
2216
|
+
<li class="never" data-hits="" data-linenumber="52">
|
2202
2217
|
|
2203
2218
|
|
2204
2219
|
<code class="ruby"> end</code>
|
2205
2220
|
</li>
|
2206
2221
|
|
2207
|
-
<li class="never" data-hits="" data-linenumber="
|
2222
|
+
<li class="never" data-hits="" data-linenumber="53">
|
2208
2223
|
|
2209
2224
|
|
2210
2225
|
<code class="ruby"></code>
|
2211
2226
|
</li>
|
2212
2227
|
|
2213
|
-
<li class="covered" data-hits="12" data-linenumber="
|
2228
|
+
<li class="covered" data-hits="12" data-linenumber="54">
|
2214
2229
|
<span class="hits">12</span>
|
2215
2230
|
|
2216
2231
|
<code class="ruby"> options = BB::Hash.symbolize_keys(args)</code>
|
2217
2232
|
</li>
|
2218
2233
|
|
2219
|
-
<li class="never" data-hits="" data-linenumber="
|
2234
|
+
<li class="never" data-hits="" data-linenumber="55">
|
2220
2235
|
|
2221
2236
|
|
2222
2237
|
<code class="ruby"></code>
|
2223
2238
|
</li>
|
2224
2239
|
|
2225
|
-
<li class="covered" data-hits="12" data-linenumber="
|
2240
|
+
<li class="covered" data-hits="12" data-linenumber="56">
|
2226
2241
|
<span class="hits">12</span>
|
2227
2242
|
|
2228
2243
|
<code class="ruby"> precision ||= (options[:precision] || 1)</code>
|
2229
2244
|
</li>
|
2230
2245
|
|
2231
|
-
<li class="covered" data-hits="12" data-linenumber="
|
2246
|
+
<li class="covered" data-hits="12" data-linenumber="57">
|
2232
2247
|
<span class="hits">12</span>
|
2233
2248
|
|
2234
2249
|
<code class="ruby"> separator ||= (options[:separator] || '.')</code>
|
2235
2250
|
</li>
|
2236
2251
|
|
2237
|
-
<li class="covered" data-hits="12" data-linenumber="
|
2252
|
+
<li class="covered" data-hits="12" data-linenumber="58">
|
2238
2253
|
<span class="hits">12</span>
|
2239
2254
|
|
2240
2255
|
<code class="ruby"> delimiter ||= (options[:delimiter] || '')</code>
|
2241
2256
|
</li>
|
2242
2257
|
|
2243
|
-
<li class="covered" data-hits="12" data-linenumber="
|
2258
|
+
<li class="covered" data-hits="12" data-linenumber="59">
|
2244
2259
|
<span class="hits">12</span>
|
2245
2260
|
|
2246
2261
|
<code class="ruby"> kilo ||= (options[:kilo] || 1024)</code>
|
2247
2262
|
</li>
|
2248
2263
|
|
2249
|
-
<li class="covered" data-hits="12" data-linenumber="
|
2264
|
+
<li class="covered" data-hits="12" data-linenumber="60">
|
2250
2265
|
<span class="hits">12</span>
|
2251
2266
|
|
2252
2267
|
<code class="ruby"> storage_units_format ||= (options[:format] || '%n%u')</code>
|
2253
2268
|
</li>
|
2254
2269
|
|
2255
|
-
<li class="never" data-hits="" data-linenumber="
|
2270
|
+
<li class="never" data-hits="" data-linenumber="61">
|
2256
2271
|
|
2257
2272
|
|
2258
2273
|
<code class="ruby"></code>
|
2259
2274
|
</li>
|
2260
2275
|
|
2261
|
-
<li class="covered" data-hits="12" data-linenumber="
|
2276
|
+
<li class="covered" data-hits="12" data-linenumber="62">
|
2262
2277
|
<span class="hits">12</span>
|
2263
2278
|
|
2264
2279
|
<code class="ruby"> begin</code>
|
2265
2280
|
</li>
|
2266
2281
|
|
2267
|
-
<li class="covered" data-hits="12" data-linenumber="
|
2282
|
+
<li class="covered" data-hits="12" data-linenumber="63">
|
2268
2283
|
<span class="hits">12</span>
|
2269
2284
|
|
2270
2285
|
<code class="ruby"> if number.to_i < kilo</code>
|
2271
2286
|
</li>
|
2272
2287
|
|
2273
|
-
<li class="covered" data-hits="1" data-linenumber="
|
2288
|
+
<li class="covered" data-hits="1" data-linenumber="64">
|
2274
2289
|
<span class="hits">1</span>
|
2275
2290
|
|
2276
2291
|
<code class="ruby"> storage_units_format.gsub(/%n/, number.to_i.to_s).gsub(/%u/, '')</code>
|
2277
2292
|
</li>
|
2278
2293
|
|
2279
|
-
<li class="never" data-hits="" data-linenumber="
|
2294
|
+
<li class="never" data-hits="" data-linenumber="65">
|
2280
2295
|
|
2281
2296
|
|
2282
2297
|
<code class="ruby"> else</code>
|
2283
2298
|
</li>
|
2284
2299
|
|
2285
|
-
<li class="covered" data-hits="10" data-linenumber="
|
2300
|
+
<li class="covered" data-hits="10" data-linenumber="66">
|
2286
2301
|
<span class="hits">10</span>
|
2287
2302
|
|
2288
2303
|
<code class="ruby"> max_exp = STORAGE_UNITS.size - 1</code>
|
2289
2304
|
</li>
|
2290
2305
|
|
2291
|
-
<li class="covered" data-hits="10" data-linenumber="
|
2306
|
+
<li class="covered" data-hits="10" data-linenumber="67">
|
2292
2307
|
<span class="hits">10</span>
|
2293
2308
|
|
2294
2309
|
<code class="ruby"> number = Float(number)</code>
|
2295
2310
|
</li>
|
2296
2311
|
|
2297
|
-
<li class="covered" data-hits="10" data-linenumber="
|
2312
|
+
<li class="covered" data-hits="10" data-linenumber="68">
|
2298
2313
|
<span class="hits">10</span>
|
2299
2314
|
|
2300
2315
|
<code class="ruby"> exponent = (Math.log(number) / Math.log(kilo)).to_i # Convert to base</code>
|
2301
2316
|
</li>
|
2302
2317
|
|
2303
|
-
<li class="covered" data-hits="10" data-linenumber="
|
2318
|
+
<li class="covered" data-hits="10" data-linenumber="69">
|
2304
2319
|
<span class="hits">10</span>
|
2305
2320
|
|
2306
2321
|
<code class="ruby"> exponent = max_exp if exponent > max_exp # we need this to avoid overflow for the highest unit</code>
|
2307
2322
|
</li>
|
2308
2323
|
|
2309
|
-
<li class="covered" data-hits="10" data-linenumber="
|
2324
|
+
<li class="covered" data-hits="10" data-linenumber="70">
|
2310
2325
|
<span class="hits">10</span>
|
2311
2326
|
|
2312
2327
|
<code class="ruby"> number /= kilo**exponent</code>
|
2313
2328
|
</li>
|
2314
2329
|
|
2315
|
-
<li class="never" data-hits="" data-linenumber="
|
2330
|
+
<li class="never" data-hits="" data-linenumber="71">
|
2316
2331
|
|
2317
2332
|
|
2318
2333
|
<code class="ruby"></code>
|
2319
2334
|
</li>
|
2320
2335
|
|
2321
|
-
<li class="covered" data-hits="10" data-linenumber="
|
2336
|
+
<li class="covered" data-hits="10" data-linenumber="72">
|
2322
2337
|
<span class="hits">10</span>
|
2323
2338
|
|
2324
2339
|
<code class="ruby"> unit = STORAGE_UNITS[exponent]</code>
|
2325
2340
|
</li>
|
2326
2341
|
|
2327
|
-
<li class="never" data-hits="" data-linenumber="
|
2342
|
+
<li class="never" data-hits="" data-linenumber="73">
|
2328
2343
|
|
2329
2344
|
|
2330
2345
|
<code class="ruby"></code>
|
2331
2346
|
</li>
|
2332
2347
|
|
2333
|
-
<li class="covered" data-hits="10" data-linenumber="
|
2348
|
+
<li class="covered" data-hits="10" data-linenumber="74">
|
2334
2349
|
<span class="hits">10</span>
|
2335
2350
|
|
2336
2351
|
<code class="ruby"> escaped_separator = Regexp.escape(separator)</code>
|
2337
2352
|
</li>
|
2338
2353
|
|
2339
|
-
<li class="covered" data-hits="10" data-linenumber="
|
2354
|
+
<li class="covered" data-hits="10" data-linenumber="75">
|
2340
2355
|
<span class="hits">10</span>
|
2341
2356
|
|
2342
2357
|
<code class="ruby"> formatted_number = with_precision(number,</code>
|
2343
2358
|
</li>
|
2344
2359
|
|
2345
|
-
<li class="never" data-hits="" data-linenumber="
|
2360
|
+
<li class="never" data-hits="" data-linenumber="76">
|
2346
2361
|
|
2347
2362
|
|
2348
2363
|
<code class="ruby"> precision: precision,</code>
|
2349
2364
|
</li>
|
2350
2365
|
|
2351
|
-
<li class="never" data-hits="" data-linenumber="
|
2366
|
+
<li class="never" data-hits="" data-linenumber="77">
|
2352
2367
|
|
2353
2368
|
|
2354
2369
|
<code class="ruby"> separator: separator,</code>
|
2355
2370
|
</li>
|
2356
2371
|
|
2357
|
-
<li class="never" data-hits="" data-linenumber="
|
2372
|
+
<li class="never" data-hits="" data-linenumber="78">
|
2358
2373
|
|
2359
2374
|
|
2360
2375
|
<code class="ruby"> delimiter: delimiter).sub(/(#{escaped_separator})(\d*[1-9])?0+\z/, '\1\2').sub(/#{escaped_separator}\z/, '')</code>
|
2361
2376
|
</li>
|
2362
2377
|
|
2363
|
-
<li class="covered" data-hits="10" data-linenumber="
|
2378
|
+
<li class="covered" data-hits="10" data-linenumber="79">
|
2364
2379
|
<span class="hits">10</span>
|
2365
2380
|
|
2366
2381
|
<code class="ruby"> storage_units_format.gsub(/%n/, formatted_number).gsub(/%u/, unit)</code>
|
2367
2382
|
</li>
|
2368
2383
|
|
2369
|
-
<li class="never" data-hits="" data-linenumber="
|
2384
|
+
<li class="never" data-hits="" data-linenumber="80">
|
2370
2385
|
|
2371
2386
|
|
2372
2387
|
<code class="ruby"> end</code>
|
2373
2388
|
</li>
|
2374
2389
|
|
2375
|
-
<li class="
|
2376
|
-
|
2390
|
+
<li class="covered" data-hits="1" data-linenumber="81">
|
2391
|
+
<span class="hits">1</span>
|
2377
2392
|
|
2378
|
-
<code class="ruby"> rescue</code>
|
2393
|
+
<code class="ruby"> rescue StandardError</code>
|
2379
2394
|
</li>
|
2380
2395
|
|
2381
|
-
<li class="covered" data-hits="1" data-linenumber="
|
2396
|
+
<li class="covered" data-hits="1" data-linenumber="82">
|
2382
2397
|
<span class="hits">1</span>
|
2383
2398
|
|
2384
2399
|
<code class="ruby"> number</code>
|
2385
2400
|
</li>
|
2386
2401
|
|
2387
|
-
<li class="never" data-hits="" data-linenumber="
|
2402
|
+
<li class="never" data-hits="" data-linenumber="83">
|
2388
2403
|
|
2389
2404
|
|
2390
2405
|
<code class="ruby"> end</code>
|
2391
2406
|
</li>
|
2392
2407
|
|
2393
|
-
<li class="never" data-hits="" data-linenumber="
|
2408
|
+
<li class="never" data-hits="" data-linenumber="84">
|
2394
2409
|
|
2395
2410
|
|
2396
2411
|
<code class="ruby"> end</code>
|
2397
2412
|
</li>
|
2398
2413
|
|
2399
|
-
<li class="never" data-hits="" data-linenumber="
|
2414
|
+
<li class="never" data-hits="" data-linenumber="85">
|
2400
2415
|
|
2401
2416
|
|
2402
2417
|
<code class="ruby"></code>
|
2403
2418
|
</li>
|
2404
2419
|
|
2405
|
-
<li class="never" data-hits="" data-linenumber="
|
2420
|
+
<li class="never" data-hits="" data-linenumber="86">
|
2406
2421
|
|
2407
2422
|
|
2408
2423
|
<code class="ruby"> ##</code>
|
2409
2424
|
</li>
|
2410
2425
|
|
2411
|
-
<li class="never" data-hits="" data-linenumber="
|
2426
|
+
<li class="never" data-hits="" data-linenumber="87">
|
2412
2427
|
|
2413
2428
|
|
2414
2429
|
<code class="ruby"> # Formats a +number+ with the specified level of <tt>:precision</tt> (e.g., 112.32 has a precision of 2).</code>
|
2415
2430
|
</li>
|
2416
2431
|
|
2417
|
-
<li class="never" data-hits="" data-linenumber="
|
2432
|
+
<li class="never" data-hits="" data-linenumber="88">
|
2418
2433
|
|
2419
2434
|
|
2420
2435
|
<code class="ruby"> # This method returns nil if +number+ cannot be converted into a number.</code>
|
2421
2436
|
</li>
|
2422
2437
|
|
2423
|
-
<li class="never" data-hits="" data-linenumber="
|
2438
|
+
<li class="never" data-hits="" data-linenumber="89">
|
2424
2439
|
|
2425
2440
|
|
2426
2441
|
<code class="ruby"> # You can customize the format in the +options+ hash.</code>
|
2427
2442
|
</li>
|
2428
2443
|
|
2429
|
-
<li class="never" data-hits="" data-linenumber="
|
2444
|
+
<li class="never" data-hits="" data-linenumber="90">
|
2430
2445
|
|
2431
2446
|
|
2432
2447
|
<code class="ruby"> #</code>
|
2433
2448
|
</li>
|
2434
2449
|
|
2435
|
-
<li class="never" data-hits="" data-linenumber="
|
2450
|
+
<li class="never" data-hits="" data-linenumber="91">
|
2436
2451
|
|
2437
2452
|
|
2438
2453
|
<code class="ruby"> # @overload with_precision(number, options={})</code>
|
2439
2454
|
</li>
|
2440
2455
|
|
2441
|
-
<li class="never" data-hits="" data-linenumber="
|
2456
|
+
<li class="never" data-hits="" data-linenumber="92">
|
2442
2457
|
|
2443
2458
|
|
2444
2459
|
<code class="ruby"> # @param [Fixnum, Float] number</code>
|
2445
2460
|
</li>
|
2446
2461
|
|
2447
|
-
<li class="never" data-hits="" data-linenumber="
|
2462
|
+
<li class="never" data-hits="" data-linenumber="93">
|
2448
2463
|
|
2449
2464
|
|
2450
2465
|
<code class="ruby"> # Number value to format.</code>
|
2451
2466
|
</li>
|
2452
2467
|
|
2453
|
-
<li class="never" data-hits="" data-linenumber="
|
2468
|
+
<li class="never" data-hits="" data-linenumber="94">
|
2454
2469
|
|
2455
2470
|
|
2456
2471
|
<code class="ruby"> # @param [Hash] options</code>
|
2457
2472
|
</li>
|
2458
2473
|
|
2459
|
-
<li class="never" data-hits="" data-linenumber="
|
2474
|
+
<li class="never" data-hits="" data-linenumber="95">
|
2460
2475
|
|
2461
2476
|
|
2462
2477
|
<code class="ruby"> # Options for formatter.</code>
|
2463
2478
|
</li>
|
2464
2479
|
|
2465
|
-
<li class="never" data-hits="" data-linenumber="
|
2480
|
+
<li class="never" data-hits="" data-linenumber="96">
|
2466
2481
|
|
2467
2482
|
|
2468
2483
|
<code class="ruby"> # @option options [Fixnum] :precision (3)</code>
|
2469
2484
|
</li>
|
2470
2485
|
|
2471
|
-
<li class="never" data-hits="" data-linenumber="
|
2486
|
+
<li class="never" data-hits="" data-linenumber="97">
|
2472
2487
|
|
2473
2488
|
|
2474
2489
|
<code class="ruby"> # Sets the level of precision.</code>
|
2475
2490
|
</li>
|
2476
2491
|
|
2477
|
-
<li class="never" data-hits="" data-linenumber="
|
2492
|
+
<li class="never" data-hits="" data-linenumber="98">
|
2478
2493
|
|
2479
2494
|
|
2480
2495
|
<code class="ruby"> # @option options [String] :separator (".")</code>
|
2481
2496
|
</li>
|
2482
2497
|
|
2483
|
-
<li class="never" data-hits="" data-linenumber="
|
2498
|
+
<li class="never" data-hits="" data-linenumber="99">
|
2484
2499
|
|
2485
2500
|
|
2486
2501
|
<code class="ruby"> # Sets the separator between the units.</code>
|
2487
2502
|
</li>
|
2488
2503
|
|
2489
|
-
<li class="never" data-hits="" data-linenumber="
|
2504
|
+
<li class="never" data-hits="" data-linenumber="100">
|
2490
2505
|
|
2491
2506
|
|
2492
2507
|
<code class="ruby"> # @option options [String] :delimiter ("")</code>
|
2493
2508
|
</li>
|
2494
2509
|
|
2495
|
-
<li class="never" data-hits="" data-linenumber="
|
2510
|
+
<li class="never" data-hits="" data-linenumber="101">
|
2496
2511
|
|
2497
2512
|
|
2498
2513
|
<code class="ruby"> # Sets the thousands delimiter.</code>
|
2499
2514
|
</li>
|
2500
2515
|
|
2501
|
-
<li class="never" data-hits="" data-linenumber="
|
2516
|
+
<li class="never" data-hits="" data-linenumber="102">
|
2502
2517
|
|
2503
2518
|
|
2504
2519
|
<code class="ruby"> #</code>
|
2505
2520
|
</li>
|
2506
2521
|
|
2507
|
-
<li class="never" data-hits="" data-linenumber="
|
2522
|
+
<li class="never" data-hits="" data-linenumber="103">
|
2508
2523
|
|
2509
2524
|
|
2510
2525
|
<code class="ruby"> # @return [String] The formatted representation of the number.</code>
|
2511
2526
|
</li>
|
2512
2527
|
|
2513
|
-
<li class="never" data-hits="" data-linenumber="
|
2528
|
+
<li class="never" data-hits="" data-linenumber="104">
|
2514
2529
|
|
2515
2530
|
|
2516
2531
|
<code class="ruby"> #</code>
|
2517
2532
|
</li>
|
2518
2533
|
|
2519
|
-
<li class="never" data-hits="" data-linenumber="
|
2534
|
+
<li class="never" data-hits="" data-linenumber="105">
|
2520
2535
|
|
2521
2536
|
|
2522
2537
|
<code class="ruby"> # @example</code>
|
2523
2538
|
</li>
|
2524
2539
|
|
2525
|
-
<li class="never" data-hits="" data-linenumber="
|
2540
|
+
<li class="never" data-hits="" data-linenumber="106">
|
2526
2541
|
|
2527
2542
|
|
2528
2543
|
<code class="ruby"> # with_precision(111.2345) # => 111.235</code>
|
2529
2544
|
</li>
|
2530
2545
|
|
2531
|
-
<li class="never" data-hits="" data-linenumber="
|
2546
|
+
<li class="never" data-hits="" data-linenumber="107">
|
2532
2547
|
|
2533
2548
|
|
2534
2549
|
<code class="ruby"> # with_precision(111.2345, :precision => 2) # => 111.23</code>
|
2535
2550
|
</li>
|
2536
2551
|
|
2537
|
-
<li class="never" data-hits="" data-linenumber="
|
2552
|
+
<li class="never" data-hits="" data-linenumber="108">
|
2538
2553
|
|
2539
2554
|
|
2540
2555
|
<code class="ruby"> # with_precision(13, :precision => 5) # => 13.00000</code>
|
2541
2556
|
</li>
|
2542
2557
|
|
2543
|
-
<li class="never" data-hits="" data-linenumber="
|
2558
|
+
<li class="never" data-hits="" data-linenumber="109">
|
2544
2559
|
|
2545
2560
|
|
2546
2561
|
<code class="ruby"> # with_precision(389.32314, :precision => 0) # => 389</code>
|
2547
2562
|
</li>
|
2548
2563
|
|
2549
|
-
<li class="never" data-hits="" data-linenumber="
|
2564
|
+
<li class="never" data-hits="" data-linenumber="110">
|
2550
2565
|
|
2551
2566
|
|
2552
2567
|
<code class="ruby"> # with_precision(1111.2345, :precision => 2, :separator => ',', :delimiter => '.')</code>
|
2553
2568
|
</li>
|
2554
2569
|
|
2555
|
-
<li class="never" data-hits="" data-linenumber="
|
2570
|
+
<li class="never" data-hits="" data-linenumber="111">
|
2556
2571
|
|
2557
2572
|
|
2558
2573
|
<code class="ruby"> # # => 1.111,23</code>
|
2559
2574
|
</li>
|
2560
2575
|
|
2561
|
-
<li class="never" data-hits="" data-linenumber="
|
2576
|
+
<li class="never" data-hits="" data-linenumber="112">
|
2562
2577
|
|
2563
2578
|
|
2564
2579
|
<code class="ruby"> #</code>
|
2565
2580
|
</li>
|
2566
2581
|
|
2567
|
-
<li class="covered" data-hits="1" data-linenumber="
|
2582
|
+
<li class="covered" data-hits="1" data-linenumber="113">
|
2568
2583
|
<span class="hits">1</span>
|
2569
2584
|
|
2570
2585
|
<code class="ruby"> def with_precision(number, args)</code>
|
2571
2586
|
</li>
|
2572
2587
|
|
2573
|
-
<li class="covered" data-hits="14" data-linenumber="
|
2588
|
+
<li class="covered" data-hits="14" data-linenumber="114">
|
2574
2589
|
<span class="hits">14</span>
|
2575
2590
|
|
2576
2591
|
<code class="ruby"> begin</code>
|
2577
2592
|
</li>
|
2578
2593
|
|
2579
|
-
<li class="covered" data-hits="14" data-linenumber="
|
2594
|
+
<li class="covered" data-hits="14" data-linenumber="115">
|
2580
2595
|
<span class="hits">14</span>
|
2581
2596
|
|
2582
2597
|
<code class="ruby"> Float(number)</code>
|
2583
2598
|
</li>
|
2584
2599
|
|
2585
|
-
<li class="never" data-hits="" data-linenumber="
|
2600
|
+
<li class="never" data-hits="" data-linenumber="116">
|
2586
2601
|
|
2587
2602
|
|
2588
|
-
<code class="ruby"> rescue</code>
|
2603
|
+
<code class="ruby"> rescue StandardError</code>
|
2589
2604
|
</li>
|
2590
2605
|
|
2591
|
-
<li class="covered" data-hits="1" data-linenumber="
|
2606
|
+
<li class="covered" data-hits="1" data-linenumber="117">
|
2592
2607
|
<span class="hits">1</span>
|
2593
2608
|
|
2594
2609
|
<code class="ruby"> return nil</code>
|
2595
2610
|
</li>
|
2596
2611
|
|
2597
|
-
<li class="never" data-hits="" data-linenumber="
|
2612
|
+
<li class="never" data-hits="" data-linenumber="118">
|
2598
2613
|
|
2599
2614
|
|
2600
2615
|
<code class="ruby"> end</code>
|
2601
2616
|
</li>
|
2602
2617
|
|
2603
|
-
<li class="never" data-hits="" data-linenumber="
|
2618
|
+
<li class="never" data-hits="" data-linenumber="119">
|
2604
2619
|
|
2605
2620
|
|
2606
2621
|
<code class="ruby"></code>
|
2607
2622
|
</li>
|
2608
2623
|
|
2609
|
-
<li class="covered" data-hits="13" data-linenumber="
|
2624
|
+
<li class="covered" data-hits="13" data-linenumber="120">
|
2610
2625
|
<span class="hits">13</span>
|
2611
2626
|
|
2612
2627
|
<code class="ruby"> options = BB::Hash.symbolize_keys(args)</code>
|
2613
2628
|
</li>
|
2614
2629
|
|
2615
|
-
<li class="never" data-hits="" data-linenumber="
|
2630
|
+
<li class="never" data-hits="" data-linenumber="121">
|
2616
2631
|
|
2617
2632
|
|
2618
2633
|
<code class="ruby"></code>
|
2619
2634
|
</li>
|
2620
2635
|
|
2621
|
-
<li class="covered" data-hits="13" data-linenumber="
|
2636
|
+
<li class="covered" data-hits="13" data-linenumber="122">
|
2622
2637
|
<span class="hits">13</span>
|
2623
2638
|
|
2624
2639
|
<code class="ruby"> precision ||= (options[:precision] || 3)</code>
|
2625
2640
|
</li>
|
2626
2641
|
|
2627
|
-
<li class="covered" data-hits="13" data-linenumber="
|
2642
|
+
<li class="covered" data-hits="13" data-linenumber="123">
|
2628
2643
|
<span class="hits">13</span>
|
2629
2644
|
|
2630
2645
|
<code class="ruby"> separator ||= (options[:separator] || '.')</code>
|
2631
2646
|
</li>
|
2632
2647
|
|
2633
|
-
<li class="covered" data-hits="13" data-linenumber="
|
2648
|
+
<li class="covered" data-hits="13" data-linenumber="124">
|
2634
2649
|
<span class="hits">13</span>
|
2635
2650
|
|
2636
2651
|
<code class="ruby"> delimiter ||= (options[:delimiter] || '')</code>
|
2637
2652
|
</li>
|
2638
2653
|
|
2639
|
-
<li class="never" data-hits="" data-linenumber="
|
2654
|
+
<li class="never" data-hits="" data-linenumber="125">
|
2640
2655
|
|
2641
2656
|
|
2642
2657
|
<code class="ruby"></code>
|
2643
2658
|
</li>
|
2644
2659
|
|
2645
|
-
<li class="covered" data-hits="13" data-linenumber="
|
2660
|
+
<li class="covered" data-hits="13" data-linenumber="126">
|
2646
2661
|
<span class="hits">13</span>
|
2647
2662
|
|
2648
2663
|
<code class="ruby"> begin</code>
|
2649
2664
|
</li>
|
2650
2665
|
|
2651
|
-
<li class="covered" data-hits="13" data-linenumber="
|
2666
|
+
<li class="covered" data-hits="13" data-linenumber="127">
|
2652
2667
|
<span class="hits">13</span>
|
2653
2668
|
|
2654
2669
|
<code class="ruby"> rounded_number = (Float(number) * (10**precision)).round.to_f / 10**precision</code>
|
2655
2670
|
</li>
|
2656
2671
|
|
2657
|
-
<li class="covered" data-hits="12" data-linenumber="
|
2672
|
+
<li class="covered" data-hits="12" data-linenumber="128">
|
2658
2673
|
<span class="hits">12</span>
|
2659
2674
|
|
2660
2675
|
<code class="ruby"> with_delimiter("%01.#{precision}f" % rounded_number,</code>
|
2661
2676
|
</li>
|
2662
2677
|
|
2663
|
-
<li class="never" data-hits="" data-linenumber="
|
2678
|
+
<li class="never" data-hits="" data-linenumber="129">
|
2664
2679
|
|
2665
2680
|
|
2666
2681
|
<code class="ruby"> separator: separator,</code>
|
2667
2682
|
</li>
|
2668
2683
|
|
2669
|
-
<li class="never" data-hits="" data-linenumber="
|
2684
|
+
<li class="never" data-hits="" data-linenumber="130">
|
2670
2685
|
|
2671
2686
|
|
2672
2687
|
<code class="ruby"> delimiter: delimiter)</code>
|
2673
2688
|
</li>
|
2674
2689
|
|
2675
|
-
<li class="
|
2676
|
-
|
2690
|
+
<li class="covered" data-hits="1" data-linenumber="131">
|
2691
|
+
<span class="hits">1</span>
|
2677
2692
|
|
2678
|
-
<code class="ruby"> rescue</code>
|
2693
|
+
<code class="ruby"> rescue StandardError</code>
|
2679
2694
|
</li>
|
2680
2695
|
|
2681
|
-
<li class="covered" data-hits="1" data-linenumber="
|
2696
|
+
<li class="covered" data-hits="1" data-linenumber="132">
|
2682
2697
|
<span class="hits">1</span>
|
2683
2698
|
|
2684
2699
|
<code class="ruby"> number</code>
|
2685
2700
|
</li>
|
2686
2701
|
|
2687
|
-
<li class="never" data-hits="" data-linenumber="
|
2702
|
+
<li class="never" data-hits="" data-linenumber="133">
|
2688
2703
|
|
2689
2704
|
|
2690
2705
|
<code class="ruby"> end</code>
|
2691
2706
|
</li>
|
2692
2707
|
|
2693
|
-
<li class="never" data-hits="" data-linenumber="
|
2708
|
+
<li class="never" data-hits="" data-linenumber="134">
|
2694
2709
|
|
2695
2710
|
|
2696
2711
|
<code class="ruby"> end</code>
|
2697
2712
|
</li>
|
2698
2713
|
|
2699
|
-
<li class="never" data-hits="" data-linenumber="
|
2714
|
+
<li class="never" data-hits="" data-linenumber="135">
|
2700
2715
|
|
2701
2716
|
|
2702
2717
|
<code class="ruby"></code>
|
2703
2718
|
</li>
|
2704
2719
|
|
2705
|
-
<li class="never" data-hits="" data-linenumber="
|
2720
|
+
<li class="never" data-hits="" data-linenumber="136">
|
2706
2721
|
|
2707
2722
|
|
2708
2723
|
<code class="ruby"> ##</code>
|
2709
2724
|
</li>
|
2710
2725
|
|
2711
|
-
<li class="never" data-hits="" data-linenumber="
|
2726
|
+
<li class="never" data-hits="" data-linenumber="137">
|
2712
2727
|
|
2713
2728
|
|
2714
2729
|
<code class="ruby"> # Formats a +number+ with grouped thousands using +delimiter+ (e.g., 12,324).</code>
|
2715
2730
|
</li>
|
2716
2731
|
|
2717
|
-
<li class="never" data-hits="" data-linenumber="
|
2732
|
+
<li class="never" data-hits="" data-linenumber="138">
|
2718
2733
|
|
2719
2734
|
|
2720
2735
|
<code class="ruby"> # This method returns nil if +number+ cannot be converted into a number.</code>
|
2721
2736
|
</li>
|
2722
2737
|
|
2723
|
-
<li class="never" data-hits="" data-linenumber="
|
2738
|
+
<li class="never" data-hits="" data-linenumber="139">
|
2724
2739
|
|
2725
2740
|
|
2726
2741
|
<code class="ruby"> # You can customize the format in the +options+ hash.</code>
|
2727
2742
|
</li>
|
2728
2743
|
|
2729
|
-
<li class="never" data-hits="" data-linenumber="
|
2744
|
+
<li class="never" data-hits="" data-linenumber="140">
|
2730
2745
|
|
2731
2746
|
|
2732
2747
|
<code class="ruby"> #</code>
|
2733
2748
|
</li>
|
2734
2749
|
|
2735
|
-
<li class="never" data-hits="" data-linenumber="
|
2750
|
+
<li class="never" data-hits="" data-linenumber="141">
|
2736
2751
|
|
2737
2752
|
|
2738
2753
|
<code class="ruby"> # @overload with_delimiter(number, options={})</code>
|
2739
2754
|
</li>
|
2740
2755
|
|
2741
|
-
<li class="never" data-hits="" data-linenumber="
|
2756
|
+
<li class="never" data-hits="" data-linenumber="142">
|
2742
2757
|
|
2743
2758
|
|
2744
2759
|
<code class="ruby"> # @param [Fixnum, Float] number</code>
|
2745
2760
|
</li>
|
2746
2761
|
|
2747
|
-
<li class="never" data-hits="" data-linenumber="
|
2762
|
+
<li class="never" data-hits="" data-linenumber="143">
|
2748
2763
|
|
2749
2764
|
|
2750
2765
|
<code class="ruby"> # Number value to format.</code>
|
2751
2766
|
</li>
|
2752
2767
|
|
2753
|
-
<li class="never" data-hits="" data-linenumber="
|
2768
|
+
<li class="never" data-hits="" data-linenumber="144">
|
2754
2769
|
|
2755
2770
|
|
2756
2771
|
<code class="ruby"> # @param [Hash] options</code>
|
2757
2772
|
</li>
|
2758
2773
|
|
2759
|
-
<li class="never" data-hits="" data-linenumber="
|
2774
|
+
<li class="never" data-hits="" data-linenumber="145">
|
2760
2775
|
|
2761
2776
|
|
2762
2777
|
<code class="ruby"> # Options for formatter.</code>
|
2763
2778
|
</li>
|
2764
2779
|
|
2765
|
-
<li class="never" data-hits="" data-linenumber="
|
2780
|
+
<li class="never" data-hits="" data-linenumber="146">
|
2766
2781
|
|
2767
2782
|
|
2768
2783
|
<code class="ruby"> # @option options [String] :delimiter (", ")</code>
|
2769
2784
|
</li>
|
2770
2785
|
|
2771
|
-
<li class="never" data-hits="" data-linenumber="
|
2786
|
+
<li class="never" data-hits="" data-linenumber="147">
|
2772
2787
|
|
2773
2788
|
|
2774
2789
|
<code class="ruby"> # Sets the thousands delimiter.</code>
|
2775
2790
|
</li>
|
2776
2791
|
|
2777
|
-
<li class="never" data-hits="" data-linenumber="
|
2792
|
+
<li class="never" data-hits="" data-linenumber="148">
|
2778
2793
|
|
2779
2794
|
|
2780
2795
|
<code class="ruby"> # @option options [String] :separator (".")</code>
|
2781
2796
|
</li>
|
2782
2797
|
|
2783
|
-
<li class="never" data-hits="" data-linenumber="
|
2798
|
+
<li class="never" data-hits="" data-linenumber="149">
|
2784
2799
|
|
2785
2800
|
|
2786
2801
|
<code class="ruby"> # Sets the separator between the units.</code>
|
2787
2802
|
</li>
|
2788
2803
|
|
2789
|
-
<li class="never" data-hits="" data-linenumber="
|
2804
|
+
<li class="never" data-hits="" data-linenumber="150">
|
2790
2805
|
|
2791
2806
|
|
2792
2807
|
<code class="ruby"> #</code>
|
2793
2808
|
</li>
|
2794
2809
|
|
2795
|
-
<li class="never" data-hits="" data-linenumber="
|
2810
|
+
<li class="never" data-hits="" data-linenumber="151">
|
2796
2811
|
|
2797
2812
|
|
2798
2813
|
<code class="ruby"> # @return [String] The formatted representation of the number.</code>
|
2799
2814
|
</li>
|
2800
2815
|
|
2801
|
-
<li class="never" data-hits="" data-linenumber="
|
2816
|
+
<li class="never" data-hits="" data-linenumber="152">
|
2802
2817
|
|
2803
2818
|
|
2804
2819
|
<code class="ruby"> #</code>
|
2805
2820
|
</li>
|
2806
2821
|
|
2807
|
-
<li class="never" data-hits="" data-linenumber="
|
2822
|
+
<li class="never" data-hits="" data-linenumber="153">
|
2808
2823
|
|
2809
2824
|
|
2810
2825
|
<code class="ruby"> # @example</code>
|
2811
2826
|
</li>
|
2812
2827
|
|
2813
|
-
<li class="never" data-hits="" data-linenumber="
|
2828
|
+
<li class="never" data-hits="" data-linenumber="154">
|
2814
2829
|
|
2815
2830
|
|
2816
2831
|
<code class="ruby"> # with_delimiter(12345678) # => 12,345,678</code>
|
2817
2832
|
</li>
|
2818
2833
|
|
2819
|
-
<li class="never" data-hits="" data-linenumber="
|
2834
|
+
<li class="never" data-hits="" data-linenumber="155">
|
2820
2835
|
|
2821
2836
|
|
2822
2837
|
<code class="ruby"> # with_delimiter(12345678.05) # => 12,345,678.05</code>
|
2823
2838
|
</li>
|
2824
2839
|
|
2825
|
-
<li class="never" data-hits="" data-linenumber="
|
2840
|
+
<li class="never" data-hits="" data-linenumber="156">
|
2826
2841
|
|
2827
2842
|
|
2828
2843
|
<code class="ruby"> # with_delimiter(12345678, :delimiter => ".") # => 12.345.678</code>
|
2829
2844
|
</li>
|
2830
2845
|
|
2831
|
-
<li class="never" data-hits="" data-linenumber="
|
2846
|
+
<li class="never" data-hits="" data-linenumber="157">
|
2832
2847
|
|
2833
2848
|
|
2834
2849
|
<code class="ruby"> # with_delimiter(12345678, :separator => ",") # => 12,345,678</code>
|
2835
2850
|
</li>
|
2836
2851
|
|
2837
|
-
<li class="never" data-hits="" data-linenumber="
|
2852
|
+
<li class="never" data-hits="" data-linenumber="158">
|
2838
2853
|
|
2839
2854
|
|
2840
2855
|
<code class="ruby"> # with_delimiter(98765432.98, :delimiter => " ", :separator => ",")</code>
|
2841
2856
|
</li>
|
2842
2857
|
|
2843
|
-
<li class="never" data-hits="" data-linenumber="
|
2858
|
+
<li class="never" data-hits="" data-linenumber="159">
|
2844
2859
|
|
2845
2860
|
|
2846
2861
|
<code class="ruby"> # # => 98 765 432,98</code>
|
2847
2862
|
</li>
|
2848
2863
|
|
2849
|
-
<li class="never" data-hits="" data-linenumber="
|
2864
|
+
<li class="never" data-hits="" data-linenumber="160">
|
2850
2865
|
|
2851
2866
|
|
2852
2867
|
<code class="ruby"> #</code>
|
2853
2868
|
</li>
|
2854
2869
|
|
2855
|
-
<li class="covered" data-hits="1" data-linenumber="
|
2870
|
+
<li class="covered" data-hits="1" data-linenumber="161">
|
2856
2871
|
<span class="hits">1</span>
|
2857
2872
|
|
2858
2873
|
<code class="ruby"> def with_delimiter(number, args = {})</code>
|
2859
2874
|
</li>
|
2860
2875
|
|
2861
|
-
<li class="covered" data-hits="17" data-linenumber="
|
2876
|
+
<li class="covered" data-hits="17" data-linenumber="162">
|
2862
2877
|
<span class="hits">17</span>
|
2863
2878
|
|
2864
2879
|
<code class="ruby"> begin</code>
|
2865
2880
|
</li>
|
2866
2881
|
|
2867
|
-
<li class="covered" data-hits="17" data-linenumber="
|
2882
|
+
<li class="covered" data-hits="17" data-linenumber="163">
|
2868
2883
|
<span class="hits">17</span>
|
2869
2884
|
|
2870
2885
|
<code class="ruby"> Float(number)</code>
|
2871
2886
|
</li>
|
2872
2887
|
|
2873
|
-
<li class="never" data-hits="" data-linenumber="
|
2888
|
+
<li class="never" data-hits="" data-linenumber="164">
|
2874
2889
|
|
2875
2890
|
|
2876
|
-
<code class="ruby"> rescue</code>
|
2891
|
+
<code class="ruby"> rescue StandardError</code>
|
2877
2892
|
</li>
|
2878
2893
|
|
2879
|
-
<li class="covered" data-hits="1" data-linenumber="
|
2894
|
+
<li class="covered" data-hits="1" data-linenumber="165">
|
2880
2895
|
<span class="hits">1</span>
|
2881
2896
|
|
2882
2897
|
<code class="ruby"> return nil</code>
|
2883
2898
|
</li>
|
2884
2899
|
|
2885
|
-
<li class="never" data-hits="" data-linenumber="
|
2900
|
+
<li class="never" data-hits="" data-linenumber="166">
|
2886
2901
|
|
2887
2902
|
|
2888
2903
|
<code class="ruby"> end</code>
|
2889
2904
|
</li>
|
2890
2905
|
|
2891
|
-
<li class="covered" data-hits="16" data-linenumber="
|
2906
|
+
<li class="covered" data-hits="16" data-linenumber="167">
|
2892
2907
|
<span class="hits">16</span>
|
2893
2908
|
|
2894
2909
|
<code class="ruby"> options = BB::Hash.symbolize_keys(args)</code>
|
2895
2910
|
</li>
|
2896
2911
|
|
2897
|
-
<li class="never" data-hits="" data-linenumber="
|
2912
|
+
<li class="never" data-hits="" data-linenumber="168">
|
2898
2913
|
|
2899
2914
|
|
2900
2915
|
<code class="ruby"></code>
|
2901
2916
|
</li>
|
2902
2917
|
|
2903
|
-
<li class="covered" data-hits="16" data-linenumber="
|
2918
|
+
<li class="covered" data-hits="16" data-linenumber="169">
|
2904
2919
|
<span class="hits">16</span>
|
2905
2920
|
|
2906
2921
|
<code class="ruby"> delimiter ||= (options[:delimiter] || ',')</code>
|
2907
2922
|
</li>
|
2908
2923
|
|
2909
|
-
<li class="covered" data-hits="16" data-linenumber="
|
2924
|
+
<li class="covered" data-hits="16" data-linenumber="170">
|
2910
2925
|
<span class="hits">16</span>
|
2911
2926
|
|
2912
2927
|
<code class="ruby"> separator ||= (options[:separator] || '.')</code>
|
2913
2928
|
</li>
|
2914
2929
|
|
2915
|
-
<li class="never" data-hits="" data-linenumber="
|
2930
|
+
<li class="never" data-hits="" data-linenumber="171">
|
2916
2931
|
|
2917
2932
|
|
2918
2933
|
<code class="ruby"></code>
|
2919
2934
|
</li>
|
2920
2935
|
|
2921
|
-
<li class="covered" data-hits="16" data-linenumber="
|
2936
|
+
<li class="covered" data-hits="16" data-linenumber="172">
|
2922
2937
|
<span class="hits">16</span>
|
2923
2938
|
|
2924
2939
|
<code class="ruby"> begin</code>
|
2925
2940
|
</li>
|
2926
2941
|
|
2927
|
-
<li class="covered" data-hits="16" data-linenumber="
|
2942
|
+
<li class="covered" data-hits="16" data-linenumber="173">
|
2928
2943
|
<span class="hits">16</span>
|
2929
2944
|
|
2930
2945
|
<code class="ruby"> parts = number.to_s.split('.')</code>
|
2931
2946
|
</li>
|
2932
2947
|
|
2933
|
-
<li class="covered" data-hits="16" data-linenumber="
|
2948
|
+
<li class="covered" data-hits="16" data-linenumber="174">
|
2934
2949
|
<span class="hits">16</span>
|
2935
2950
|
|
2936
2951
|
<code class="ruby"> parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{delimiter}")</code>
|
2937
2952
|
</li>
|
2938
2953
|
|
2939
|
-
<li class="covered" data-hits="16" data-linenumber="
|
2954
|
+
<li class="covered" data-hits="16" data-linenumber="175">
|
2940
2955
|
<span class="hits">16</span>
|
2941
2956
|
|
2942
2957
|
<code class="ruby"> parts.join(separator)</code>
|
2943
2958
|
</li>
|
2944
2959
|
|
2945
|
-
<li class="
|
2946
|
-
|
2960
|
+
<li class="covered" data-hits="1" data-linenumber="176">
|
2961
|
+
<span class="hits">1</span>
|
2947
2962
|
|
2948
|
-
<code class="ruby"> rescue</code>
|
2963
|
+
<code class="ruby"> rescue StandardError</code>
|
2949
2964
|
</li>
|
2950
2965
|
|
2951
|
-
<li class="covered" data-hits="1" data-linenumber="
|
2966
|
+
<li class="covered" data-hits="1" data-linenumber="177">
|
2952
2967
|
<span class="hits">1</span>
|
2953
2968
|
|
2954
2969
|
<code class="ruby"> number</code>
|
2955
2970
|
</li>
|
2956
2971
|
|
2957
|
-
<li class="never" data-hits="" data-linenumber="
|
2972
|
+
<li class="never" data-hits="" data-linenumber="178">
|
2958
2973
|
|
2959
2974
|
|
2960
2975
|
<code class="ruby"> end</code>
|
2961
2976
|
</li>
|
2962
2977
|
|
2963
|
-
<li class="never" data-hits="" data-linenumber="
|
2978
|
+
<li class="never" data-hits="" data-linenumber="179">
|
2964
2979
|
|
2965
2980
|
|
2966
2981
|
<code class="ruby"> end</code>
|
2967
2982
|
</li>
|
2968
2983
|
|
2969
|
-
<li class="never" data-hits="" data-linenumber="
|
2984
|
+
<li class="never" data-hits="" data-linenumber="180">
|
2970
2985
|
|
2971
2986
|
|
2972
2987
|
<code class="ruby"> end</code>
|
2973
2988
|
</li>
|
2974
2989
|
|
2975
|
-
<li class="never" data-hits="" data-linenumber="
|
2990
|
+
<li class="never" data-hits="" data-linenumber="181">
|
2976
2991
|
|
2977
2992
|
|
2978
2993
|
<code class="ruby"> end</code>
|
2979
2994
|
</li>
|
2980
2995
|
|
2981
|
-
<li class="never" data-hits="" data-linenumber="
|
2996
|
+
<li class="never" data-hits="" data-linenumber="182">
|
2982
2997
|
|
2983
2998
|
|
2984
2999
|
<code class="ruby">end</code>
|
@@ -2987,6 +3002,7 @@
|
|
2987
3002
|
</ol>
|
2988
3003
|
</pre>
|
2989
3004
|
</div>
|
3005
|
+
|
2990
3006
|
|
2991
3007
|
<div class="source_table" id="1503164dbfa2b2b494fd2100a9b38b04be306a6e">
|
2992
3008
|
<div class="header">
|
@@ -3008,97 +3024,103 @@
|
|
3008
3024
|
<code class="ruby"># frozen_string_literal: true</code>
|
3009
3025
|
</li>
|
3010
3026
|
|
3011
|
-
<li class="
|
3027
|
+
<li class="never" data-hits="" data-linenumber="2">
|
3028
|
+
|
3029
|
+
|
3030
|
+
<code class="ruby"></code>
|
3031
|
+
</li>
|
3032
|
+
|
3033
|
+
<li class="covered" data-hits="1" data-linenumber="3">
|
3012
3034
|
<span class="hits">1</span>
|
3013
3035
|
|
3014
3036
|
<code class="ruby">module BB</code>
|
3015
3037
|
</li>
|
3016
3038
|
|
3017
|
-
<li class="never" data-hits="" data-linenumber="
|
3039
|
+
<li class="never" data-hits="" data-linenumber="4">
|
3018
3040
|
|
3019
3041
|
|
3020
3042
|
<code class="ruby"> # String utilities.</code>
|
3021
3043
|
</li>
|
3022
3044
|
|
3023
|
-
<li class="covered" data-hits="1" data-linenumber="
|
3045
|
+
<li class="covered" data-hits="1" data-linenumber="5">
|
3024
3046
|
<span class="hits">1</span>
|
3025
3047
|
|
3026
3048
|
<code class="ruby"> module String</code>
|
3027
3049
|
</li>
|
3028
3050
|
|
3029
|
-
<li class="covered" data-hits="1" data-linenumber="
|
3051
|
+
<li class="covered" data-hits="1" data-linenumber="6">
|
3030
3052
|
<span class="hits">1</span>
|
3031
3053
|
|
3032
3054
|
<code class="ruby"> class << self</code>
|
3033
3055
|
</li>
|
3034
3056
|
|
3035
|
-
<li class="never" data-hits="" data-linenumber="
|
3057
|
+
<li class="never" data-hits="" data-linenumber="7">
|
3036
3058
|
|
3037
3059
|
|
3038
3060
|
<code class="ruby"> # Strip ANSI escape sequences from String.</code>
|
3039
3061
|
</li>
|
3040
3062
|
|
3041
|
-
<li class="never" data-hits="" data-linenumber="
|
3063
|
+
<li class="never" data-hits="" data-linenumber="8">
|
3042
3064
|
|
3043
3065
|
|
3044
3066
|
<code class="ruby"> #</code>
|
3045
3067
|
</li>
|
3046
3068
|
|
3047
|
-
<li class="never" data-hits="" data-linenumber="
|
3069
|
+
<li class="never" data-hits="" data-linenumber="9">
|
3048
3070
|
|
3049
3071
|
|
3050
3072
|
<code class="ruby"> # @param [String] text Input string (dirty)</code>
|
3051
3073
|
</li>
|
3052
3074
|
|
3053
|
-
<li class="never" data-hits="" data-linenumber="
|
3075
|
+
<li class="never" data-hits="" data-linenumber="10">
|
3054
3076
|
|
3055
3077
|
|
3056
3078
|
<code class="ruby"> # @return [String] Output string (cleaned)</code>
|
3057
3079
|
</li>
|
3058
3080
|
|
3059
|
-
<li class="covered" data-hits="1" data-linenumber="
|
3081
|
+
<li class="covered" data-hits="1" data-linenumber="11">
|
3060
3082
|
<span class="hits">1</span>
|
3061
3083
|
|
3062
3084
|
<code class="ruby"> def strip_ansi(text)</code>
|
3063
3085
|
</li>
|
3064
3086
|
|
3065
|
-
<li class="never" data-hits="" data-linenumber="
|
3087
|
+
<li class="never" data-hits="" data-linenumber="12">
|
3066
3088
|
|
3067
3089
|
|
3068
3090
|
<code class="ruby"> text.gsub(/\x1b(\[|\(|\))[;?0-9]*[0-9A-Za-z]/, '')</code>
|
3069
3091
|
</li>
|
3070
3092
|
|
3071
|
-
<li class="never" data-hits="" data-linenumber="
|
3093
|
+
<li class="never" data-hits="" data-linenumber="13">
|
3072
3094
|
|
3073
3095
|
|
3074
3096
|
<code class="ruby"> .gsub(/\x1b(\[|\(|\))[;?0-9]*[0-9A-Za-z]/, '')</code>
|
3075
3097
|
</li>
|
3076
3098
|
|
3077
|
-
<li class="covered" data-hits="1" data-linenumber="
|
3099
|
+
<li class="covered" data-hits="1" data-linenumber="14">
|
3078
3100
|
<span class="hits">1</span>
|
3079
3101
|
|
3080
3102
|
<code class="ruby"> .gsub(/(\x03|\x1a)/, '')</code>
|
3081
3103
|
</li>
|
3082
3104
|
|
3083
|
-
<li class="never" data-hits="" data-linenumber="
|
3105
|
+
<li class="never" data-hits="" data-linenumber="15">
|
3084
3106
|
|
3085
3107
|
|
3086
3108
|
<code class="ruby"> end</code>
|
3087
3109
|
</li>
|
3088
3110
|
|
3089
|
-
<li class="never" data-hits="" data-linenumber="
|
3111
|
+
<li class="never" data-hits="" data-linenumber="16">
|
3090
3112
|
|
3091
3113
|
|
3092
3114
|
<code class="ruby"> end</code>
|
3093
3115
|
</li>
|
3094
3116
|
|
3095
|
-
<li class="never" data-hits="" data-linenumber="
|
3117
|
+
<li class="never" data-hits="" data-linenumber="17">
|
3096
3118
|
|
3097
3119
|
|
3098
3120
|
<code class="ruby"> end</code>
|
3099
3121
|
</li>
|
3100
3122
|
|
3101
|
-
<li class="never" data-hits="" data-linenumber="
|
3123
|
+
<li class="never" data-hits="" data-linenumber="18">
|
3102
3124
|
|
3103
3125
|
|
3104
3126
|
<code class="ruby">end</code>
|
@@ -3107,14 +3129,15 @@
|
|
3107
3129
|
</ol>
|
3108
3130
|
</pre>
|
3109
3131
|
</div>
|
3132
|
+
|
3110
3133
|
|
3111
3134
|
<div class="source_table" id="ef107940f0bb318164d36d5de1cd48192edb65f2">
|
3112
3135
|
<div class="header">
|
3113
3136
|
<h3>lib/blackbox/unix.rb</h3>
|
3114
|
-
<h4><span class="red">45.
|
3137
|
+
<h4><span class="red">45.07 %</span> covered</h4>
|
3115
3138
|
<div>
|
3116
|
-
<b>
|
3117
|
-
<span class="green"><b>
|
3139
|
+
<b>71</b> relevant lines.
|
3140
|
+
<span class="green"><b>32</b> lines covered</span> and
|
3118
3141
|
<span class="red"><b>39</b> lines missed.</span>
|
3119
3142
|
</div>
|
3120
3143
|
</div>
|
@@ -3128,16 +3151,16 @@
|
|
3128
3151
|
<code class="ruby"># frozen_string_literal: true</code>
|
3129
3152
|
</li>
|
3130
3153
|
|
3131
|
-
<li class="
|
3132
|
-
<span class="hits">1</span>
|
3154
|
+
<li class="never" data-hits="" data-linenumber="2">
|
3133
3155
|
|
3134
|
-
|
3156
|
+
|
3157
|
+
<code class="ruby"></code>
|
3135
3158
|
</li>
|
3136
3159
|
|
3137
3160
|
<li class="covered" data-hits="1" data-linenumber="3">
|
3138
3161
|
<span class="hits">1</span>
|
3139
3162
|
|
3140
|
-
<code class="ruby">require '
|
3163
|
+
<code class="ruby">require 'lolcat/lol'</code>
|
3141
3164
|
</li>
|
3142
3165
|
|
3143
3166
|
<li class="covered" data-hits="1" data-linenumber="4">
|
@@ -3398,7 +3421,7 @@
|
|
3398
3421
|
<code class="ruby"> @minispin_last_char_at = Time.now</code>
|
3399
3422
|
</li>
|
3400
3423
|
|
3401
|
-
<li class="
|
3424
|
+
<li class="missed" data-hits="0" data-linenumber="47">
|
3402
3425
|
|
3403
3426
|
|
3404
3427
|
<code class="ruby"> @tspin ||= Thread.new do</code>
|
@@ -3425,7 +3448,7 @@
|
|
3425
3448
|
<li class="missed" data-hits="0" data-linenumber="51">
|
3426
3449
|
|
3427
3450
|
|
3428
|
-
<code class="ruby"> if
|
3451
|
+
<code class="ruby"> if Time.now - @minispin_last_char_at < 0.23 || @minispin_disable</code>
|
3429
3452
|
</li>
|
3430
3453
|
|
3431
3454
|
<li class="missed" data-hits="0" data-linenumber="52">
|
@@ -3518,7 +3541,7 @@
|
|
3518
3541
|
<code class="ruby"> end</code>
|
3519
3542
|
</li>
|
3520
3543
|
|
3521
|
-
<li class="
|
3544
|
+
<li class="never" data-hits="" data-linenumber="67">
|
3522
3545
|
|
3523
3546
|
|
3524
3547
|
<code class="ruby"> end</code>
|
@@ -3683,7 +3706,7 @@
|
|
3683
3706
|
<li class="covered" data-hits="4" data-linenumber="94">
|
3684
3707
|
<span class="hits">4</span>
|
3685
3708
|
|
3686
|
-
<code class="ruby"> opts[:spinner]
|
3709
|
+
<code class="ruby"> opts[:spinner]&.call(true)</code>
|
3687
3710
|
</li>
|
3688
3711
|
|
3689
3712
|
<li class="covered" data-hits="4" data-linenumber="95">
|
@@ -3695,13 +3718,13 @@
|
|
3695
3718
|
<li class="covered" data-hits="4" data-linenumber="96">
|
3696
3719
|
<span class="hits">4</span>
|
3697
3720
|
|
3698
|
-
<code class="ruby"> opts[:spinner]
|
3721
|
+
<code class="ruby"> opts[:spinner]&.call(false)</code>
|
3699
3722
|
</li>
|
3700
3723
|
|
3701
3724
|
<li class="covered" data-hits="4" data-linenumber="97">
|
3702
3725
|
<span class="hits">4</span>
|
3703
3726
|
|
3704
|
-
<code class="ruby"> color =
|
3727
|
+
<code class="ruby"> color = status.exitstatus == 0 ? :green : :red</code>
|
3705
3728
|
</li>
|
3706
3729
|
|
3707
3730
|
<li class="covered" data-hits="4" data-linenumber="98">
|
@@ -3803,6 +3826,7 @@
|
|
3803
3826
|
</ol>
|
3804
3827
|
</pre>
|
3805
3828
|
</div>
|
3829
|
+
|
3806
3830
|
|
3807
3831
|
</div>
|
3808
3832
|
</div>
|