lazier 3.2.6 → 3.2.7

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -8,4 +8,22 @@ require "bundler/gem_tasks"
8
8
  require "rspec/core/rake_task"
9
9
 
10
10
  RSpec::Core::RakeTask.new("spec")
11
- RSpec::Core::RakeTask.new("spec:coverage") { |t| t.ruby_opts = "-r./spec/coverage_helper" }
11
+ RSpec::Core::RakeTask.new("spec:coverage") { |t| t.ruby_opts = "-r./spec/coverage_helper" }
12
+
13
+ desc "Generate the documentation"
14
+ task :docs do
15
+ system("yardoc") || raise("Failed Execution of: yardoc")
16
+ end
17
+
18
+ desc "Get the current release version"
19
+ task :version, :with_name do |_, args|
20
+ gem = Bundler::GemHelper.instance.gemspec
21
+ puts [args[:with_name] == "true" ? gem.name : nil, gem.version].compact.join("-")
22
+ end
23
+
24
+ desc "Prepare the release"
25
+ task :prerelease => ["spec:coverage", "docs"] do
26
+ ["git add -A", "git commit -am \"Version #{Bundler::GemHelper.instance.gemspec.version}\""].each do |cmd|
27
+ system(cmd) || raise("Failed Execution of: #{cmd}")
28
+ end
29
+ end
@@ -969,7 +969,7 @@ Licensed under the MIT license, which can be found at http://www.opensource.org/
969
969
  </div>
970
970
 
971
971
  <div id="footer">
972
- Generated on Sat Jul 20 10:18:17 2013 by
972
+ Generated on Sat Jul 20 12:56:18 2013 by
973
973
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
974
974
  0.8.6.2 (ruby-1.9.3).
975
975
  </div>
@@ -288,7 +288,7 @@
288
288
  </div>
289
289
 
290
290
  <div id="footer">
291
- Generated on Sat Jul 20 10:18:18 2013 by
291
+ Generated on Sat Jul 20 12:56:19 2013 by
292
292
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
293
293
  0.8.6.2 (ruby-1.9.3).
294
294
  </div>
@@ -386,7 +386,7 @@ Options are as follows:</p>
386
386
  </div>
387
387
 
388
388
  <div id="footer">
389
- Generated on Sat Jul 20 10:18:19 2013 by
389
+ Generated on Sat Jul 20 12:56:20 2013 by
390
390
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
391
391
  0.8.6.2 (ruby-1.9.3).
392
392
  </div>
@@ -721,7 +721,7 @@ DateTime.civil(2013, 6, 1).in_months(2011)
721
721
  </div>
722
722
 
723
723
  <div id="footer">
724
- Generated on Sat Jul 20 10:18:18 2013 by
724
+ Generated on Sat Jul 20 12:56:19 2013 by
725
725
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
726
726
  0.8.6.2 (ruby-1.9.3).
727
727
  </div>
@@ -1542,7 +1542,7 @@ Date.years(1, true, 2010, true)
1542
1542
  </div>
1543
1543
 
1544
1544
  <div id="footer">
1545
- Generated on Sat Jul 20 10:18:18 2013 by
1545
+ Generated on Sat Jul 20 12:56:19 2013 by
1546
1546
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1547
1547
  0.8.6.2 (ruby-1.9.3).
1548
1548
  </div>
@@ -116,7 +116,7 @@
116
116
  </div>
117
117
 
118
118
  <div id="footer">
119
- Generated on Sat Jul 20 10:18:19 2013 by
119
+ Generated on Sat Jul 20 12:56:20 2013 by
120
120
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
121
121
  0.8.6.2 (ruby-1.9.3).
122
122
  </div>
@@ -124,7 +124,7 @@
124
124
  </div>
125
125
 
126
126
  <div id="footer">
127
- Generated on Sat Jul 20 10:18:19 2013 by
127
+ Generated on Sat Jul 20 12:56:20 2013 by
128
128
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
129
129
  0.8.6.2 (ruby-1.9.3).
130
130
  </div>
@@ -238,7 +238,7 @@
238
238
  </div>
239
239
 
240
240
  <div id="footer">
241
- Generated on Sat Jul 20 10:18:19 2013 by
241
+ Generated on Sat Jul 20 12:56:20 2013 by
242
242
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
243
243
  0.8.6.2 (ruby-1.9.3).
244
244
  </div>
@@ -111,7 +111,7 @@
111
111
  </div>
112
112
 
113
113
  <div id="footer">
114
- Generated on Sat Jul 20 10:18:17 2013 by
114
+ Generated on Sat Jul 20 12:56:18 2013 by
115
115
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
116
116
  0.8.6.2 (ruby-1.9.3).
117
117
  </div>
@@ -1056,7 +1056,7 @@
1056
1056
  </div>
1057
1057
 
1058
1058
  <div id="footer">
1059
- Generated on Sat Jul 20 10:18:18 2013 by
1059
+ Generated on Sat Jul 20 12:56:18 2013 by
1060
1060
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1061
1061
  0.8.6.2 (ruby-1.9.3).
1062
1062
  </div>
@@ -536,7 +536,7 @@
536
536
  </div>
537
537
 
538
538
  <div id="footer">
539
- Generated on Sat Jul 20 10:18:19 2013 by
539
+ Generated on Sat Jul 20 12:56:20 2013 by
540
540
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
541
541
  0.8.6.2 (ruby-1.9.3).
542
542
  </div>
@@ -121,7 +121,7 @@
121
121
  </div>
122
122
 
123
123
  <div id="footer">
124
- Generated on Sat Jul 20 10:18:18 2013 by
124
+ Generated on Sat Jul 20 12:56:18 2013 by
125
125
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
126
126
  0.8.6.2 (ruby-1.9.3).
127
127
  </div>
@@ -321,7 +321,7 @@
321
321
  </div>
322
322
 
323
323
  <div id="footer">
324
- Generated on Sat Jul 20 10:18:18 2013 by
324
+ Generated on Sat Jul 20 12:56:18 2013 by
325
325
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
326
326
  0.8.6.2 (ruby-1.9.3).
327
327
  </div>
@@ -210,7 +210,7 @@
210
210
  <li class="public ">
211
211
  <span class="summary_signature">
212
212
 
213
- <a href="#ensure_array-instance_method" title="#ensure_array (instance method)">- (Array) <strong>ensure_array</strong>(default_value = nil, uniq = false, compact = false, sanitizer = nil, &amp;block) </a>
213
+ <a href="#ensure_array-instance_method" title="#ensure_array (instance method)">- (Array) <strong>ensure_array</strong>(default_value = nil, uniq = false, compact = false, flatten = nil, sanitizer = nil, &amp;block) </a>
214
214
 
215
215
 
216
216
 
@@ -233,7 +233,7 @@
233
233
  <li class="public ">
234
234
  <span class="summary_signature">
235
235
 
236
- <a href="#ensure_hash-instance_method" title="#ensure_hash (instance method)">- (Hash) <strong>ensure_hash</strong>(default_value = nil, sanitizer = nil) </a>
236
+ <a href="#ensure_hash-instance_method" title="#ensure_hash (instance method)">- (Hash) <strong>ensure_hash</strong>(default_value = {}, sanitizer = nil) </a>
237
237
 
238
238
 
239
239
 
@@ -663,7 +663,7 @@
663
663
  <div class="method_details ">
664
664
  <h3 class="signature " id="ensure_array-instance_method">
665
665
 
666
- - (<tt>Array</tt>) <strong>ensure_array</strong>(default_value = nil, uniq = false, compact = false, sanitizer = nil, &amp;block)
666
+ - (<tt>Array</tt>) <strong>ensure_array</strong>(default_value = nil, uniq = false, compact = false, flatten = nil, sanitizer = nil, &amp;block)
667
667
 
668
668
 
669
669
 
@@ -731,6 +731,23 @@
731
731
 
732
732
  </li>
733
733
 
734
+ <li>
735
+
736
+ <span class='name'>flatten</span>
737
+
738
+
739
+ <span class='type'>(<tt><span class='object_link'><a href="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
740
+
741
+
742
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
743
+
744
+
745
+ &mdash;
746
+ <div class='inline'><p>If to flatten the array before sanitizing.</p>
747
+ </div>
748
+
749
+ </li>
750
+
734
751
  <li>
735
752
 
736
753
  <span class='name'>sanitizer</span>
@@ -789,22 +806,24 @@
789
806
  <pre class="lines">
790
807
 
791
808
 
792
- 81
793
809
  82
794
810
  83
795
811
  84
796
812
  85
797
813
  86
798
- 87</pre>
814
+ 87
815
+ 88
816
+ 89</pre>
799
817
  </td>
800
818
  <td>
801
- <pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 81</span>
819
+ <pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 82</span>
802
820
 
803
- <span class='kw'>def</span> <span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='id identifier rubyid_default_value'>default_value</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_uniq'>uniq</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_compact'>compact</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_sanitizer'>sanitizer</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
821
+ <span class='kw'>def</span> <span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='id identifier rubyid_default_value'>default_value</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_uniq'>uniq</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_compact'>compact</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_flatten'>flatten</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_sanitizer'>sanitizer</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
804
822
  <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Array</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_dup'>dup</span> <span class='op'>:</span> <span class='lparen'>(</span><span class='id identifier rubyid_default_value'>default_value</span> <span class='op'>||</span> <span class='lbracket'>[</span><span class='kw'>self</span><span class='rbracket'>]</span><span class='rparen'>)</span>
805
823
  <span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_collect!'>collect!</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='lparen'>(</span><span class='id identifier rubyid_block'>block</span> <span class='op'>||</span> <span class='id identifier rubyid_sanitizer'>sanitizer</span><span class='rparen'>)</span><span class='rparen'>)</span>
806
824
  <span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_uniq!'>uniq!</span> <span class='kw'>if</span> <span class='id identifier rubyid_uniq'>uniq</span>
807
825
  <span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_compact!'>compact!</span> <span class='kw'>if</span> <span class='id identifier rubyid_compact'>compact</span>
826
+ <span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_flatten!'>flatten!</span> <span class='kw'>if</span> <span class='id identifier rubyid_flatten'>flatten</span>
808
827
  <span class='id identifier rubyid_rv'>rv</span>
809
828
  <span class='kw'>end</span></pre>
810
829
  </td>
@@ -815,7 +834,7 @@
815
834
  <div class="method_details ">
816
835
  <h3 class="signature " id="ensure_hash-instance_method">
817
836
 
818
- - (<tt><span class='object_link'><a href="Hash.html" title="Lazier::Hash (module)">Hash</a></span></tt>) <strong>ensure_hash</strong>(default_value = nil, sanitizer = nil)
837
+ - (<tt><span class='object_link'><a href="Hash.html" title="Lazier::Hash (module)">Hash</a></span></tt>) <strong>ensure_hash</strong>(default_value = {}, sanitizer = nil)
819
838
 
820
839
 
821
840
 
@@ -840,7 +859,7 @@
840
859
  <span class='type'>(<tt><span class='object_link'><a href="Hash.html" title="Lazier::Hash (module)">Hash</a></span>|<span class='object_link'><a href="" title="Lazier::Object (module)">Object</a></span>|NilClass</tt>)</span>
841
860
 
842
861
 
843
- <em class="default">(defaults to: <tt>nil</tt>)</em>
862
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
844
863
 
845
864
 
846
865
  &mdash;
@@ -892,8 +911,6 @@
892
911
  <pre class="lines">
893
912
 
894
913
 
895
- 94
896
- 95
897
914
  96
898
915
  97
899
916
  98
@@ -910,12 +927,14 @@
910
927
  109
911
928
  110
912
929
  111
913
- 112</pre>
930
+ 112
931
+ 113
932
+ 114</pre>
914
933
  </td>
915
934
  <td>
916
- <pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 94</span>
935
+ <pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 96</span>
917
936
 
918
- <span class='kw'>def</span> <span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_default_value'>default_value</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_sanitizer'>sanitizer</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
937
+ <span class='kw'>def</span> <span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_default_value'>default_value</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='id identifier rubyid_sanitizer'>sanitizer</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
919
938
  <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
920
939
  <span class='kw'>self</span>
921
940
  <span class='kw'>elsif</span> <span class='id identifier rubyid_default_value'>default_value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
@@ -1114,8 +1133,6 @@
1114
1133
  <pre class="lines">
1115
1134
 
1116
1135
 
1117
- 191
1118
- 192
1119
1136
  193
1120
1137
  194
1121
1138
  195
@@ -1123,10 +1140,12 @@
1123
1140
  197
1124
1141
  198
1125
1142
  199
1126
- 200</pre>
1143
+ 200
1144
+ 201
1145
+ 202</pre>
1127
1146
  </td>
1128
1147
  <td>
1129
- <pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 191</span>
1148
+ <pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 193</span>
1130
1149
 
1131
1150
  <span class='kw'>def</span> <span class='id identifier rubyid_for_debug'>for_debug</span><span class='lparen'>(</span><span class='id identifier rubyid_format'>format</span> <span class='op'>=</span> <span class='symbol'>:yaml</span><span class='comma'>,</span> <span class='id identifier rubyid_as_exception'>as_exception</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
1132
1151
  <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='kw'>case</span> <span class='id identifier rubyid_format'>format</span>
@@ -1230,13 +1249,13 @@
1230
1249
  <pre class="lines">
1231
1250
 
1232
1251
 
1233
- 171
1234
- 172
1235
1252
  173
1236
- 174</pre>
1253
+ 174
1254
+ 175
1255
+ 176</pre>
1237
1256
  </td>
1238
1257
  <td>
1239
- <pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 171</span>
1258
+ <pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 173</span>
1240
1259
 
1241
1260
  <span class='kw'>def</span> <span class='id identifier rubyid_format_boolean'>format_boolean</span><span class='lparen'>(</span><span class='id identifier rubyid_true_name'>true_name</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_false_name'>false_name</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
1242
1261
  <span class='id identifier rubyid_settings'>settings</span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>Lazier</span><span class='period'>.</span><span class='id identifier rubyid_settings'>settings</span><span class='period'>.</span><span class='id identifier rubyid_boolean_names'>boolean_names</span>
@@ -1368,8 +1387,6 @@
1368
1387
  <pre class="lines">
1369
1388
 
1370
1389
 
1371
- 153
1372
- 154
1373
1390
  155
1374
1391
  156
1375
1392
  157
@@ -1378,10 +1395,12 @@
1378
1395
  160
1379
1396
  161
1380
1397
  162
1381
- 163</pre>
1398
+ 163
1399
+ 164
1400
+ 165</pre>
1382
1401
  </td>
1383
1402
  <td>
1384
- <pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 153</span>
1403
+ <pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 155</span>
1385
1404
 
1386
1405
  <span class='kw'>def</span> <span class='id identifier rubyid_format_number'>format_number</span><span class='lparen'>(</span><span class='id identifier rubyid_precision'>precision</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_decimal_separator'>decimal_separator</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_add_string'>add_string</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_k_separator'>k_separator</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
1387
1406
  <span class='kw'>if</span> <span class='id identifier rubyid_is_number?'>is_number?</span> <span class='kw'>then</span>
@@ -1496,12 +1515,12 @@
1496
1515
  <pre class="lines">
1497
1516
 
1498
1517
 
1499
- 182
1500
- 183
1501
- 184</pre>
1518
+ 184
1519
+ 185
1520
+ 186</pre>
1502
1521
  </td>
1503
1522
  <td>
1504
- <pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 182</span>
1523
+ <pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 184</span>
1505
1524
 
1506
1525
  <span class='kw'>def</span> <span class='id identifier rubyid_indexize'>indexize</span><span class='lparen'>(</span><span class='id identifier rubyid_length'>length</span> <span class='op'>=</span> <span class='int'>2</span><span class='comma'>,</span> <span class='id identifier rubyid_filler'>filler</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>0</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_formatter'>formatter</span> <span class='op'>=</span> <span class='symbol'>:rjust</span><span class='rparen'>)</span>
1507
1526
  <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_formatter'>formatter</span><span class='comma'>,</span> <span class='id identifier rubyid_length'>length</span><span class='comma'>,</span> <span class='id identifier rubyid_filler'>filler</span><span class='rparen'>)</span>
@@ -1806,12 +1825,12 @@
1806
1825
  <pre class="lines">
1807
1826
 
1808
1827
 
1809
- 141
1810
- 142
1811
- 143</pre>
1828
+ 143
1829
+ 144
1830
+ 145</pre>
1812
1831
  </td>
1813
1832
  <td>
1814
- <pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 141</span>
1833
+ <pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 143</span>
1815
1834
 
1816
1835
  <span class='kw'>def</span> <span class='id identifier rubyid_round_to_precision'>round_to_precision</span><span class='lparen'>(</span><span class='id identifier rubyid_precision'>precision</span> <span class='op'>=</span> <span class='int'>2</span><span class='rparen'>)</span>
1817
1836
  <span class='id identifier rubyid_is_number?'>is_number?</span> <span class='op'>?</span> <span class='id identifier rubyid_number_with_precision'>number_with_precision</span><span class='lparen'>(</span><span class='id identifier rubyid_to_float'>to_float</span><span class='comma'>,</span> <span class='label'>precision:</span> <span class='lbracket'>[</span><span class='id identifier rubyid_precision'>precision</span><span class='comma'>,</span> <span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>nil</span>
@@ -1863,12 +1882,12 @@
1863
1882
  <pre class="lines">
1864
1883
 
1865
1884
 
1866
- 117
1867
- 118
1868
- 119</pre>
1885
+ 119
1886
+ 120
1887
+ 121</pre>
1869
1888
  </td>
1870
1889
  <td>
1871
- <pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 117</span>
1890
+ <pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 119</span>
1872
1891
 
1873
1892
  <span class='kw'>def</span> <span class='id identifier rubyid_to_boolean'>to_boolean</span>
1874
1893
  <span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>TrueClass</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='kw'>self</span> <span class='op'>==</span> <span class='float'>1.0</span> <span class='op'>||</span> <span class='kw'>self</span> <span class='op'>==</span> <span class='int'>1</span> <span class='op'>||</span> <span class='id identifier rubyid_ensure_string'>ensure_string</span> <span class='op'>=~</span> <span class='op'>::</span><span class='const'>Lazier</span><span class='op'>::</span><span class='const'>Object</span><span class='op'>::</span><span class='const'>BOOLEAN_TRUE_MATCHER</span> <span class='op'>||</span> <span class='kw'>false</span>
@@ -1941,12 +1960,12 @@
1941
1960
  <pre class="lines">
1942
1961
 
1943
1962
 
1944
- 133
1945
- 134
1946
- 135</pre>
1963
+ 135
1964
+ 136
1965
+ 137</pre>
1947
1966
  </td>
1948
1967
  <td>
1949
- <pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 133</span>
1968
+ <pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 135</span>
1950
1969
 
1951
1970
  <span class='kw'>def</span> <span class='id identifier rubyid_to_float'>to_float</span><span class='lparen'>(</span><span class='id identifier rubyid_default_value'>default_value</span> <span class='op'>=</span> <span class='float'>0.0</span><span class='rparen'>)</span>
1952
1971
  <span class='id identifier rubyid_is_float?'>is_float?</span> <span class='op'>?</span> <span class='op'>::</span><span class='const'>Kernel</span><span class='period'>.</span><span class='const'>Float</span><span class='lparen'>(</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Numeric</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='kw'>self</span> <span class='op'>:</span> <span class='id identifier rubyid_normalize_number'>normalize_number</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_default_value'>default_value</span>
@@ -2019,12 +2038,12 @@
2019
2038
  <pre class="lines">
2020
2039
 
2021
2040
 
2022
- 125
2023
- 126
2024
- 127</pre>
2041
+ 127
2042
+ 128
2043
+ 129</pre>
2025
2044
  </td>
2026
2045
  <td>
2027
- <pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 125</span>
2046
+ <pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 127</span>
2028
2047
 
2029
2048
  <span class='kw'>def</span> <span class='id identifier rubyid_to_integer'>to_integer</span><span class='lparen'>(</span><span class='id identifier rubyid_default_value'>default_value</span> <span class='op'>=</span> <span class='int'>0</span><span class='rparen'>)</span>
2030
2049
  <span class='id identifier rubyid_to_float'>to_float</span><span class='lparen'>(</span><span class='id identifier rubyid_default_value'>default_value</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span>
@@ -2039,7 +2058,7 @@
2039
2058
  </div>
2040
2059
 
2041
2060
  <div id="footer">
2042
- Generated on Sat Jul 20 10:18:18 2013 by
2061
+ Generated on Sat Jul 20 12:56:19 2013 by
2043
2062
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
2044
2063
  0.8.6.2 (ruby-1.9.3).
2045
2064
  </div>
@@ -213,7 +213,7 @@ Pathname.new("/usr/bin/ruby").components
213
213
  </div>
214
214
 
215
215
  <div id="footer">
216
- Generated on Sat Jul 20 10:18:19 2013 by
216
+ Generated on Sat Jul 20 12:56:20 2013 by
217
217
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
218
218
  0.8.6.2 (ruby-1.9.3).
219
219
  </div>
@@ -2405,7 +2405,7 @@
2405
2405
  </div>
2406
2406
 
2407
2407
  <div id="footer">
2408
- Generated on Sat Jul 20 10:18:19 2013 by
2408
+ Generated on Sat Jul 20 12:56:20 2013 by
2409
2409
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
2410
2410
  0.8.6.2 (ruby-1.9.3).
2411
2411
  </div>
@@ -563,7 +563,7 @@
563
563
  </div>
564
564
 
565
565
  <div id="footer">
566
- Generated on Sat Jul 20 10:18:18 2013 by
566
+ Generated on Sat Jul 20 12:56:18 2013 by
567
567
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
568
568
  0.8.6.2 (ruby-1.9.3).
569
569
  </div>
@@ -1663,7 +1663,7 @@
1663
1663
  </div>
1664
1664
 
1665
1665
  <div id="footer">
1666
- Generated on Sat Jul 20 10:18:19 2013 by
1666
+ Generated on Sat Jul 20 12:56:19 2013 by
1667
1667
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1668
1668
  0.8.6.2 (ruby-1.9.3).
1669
1669
  </div>
@@ -1015,7 +1015,7 @@ DateTime.parameterize_zone(ActiveSupport::TimeZone["Pacific Time (US &amp; Canad
1015
1015
  </div>
1016
1016
 
1017
1017
  <div id="footer">
1018
- Generated on Sat Jul 20 10:18:19 2013 by
1018
+ Generated on Sat Jul 20 12:56:20 2013 by
1019
1019
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1020
1020
  0.8.6.2 (ruby-1.9.3).
1021
1021
  </div>
@@ -149,7 +149,7 @@
149
149
 
150
150
  </div>
151
151
  </dt>
152
- <dd><pre class="code"><span class='int'>6</span></pre></dd>
152
+ <dd><pre class="code"><span class='int'>7</span></pre></dd>
153
153
 
154
154
  <dt id="STRING-constant" class="">STRING =
155
155
  <div class="docstring">
@@ -180,7 +180,7 @@
180
180
  </div>
181
181
 
182
182
  <div id="footer">
183
- Generated on Sat Jul 20 10:18:18 2013 by
183
+ Generated on Sat Jul 20 12:56:19 2013 by
184
184
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
185
185
  0.8.6.2 (ruby-1.9.3).
186
186
  </div>
@@ -333,7 +333,7 @@
333
333
  </div>
334
334
 
335
335
  <div id="footer">
336
- Generated on Sat Jul 20 10:18:17 2013 by
336
+ Generated on Sat Jul 20 12:56:18 2013 by
337
337
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
338
338
  0.8.6.2 (ruby-1.9.3).
339
339
  </div>
@@ -105,7 +105,7 @@ See documentation for more informations.</p>
105
105
  </div></div>
106
106
 
107
107
  <div id="footer">
108
- Generated on Sat Jul 20 10:18:17 2013 by
108
+ Generated on Sat Jul 20 12:56:18 2013 by
109
109
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
110
110
  0.8.6.2 (ruby-1.9.3).
111
111
  </div>
@@ -105,7 +105,7 @@ See documentation for more informations.</p>
105
105
  </div></div>
106
106
 
107
107
  <div id="footer">
108
- Generated on Sat Jul 20 10:18:17 2013 by
108
+ Generated on Sat Jul 20 12:56:18 2013 by
109
109
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
110
110
  0.8.6.2 (ruby-1.9.3).
111
111
  </div>
@@ -103,7 +103,7 @@
103
103
  </div>
104
104
 
105
105
  <div id="footer">
106
- Generated on Sat Jul 20 10:18:17 2013 by
106
+ Generated on Sat Jul 20 12:56:18 2013 by
107
107
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
108
108
  0.8.6.2 (ruby-1.9.3).
109
109
  </div>
@@ -75,14 +75,16 @@ module Lazier
75
75
  # @param default_value [Array|NilClass] The default array to use. If not specified, an array containing the object is returned.
76
76
  # @param uniq [Boolean] If to remove duplicates from the array before sanitizing.
77
77
  # @param compact [Boolean] If to compact the array before sanitizing.
78
+ # @param flatten [Boolean] If to flatten the array before sanitizing.
78
79
  # @param sanitizer [Symbol|nil] If not `nil`, the method to use to sanitize entries of the array. *Ignored if a block is present.*
79
80
  # @param block [Proc] A block to sanitize entries. It must accept the value as unique argument.
80
81
  # @return [Array] If the object is an array, then the object itself, a single element array containing the object otherwise.
81
- def ensure_array(default_value = nil, uniq = false, compact = false, sanitizer = nil, &block)
82
+ def ensure_array(default_value = nil, uniq = false, compact = false, flatten = nil, sanitizer = nil, &block)
82
83
  rv = is_a?(::Array) ? dup : (default_value || [self])
83
84
  rv.collect!(&(block || sanitizer))
84
85
  rv.uniq! if uniq
85
86
  rv.compact! if compact
87
+ rv.flatten! if flatten
86
88
  rv
87
89
  end
88
90
 
@@ -91,7 +93,7 @@ module Lazier
91
93
  # @param default_value [Hash|Object|NilClass] The default value to use. If it is an `Hash`, it is returned as value otherwise it is used to build as a key to build an hash with the current object as only value (everything but strings and symbols are mapped to `key`).
92
94
  # @param sanitizer [Symbol|nil] If not `nil`, the method to use to sanitize values of the hash. *Ignored if a block is present.*
93
95
  # @return [Hash] If the object is an hash, then the object itself, a hash with the object as single value otherwise.
94
- def ensure_hash(default_value = nil, sanitizer = nil)
96
+ def ensure_hash(default_value = {}, sanitizer = nil)
95
97
  rv = if is_a?(::Hash) then
96
98
  self
97
99
  elsif default_value.is_a?(::Hash) then
@@ -16,7 +16,7 @@ module Lazier
16
16
  MINOR = 2
17
17
 
18
18
  # The patch version.
19
- PATCH = 6
19
+ PATCH = 7
20
20
 
21
21
  # The current version of lazier.
22
22
  STRING = [MAJOR, MINOR, PATCH].compact.join(".")
@@ -147,14 +147,15 @@ describe Lazier::Object do
147
147
 
148
148
  it "should sanitize elements of the array using a method or a block" do
149
149
  expect(" 123 ".ensure_array).to eq([" 123 "])
150
- expect(" 123 ".ensure_array(nil, false, false, :strip)).to eq(["123"])
150
+ expect(" 123 ".ensure_array(nil, false, false, false, :strip)).to eq(["123"])
151
151
  expect(" 123 ".ensure_array(nil, false, false) { |e| e.reverse }).to eq([" 321 "])
152
152
  end
153
153
 
154
- it "should unicize and compact array if requested to" do
155
- expect([1, 2, 3, nil, 3, 2, 1].ensure_array(nil, true, false)).to eq([1, 2, 3, nil])
156
- expect([1, 2, 3, nil, 3, 2, 1].ensure_array(nil, false, true)).to eq([1, 2, 3, 3, 2, 1])
157
- expect([1, 2, 3, nil, 3, 2, 1].ensure_array(nil, true, true)).to eq([1, 2, 3])
154
+ it "should unicize, compact and flatten, array if requested to" do
155
+ expect([1, 2, 3, nil, 3, 2, 1, [4]].ensure_array(nil, true, false)).to eq([1, 2, 3, nil, [4]])
156
+ expect([1, 2, 3, nil, 3, 2, 1, [4]].ensure_array(nil, false, true)).to eq([1, 2, 3, 3, 2, 1, [4]])
157
+ expect([1, 2, 3, nil, 3, 2, 1, [4]].ensure_array(nil, true, true)).to eq([1, 2, 3, [4]])
158
+ expect([1, 2, 3, nil, 3, 2, 1, [4]].ensure_array(nil, true, true, true)).to eq([1, 2, 3, 4])
158
159
  end
159
160
  end
160
161
 
@@ -163,7 +164,7 @@ describe Lazier::Object do
163
164
  expect({a: "b"}.ensure_hash).to eq({a: "b"})
164
165
  expect(nil.ensure_hash({a: "b"})).to eq({a: "b"})
165
166
 
166
- expect(1.ensure_hash).to eq({key: 1})
167
+ expect(1.ensure_hash).to eq({})
167
168
  expect(1.ensure_hash(:test)).to eq({test: 1})
168
169
  expect(1.ensure_hash("test")).to eq({"test" => 1})
169
170
  expect(1.ensure_hash(2)).to eq({key: 1})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazier
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.6
4
+ version: 3.2.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
191
  version: '0'
192
192
  segments:
193
193
  - 0
194
- hash: 4413349439810427105
194
+ hash: -1967236641489505845
195
195
  requirements: []
196
196
  rubyforge_project: lazier
197
197
  rubygems_version: 1.8.25