zucker 100.0.0 → 100.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f8bb75403057690cfed951ee4e2762cf1357e591
4
- data.tar.gz: d311619cb79f5f27d0a508a730f2898f5804cdd2
3
+ metadata.gz: ecb89745ee4f24f789c3ad475057cfa774dbd0a8
4
+ data.tar.gz: 771104b172b788de3af437f9348e3221da2ba873
5
5
  SHA512:
6
- metadata.gz: 4cb68f3789887e3840c2f1ef48c1ee4e0d67e86004b70694e326de42fa700acf21a99f68d9bbc3180bbddb583d4fb8a30ad97cc7411f38abc925ed07014d5438
7
- data.tar.gz: 25093ae6399628b5ef854341381e33bfbb7cbc525c8382a556cb3c2ddca0135058ddcfa2be6c0029b154aa802ad2511929f564618e69474317eb5b45e7eebc23
6
+ metadata.gz: 0f231f34bb90f719cb10b34d208e182423ae0be29633bc1d599b41f225ad2def9c808090c37da2838f0cc5c195f70dace1e6aa89a4e3ad105a45e971ee3a9c31
7
+ data.tar.gz: d57f276d213293293a85ae3ac8d55efc86b61833cf0518c3c85b3db35370513ff273ffd0e2ecd37caea8f4f74a74a4a9ad7d22b898093cbf1bcaec7a40c0fef3
@@ -1,3 +1,11 @@
1
+ 2015-04-01 | Zucker 100.1.0
2
+ * drop Ruby 1.9 support
3
+ * add float_extras for Float#same?
4
+ * add chain_map
5
+ * add inner_map
6
+ * add array_stats
7
+
8
+
1
9
  2014-04-01 | Zucker 100.0.0
2
10
  * drop Ruby 1.8 support
3
11
  * rewrite zucker to use refinements!
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2014 Jan Lelis
1
+ Copyright (c) 2010-2015 Jan Lelis
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,13 +1,15 @@
1
- # Zucker [![travis](https://travis-ci.org/janlelis/zucker.png?branch=master)](https://travis-ci.org/janlelis/zucker)
1
+ # Ruby Zucker [![version](https://badge.fury.io/rb/zucker.svg)](http://badge.fury.io/rb/zucker) [![travis](https://travis-ci.org/janlelis/zucker.png?branch=master)](https://travis-ci.org/janlelis/zucker)
2
2
 
3
3
  Lots of small refinements to sweeten your Ruby code. See http://rubyzucker.info for more documentation.
4
4
 
5
5
  ## Example
6
6
 
7
- require 'zucker/camel_snake'
8
- using Zucker::CamelSnake
9
- 'was_snake_string'.to_camel # => 'WasSnakeString'
10
- 'WasCamelString'.to_snake # => 'was_camel_string'
7
+ ```ruby
8
+ require 'zucker/camel_snake'
9
+ using Zucker::CamelSnake
10
+ 'was_snake_string'.to_camel # => 'WasSnakeString'
11
+ 'WasCamelString'.to_snake # => 'was_camel_string'
12
+ ```
11
13
 
12
14
  ## Changes
13
15
 
@@ -19,4 +21,4 @@ Missing former functionality? It might have been extracted to separate gems:
19
21
  * [ruby_version](https://github.com/janlelis/ruby_version)
20
22
  * [ruby_engine](https://github.com/janlelis/ruby_engine)
21
23
 
22
- Copyright (c) 2010-2014 Jan Lelis | http://janlelis.de | Released under the MIT license
24
+ Copyright (c) 2010-2015 Jan Lelis | http://janlelis.de | Released under the MIT license
@@ -29,8 +29,8 @@ class ZuckerDoc
29
29
  @date = Zucker::DATE
30
30
 
31
31
  # include + format changelog
32
- @changelog = replace_html_special_chars File.read File.join( @path, 'CHANGELOG' )
33
- @changelog.gsub! /\| Zucker (?<version>\d+(?:\.\d+)?)/ do
32
+ @changelog = replace_html_special_chars File.read File.join( @path, 'CHANGELOG.txt' )
33
+ @changelog.gsub! /\| Zucker (?<version>\d+(?:\.\d+)*?)/ do
34
34
  version = $~[:version].to_f
35
35
  version = version.to_i if version == version.to_i # oO
36
36
  if version && version > 0
data/doc/zucker.html CHANGED
@@ -317,12 +317,12 @@ Hash.zip [1,2,3], [4,5,6] # => {1=>4, 2=>5, 3=>6}</pre>
317
317
  <div class="code"><pre>using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">AliasFor</span></pre></div>
318
318
  </div>
319
319
  </div></td></tr><tr><th>Usage</th> <td><h5>Module#alias_for, Module#aliases_for</h5><div class="usage source" style="display:block"><div class="CodeRay">
320
- <div class="code"><pre><span style="color:#888"># creates an alias for the method :methods with the name ms</span>
320
+ <div class="code"><pre><span style="color:#777"># creates an alias for the method :methods with the name ms</span>
321
321
  <span style="color:#080;font-weight:bold">class</span> <span style="color:#B06;font-weight:bold">Object</span>
322
322
  alias_for <span style="color:#A60">:methods</span>, <span style="color:#A60">:ms</span>
323
323
  <span style="color:#080;font-weight:bold">end</span>
324
324
 
325
- <span style="color:#888"># creates multiple aliases</span>
325
+ <span style="color:#777"># creates multiple aliases</span>
326
326
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Enumerable</span>
327
327
  aliases_for <span style="color:#A60">:zip</span>, <span style="color:#A60">:with</span>, <span style="color:#A60">:%</span>
328
328
  <span style="color:#080;font-weight:bold">end</span>
@@ -330,65 +330,65 @@ Hash.zip [1,2,3], [4,5,6] # => {1=>4, 2=>5, 3=>6}</pre>
330
330
  </div>
331
331
  </div></td></tr><tr><th>Specification</th> <td> <span id="show_alias_for_spec">(<a href="javascript:show('alias_for_spec')">show</a>)</span>
332
332
  <div class="source" id="alias_for_spec"><div class="CodeRay">
333
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker/alias_for</span><span style="color:#710">'</span></span>
333
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker/alias_for</span><span style="color:#710">'</span></span>
334
334
  using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">AliasFor</span>
335
335
 
336
336
 
337
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">alias_for</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
338
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should create an alias for instance methods</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
337
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">alias_for</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
338
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should create an alias for instance methods</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
339
339
  <span style="color:#080;font-weight:bold">class</span> <span style="color:#B06;font-weight:bold">Array</span>
340
340
  <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">m2</span>
341
- <span style="color:#00D;font-weight:bold">2</span>
341
+ <span style="color:#00D">2</span>
342
342
  <span style="color:#080;font-weight:bold">end</span>
343
- aliases_for <span style="color:#A60">:m2</span>, <span style="color:#A60">:a2</span>, <span style="color:#A60"><span style="color:#A60">:</span><span style="color:#630">'</span><span style="color:#A60">a-2</span><span style="color:#630">'</span></span>
343
+ aliases_for <span style="color:#A60">:m2</span>, <span style="color:#A60">:a2</span>, <span style="color:#A60"><span style="color:#A60">:</span><span style="color:#740">'</span><span style="color:#A60">a-2</span><span style="color:#740">'</span></span>
344
344
  <span style="color:#080;font-weight:bold">end</span>
345
345
  proc <span style="color:#080;font-weight:bold">do</span>
346
- [<span style="color:#00D;font-weight:bold">1</span>,<span style="color:#00D;font-weight:bold">2</span>,<span style="color:#00D;font-weight:bold">3</span>].a2.should == <span style="color:#00D;font-weight:bold">2</span>
347
- [<span style="color:#00D;font-weight:bold">1</span>,<span style="color:#00D;font-weight:bold">2</span>,<span style="color:#00D;font-weight:bold">3</span>].send(<span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">a-2</span><span style="color:#710">'</span></span>).should == <span style="color:#00D;font-weight:bold">2</span>
346
+ [<span style="color:#00D">1</span>,<span style="color:#00D">2</span>,<span style="color:#00D">3</span>].a2.should == <span style="color:#00D">2</span>
347
+ [<span style="color:#00D">1</span>,<span style="color:#00D">2</span>,<span style="color:#00D">3</span>].send(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">a-2</span><span style="color:#710">'</span></span>).should == <span style="color:#00D">2</span>
348
348
  <span style="color:#080;font-weight:bold">end</span>.should_not raise_exception
349
349
  <span style="color:#080;font-weight:bold">end</span>
350
350
 
351
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should create an alias for class (singleton) methods</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
351
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should create an alias for class (singleton) methods</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
352
352
  <span style="color:#080;font-weight:bold">class</span> <span style="color:#B06;font-weight:bold">Array</span>
353
353
  <span style="color:#080;font-weight:bold">class</span> &lt;&lt; <span style="color:#B06;font-weight:bold">Array</span>
354
354
  <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">m3</span>
355
- <span style="color:#00D;font-weight:bold">3</span>
355
+ <span style="color:#00D">3</span>
356
356
  <span style="color:#080;font-weight:bold">end</span>
357
357
  alias_for <span style="color:#A60">:m3</span>, <span style="color:#A60">:a3</span>
358
358
  <span style="color:#080;font-weight:bold">end</span>
359
359
  <span style="color:#080;font-weight:bold">end</span>
360
360
 
361
361
  proc{
362
- <span style="color:#036;font-weight:bold">Array</span>.a3.should == <span style="color:#00D;font-weight:bold">3</span>
362
+ <span style="color:#036;font-weight:bold">Array</span>.a3.should == <span style="color:#00D">3</span>
363
363
  }.should_not raise_exception
364
364
  <span style="color:#080;font-weight:bold">end</span>
365
365
 
366
366
 
367
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should create aliases for the first argument with all other arguments</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
367
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should create aliases for the first argument with all other arguments</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
368
368
  <span style="color:#080;font-weight:bold">class</span> <span style="color:#B06;font-weight:bold">Object</span>
369
369
  <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">m4</span>
370
- <span style="color:#00D;font-weight:bold">4</span>
370
+ <span style="color:#00D">4</span>
371
371
  <span style="color:#080;font-weight:bold">end</span>
372
372
  alias_for <span style="color:#A60">:m4</span>, <span style="color:#A60">:ma</span>, <span style="color:#A60">:mb</span>, <span style="color:#A60">:mc</span>
373
373
  <span style="color:#080;font-weight:bold">end</span>
374
374
 
375
375
  proc{
376
- <span style="color:#00D;font-weight:bold">1</span>.ma.should == <span style="color:#00D;font-weight:bold">4</span>
377
- <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">&quot;</span><span style="">1</span><span style="color:#710">&quot;</span></span>.mb.should == <span style="color:#00D;font-weight:bold">4</span>
378
- [<span style="color:#00D;font-weight:bold">1</span>].mc.should == <span style="color:#00D;font-weight:bold">4</span>
376
+ <span style="color:#00D">1</span>.ma.should == <span style="color:#00D">4</span>
377
+ <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">1</span><span style="color:#710">&quot;</span></span>.mb.should == <span style="color:#00D">4</span>
378
+ [<span style="color:#00D">1</span>].mc.should == <span style="color:#00D">4</span>
379
379
  }.should_not raise_exception
380
380
  <span style="color:#080;font-weight:bold">end</span>
381
381
 
382
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">works with uncommon chars</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
382
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">works with uncommon chars</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
383
383
  <span style="color:#080;font-weight:bold">class</span> <span style="color:#B06;font-weight:bold">Object</span>
384
- alias_for <span style="color:#A60">:tainted?</span>, <span style="color:#A60"><span style="color:#A60">:</span><span style="color:#630">&quot;</span><span style="color:#A60">tain-ted?</span><span style="color:#630">&quot;</span></span>
384
+ alias_for <span style="color:#A60">:tainted?</span>, <span style="color:#A60"><span style="color:#A60">:</span><span style="color:#740">&quot;</span><span style="color:#A60">tain-ted?</span><span style="color:#740">&quot;</span></span>
385
385
  <span style="color:#080;font-weight:bold">end</span>
386
386
  <span style="color:#080;font-weight:bold">end</span>
387
387
  <span style="color:#080;font-weight:bold">end</span></pre></div>
388
388
  </div>
389
389
  </div> </td></tr><tr><th>Source</th> <td> <span id="show_alias_for_source">(<a href="javascript:show('alias_for_source')">show</a>)</span>
390
390
  <div class="source" id="alias_for_source"><div class="CodeRay">
391
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker</span><span style="color:#710">'</span></span>
391
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker</span><span style="color:#710">'</span></span>
392
392
 
393
393
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Zucker</span>
394
394
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">AliasFor</span>
@@ -396,7 +396,7 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
396
396
  private
397
397
 
398
398
  <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">alias_for</span>(m, *aliases)
399
- aliases.each{ |a| class_eval <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">&quot;</span><span style="">alias :'</span><span style="background:#ddd;color:black"><span style="background:#ddd;font-weight:bold;color:#666">#{</span> a <span style="background:#ddd;font-weight:bold;color:#666">}</span></span><span style="">' :'</span><span style="background:#ddd;color:black"><span style="background:#ddd;font-weight:bold;color:#666">#{</span> m <span style="background:#ddd;font-weight:bold;color:#666">}</span></span><span style="">'</span><span style="color:#710">&quot;</span></span> }
399
+ aliases.each{ |a| class_eval <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">alias :'</span><span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="font-weight:bold;color:#666">#{</span> a <span style="font-weight:bold;color:#666">}</span></span><span style="color:#D20">' :'</span><span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="font-weight:bold;color:#666">#{</span> m <span style="font-weight:bold;color:#666">}</span></span><span style="color:#D20">'</span><span style="color:#710">&quot;</span></span> }
400
400
  <span style="color:#080;font-weight:bold">end</span>
401
401
 
402
402
  <span style="color:#080;font-weight:bold">alias</span> <span style="color:#06B;font-weight:bold">aliases_for</span> <span style="color:#06B;font-weight:bold">alias_for</span>
@@ -411,37 +411,37 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
411
411
  <div class="code"><pre>using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">ArrayOp</span></pre></div>
412
412
  </div>
413
413
  </div></td></tr><tr><th>Usage</th> <td><h5>Array#^</h5><div class="usage source" style="display:block"><div class="CodeRay">
414
- <div class="code"><pre>[<span style="color:#00D;font-weight:bold">1</span>,<span style="color:#00D;font-weight:bold">2</span>,<span style="color:#00D;font-weight:bold">3</span>,<span style="color:#00D;font-weight:bold">4</span>] ^ [<span style="color:#00D;font-weight:bold">3</span>,<span style="color:#00D;font-weight:bold">4</span>,<span style="color:#00D;font-weight:bold">5</span>,<span style="color:#00D;font-weight:bold">6</span>] <span style="color:#888"># =&gt; [1,2,5,6]</span></pre></div>
414
+ <div class="code"><pre>[<span style="color:#00D">1</span>,<span style="color:#00D">2</span>,<span style="color:#00D">3</span>,<span style="color:#00D">4</span>] ^ [<span style="color:#00D">3</span>,<span style="color:#00D">4</span>,<span style="color:#00D">5</span>,<span style="color:#00D">6</span>] <span style="color:#777"># =&gt; [1,2,5,6]</span></pre></div>
415
415
  </div>
416
416
  </div></td></tr><tr><th>Specification</th> <td> <span id="show_array_op_spec">(<a href="javascript:show('array_op_spec')">show</a>)</span>
417
417
  <div class="source" id="array_op_spec"><div class="CodeRay">
418
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker/array_op</span><span style="color:#710">'</span></span>
418
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker/array_op</span><span style="color:#710">'</span></span>
419
419
  using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">ArrayOp</span>
420
420
 
421
421
 
422
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">Array#^</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
423
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">does an exclusive or</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
424
- a = [<span style="color:#00D;font-weight:bold">1</span>,<span style="color:#00D;font-weight:bold">2</span>,<span style="color:#00D;font-weight:bold">3</span>,<span style="color:#00D;font-weight:bold">4</span>]
425
- b = [<span style="color:#00D;font-weight:bold">3</span>,<span style="color:#00D;font-weight:bold">4</span>,<span style="color:#00D;font-weight:bold">5</span>,<span style="color:#00D;font-weight:bold">6</span>]
426
- (a^b).should == [<span style="color:#00D;font-weight:bold">1</span>,<span style="color:#00D;font-weight:bold">2</span>,<span style="color:#00D;font-weight:bold">5</span>,<span style="color:#00D;font-weight:bold">6</span>]
422
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Array#^</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
423
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">does an exclusive or</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
424
+ a = [<span style="color:#00D">1</span>,<span style="color:#00D">2</span>,<span style="color:#00D">3</span>,<span style="color:#00D">4</span>]
425
+ b = [<span style="color:#00D">3</span>,<span style="color:#00D">4</span>,<span style="color:#00D">5</span>,<span style="color:#00D">6</span>]
426
+ (a^b).should == [<span style="color:#00D">1</span>,<span style="color:#00D">2</span>,<span style="color:#00D">5</span>,<span style="color:#00D">6</span>]
427
427
  <span style="color:#080;font-weight:bold">end</span>
428
428
  <span style="color:#080;font-weight:bold">end</span>
429
429
 
430
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">Array#**</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
431
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">returns the array product</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
432
- ([<span style="color:#00D;font-weight:bold">1</span>,<span style="color:#00D;font-weight:bold">2</span>] ** <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">%w[</span><span style="">a b</span><span style="color:#710">]</span></span>).should == [[<span style="color:#00D;font-weight:bold">1</span>, <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">&quot;</span><span style="">a</span><span style="color:#710">&quot;</span></span>], [<span style="color:#00D;font-weight:bold">1</span>, <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">&quot;</span><span style="">b</span><span style="color:#710">&quot;</span></span>], [<span style="color:#00D;font-weight:bold">2</span>, <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">&quot;</span><span style="">a</span><span style="color:#710">&quot;</span></span>], [<span style="color:#00D;font-weight:bold">2</span>, <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">&quot;</span><span style="">b</span><span style="color:#710">&quot;</span></span>]]
430
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Array#**</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
431
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">returns the array product</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
432
+ ([<span style="color:#00D">1</span>,<span style="color:#00D">2</span>] ** <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">%w[</span><span style="color:#D20">a b</span><span style="color:#710">]</span></span>).should == [[<span style="color:#00D">1</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">a</span><span style="color:#710">&quot;</span></span>], [<span style="color:#00D">1</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">b</span><span style="color:#710">&quot;</span></span>], [<span style="color:#00D">2</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">a</span><span style="color:#710">&quot;</span></span>], [<span style="color:#00D">2</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">b</span><span style="color:#710">&quot;</span></span>]]
433
433
  <span style="color:#080;font-weight:bold">end</span>
434
434
  <span style="color:#080;font-weight:bold">end</span></pre></div>
435
435
  </div>
436
436
  </div> </td></tr><tr><th>Source</th> <td> <span id="show_array_op_source">(<a href="javascript:show('array_op_source')">show</a>)</span>
437
437
  <div class="source" id="array_op_source"><div class="CodeRay">
438
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker</span><span style="color:#710">'</span></span>
438
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker</span><span style="color:#710">'</span></span>
439
439
 
440
440
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Zucker</span>
441
441
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">ArrayOp</span>
442
442
  refine <span style="color:#036;font-weight:bold">Array</span> <span style="color:#080;font-weight:bold">do</span>
443
443
  <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">^</span>(other)
444
- (<span style="color:#038;font-weight:bold">self</span> - other) + (other - <span style="color:#038;font-weight:bold">self</span>)
444
+ (<span style="color:#069">self</span> - other) + (other - <span style="color:#069">self</span>)
445
445
  <span style="color:#080;font-weight:bold">end</span>
446
446
 
447
447
  <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">**</span>(*o, &amp;block)
@@ -451,6 +451,146 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
451
451
  <span style="color:#080;font-weight:bold">end</span>
452
452
  <span style="color:#080;font-weight:bold">end</span></pre></div>
453
453
  </div>
454
+ </div> </td></tr></table></div> <div class="cubes"><h3 title="require 'zucker/array_stats'" id="array_stats">array_stats</h3>
455
+ <table class="cube_table"
456
+ id="array_stats_cube"
457
+ title="require 'zucker/array_stats'"> <tr><th>Summary</th> <td>Statistics for <code>Array</code></td></tr><tr><th>Activate</th> <td><div class="using source" style="display:block"><div class="CodeRay">
458
+ <div class="code"><pre>using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">ArrayStats</span></pre></div>
459
+ </div>
460
+ </div></td></tr><tr><th>Usage</th> <td><h5>Array#mean</h5><div class="usage source" style="display:block"><div class="CodeRay">
461
+ <div class="code"><pre><span style="color:#777"># calculates mean (average)</span></pre></div>
462
+ </div>
463
+ </div><h5>Array#stdev</h5><div class="usage source" style="display:block"><div class="CodeRay">
464
+ <div class="code"><pre><span style="color:#777"># calculates standard deviation (takes :sample or :population as argument)</span></pre></div>
465
+ </div>
466
+ </div><h5>Array#stdev_sample</h5><div class="usage source" style="display:block"><div class="CodeRay">
467
+ <div class="code"><pre><span style="color:#777"># calculates sample standard deviation</span></pre></div>
468
+ </div>
469
+ </div><h5>Array#stdev_population</h5><div class="usage source" style="display:block"><div class="CodeRay">
470
+ <div class="code"><pre><span style="color:#777"># calculates population standard deviation</span></pre></div>
471
+ </div>
472
+ </div><h5>Array#z_score</h5><div class="usage source" style="display:block"><div class="CodeRay">
473
+ <div class="code"><pre><span style="color:#777"># calculates standard score</span></pre></div>
474
+ </div>
475
+ </div></td></tr><tr><th>Specification</th> <td> <span id="show_array_stats_spec">(<a href="javascript:show('array_stats_spec')">show</a>)</span>
476
+ <div class="source" id="array_stats_spec"><div class="CodeRay">
477
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">zucker/array_stats</span><span style="color:#710">&quot;</span></span>
478
+ using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">ArrayStats</span>
479
+
480
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">doing statistics on arrays</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
481
+ let(<span style="color:#A60">:list</span>) { (<span style="color:#00D">2</span>..<span style="color:#00D">5</span>).to_a }
482
+
483
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Array#mean</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
484
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">should return the average</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
485
+ list.mean.should == <span style="color:#60E">3.5</span>
486
+ <span style="color:#080;font-weight:bold">end</span>
487
+ <span style="color:#080;font-weight:bold">end</span>
488
+
489
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Array#stdev_sample</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
490
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">should return the standard deviation of the sample</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
491
+ list.stdev_sample.should be_close(<span style="color:#60E">1.2909944487358056</span>, <span style="color:#60E">1e-8</span>)
492
+ <span style="color:#080;font-weight:bold">end</span>
493
+ <span style="color:#080;font-weight:bold">end</span>
494
+
495
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Array#stdev_population</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
496
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">should return the standard deviation of the population</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
497
+ list.stdev_population.should be_close(<span style="color:#60E">1.118033988749895</span>, <span style="color:#60E">1e-8</span>)
498
+ <span style="color:#080;font-weight:bold">end</span>
499
+ <span style="color:#080;font-weight:bold">end</span>
500
+
501
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Array#stdev</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
502
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">should default to population</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
503
+ list.stdev.should be_close(list.stdev_population, <span style="color:#60E">1e-8</span>)
504
+ <span style="color:#080;font-weight:bold">end</span>
505
+
506
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">should delegate sample correctly</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
507
+ list.stdev(<span style="color:#A60">:sample</span>).should be_close(list.stdev_sample, <span style="color:#60E">1e-8</span>)
508
+ <span style="color:#080;font-weight:bold">end</span>
509
+
510
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">should delegate population correctly</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
511
+ list.stdev(<span style="color:#A60">:population</span>).should be_close(list.stdev_population, <span style="color:#60E">1e-8</span>)
512
+ <span style="color:#080;font-weight:bold">end</span>
513
+
514
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">should raise an error with any other key</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
515
+ expect { list.stdev(<span style="color:#A60">:pony</span>) }.to raise_error(<span style="color:#036;font-weight:bold">ArgumentError</span>)
516
+ <span style="color:#080;font-weight:bold">end</span>
517
+ <span style="color:#080;font-weight:bold">end</span>
518
+
519
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Array#z_score</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
520
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">should default to population</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
521
+ list.z_score.zip(list.z_score(<span style="color:#A60">:population</span>)).each <span style="color:#080;font-weight:bold">do</span> |value, actual|
522
+ value.should be_close(actual, <span style="color:#60E">1e-8</span>)
523
+ <span style="color:#080;font-weight:bold">end</span>
524
+ <span style="color:#080;font-weight:bold">end</span>
525
+
526
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">should delegate sample correctly</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
527
+ sample_z_score = [
528
+ <span style="color:#60E">-1.161895003862225</span>,
529
+ <span style="color:#60E">-0.3872983346207417</span>,
530
+ <span style="color:#60E">0.3872983346207417</span>,
531
+ <span style="color:#60E">1.161895003862225</span>
532
+ ]
533
+
534
+ p list
535
+
536
+ list.z_score(<span style="color:#A60">:sample</span>).zip(sample_z_score).each <span style="color:#080;font-weight:bold">do</span> |value, actual|
537
+ value.should be_close(actual, <span style="color:#60E">1e-8</span>)
538
+ <span style="color:#080;font-weight:bold">end</span>
539
+ <span style="color:#080;font-weight:bold">end</span>
540
+
541
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">should delegate population correctly</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
542
+ population_z_score = [
543
+ <span style="color:#60E">-1.3416407864998738</span>,
544
+ <span style="color:#60E">-0.4472135954999579</span>,
545
+ <span style="color:#60E">0.4472135954999579</span>,
546
+ <span style="color:#60E">1.3416407864998738</span>
547
+ ]
548
+
549
+ list.z_score(<span style="color:#A60">:population</span>).zip(population_z_score).each <span style="color:#080;font-weight:bold">do</span> |value, actual|
550
+ value.should be_close(actual, <span style="color:#60E">1e-8</span>)
551
+ <span style="color:#080;font-weight:bold">end</span>
552
+ <span style="color:#080;font-weight:bold">end</span>
553
+
554
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">should raise an error with any other key</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
555
+ expect { list.z_score(<span style="color:#A60">:pony</span>) }.to raise_error(<span style="color:#036;font-weight:bold">ArgumentError</span>)
556
+ <span style="color:#080;font-weight:bold">end</span>
557
+ <span style="color:#080;font-weight:bold">end</span>
558
+ <span style="color:#080;font-weight:bold">end</span></pre></div>
559
+ </div>
560
+ </div> </td></tr><tr><th>Source</th> <td> <span id="show_array_stats_source">(<a href="javascript:show('array_stats_source')">show</a>)</span>
561
+ <div class="source" id="array_stats_source"><div class="CodeRay">
562
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">zucker</span><span style="color:#710">&quot;</span></span>
563
+
564
+ <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Zucker</span>
565
+ <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">ArrayStats</span>
566
+ refine <span style="color:#036;font-weight:bold">Array</span> <span style="color:#080;font-weight:bold">do</span>
567
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">mean</span>
568
+ inject(&amp;<span style="color:#A60">:+</span>) / length.to_f
569
+ <span style="color:#080;font-weight:bold">end</span>
570
+
571
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">stdev</span>(type = <span style="color:#A60">:population</span>)
572
+ <span style="color:#080;font-weight:bold">case</span> type
573
+ <span style="color:#080;font-weight:bold">when</span> <span style="color:#A60">:population</span> <span style="color:#080;font-weight:bold">then</span> stdev_population
574
+ <span style="color:#080;font-weight:bold">when</span> <span style="color:#A60">:sample</span> <span style="color:#080;font-weight:bold">then</span> stdev_sample
575
+ <span style="color:#080;font-weight:bold">else</span> raise <span style="color:#036;font-weight:bold">ArgumentError</span>.new(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">%s is not a valid argument</span><span style="color:#710">&quot;</span></span> % type)
576
+ <span style="color:#080;font-weight:bold">end</span>
577
+ <span style="color:#080;font-weight:bold">end</span>
578
+
579
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">stdev_sample</span>
580
+ <span style="color:#036;font-weight:bold">Math</span>.sqrt(inject(<span style="color:#60E">0.0</span>) { |sum, x| sum + (mean - x) ** <span style="color:#00D">2</span> } / (length - <span style="color:#00D">1</span>))
581
+ <span style="color:#080;font-weight:bold">end</span>
582
+
583
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">stdev_population</span>
584
+ <span style="color:#036;font-weight:bold">Math</span>.sqrt(inject(<span style="color:#60E">0.0</span>) { |sum, x| sum + (mean - x) ** <span style="color:#00D">2</span> } / length)
585
+ <span style="color:#080;font-weight:bold">end</span>
586
+
587
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">z_score</span>(type = <span style="color:#A60">:population</span>)
588
+ map { |x| (x - mean) / stdev(type) }
589
+ <span style="color:#080;font-weight:bold">end</span>
590
+ <span style="color:#080;font-weight:bold">end</span>
591
+ <span style="color:#080;font-weight:bold">end</span>
592
+ <span style="color:#080;font-weight:bold">end</span></pre></div>
593
+ </div>
454
594
  </div> </td></tr></table></div> <div class="cubes"><h3 title="require 'zucker/blank'" id="blank">blank</h3>
455
595
  <table class="cube_table"
456
596
  id="blank_cube"
@@ -458,43 +598,43 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
458
598
  <div class="code"><pre>using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">Blank</span></pre></div>
459
599
  </div>
460
600
  </div></td></tr><tr><th>Usage</th> <td><h5>Object#blank?</h5><div class="usage source" style="display:block"><div class="CodeRay">
461
- <div class="code"><pre><span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">an object</span><span style="color:#710">'</span></span>.blank? <span style="color:#888"># =&gt; false</span>
462
- <span style="color:#038;font-weight:bold">nil</span>.present? <span style="color:#888"># =&gt; false</span>
601
+ <div class="code"><pre><span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">an object</span><span style="color:#710">'</span></span>.blank? <span style="color:#777"># =&gt; false</span>
602
+ <span style="color:#069">nil</span>.present? <span style="color:#777"># =&gt; false</span>
463
603
  </pre></div>
464
604
  </div>
465
605
  </div></td></tr><tr><th>Specification</th> <td> <span id="show_blank_spec">(<a href="javascript:show('blank_spec')">show</a>)</span>
466
606
  <div class="source" id="blank_spec"><div class="CodeRay">
467
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker/blank</span><span style="color:#710">'</span></span>
607
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker/blank</span><span style="color:#710">'</span></span>
468
608
  using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">Blank</span>
469
609
 
470
610
 
471
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">Object#blank?</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
472
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should be blank for blank values</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
473
- blank_values = [ <span style="color:#038;font-weight:bold">nil</span>, <span style="color:#038;font-weight:bold">false</span>, <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="color:#710">'</span></span>, <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style=""> </span><span style="color:#710">'</span></span>, <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">&quot;</span><span style=""> </span><span style="color:#b0b">\n</span><span style="color:#b0b">\t</span><span style=""> </span><span style="color:#b0b">\r</span><span style=""> </span><span style="color:#710">&quot;</span></span>, [], {}, <span style="background-color:#fff0ff"><span style="color:#404">/</span><span style="color:#404">/</span></span> ]
611
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Object#blank?</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
612
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should be blank for blank values</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
613
+ blank_values = [ <span style="color:#069">nil</span>, <span style="color:#069">false</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#710">'</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20"> </span><span style="color:#710">'</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20"> </span><span style="color:#b0b">\n</span><span style="color:#b0b">\t</span><span style="color:#D20"> </span><span style="color:#b0b">\r</span><span style="color:#D20"> </span><span style="color:#710">&quot;</span></span>, [], {}, <span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#404">/</span></span> ]
474
614
 
475
615
  blank_values.each{ |blank|
476
- blank.blank?.should == <span style="color:#038;font-weight:bold">true</span>
616
+ blank.blank?.should == <span style="color:#069">true</span>
477
617
  }
478
618
  <span style="color:#080;font-weight:bold">end</span>
479
619
 
480
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should not be blank for non blank values</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
481
- present_values = [ <span style="color:#036;font-weight:bold">Object</span>.new, <span style="color:#038;font-weight:bold">true</span>, <span style="color:#00D;font-weight:bold">0</span>, <span style="color:#00D;font-weight:bold">1</span>, <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">a</span><span style="color:#710">'</span></span>, [<span style="color:#038;font-weight:bold">nil</span>], { <span style="color:#038;font-weight:bold">nil</span> =&gt; <span style="color:#038;font-weight:bold">nil</span> } ]
620
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should not be blank for non blank values</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
621
+ present_values = [ <span style="color:#036;font-weight:bold">Object</span>.new, <span style="color:#069">true</span>, <span style="color:#00D">0</span>, <span style="color:#00D">1</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">a</span><span style="color:#710">'</span></span>, [<span style="color:#069">nil</span>], { <span style="color:#069">nil</span> =&gt; <span style="color:#069">nil</span> } ]
482
622
 
483
623
  present_values.each{ |present|
484
- present.blank?.should == <span style="color:#038;font-weight:bold">false</span>
624
+ present.blank?.should == <span style="color:#069">false</span>
485
625
  }
486
626
  <span style="color:#080;font-weight:bold">end</span>
487
627
  <span style="color:#080;font-weight:bold">end</span></pre></div>
488
628
  </div>
489
629
  </div> </td></tr><tr><th>Source</th> <td> <span id="show_blank_source">(<a href="javascript:show('blank_source')">show</a>)</span>
490
630
  <div class="source" id="blank_source"><div class="CodeRay">
491
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker</span><span style="color:#710">'</span></span>
631
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker</span><span style="color:#710">'</span></span>
492
632
 
493
633
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Zucker</span>
494
634
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Blank</span>
495
635
  refine <span style="color:#036;font-weight:bold">Object</span> <span style="color:#080;font-weight:bold">do</span>
496
636
  <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">blank?</span>
497
- <span style="color:#080;font-weight:bold">if</span> respond_to? <span style="color:#A60">:empty?</span> <span style="color:#080;font-weight:bold">then</span> empty? <span style="color:#080;font-weight:bold">else</span> !<span style="color:#038;font-weight:bold">self</span> <span style="color:#080;font-weight:bold">end</span>
637
+ <span style="color:#080;font-weight:bold">if</span> respond_to? <span style="color:#A60">:empty?</span> <span style="color:#080;font-weight:bold">then</span> empty? <span style="color:#080;font-weight:bold">else</span> !<span style="color:#069">self</span> <span style="color:#080;font-weight:bold">end</span>
498
638
  <span style="color:#080;font-weight:bold">end</span>
499
639
 
500
640
  <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">present?</span>
@@ -503,19 +643,19 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
503
643
  <span style="color:#080;font-weight:bold">end</span>
504
644
 
505
645
  refine <span style="color:#036;font-weight:bold">NilClass</span> <span style="color:#080;font-weight:bold">do</span>
506
- <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">blank?</span>() <span style="color:#038;font-weight:bold">true</span> <span style="color:#080;font-weight:bold">end</span>
646
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">blank?</span>() <span style="color:#069">true</span> <span style="color:#080;font-weight:bold">end</span>
507
647
  <span style="color:#080;font-weight:bold">end</span>
508
648
 
509
649
  refine <span style="color:#036;font-weight:bold">FalseClass</span> <span style="color:#080;font-weight:bold">do</span>
510
- <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">blank?</span>() <span style="color:#038;font-weight:bold">true</span> <span style="color:#080;font-weight:bold">end</span>
650
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">blank?</span>() <span style="color:#069">true</span> <span style="color:#080;font-weight:bold">end</span>
511
651
  <span style="color:#080;font-weight:bold">end</span>
512
652
 
513
653
  refine <span style="color:#036;font-weight:bold">TrueClass</span> <span style="color:#080;font-weight:bold">do</span>
514
- <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">blank?</span>() <span style="color:#038;font-weight:bold">false</span> <span style="color:#080;font-weight:bold">end</span>
654
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">blank?</span>() <span style="color:#069">false</span> <span style="color:#080;font-weight:bold">end</span>
515
655
  <span style="color:#080;font-weight:bold">end</span>
516
656
 
517
657
  refine <span style="color:#036;font-weight:bold">Numeric</span> <span style="color:#080;font-weight:bold">do</span>
518
- <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">blank?</span>() <span style="color:#038;font-weight:bold">false</span> <span style="color:#080;font-weight:bold">end</span>
658
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">blank?</span>() <span style="color:#069">false</span> <span style="color:#080;font-weight:bold">end</span>
519
659
  <span style="color:#080;font-weight:bold">end</span>
520
660
 
521
661
  refine <span style="color:#036;font-weight:bold">Array</span> <span style="color:#080;font-weight:bold">do</span>
@@ -527,11 +667,11 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
527
667
  <span style="color:#080;font-weight:bold">end</span>
528
668
 
529
669
  refine <span style="color:#036;font-weight:bold">String</span> <span style="color:#080;font-weight:bold">do</span>
530
- <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">blank?</span>() <span style="color:#038;font-weight:bold">self</span> !~ <span style="background-color:#fff0ff"><span style="color:#404">/</span><span style="color:#04D">\S</span><span style="color:#404">/</span></span> <span style="color:#080;font-weight:bold">end</span>
670
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">blank?</span>() <span style="color:#069">self</span> !~ <span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#D20">\S</span><span style="color:#404">/</span></span> <span style="color:#080;font-weight:bold">end</span>
531
671
  <span style="color:#080;font-weight:bold">end</span>
532
672
 
533
673
  refine <span style="color:#036;font-weight:bold">Regexp</span> <span style="color:#080;font-weight:bold">do</span>
534
- <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">blank?</span>() <span style="color:#038;font-weight:bold">self</span> == <span style="background-color:#fff0ff"><span style="color:#404">/</span><span style="color:#404">/</span></span> <span style="color:#080;font-weight:bold">end</span>
674
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">blank?</span>() <span style="color:#069">self</span> == <span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#404">/</span></span> <span style="color:#080;font-weight:bold">end</span>
535
675
  <span style="color:#080;font-weight:bold">end</span>
536
676
  <span style="color:#080;font-weight:bold">end</span>
537
677
  <span style="color:#080;font-weight:bold">end</span></pre></div>
@@ -543,42 +683,84 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
543
683
  <div class="code"><pre>using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">CamelSnake</span></pre></div>
544
684
  </div>
545
685
  </div></td></tr><tr><th>Usage</th> <td><h5>String#to_camel</h5><div class="usage source" style="display:block"><div class="CodeRay">
546
- <div class="code"><pre><span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">was_snake_string</span><span style="color:#710">'</span></span>.to_camel <span style="color:#888"># =&gt; 'WasSnakeString'</span></pre></div>
686
+ <div class="code"><pre><span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">was_snake_string</span><span style="color:#710">'</span></span>.to_camel <span style="color:#777"># =&gt; 'WasSnakeString'</span></pre></div>
547
687
  </div>
548
688
  </div><h5>String#to_snake</h5><div class="usage source" style="display:block"><div class="CodeRay">
549
- <div class="code"><pre><span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">WasCamelString</span><span style="color:#710">'</span></span>.to_snake <span style="color:#888"># =&gt; 'was_camel_string'</span></pre></div>
689
+ <div class="code"><pre><span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">WasCamelString</span><span style="color:#710">'</span></span>.to_snake <span style="color:#777"># =&gt; 'was_camel_string'</span></pre></div>
550
690
  </div>
551
691
  </div></td></tr><tr><th>Specification</th> <td> <span id="show_camel_snake_spec">(<a href="javascript:show('camel_snake_spec')">show</a>)</span>
552
692
  <div class="source" id="camel_snake_spec"><div class="CodeRay">
553
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker/camel_snake</span><span style="color:#710">'</span></span>
693
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker/camel_snake</span><span style="color:#710">'</span></span>
554
694
  using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">CamelSnake</span>
555
695
 
556
696
 
557
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">String#to_camel</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
558
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should turn a snake_cased string to CamelCase</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
559
- <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">was_snake_case</span><span style="color:#710">'</span></span>.to_camel.should == <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">WasSnakeCase</span><span style="color:#710">'</span></span>
697
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">String#to_camel</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
698
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should turn a snake_cased string to CamelCase</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
699
+ <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">was_snake_case</span><span style="color:#710">'</span></span>.to_camel.should == <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">WasSnakeCase</span><span style="color:#710">'</span></span>
560
700
  <span style="color:#080;font-weight:bold">end</span>
561
701
  <span style="color:#080;font-weight:bold">end</span>
562
702
 
563
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">String#to_snake</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
564
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should turn a CamelCased string to snake_case</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
565
- <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">WasCamelCase</span><span style="color:#710">'</span></span>.to_snake.should == <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">was_camel_case</span><span style="color:#710">'</span></span>
703
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">String#to_snake</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
704
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should turn a CamelCased string to snake_case</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
705
+ <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">WasCamelCase</span><span style="color:#710">'</span></span>.to_snake.should == <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">was_camel_case</span><span style="color:#710">'</span></span>
566
706
  <span style="color:#080;font-weight:bold">end</span>
567
707
  <span style="color:#080;font-weight:bold">end</span></pre></div>
568
708
  </div>
569
709
  </div> </td></tr><tr><th>Source</th> <td> <span id="show_camel_snake_source">(<a href="javascript:show('camel_snake_source')">show</a>)</span>
570
710
  <div class="source" id="camel_snake_source"><div class="CodeRay">
571
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker</span><span style="color:#710">'</span></span>
711
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker</span><span style="color:#710">'</span></span>
572
712
 
573
713
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Zucker</span>
574
714
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">CamelSnake</span>
575
715
  refine <span style="color:#036;font-weight:bold">String</span> <span style="color:#080;font-weight:bold">do</span>
576
716
  <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">to_snake</span>
577
- gsub(<span style="background-color:#fff0ff"><span style="color:#404">/</span><span style="color:#808">(?&lt;!^)[A-Z]</span><span style="color:#404">/</span></span>) <span style="color:#080;font-weight:bold">do</span> <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">&quot;</span><span style="">_</span><span style="color:#710">#</span><span style="color:#d70;font-weight:bold">$&amp;</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">end</span>.downcase
717
+ gsub(<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#808">(?&lt;!^)[A-Z]</span><span style="color:#404">/</span></span>) <span style="color:#080;font-weight:bold">do</span> <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">_</span><span style="color:#666">#</span><span style="color:#d70">$&amp;</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">end</span>.downcase
578
718
  <span style="color:#080;font-weight:bold">end</span>
579
719
 
580
720
  <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">to_camel</span>
581
- gsub(<span style="background-color:#fff0ff"><span style="color:#404">/</span><span style="color:#808">(?:^|_)([a-z])</span><span style="color:#404">/</span></span>) <span style="color:#080;font-weight:bold">do</span> <span style="color:#d70;font-weight:bold">$1</span>.upcase <span style="color:#080;font-weight:bold">end</span>
721
+ gsub(<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#808">(?:^|_)([a-z])</span><span style="color:#404">/</span></span>) <span style="color:#080;font-weight:bold">do</span> <span style="color:#d70">$1</span>.upcase <span style="color:#080;font-weight:bold">end</span>
722
+ <span style="color:#080;font-weight:bold">end</span>
723
+ <span style="color:#080;font-weight:bold">end</span>
724
+ <span style="color:#080;font-weight:bold">end</span>
725
+ <span style="color:#080;font-weight:bold">end</span></pre></div>
726
+ </div>
727
+ </div> </td></tr></table></div> <div class="cubes"><h3 title="require 'zucker/chain_map'" id="chain_map">chain_map</h3>
728
+ <table class="cube_table"
729
+ id="chain_map_cube"
730
+ title="require 'zucker/chain_map'"> <tr><th>Summary</th> <td>Chain multiple procs on <code>Array</code> elements</td></tr><tr><th>Activate</th> <td><div class="using source" style="display:block"><div class="CodeRay">
731
+ <div class="code"><pre>using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">ChainMap</span></pre></div>
732
+ </div>
733
+ </div></td></tr><tr><th>Usage</th> <td><h5>Array#chain_map</h5><div class="usage source" style="display:block"><div class="CodeRay">
734
+ <div class="code"><pre>[<span style="color:#00D">-3</span>, <span style="color:#00D">-2</span>, <span style="color:#00D">-1</span>].chain_map(<span style="color:#A60">:abs</span>, <span style="color:#A60">:to_s</span>) <span style="color:#777"># =&gt; [&quot;3&quot;, &quot;2&quot;, &quot;1&quot;]</span></pre></div>
735
+ </div>
736
+ </div></td></tr><tr><th>Specification</th> <td> <span id="show_chain_map_spec">(<a href="javascript:show('chain_map_spec')">show</a>)</span>
737
+ <div class="source" id="chain_map_spec"><div class="CodeRay">
738
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">zucker/chain_map</span><span style="color:#710">&quot;</span></span>
739
+ using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">ChainMap</span>
740
+
741
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Array#chain_map</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
742
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">should repeatedly chain symbols as map calls</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
743
+ list = [<span style="color:#00D">-3</span>, <span style="color:#00D">-2</span>, <span style="color:#00D">-1</span>]
744
+
745
+ list.chain_map(<span style="color:#A60">:abs</span>, <span style="color:#A60">:to_s</span>) == <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">%w{</span><span style="color:#D20">3 2 1</span><span style="color:#710">}</span></span>
746
+ <span style="color:#080;font-weight:bold">end</span>
747
+
748
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">should repeatedly chain blocks as map calls</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
749
+ list = [<span style="color:#00D">-3</span>, <span style="color:#00D">-2</span>, <span style="color:#00D">-1</span>]
750
+
751
+ list.chain_map(-&gt;(e) { e ** <span style="color:#00D">2</span> }, -&gt;(e) { e * <span style="color:#00D">-1</span> }) == [<span style="color:#00D">-9</span>, <span style="color:#00D">-4</span>, <span style="color:#00D">-1</span>]
752
+ <span style="color:#080;font-weight:bold">end</span>
753
+ <span style="color:#080;font-weight:bold">end</span></pre></div>
754
+ </div>
755
+ </div> </td></tr><tr><th>Source</th> <td> <span id="show_chain_map_source">(<a href="javascript:show('chain_map_source')">show</a>)</span>
756
+ <div class="source" id="chain_map_source"><div class="CodeRay">
757
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">zucker</span><span style="color:#710">&quot;</span></span>
758
+
759
+ <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Zucker</span>
760
+ <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">ChainMap</span>
761
+ refine <span style="color:#036;font-weight:bold">Array</span> <span style="color:#080;font-weight:bold">do</span>
762
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">chain_map</span>(*args)
763
+ args.inject(<span style="color:#069">self</span>) { |collection, action| collection.map(&amp;action) }
582
764
  <span style="color:#080;font-weight:bold">end</span>
583
765
  <span style="color:#080;font-weight:bold">end</span>
584
766
  <span style="color:#080;font-weight:bold">end</span>
@@ -591,61 +773,61 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
591
773
  <div class="code"><pre>using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">Constantize</span></pre></div>
592
774
  </div>
593
775
  </div></td></tr><tr><th>Usage</th> <td><h5>String#constantize</h5><div class="usage source" style="display:block"><div class="CodeRay">
594
- <div class="code"><pre><span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">Object</span><span style="color:#710">'</span></span>.constantize <span style="color:#888"># =&gt; Object</span>
595
- <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">Spec::VERSION</span><span style="color:#710">'</span></span>.constantize <span style="color:#888"># =&gt; Spec::VERSION if rspec is loaded</span>
596
- <span style="color:#888"># you can also pass a parameter or block to define what happens, when constant does not exist</span>
597
- <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">IdontExist</span><span style="color:#710">'</span></span>.constantize(<span style="color:#036;font-weight:bold">Array</span>) <span style="color:#888"># =&gt; Array</span>
598
- <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">String5</span><span style="color:#710">'</span></span>.constantize <span style="color:#080;font-weight:bold">do</span> |string|
776
+ <div class="code"><pre><span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Object</span><span style="color:#710">'</span></span>.constantize <span style="color:#777"># =&gt; Object</span>
777
+ <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Spec::VERSION</span><span style="color:#710">'</span></span>.constantize <span style="color:#777"># =&gt; Spec::VERSION if rspec is loaded</span>
778
+ <span style="color:#777"># you can also pass a parameter or block to define what happens, when constant does not exist</span>
779
+ <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">IdontExist</span><span style="color:#710">'</span></span>.constantize(<span style="color:#036;font-weight:bold">Array</span>) <span style="color:#777"># =&gt; Array</span>
780
+ <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">String5</span><span style="color:#710">'</span></span>.constantize <span style="color:#080;font-weight:bold">do</span> |string|
599
781
  string.chop.constantize
600
- <span style="color:#080;font-weight:bold">end</span> <span style="color:#888"># =&gt; String</span>
782
+ <span style="color:#080;font-weight:bold">end</span> <span style="color:#777"># =&gt; String</span>
601
783
  </pre></div>
602
784
  </div>
603
785
  </div></td></tr><tr><th>Information</th> <td>An improved version of ActiveSupport's one</td></tr><tr><th>Specification</th> <td> <span id="show_constantize_spec">(<a href="javascript:show('constantize_spec')">show</a>)</span>
604
786
  <div class="source" id="constantize_spec"><div class="CodeRay">
605
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker/constantize</span><span style="color:#710">'</span></span>
787
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker/constantize</span><span style="color:#710">'</span></span>
606
788
  using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">Constantize</span>
607
789
 
608
790
 
609
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">String#constantize</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
610
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should return the constant with that name</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
611
- <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">Object</span><span style="color:#710">'</span></span>.constantize.should == <span style="color:#036;font-weight:bold">Object</span>
791
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">String#constantize</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
792
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should return the constant with that name</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
793
+ <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Object</span><span style="color:#710">'</span></span>.constantize.should == <span style="color:#036;font-weight:bold">Object</span>
612
794
  <span style="color:#080;font-weight:bold">end</span>
613
795
 
614
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should also work for nested constants</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
615
- <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">Zucker::VERSION</span><span style="color:#710">'</span></span>.constantize.should == <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">VERSION</span>
796
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should also work for nested constants</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
797
+ <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Zucker::VERSION</span><span style="color:#710">'</span></span>.constantize.should == <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">VERSION</span>
616
798
  <span style="color:#080;font-weight:bold">end</span>
617
799
 
618
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should throw name error if constant does not exist (and no parameter is given)</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
800
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should throw name error if constant does not exist (and no parameter is given)</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
619
801
  proc <span style="color:#080;font-weight:bold">do</span>
620
- <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">ObfsefsefsefafesafaefRubyZuckerafdfselijfesject</span><span style="color:#710">'</span></span>.constantize
802
+ <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">ObfsefsefsefafesafaefRubyZuckerafdfselijfesject</span><span style="color:#710">'</span></span>.constantize
621
803
  <span style="color:#080;font-weight:bold">end</span>.should raise_exception <span style="color:#036;font-weight:bold">NameError</span>
622
804
  <span style="color:#080;font-weight:bold">end</span>
623
805
 
624
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should call the block (and not raise an error) if constant does not exist and block given</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
806
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should call the block (and not raise an error) if constant does not exist and block given</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
625
807
  proc <span style="color:#080;font-weight:bold">do</span>
626
- <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">ObfsefsefsefafesafaefRubyZuckerafdfselijfesject</span><span style="color:#710">'</span></span>.constantize <span style="color:#080;font-weight:bold">do</span> |string|
627
- <span style="color:#036;font-weight:bold">Default</span> = [<span style="color:#00D;font-weight:bold">1</span>,<span style="color:#00D;font-weight:bold">2</span>,<span style="color:#00D;font-weight:bold">3</span>]
628
- <span style="color:#080;font-weight:bold">end</span>.should == [<span style="color:#00D;font-weight:bold">1</span>,<span style="color:#00D;font-weight:bold">2</span>,<span style="color:#00D;font-weight:bold">3</span>]
808
+ <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">ObfsefsefsefafesafaefRubyZuckerafdfselijfesject</span><span style="color:#710">'</span></span>.constantize <span style="color:#080;font-weight:bold">do</span> |string|
809
+ <span style="color:#036;font-weight:bold">Default</span> = [<span style="color:#00D">1</span>,<span style="color:#00D">2</span>,<span style="color:#00D">3</span>]
810
+ <span style="color:#080;font-weight:bold">end</span>.should == [<span style="color:#00D">1</span>,<span style="color:#00D">2</span>,<span style="color:#00D">3</span>]
629
811
  <span style="color:#080;font-weight:bold">end</span>.should_not raise_exception
630
812
  <span style="color:#080;font-weight:bold">end</span>
631
813
 
632
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should return the second parameter (and not raise an error) if constant does not exist and parameter given</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
814
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should return the second parameter (and not raise an error) if constant does not exist and parameter given</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
633
815
  proc <span style="color:#080;font-weight:bold">do</span>
634
- <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">ObfsefsefsefafesafaefRubyZuckerafdfselijfesject</span><span style="color:#710">'</span></span>.constantize(<span style="color:#036;font-weight:bold">Array</span>).should == <span style="color:#036;font-weight:bold">Array</span>
816
+ <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">ObfsefsefsefafesafaefRubyZuckerafdfselijfesject</span><span style="color:#710">'</span></span>.constantize(<span style="color:#036;font-weight:bold">Array</span>).should == <span style="color:#036;font-weight:bold">Array</span>
635
817
  <span style="color:#080;font-weight:bold">end</span>.should_not raise_exception
636
818
  <span style="color:#080;font-weight:bold">end</span>
637
819
  <span style="color:#080;font-weight:bold">end</span></pre></div>
638
820
  </div>
639
821
  </div> </td></tr><tr><th>Source</th> <td> <span id="show_constantize_source">(<a href="javascript:show('constantize_source')">show</a>)</span>
640
822
  <div class="source" id="constantize_source"><div class="CodeRay">
641
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker</span><span style="color:#710">'</span></span>
823
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker</span><span style="color:#710">'</span></span>
642
824
 
643
825
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Zucker</span>
644
826
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Constantize</span>
645
827
  refine <span style="color:#036;font-weight:bold">String</span> <span style="color:#080;font-weight:bold">do</span>
646
- <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">constantize</span>(default_value = <span style="color:#038;font-weight:bold">nil</span>) <span style="color:#888"># always uses global scope as in AS... is this good?</span>
828
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">constantize</span>(default_value = <span style="color:#069">nil</span>) <span style="color:#777"># always uses global scope as in AS... is this good?</span>
647
829
  get_constant = lambda{
648
- <span style="color:#038;font-weight:bold">self</span>.split(<span style="background-color:#fff0ff"><span style="color:#404">/</span><span style="color:#808">::</span><span style="color:#404">/</span></span>).inject( <span style="color:#036;font-weight:bold">Object</span> ){ |base_constant, current_constant|
830
+ <span style="color:#069">self</span>.split(<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#808">::</span><span style="color:#404">/</span></span>).inject( <span style="color:#036;font-weight:bold">Object</span> ){ |base_constant, current_constant|
649
831
  base_constant.const_get current_constant
650
832
  }
651
833
  }
@@ -657,7 +839,7 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
657
839
  get_constant.call
658
840
  <span style="color:#080;font-weight:bold">rescue</span> <span style="color:#036;font-weight:bold">NameError</span>
659
841
  <span style="color:#080;font-weight:bold">if</span> block_given?
660
- <span style="color:#080;font-weight:bold">yield</span> <span style="color:#038;font-weight:bold">self</span>
842
+ <span style="color:#080;font-weight:bold">yield</span> <span style="color:#069">self</span>
661
843
  <span style="color:#080;font-weight:bold">else</span>
662
844
  default_value
663
845
  <span style="color:#080;font-weight:bold">end</span>
@@ -685,43 +867,43 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
685
867
  </div>
686
868
  </div></td></tr><tr><th>Specification</th> <td> <span id="show_dir_extras_spec">(<a href="javascript:show('dir_extras_spec')">show</a>)</span>
687
869
  <div class="source" id="dir_extras_spec"><div class="CodeRay">
688
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker/dir_extras</span><span style="color:#710">'</span></span>
689
- require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">securerandom</span><span style="color:#710">'</span></span>
870
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker/dir_extras</span><span style="color:#710">'</span></span>
871
+ require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">securerandom</span><span style="color:#710">'</span></span>
690
872
  using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">DirExtras</span>
691
873
 
692
874
 
693
875
  describe <span style="color:#036;font-weight:bold">Dir</span> <span style="color:#080;font-weight:bold">do</span>
694
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">.join</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
695
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">delegates to File.join</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
696
- a = <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">%w[</span><span style="">some file path</span><span style="color:#710">]</span></span>
876
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">.join</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
877
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">delegates to File.join</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
878
+ a = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">%w[</span><span style="color:#D20">some file path</span><span style="color:#710">]</span></span>
697
879
  expect( <span style="color:#036;font-weight:bold">Dir</span>.join(a) ).to be == <span style="color:#036;font-weight:bold">File</span>.join(a)
698
880
  <span style="color:#080;font-weight:bold">end</span>
699
881
  <span style="color:#080;font-weight:bold">end</span>
700
882
 
701
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">.split</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
702
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">delegates to File.split</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
703
- a = <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">some/file/path</span><span style="color:#710">'</span></span>
883
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">.split</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
884
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">delegates to File.split</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
885
+ a = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">some/file/path</span><span style="color:#710">'</span></span>
704
886
  expect( <span style="color:#036;font-weight:bold">Dir</span>.split(a) ).to be == <span style="color:#036;font-weight:bold">File</span>.split(a)
705
887
  <span style="color:#080;font-weight:bold">end</span>
706
888
  <span style="color:#080;font-weight:bold">end</span>
707
889
 
708
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">.rm</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
709
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">removes directories with content</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
710
- path = <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">&quot;</span><span style="">tmp_</span><span style="background:#ddd;color:black"><span style="background:#ddd;font-weight:bold;color:#666">#{</span><span style="color:#036;font-weight:bold">SecureRandom</span>.uuid<span style="background:#ddd;font-weight:bold;color:#666">}</span></span><span style="color:#710">&quot;</span></span>
890
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">.rm</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
891
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">removes directories with content</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
892
+ path = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">tmp_</span><span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="font-weight:bold;color:#666">#{</span><span style="color:#036;font-weight:bold">SecureRandom</span>.uuid<span style="font-weight:bold;color:#666">}</span></span><span style="color:#710">&quot;</span></span>
711
893
  <span style="color:#036;font-weight:bold">FileUtils</span>.mkdir path
712
- <span style="color:#036;font-weight:bold">FileUtils</span>.touch <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">&quot;</span><span style="background:#ddd;color:black"><span style="background:#ddd;font-weight:bold;color:#666">#{</span>path<span style="background:#ddd;font-weight:bold;color:#666">}</span></span><span style="">/123</span><span style="color:#710">&quot;</span></span>
894
+ <span style="color:#036;font-weight:bold">FileUtils</span>.touch <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="font-weight:bold;color:#666">#{</span>path<span style="font-weight:bold;color:#666">}</span></span><span style="color:#D20">/123</span><span style="color:#710">&quot;</span></span>
713
895
  expect{
714
896
  <span style="color:#036;font-weight:bold">Dir</span>.rm path
715
897
  }.not_to raise_error
716
- expect( <span style="color:#036;font-weight:bold">Dir</span>[<span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">*</span><span style="color:#710">'</span></span>] ).to_not include(path)
898
+ expect( <span style="color:#036;font-weight:bold">Dir</span>[<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">*</span><span style="color:#710">'</span></span>] ).to_not include(path)
717
899
  <span style="color:#080;font-weight:bold">end</span>
718
900
  <span style="color:#080;font-weight:bold">end</span>
719
901
  <span style="color:#080;font-weight:bold">end</span></pre></div>
720
902
  </div>
721
903
  </div> </td></tr><tr><th>Source</th> <td> <span id="show_dir_extras_source">(<a href="javascript:show('dir_extras_source')">show</a>)</span>
722
904
  <div class="source" id="dir_extras_source"><div class="CodeRay">
723
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker</span><span style="color:#710">'</span></span>
724
- require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">fileutils</span><span style="color:#710">'</span></span>
905
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker</span><span style="color:#710">'</span></span>
906
+ require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">fileutils</span><span style="color:#710">'</span></span>
725
907
 
726
908
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Zucker</span>
727
909
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">DirExtras</span>
@@ -749,48 +931,48 @@ require <span style="background-color:#fff0f0;color:#D20"><span style="color:#71
749
931
  </div>
750
932
  </div></td></tr><tr><th>Usage</th> <td><h5>egonil</h5><div class="usage source" style="display:block"><div class="CodeRay">
751
933
  <div class="code"><pre>egonil{
752
- <span style="color:#038;font-weight:bold">nil</span>.some_methods.that[<span style="color:#A60">:do</span>].not.exist
934
+ <span style="color:#069">nil</span>.some_methods.that[<span style="color:#A60">:do</span>].not.exist
753
935
  }
754
936
  </pre></div>
755
937
  </div>
756
938
  </div></td></tr><tr><th>Information</th> <td>See <a href="http://rbjl.net/26-the-28-bytes-of-ruby-joy">this post</a> for more information and discussion.</td></tr><tr><th>Specification</th> <td> <span id="show_egonil_spec">(<a href="javascript:show('egonil_spec')">show</a>)</span>
757
939
  <div class="source" id="egonil_spec"><div class="CodeRay">
758
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker/egonil</span><span style="color:#710">'</span></span>
940
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker/egonil</span><span style="color:#710">'</span></span>
759
941
  using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">Egonil</span>
760
942
 
761
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">egonil</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
762
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should not raise nil exceptions in the block</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
943
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">egonil</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
944
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should not raise nil exceptions in the block</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
763
945
  proc <span style="color:#080;font-weight:bold">do</span>
764
- egonil{ <span style="color:#038;font-weight:bold">nil</span>.some_methods.that[<span style="color:#A60">:do</span>].not.exist }
946
+ egonil{ <span style="color:#069">nil</span>.some_methods.that[<span style="color:#A60">:do</span>].not.exist }
765
947
  <span style="color:#080;font-weight:bold">end</span>.should_not raise_exception
766
948
  <span style="color:#080;font-weight:bold">end</span>
767
949
 
768
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should restore default behaviour after the block</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
950
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should restore default behaviour after the block</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
769
951
  proc <span style="color:#080;font-weight:bold">do</span>
770
- egonil{ <span style="color:#038;font-weight:bold">nil</span>.some_methods.that[<span style="color:#A60">:do</span>].not.exist }
952
+ egonil{ <span style="color:#069">nil</span>.some_methods.that[<span style="color:#A60">:do</span>].not.exist }
771
953
  <span style="color:#080;font-weight:bold">end</span>.should_not raise_exception
772
954
 
773
955
  proc <span style="color:#080;font-weight:bold">do</span>
774
- <span style="color:#038;font-weight:bold">nil</span>.a_method
956
+ <span style="color:#069">nil</span>.a_method
775
957
  <span style="color:#080;font-weight:bold">end</span>.should raise_exception <span style="color:#036;font-weight:bold">NoMethodError</span>
776
958
  <span style="color:#080;font-weight:bold">end</span>
777
959
 
778
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">raise NoMethodError for non-nil objects</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
960
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">raise NoMethodError for non-nil objects</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
779
961
  proc <span style="color:#080;font-weight:bold">do</span>
780
- egonil{ <span style="color:#00D;font-weight:bold">5</span>.a_method }
962
+ egonil{ <span style="color:#00D">5</span>.a_method }
781
963
  <span style="color:#080;font-weight:bold">end</span>.should raise_exception <span style="color:#036;font-weight:bold">NoMethodError</span>
782
964
  <span style="color:#080;font-weight:bold">end</span>
783
965
 
784
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should raise other Exceptions</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
966
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should raise other Exceptions</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
785
967
  proc <span style="color:#080;font-weight:bold">do</span>
786
- egonil{ <span style="color:#00D;font-weight:bold">5</span> / <span style="color:#00D;font-weight:bold">0</span> }
968
+ egonil{ <span style="color:#00D">5</span> / <span style="color:#00D">0</span> }
787
969
  <span style="color:#080;font-weight:bold">end</span>.should raise_exception <span style="color:#036;font-weight:bold">ZeroDivisionError</span>
788
970
  <span style="color:#080;font-weight:bold">end</span>
789
971
  <span style="color:#080;font-weight:bold">end</span></pre></div>
790
972
  </div>
791
973
  </div> </td></tr><tr><th>Source</th> <td> <span id="show_egonil_source">(<a href="javascript:show('egonil_source')">show</a>)</span>
792
974
  <div class="source" id="egonil_source"><div class="CodeRay">
793
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker</span><span style="color:#710">'</span></span>
975
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker</span><span style="color:#710">'</span></span>
794
976
 
795
977
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Zucker</span>
796
978
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Egonil</span>
@@ -815,45 +997,81 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
815
997
  <div class="code"><pre>using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">File</span></pre></div>
816
998
  </div>
817
999
  </div></td></tr><tr><th>Usage</th> <td><h5>File.gsub</h5><div class="usage source" style="display:block"><div class="CodeRay">
818
- <div class="code"><pre><span style="color:#036;font-weight:bold">File</span>.gsub <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">some_filename</span><span style="color:#710">'</span></span>, <span style="color:#888"># will read the file and substitute the hash keys with their values</span>
819
- <span style="background-color:#fff0ff"><span style="color:#404">/</span><span style="color:#808">hi</span><span style="color:#404">/</span></span> =&gt; <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">cu</span><span style="color:#710">'</span></span>,
820
- <span style="background-color:#fff0ff"><span style="color:#404">/</span><span style="color:#04D">\d</span><span style="color:#404">/</span></span> =&gt; proc{ |m| (m.to_i+<span style="color:#00D;font-weight:bold">1</span>).to_s }
1000
+ <div class="code"><pre><span style="color:#036;font-weight:bold">File</span>.gsub <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">some_filename</span><span style="color:#710">'</span></span>, <span style="color:#777"># will read the file and substitute the hash keys with their values</span>
1001
+ <span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#808">hi</span><span style="color:#404">/</span></span> =&gt; <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">cu</span><span style="color:#710">'</span></span>,
1002
+ <span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#D20">\d</span><span style="color:#404">/</span></span> =&gt; proc{ |m| (m.to_i+<span style="color:#00D">1</span>).to_s }
821
1003
  </pre></div>
822
1004
  </div>
823
1005
  </div><h5>File.delete!</h5><div class="usage source" style="display:block"><div class="CodeRay">
824
- <div class="code"><pre><span style="color:#036;font-weight:bold">File</span>.delete! <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">some_filename</span><span style="color:#710">'</span></span> <span style="color:#888"># will delete the file, don't care if it exist.</span></pre></div>
1006
+ <div class="code"><pre><span style="color:#036;font-weight:bold">File</span>.delete! <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">some_filename</span><span style="color:#710">'</span></span> <span style="color:#777"># will delete the file, don't care if it exist.</span></pre></div>
825
1007
  </div>
826
1008
  </div><h5>File.filename</h5><div class="usage source" style="display:block"><div class="CodeRay">
827
1009
  <div class="code"><pre><span style="color:#036;font-weight:bold">File</span>.basename</pre></div>
828
1010
  </div>
829
1011
  </div></td></tr><tr><th>Information</th> <td>Idea for <code>File.delete!</code> from sugar-high.</td></tr><tr><th>Specification</th> <td> <span id="show_file_spec">(<a href="javascript:show('file_spec')">show</a>)</span>
830
1012
  <div class="source" id="file_spec"><em>FIXME: missing (please create a <a href="http://github.com/janlelis/zucker/issues">github issue</a>)</em></div> </td></tr><tr><th>Source</th> <td> <span id="show_file_source">(<a href="javascript:show('file_source')">show</a>)</span>
831
- <div class="source" id="file_source"><em>FIXME: missing (please create a <a href="http://github.com/janlelis/zucker/issues">github issue</a>)</em></div> </td></tr></table></div> <div class="cubes"><h3 title="require 'zucker/hash_extras'" id="hash_extras">hash_extras</h3>
1013
+ <div class="source" id="file_source"><em>FIXME: missing (please create a <a href="http://github.com/janlelis/zucker/issues">github issue</a>)</em></div> </td></tr></table></div> <div class="cubes"><h3 title="require 'zucker/float_extras'" id="float_extras">float_extras</h3>
1014
+ <table class="cube_table"
1015
+ id="float_extras_cube"
1016
+ title="require 'zucker/float_extras'"> <tr><th>Summary</th> <td><code>Float</code> extensions.</td></tr><tr><th>Activate</th> <td><div class="using source" style="display:block"><div class="CodeRay">
1017
+ <div class="code"><pre>using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">FloatExtras</span></pre></div>
1018
+ </div>
1019
+ </div></td></tr><tr><th>Usage</th> <td><h5>Float#same?</h5><div class="usage source" style="display:block"><div class="CodeRay">
1020
+ <div class="code"><pre>(<span style="color:#60E">0.1</span> + <span style="color:#60E">0.2</span>).same? <span style="color:#60E">0.3</span> <span style="color:#777"># true</span></pre></div>
1021
+ </div>
1022
+ </div></td></tr><tr><th>Specification</th> <td> <span id="show_float_extras_spec">(<a href="javascript:show('float_extras_spec')">show</a>)</span>
1023
+ <div class="source" id="float_extras_spec"><div class="CodeRay">
1024
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker/float_extras</span><span style="color:#710">'</span></span>
1025
+ using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">FloatExtras</span>
1026
+
1027
+ describe <span style="color:#036;font-weight:bold">Float</span> <span style="color:#080;font-weight:bold">do</span>
1028
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">#same?</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1029
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">returns true if other float represents the same number</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1030
+ expect( <span style="color:#60E">0.3</span>.same?(<span style="color:#60E">0.1</span> + <span style="color:#60E">0.2</span>) ).to be <span style="color:#069">true</span>
1031
+ <span style="color:#080;font-weight:bold">end</span>
1032
+ <span style="color:#080;font-weight:bold">end</span>
1033
+ <span style="color:#080;font-weight:bold">end</span></pre></div>
1034
+ </div>
1035
+ </div> </td></tr><tr><th>Source</th> <td> <span id="show_float_extras_source">(<a href="javascript:show('float_extras_source')">show</a>)</span>
1036
+ <div class="source" id="float_extras_source"><div class="CodeRay">
1037
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker</span><span style="color:#710">'</span></span>
1038
+
1039
+ <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Zucker</span>
1040
+ <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">FloatExtras</span>
1041
+ refine <span style="color:#036;font-weight:bold">Float</span> <span style="color:#080;font-weight:bold">do</span>
1042
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">same?</span>(other)
1043
+ (<span style="color:#069">self</span> - other).abs &lt; <span style="color:#036;font-weight:bold">Float</span>::<span style="color:#036;font-weight:bold">EPSILON</span>
1044
+ <span style="color:#080;font-weight:bold">end</span>
1045
+ <span style="color:#080;font-weight:bold">end</span>
1046
+ <span style="color:#080;font-weight:bold">end</span>
1047
+ <span style="color:#080;font-weight:bold">end</span></pre></div>
1048
+ </div>
1049
+ </div> </td></tr></table></div> <div class="cubes"><h3 title="require 'zucker/hash_extras'" id="hash_extras">hash_extras</h3>
832
1050
  <table class="cube_table"
833
1051
  id="hash_extras_cube"
834
1052
  title="require 'zucker/hash_extras'"> <tr><th>Summary</th> <td>Sugar for dealing with hashes</td></tr><tr><th>Activate</th> <td><div class="using source" style="display:block"><div class="CodeRay">
835
1053
  <div class="code"><pre>using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">HashExtras</span></pre></div>
836
1054
  </div>
837
1055
  </div></td></tr><tr><th>Usage</th> <td><h5>Hash.zip</h5><div class="usage source" style="display:block"><div class="CodeRay">
838
- <div class="code"><pre><span style="color:#036;font-weight:bold">Hash</span>.zip [<span style="color:#00D;font-weight:bold">1</span>,<span style="color:#00D;font-weight:bold">2</span>,<span style="color:#00D;font-weight:bold">3</span>], [<span style="color:#00D;font-weight:bold">4</span>,<span style="color:#00D;font-weight:bold">5</span>,<span style="color:#00D;font-weight:bold">6</span>] <span style="color:#888"># =&gt; {1=&gt;4, 2=&gt;5, 3=&gt;6}</span></pre></div>
1056
+ <div class="code"><pre><span style="color:#036;font-weight:bold">Hash</span>.zip [<span style="color:#00D">1</span>,<span style="color:#00D">2</span>,<span style="color:#00D">3</span>], [<span style="color:#00D">4</span>,<span style="color:#00D">5</span>,<span style="color:#00D">6</span>] <span style="color:#777"># =&gt; {1=&gt;4, 2=&gt;5, 3=&gt;6}</span></pre></div>
839
1057
  </div>
840
1058
  </div></td></tr><tr><th>Specification</th> <td> <span id="show_hash_extras_spec">(<a href="javascript:show('hash_extras_spec')">show</a>)</span>
841
1059
  <div class="source" id="hash_extras_spec"><div class="CodeRay">
842
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker/hash_extras</span><span style="color:#710">'</span></span>
1060
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker/hash_extras</span><span style="color:#710">'</span></span>
843
1061
  using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">HashExtras</span>
844
1062
 
845
1063
 
846
1064
  describe <span style="color:#036;font-weight:bold">Hash</span> <span style="color:#080;font-weight:bold">do</span>
847
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">.zip</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
848
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should zip together both given enumerables and take them as key=&gt;values for a new hash</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
849
- <span style="color:#036;font-weight:bold">Hash</span>.zip( [<span style="color:#00D;font-weight:bold">1</span>,<span style="color:#00D;font-weight:bold">2</span>,<span style="color:#00D;font-weight:bold">3</span>], [<span style="color:#00D;font-weight:bold">4</span>,<span style="color:#00D;font-weight:bold">5</span>,<span style="color:#00D;font-weight:bold">6</span>] ).should == { <span style="color:#00D;font-weight:bold">1</span>=&gt;<span style="color:#00D;font-weight:bold">4</span>, <span style="color:#00D;font-weight:bold">2</span>=&gt;<span style="color:#00D;font-weight:bold">5</span>, <span style="color:#00D;font-weight:bold">3</span>=&gt;<span style="color:#00D;font-weight:bold">6</span> }
1065
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">.zip</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1066
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should zip together both given enumerables and take them as key=&gt;values for a new hash</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1067
+ <span style="color:#036;font-weight:bold">Hash</span>.zip( [<span style="color:#00D">1</span>,<span style="color:#00D">2</span>,<span style="color:#00D">3</span>], [<span style="color:#00D">4</span>,<span style="color:#00D">5</span>,<span style="color:#00D">6</span>] ).should == { <span style="color:#00D">1</span>=&gt;<span style="color:#00D">4</span>, <span style="color:#00D">2</span>=&gt;<span style="color:#00D">5</span>, <span style="color:#00D">3</span>=&gt;<span style="color:#00D">6</span> }
850
1068
  <span style="color:#080;font-weight:bold">end</span>
851
1069
  <span style="color:#080;font-weight:bold">end</span>
852
1070
  <span style="color:#080;font-weight:bold">end</span></pre></div>
853
1071
  </div>
854
1072
  </div> </td></tr><tr><th>Source</th> <td> <span id="show_hash_extras_source">(<a href="javascript:show('hash_extras_source')">show</a>)</span>
855
1073
  <div class="source" id="hash_extras_source"><div class="CodeRay">
856
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker</span><span style="color:#710">'</span></span>
1074
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker</span><span style="color:#710">'</span></span>
857
1075
 
858
1076
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Zucker</span>
859
1077
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">HashExtras</span>
@@ -872,47 +1090,47 @@ describe <span style="color:#036;font-weight:bold">Hash</span> <span style="colo
872
1090
  <div class="code"><pre>using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">HashOp</span></pre></div>
873
1091
  </div>
874
1092
  </div></td></tr><tr><th>Usage</th> <td><h5>Hash#&lt;&lt;</h5><div class="usage source" style="display:block"><div class="CodeRay">
875
- <div class="code"><pre>{<span style="color:#00D;font-weight:bold">1</span>=&gt;<span style="color:#00D;font-weight:bold">2</span>} &lt;&lt; [<span style="color:#00D;font-weight:bold">3</span>, <span style="color:#00D;font-weight:bold">4</span>] <span style="color:#888"># =&gt; { 1=&gt;2, 3=&gt;4 }</span>
876
- {<span style="color:#00D;font-weight:bold">1</span>=&gt;<span style="color:#00D;font-weight:bold">2</span>} &lt;&lt; { <span style="color:#00D;font-weight:bold">5</span>=&gt;<span style="color:#00D;font-weight:bold">6</span> } <span style="color:#888"># =&gt; { 1=&gt;2, 5=&gt;6 }</span>
1093
+ <div class="code"><pre>{<span style="color:#00D">1</span>=&gt;<span style="color:#00D">2</span>} &lt;&lt; [<span style="color:#00D">3</span>, <span style="color:#00D">4</span>] <span style="color:#777"># =&gt; { 1=&gt;2, 3=&gt;4 }</span>
1094
+ {<span style="color:#00D">1</span>=&gt;<span style="color:#00D">2</span>} &lt;&lt; { <span style="color:#00D">5</span>=&gt;<span style="color:#00D">6</span> } <span style="color:#777"># =&gt; { 1=&gt;2, 5=&gt;6 }</span>
877
1095
  </pre></div>
878
1096
  </div>
879
1097
  </div><h5>Hash#&amp;</h5><div class="usage source" style="display:block"><div class="CodeRay">
880
- <div class="code"><pre>{ <span style="color:#00D;font-weight:bold">1</span>=&gt;<span style="color:#00D;font-weight:bold">4</span>, <span style="color:#00D;font-weight:bold">2</span>=&gt;<span style="color:#00D;font-weight:bold">5</span>, <span style="color:#00D;font-weight:bold">3</span>=&gt;<span style="color:#00D;font-weight:bold">6</span> } &amp; { <span style="color:#00D;font-weight:bold">1</span>=&gt;<span style="color:#00D;font-weight:bold">4</span>, <span style="color:#00D;font-weight:bold">2</span>=&gt;<span style="color:#00D;font-weight:bold">7</span> } <span style="color:#888"># =&gt; { 1=&gt;4 }</span></pre></div>
1098
+ <div class="code"><pre>{ <span style="color:#00D">1</span>=&gt;<span style="color:#00D">4</span>, <span style="color:#00D">2</span>=&gt;<span style="color:#00D">5</span>, <span style="color:#00D">3</span>=&gt;<span style="color:#00D">6</span> } &amp; { <span style="color:#00D">1</span>=&gt;<span style="color:#00D">4</span>, <span style="color:#00D">2</span>=&gt;<span style="color:#00D">7</span> } <span style="color:#777"># =&gt; { 1=&gt;4 }</span></pre></div>
881
1099
  </div>
882
1100
  </div></td></tr><tr><th>Information</th> <td>Some of the operators are inspired by Ruby Facets.</td></tr><tr><th>Specification</th> <td> <span id="show_hash_op_spec">(<a href="javascript:show('hash_op_spec')">show</a>)</span>
883
1101
  <div class="source" id="hash_op_spec"><div class="CodeRay">
884
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker/hash_op</span><span style="color:#710">'</span></span>
1102
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker/hash_op</span><span style="color:#710">'</span></span>
885
1103
  using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">HashOp</span>
886
1104
 
887
1105
 
888
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">Hash#&lt;&lt;</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
889
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">appends new elements to the hash</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
890
- a = { <span style="color:#00D;font-weight:bold">1</span>=&gt;<span style="color:#00D;font-weight:bold">4</span>, <span style="color:#00D;font-weight:bold">2</span>=&gt;<span style="color:#00D;font-weight:bold">5</span>, <span style="color:#00D;font-weight:bold">3</span>=&gt;<span style="color:#00D;font-weight:bold">6</span> }
891
- a &lt;&lt; { <span style="color:#00D;font-weight:bold">4</span>=&gt;<span style="color:#00D;font-weight:bold">7</span> }
892
- a &lt;&lt; [<span style="color:#00D;font-weight:bold">5</span>, <span style="color:#00D;font-weight:bold">8</span>]
893
- a.should == { <span style="color:#00D;font-weight:bold">1</span>=&gt;<span style="color:#00D;font-weight:bold">4</span>, <span style="color:#00D;font-weight:bold">2</span>=&gt;<span style="color:#00D;font-weight:bold">5</span>, <span style="color:#00D;font-weight:bold">3</span>=&gt;<span style="color:#00D;font-weight:bold">6</span>, <span style="color:#00D;font-weight:bold">4</span>=&gt;<span style="color:#00D;font-weight:bold">7</span>, <span style="color:#00D;font-weight:bold">5</span>=&gt;<span style="color:#00D;font-weight:bold">8</span> }
1106
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Hash#&lt;&lt;</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1107
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">appends new elements to the hash</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1108
+ a = { <span style="color:#00D">1</span>=&gt;<span style="color:#00D">4</span>, <span style="color:#00D">2</span>=&gt;<span style="color:#00D">5</span>, <span style="color:#00D">3</span>=&gt;<span style="color:#00D">6</span> }
1109
+ a &lt;&lt; { <span style="color:#00D">4</span>=&gt;<span style="color:#00D">7</span> }
1110
+ a &lt;&lt; [<span style="color:#00D">5</span>, <span style="color:#00D">8</span>]
1111
+ a.should == { <span style="color:#00D">1</span>=&gt;<span style="color:#00D">4</span>, <span style="color:#00D">2</span>=&gt;<span style="color:#00D">5</span>, <span style="color:#00D">3</span>=&gt;<span style="color:#00D">6</span>, <span style="color:#00D">4</span>=&gt;<span style="color:#00D">7</span>, <span style="color:#00D">5</span>=&gt;<span style="color:#00D">8</span> }
894
1112
  <span style="color:#080;font-weight:bold">end</span>
895
1113
  <span style="color:#080;font-weight:bold">end</span>
896
1114
 
897
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">Hash#&amp;</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
898
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">selects a sub hash containt only equal key-value pairs</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
899
- a = { <span style="color:#00D;font-weight:bold">1</span>=&gt;<span style="color:#00D;font-weight:bold">4</span>, <span style="color:#00D;font-weight:bold">2</span>=&gt;<span style="color:#00D;font-weight:bold">5</span>, <span style="color:#00D;font-weight:bold">3</span>=&gt;<span style="color:#00D;font-weight:bold">6</span> }
900
- b = { <span style="color:#00D;font-weight:bold">1</span>=&gt;<span style="color:#00D;font-weight:bold">4</span>, <span style="color:#00D;font-weight:bold">2</span>=&gt;<span style="color:#00D;font-weight:bold">7</span> }
901
- (a &amp; b).should == { <span style="color:#00D;font-weight:bold">1</span>=&gt;<span style="color:#00D;font-weight:bold">4</span> }
1115
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Hash#&amp;</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1116
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">selects a sub hash containt only equal key-value pairs</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1117
+ a = { <span style="color:#00D">1</span>=&gt;<span style="color:#00D">4</span>, <span style="color:#00D">2</span>=&gt;<span style="color:#00D">5</span>, <span style="color:#00D">3</span>=&gt;<span style="color:#00D">6</span> }
1118
+ b = { <span style="color:#00D">1</span>=&gt;<span style="color:#00D">4</span>, <span style="color:#00D">2</span>=&gt;<span style="color:#00D">7</span> }
1119
+ (a &amp; b).should == { <span style="color:#00D">1</span>=&gt;<span style="color:#00D">4</span> }
902
1120
  <span style="color:#080;font-weight:bold">end</span>
903
1121
  <span style="color:#080;font-weight:bold">end</span>
904
1122
 
905
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">Hash#+</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
906
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">merges two hashes</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
907
- a = { <span style="color:#00D;font-weight:bold">1</span>=&gt;<span style="color:#00D;font-weight:bold">4</span>, <span style="color:#00D;font-weight:bold">2</span>=&gt;<span style="color:#00D;font-weight:bold">5</span>, <span style="color:#00D;font-weight:bold">3</span>=&gt;<span style="color:#00D;font-weight:bold">6</span> }
908
- b = { <span style="color:#00D;font-weight:bold">1</span>=&gt;<span style="color:#00D;font-weight:bold">4</span>, <span style="color:#00D;font-weight:bold">2</span>=&gt;<span style="color:#00D;font-weight:bold">7</span>, <span style="color:#00D;font-weight:bold">4</span>=&gt;<span style="color:#00D;font-weight:bold">0</span> }
909
- (a + b).should == { <span style="color:#00D;font-weight:bold">1</span>=&gt;<span style="color:#00D;font-weight:bold">4</span>, <span style="color:#00D;font-weight:bold">2</span>=&gt;<span style="color:#00D;font-weight:bold">7</span>, <span style="color:#00D;font-weight:bold">3</span>=&gt;<span style="color:#00D;font-weight:bold">6</span>, <span style="color:#00D;font-weight:bold">4</span>=&gt;<span style="color:#00D;font-weight:bold">0</span> }
1123
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Hash#+</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1124
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">merges two hashes</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1125
+ a = { <span style="color:#00D">1</span>=&gt;<span style="color:#00D">4</span>, <span style="color:#00D">2</span>=&gt;<span style="color:#00D">5</span>, <span style="color:#00D">3</span>=&gt;<span style="color:#00D">6</span> }
1126
+ b = { <span style="color:#00D">1</span>=&gt;<span style="color:#00D">4</span>, <span style="color:#00D">2</span>=&gt;<span style="color:#00D">7</span>, <span style="color:#00D">4</span>=&gt;<span style="color:#00D">0</span> }
1127
+ (a + b).should == { <span style="color:#00D">1</span>=&gt;<span style="color:#00D">4</span>, <span style="color:#00D">2</span>=&gt;<span style="color:#00D">7</span>, <span style="color:#00D">3</span>=&gt;<span style="color:#00D">6</span>, <span style="color:#00D">4</span>=&gt;<span style="color:#00D">0</span> }
910
1128
  <span style="color:#080;font-weight:bold">end</span>
911
1129
  <span style="color:#080;font-weight:bold">end</span></pre></div>
912
1130
  </div>
913
1131
  </div> </td></tr><tr><th>Source</th> <td> <span id="show_hash_op_source">(<a href="javascript:show('hash_op_source')">show</a>)</span>
914
1132
  <div class="source" id="hash_op_source"><div class="CodeRay">
915
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker</span><span style="color:#710">'</span></span>
1133
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker</span><span style="color:#710">'</span></span>
916
1134
 
917
1135
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Zucker</span>
918
1136
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">HashOp</span>
@@ -924,7 +1142,7 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
924
1142
  <span style="color:#080;font-weight:bold">when</span> other.is_a?(<span style="color:#036;font-weight:bold">Enumerable</span>) || other.respond_to?(<span style="color:#A60">:to_splat</span>)
925
1143
  merge! <span style="color:#036;font-weight:bold">Hash</span>[*other]
926
1144
  <span style="color:#080;font-weight:bold">else</span>
927
- raise <span style="color:#036;font-weight:bold">TypeError</span>, <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">can only append other Hashs and Enumerables (or Classes that implement to_splat)</span><span style="color:#710">'</span></span>
1145
+ raise <span style="color:#036;font-weight:bold">TypeError</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">can only append other Hashs and Enumerables (or Classes that implement to_splat)</span><span style="color:#710">'</span></span>
928
1146
  <span style="color:#080;font-weight:bold">end</span>
929
1147
  <span style="color:#080;font-weight:bold">end</span>
930
1148
 
@@ -941,6 +1159,63 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
941
1159
  <span style="color:#080;font-weight:bold">end</span>
942
1160
  <span style="color:#080;font-weight:bold">end</span></pre></div>
943
1161
  </div>
1162
+ </div> </td></tr></table></div> <div class="cubes"><h3 title="require 'zucker/inner_map'" id="inner_map">inner_map</h3>
1163
+ <table class="cube_table"
1164
+ id="inner_map_cube"
1165
+ title="require 'zucker/inner_map'"> <tr><th>Summary</th> <td>Runs blocks on inner <code>Array</code> elements</td></tr><tr><th>Activate</th> <td><div class="using source" style="display:block"><div class="CodeRay">
1166
+ <div class="code"><pre>using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">InnerMap</span></pre></div>
1167
+ </div>
1168
+ </div></td></tr><tr><th>Usage</th> <td><h5>Array#inner_map</h5><div class="usage source" style="display:block"><div class="CodeRay">
1169
+ <div class="code"><pre>[[<span style="color:#00D">1</span>, <span style="color:#00D">2</span>], [<span style="color:#00D">3</span>, <span style="color:#00D">4</span>]].inner_map{ |i| i + <span style="color:#00D">1</span> } <span style="color:#777"># =&gt; [[2, 3], [4, 5]]</span></pre></div>
1170
+ </div>
1171
+ </div><h5>Array#inner_inject</h5><div class="usage source" style="display:block"><div class="CodeRay">
1172
+ <div class="code"><pre>[[<span style="color:#00D">1</span>, <span style="color:#00D">2</span>], [<span style="color:#00D">3</span>, <span style="color:#00D">4</span>]].inner_inject(&amp;<span style="color:#A60">:+</span>) <span style="color:#777"># =&gt; [3, 7]</span></pre></div>
1173
+ </div>
1174
+ </div></td></tr><tr><th>Specification</th> <td> <span id="show_inner_map_spec">(<a href="javascript:show('inner_map_spec')">show</a>)</span>
1175
+ <div class="source" id="inner_map_spec"><div class="CodeRay">
1176
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">zucker/inner_map</span><span style="color:#710">&quot;</span></span>
1177
+ using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">InnerMap</span>
1178
+
1179
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Array#inner_map</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
1180
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">should delegate map to inner lists</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
1181
+ list = [[<span style="color:#00D">1</span>, <span style="color:#00D">2</span>], [<span style="color:#00D">3</span>, <span style="color:#00D">4</span>]]
1182
+
1183
+ list.inner_map { |i| i + <span style="color:#00D">1</span> }.should == [[<span style="color:#00D">2</span>, <span style="color:#00D">3</span>], [<span style="color:#00D">4</span>, <span style="color:#00D">5</span>]]
1184
+ <span style="color:#080;font-weight:bold">end</span>
1185
+ <span style="color:#080;font-weight:bold">end</span>
1186
+
1187
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Array#inner_inject</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
1188
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">should delegate inject to inner lists</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
1189
+ list = [<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">%w{</span><span style="color:#D20">a b c</span><span style="color:#710">}</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">%w{</span><span style="color:#D20">d e f</span><span style="color:#710">}</span></span>]
1190
+
1191
+ list.inner_inject(&amp;<span style="color:#A60">:+</span>).should == list.map(&amp;<span style="color:#A60">:join</span>)
1192
+ <span style="color:#080;font-weight:bold">end</span>
1193
+
1194
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">should take default values</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
1195
+ list = [[<span style="color:#00D">3</span>, <span style="color:#00D">2</span>, <span style="color:#00D">1</span>], [<span style="color:#00D">-4</span>]]
1196
+
1197
+ list.inner_inject(<span style="color:#00D">4</span>, &amp;<span style="color:#A60">:+</span>).should == [<span style="color:#00D">10</span>, <span style="color:#00D">0</span>]
1198
+ <span style="color:#080;font-weight:bold">end</span>
1199
+ <span style="color:#080;font-weight:bold">end</span></pre></div>
1200
+ </div>
1201
+ </div> </td></tr><tr><th>Source</th> <td> <span id="show_inner_map_source">(<a href="javascript:show('inner_map_source')">show</a>)</span>
1202
+ <div class="source" id="inner_map_source"><div class="CodeRay">
1203
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">zucker</span><span style="color:#710">&quot;</span></span>
1204
+
1205
+ <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Zucker</span>
1206
+ <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">InnerMap</span>
1207
+ refine <span style="color:#036;font-weight:bold">Array</span> <span style="color:#080;font-weight:bold">do</span>
1208
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">inner_map</span>(&amp;block)
1209
+ map { |object| object.map(&amp;block) }
1210
+ <span style="color:#080;font-weight:bold">end</span>
1211
+
1212
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">inner_inject</span>(default = <span style="color:#A60">:not_used</span>, &amp;block)
1213
+ map { |object| default == <span style="color:#A60">:not_used</span> ? object.inject(&amp;block) : object.inject(default, &amp;block) }
1214
+ <span style="color:#080;font-weight:bold">end</span>
1215
+ <span style="color:#080;font-weight:bold">end</span>
1216
+ <span style="color:#080;font-weight:bold">end</span>
1217
+ <span style="color:#080;font-weight:bold">end</span></pre></div>
1218
+ </div>
944
1219
  </div> </td></tr></table></div> <div class="cubes"><h3 title="require 'zucker/instance_variables_from'" id="instance_variables_from">instance_variables_from</h3>
945
1220
  <table class="cube_table"
946
1221
  id="instance_variables_from_cube"
@@ -948,43 +1223,43 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
948
1223
  <div class="code"><pre>using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">InstanceVariablesFrom</span></pre></div>
949
1224
  </div>
950
1225
  </div></td></tr><tr><th>Usage</th> <td><h5>instance_variables_from</h5><div class="usage source" style="display:block"><div class="CodeRay">
951
- <div class="code"><pre><span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">some_method</span>(a = <span style="color:#00D;font-weight:bold">1</span>, b = <span style="color:#00D;font-weight:bold">2</span>)
952
- instance_variables_from binding <span style="color:#888"># assigns @a and @b</span>
1226
+ <div class="code"><pre><span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">some_method</span>(a = <span style="color:#00D">1</span>, b = <span style="color:#00D">2</span>)
1227
+ instance_variables_from binding <span style="color:#777"># assigns @a and @b</span>
953
1228
 
954
- params = {<span style="color:#A60">:c</span> =&gt; <span style="color:#00D;font-weight:bold">3</span>, <span style="color:#A60">:d</span> =&gt; <span style="color:#00D;font-weight:bold">4</span>}
955
- instance_variables_from params <span style="color:#888"># # assigns @c and @d</span>
1229
+ params = {<span style="color:#A60">:c</span> =&gt; <span style="color:#00D">3</span>, <span style="color:#A60">:d</span> =&gt; <span style="color:#00D">4</span>}
1230
+ instance_variables_from params <span style="color:#777"># # assigns @c and @d</span>
956
1231
  <span style="color:#080;font-weight:bold">end</span>
957
1232
  </pre></div>
958
1233
  </div>
959
1234
  </div></td></tr><tr><th>Specification</th> <td> <span id="show_instance_variables_from_spec">(<a href="javascript:show('instance_variables_from_spec')">show</a>)</span>
960
1235
  <div class="source" id="instance_variables_from_spec"><div class="CodeRay">
961
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker/instance_variables_from</span><span style="color:#710">'</span></span>
1236
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker/instance_variables_from</span><span style="color:#710">'</span></span>
962
1237
  using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">InstanceVariablesFrom</span>
963
1238
 
964
1239
 
965
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">instance_variables_from</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
966
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">transforms the given parameter to instance variables when in it is a binding</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
967
- <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">example_method</span>(a = <span style="color:#00D;font-weight:bold">1</span>, b = <span style="color:#00D;font-weight:bold">2</span>)
968
- instance_variables_from binding <span style="color:#888"># assigns @a and @b</span>
1240
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">instance_variables_from</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1241
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">transforms the given parameter to instance variables when in it is a binding</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1242
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">example_method</span>(a = <span style="color:#00D">1</span>, b = <span style="color:#00D">2</span>)
1243
+ instance_variables_from binding <span style="color:#777"># assigns @a and @b</span>
969
1244
  <span style="color:#080;font-weight:bold">end</span>
970
1245
 
971
1246
  example_method
972
- <span style="color:#33B">@a</span>.should == <span style="color:#00D;font-weight:bold">1</span>
973
- <span style="color:#33B">@b</span>.should == <span style="color:#00D;font-weight:bold">2</span>
1247
+ <span style="color:#33B">@a</span>.should == <span style="color:#00D">1</span>
1248
+ <span style="color:#33B">@b</span>.should == <span style="color:#00D">2</span>
974
1249
  <span style="color:#080;font-weight:bold">end</span>
975
1250
 
976
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">transforms the given parameter to instance variables when in it is a hash</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
977
- params = { <span style="color:#808">c</span>: <span style="color:#00D;font-weight:bold">3</span>, <span style="color:#808">d</span>: <span style="color:#00D;font-weight:bold">4</span> }
1251
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">transforms the given parameter to instance variables when in it is a hash</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1252
+ params = { <span style="color:#606">c</span>: <span style="color:#00D">3</span>, <span style="color:#606">d</span>: <span style="color:#00D">4</span> }
978
1253
  instance_variables_from params
979
1254
 
980
- <span style="color:#33B">@c</span>.should == <span style="color:#00D;font-weight:bold">3</span>
981
- <span style="color:#33B">@d</span>.should == <span style="color:#00D;font-weight:bold">4</span>
1255
+ <span style="color:#33B">@c</span>.should == <span style="color:#00D">3</span>
1256
+ <span style="color:#33B">@d</span>.should == <span style="color:#00D">4</span>
982
1257
  <span style="color:#080;font-weight:bold">end</span>
983
1258
  <span style="color:#080;font-weight:bold">end</span></pre></div>
984
1259
  </div>
985
1260
  </div> </td></tr><tr><th>Source</th> <td> <span id="show_instance_variables_from_source">(<a href="javascript:show('instance_variables_from_source')">show</a>)</span>
986
1261
  <div class="source" id="instance_variables_from_source"><div class="CodeRay">
987
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker</span><span style="color:#710">'</span></span>
1262
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker</span><span style="color:#710">'</span></span>
988
1263
 
989
1264
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Zucker</span>
990
1265
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">InstanceVariablesFrom</span>
@@ -994,11 +1269,11 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
994
1269
  <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">instance_variables_from</span>(obj, *only)
995
1270
  iter =
996
1271
  <span style="color:#080;font-weight:bold">if</span> obj.is_a? <span style="color:#036;font-weight:bold">Binding</span>
997
- obj.eval(<span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">local_variables</span><span style="color:#710">'</span></span>).map{|e| [obj.eval(<span style="background-color:#fff0f0;color:#D20"><span style="color:#710">&quot;</span><span style="background:#ddd;color:black"><span style="background:#ddd;font-weight:bold;color:#666">#{</span>e<span style="background:#ddd;font-weight:bold;color:#666">}</span></span><span style="color:#710">&quot;</span></span>), e] }
1272
+ obj.eval(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">local_variables</span><span style="color:#710">'</span></span>).map{|e| [obj.eval(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="font-weight:bold;color:#666">#{</span>e<span style="font-weight:bold;color:#666">}</span></span><span style="color:#710">&quot;</span></span>), e] }
998
1273
  <span style="color:#080;font-weight:bold">elsif</span> obj.is_a? <span style="color:#036;font-weight:bold">Hash</span>
999
1274
  obj.map{|k,v| [v,k] }
1000
1275
  <span style="color:#080;font-weight:bold">else</span>
1001
- <span style="color:#888"># elsif obj.is_a? Enumerable</span>
1276
+ <span style="color:#777"># elsif obj.is_a? Enumerable</span>
1002
1277
  obj.each.with_index
1003
1278
  <span style="color:#080;font-weight:bold">end</span>
1004
1279
 
@@ -1006,9 +1281,9 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
1006
1281
  iter.each{ |value, arg|
1007
1282
  arg = arg.to_s
1008
1283
  <span style="color:#080;font-weight:bold">if</span> only.include?(arg) || only.include?(arg.to_sym) || only.empty?
1009
- arg = <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">_</span><span style="color:#710">'</span></span> + arg <span style="color:#080;font-weight:bold">if</span> (<span style="color:#00D;font-weight:bold">48</span>..<span style="color:#00D;font-weight:bold">57</span>).member? arg.unpack(<span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">C</span><span style="color:#710">'</span></span>)[<span style="color:#00D;font-weight:bold">0</span>] <span style="color:#888"># 1.8+1.9</span>
1010
- ret &lt;&lt; ivar = <span style="color:#A60"><span style="color:#A60">:</span><span style="color:#630">&quot;</span><span style="color:#A60">@</span><span style="background:#ddd;color:black"><span style="background:#ddd;font-weight:bold;color:#666">#{</span>arg<span style="background:#ddd;font-weight:bold;color:#666">}</span></span><span style="color:#630">&quot;</span></span>
1011
- <span style="color:#038;font-weight:bold">self</span>.instance_variable_set ivar, value
1284
+ arg = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">_</span><span style="color:#710">'</span></span> + arg <span style="color:#080;font-weight:bold">if</span> (<span style="color:#00D">48</span>..<span style="color:#00D">57</span>).member? arg.unpack(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">C</span><span style="color:#710">'</span></span>)[<span style="color:#00D">0</span>] <span style="color:#777"># 1.8+1.9</span>
1285
+ ret &lt;&lt; ivar = <span style="color:#A60"><span style="color:#A60">:</span><span style="color:#740">&quot;</span><span style="color:#A60">@</span><span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="font-weight:bold;color:#666">#{</span>arg<span style="font-weight:bold;color:#666">}</span></span><span style="color:#740">&quot;</span></span>
1286
+ <span style="color:#069">self</span>.instance_variable_set ivar, value
1012
1287
  <span style="color:#080;font-weight:bold">end</span>
1013
1288
  }
1014
1289
  ret
@@ -1024,27 +1299,27 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
1024
1299
  <div class="code"><pre>using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">Iterate</span></pre></div>
1025
1300
  </div>
1026
1301
  </div></td></tr><tr><th>Usage</th> <td><h5>iterate</h5><div class="usage source" style="display:block"><div class="CodeRay">
1027
- <div class="code"><pre>iterate [<span style="color:#00D;font-weight:bold">1</span>,<span style="color:#00D;font-weight:bold">2</span>], [<span style="color:#00D;font-weight:bold">3</span>,<span style="color:#00D;font-weight:bold">4</span>,<span style="color:#00D;font-weight:bold">5</span>] <span style="color:#080;font-weight:bold">do</span> |e,f|
1028
- puts <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">&quot;</span><span style="background:#ddd;color:black"><span style="background:#ddd;font-weight:bold;color:#666">#{</span>e<span style="background:#ddd;font-weight:bold;color:#666">}</span></span><span style="">,</span><span style="background:#ddd;color:black"><span style="background:#ddd;font-weight:bold;color:#666">#{</span>f<span style="background:#ddd;font-weight:bold;color:#666">}</span></span><span style="color:#710">&quot;</span></span>
1302
+ <div class="code"><pre>iterate [<span style="color:#00D">1</span>,<span style="color:#00D">2</span>], [<span style="color:#00D">3</span>,<span style="color:#00D">4</span>,<span style="color:#00D">5</span>] <span style="color:#080;font-weight:bold">do</span> |e,f|
1303
+ puts <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="font-weight:bold;color:#666">#{</span>e<span style="font-weight:bold;color:#666">}</span></span><span style="color:#D20">,</span><span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="font-weight:bold;color:#666">#{</span>f<span style="font-weight:bold;color:#666">}</span></span><span style="color:#710">&quot;</span></span>
1029
1304
  <span style="color:#080;font-weight:bold">end</span>
1030
- <span style="color:#888"># outputs</span>
1031
- <span style="color:#888"># 1,3</span>
1032
- <span style="color:#888"># 2,4</span>
1033
- <span style="color:#888"># ,5</span>
1305
+ <span style="color:#777"># outputs</span>
1306
+ <span style="color:#777"># 1,3</span>
1307
+ <span style="color:#777"># 2,4</span>
1308
+ <span style="color:#777"># ,5</span>
1034
1309
  </pre></div>
1035
1310
  </div>
1036
1311
  </div></td></tr><tr><th>Specification</th> <td> <span id="show_iterate_spec">(<a href="javascript:show('iterate_spec')">show</a>)</span>
1037
1312
  <div class="source" id="iterate_spec"><div class="CodeRay">
1038
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker/iterate</span><span style="color:#710">'</span></span>
1313
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker/iterate</span><span style="color:#710">'</span></span>
1039
1314
  using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">Iterate</span>
1040
1315
 
1041
1316
 
1042
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">Object#iterate</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1043
- let <span style="color:#A60">:a</span> <span style="color:#080;font-weight:bold">do</span> [<span style="color:#00D;font-weight:bold">1</span>, <span style="color:#00D;font-weight:bold">2</span>, <span style="color:#00D;font-weight:bold">3</span>] <span style="color:#080;font-weight:bold">end</span>
1044
- let <span style="color:#A60">:b</span> <span style="color:#080;font-weight:bold">do</span> <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">%w|</span><span style="">a b c d</span><span style="color:#710">|</span></span> <span style="color:#080;font-weight:bold">end</span>
1317
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Object#iterate</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1318
+ let <span style="color:#A60">:a</span> <span style="color:#080;font-weight:bold">do</span> [<span style="color:#00D">1</span>, <span style="color:#00D">2</span>, <span style="color:#00D">3</span>] <span style="color:#080;font-weight:bold">end</span>
1319
+ let <span style="color:#A60">:b</span> <span style="color:#080;font-weight:bold">do</span> <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">%w|</span><span style="color:#D20">a b c d</span><span style="color:#710">|</span></span> <span style="color:#080;font-weight:bold">end</span>
1045
1320
  let <span style="color:#A60">:res</span> <span style="color:#080;font-weight:bold">do</span> <span style="color:#036;font-weight:bold">Hash</span>.new {[]} <span style="color:#080;font-weight:bold">end</span>
1046
1321
 
1047
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should behave like Enumerable#each for a single argument</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1322
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should behave like Enumerable#each for a single argument</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1048
1323
  iterate a <span style="color:#080;font-weight:bold">do</span> |ele|
1049
1324
  res[<span style="color:#A60">:iter</span>] &lt;&lt; ele
1050
1325
  <span style="color:#080;font-weight:bold">end</span>
@@ -1056,10 +1331,10 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
1056
1331
  res[<span style="color:#A60">:iter</span>].should == res[<span style="color:#A60">:each</span>]
1057
1332
  <span style="color:#080;font-weight:bold">end</span>
1058
1333
 
1059
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should pass the right params to the block</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1060
- res = <span style="color:#036;font-weight:bold">Hash</span>.new {[]} <span style="color:#888"># TODO: why?</span>
1061
- res[<span style="color:#A60">:iter_a_b</span>] = [] <span style="color:#888"># ....</span>
1062
- res[<span style="color:#A60">:iter_b_a</span>] = [] <span style="color:#888"># ....</span>
1334
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should pass the right params to the block</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1335
+ res = <span style="color:#036;font-weight:bold">Hash</span>.new {[]} <span style="color:#777"># TODO: why?</span>
1336
+ res[<span style="color:#A60">:iter_a_b</span>] = [] <span style="color:#777"># ....</span>
1337
+ res[<span style="color:#A60">:iter_b_a</span>] = [] <span style="color:#777"># ....</span>
1063
1338
 
1064
1339
 
1065
1340
  iterate a, b <span style="color:#080;font-weight:bold">do</span> |e,f|
@@ -1067,10 +1342,10 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
1067
1342
  <span style="color:#080;font-weight:bold">end</span>
1068
1343
 
1069
1344
  res[<span style="color:#A60">:iter_a_b</span>].should == [
1070
- [<span style="color:#00D;font-weight:bold">1</span>, <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">a</span><span style="color:#710">'</span></span>],
1071
- [<span style="color:#00D;font-weight:bold">2</span>, <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">b</span><span style="color:#710">'</span></span>],
1072
- [<span style="color:#00D;font-weight:bold">3</span>, <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">c</span><span style="color:#710">'</span></span>],
1073
- [<span style="color:#038;font-weight:bold">nil</span>, <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">d</span><span style="color:#710">'</span></span>],
1345
+ [<span style="color:#00D">1</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">a</span><span style="color:#710">'</span></span>],
1346
+ [<span style="color:#00D">2</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">b</span><span style="color:#710">'</span></span>],
1347
+ [<span style="color:#00D">3</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">c</span><span style="color:#710">'</span></span>],
1348
+ [<span style="color:#069">nil</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">d</span><span style="color:#710">'</span></span>],
1074
1349
  ]
1075
1350
 
1076
1351
  iterate b, a <span style="color:#080;font-weight:bold">do</span> |e,f|
@@ -1078,46 +1353,46 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
1078
1353
  <span style="color:#080;font-weight:bold">end</span>
1079
1354
 
1080
1355
  res[<span style="color:#A60">:iter_b_a</span>].should == [
1081
- [<span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">a</span><span style="color:#710">'</span></span>, <span style="color:#00D;font-weight:bold">1</span>],
1082
- [<span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">b</span><span style="color:#710">'</span></span>, <span style="color:#00D;font-weight:bold">2</span>],
1083
- [<span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">c</span><span style="color:#710">'</span></span>, <span style="color:#00D;font-weight:bold">3</span>],
1084
- [<span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">d</span><span style="color:#710">'</span></span>, <span style="color:#038;font-weight:bold">nil</span>],
1356
+ [<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">a</span><span style="color:#710">'</span></span>, <span style="color:#00D">1</span>],
1357
+ [<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">b</span><span style="color:#710">'</span></span>, <span style="color:#00D">2</span>],
1358
+ [<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">c</span><span style="color:#710">'</span></span>, <span style="color:#00D">3</span>],
1359
+ [<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">d</span><span style="color:#710">'</span></span>, <span style="color:#069">nil</span>],
1085
1360
  ]
1086
1361
 
1087
1362
  <span style="color:#080;font-weight:bold">end</span>
1088
1363
 
1089
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should return enumerators if no block is applied</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1090
- res = <span style="color:#036;font-weight:bold">Hash</span>.new {[]} <span style="color:#888"># TODO: why?</span>
1091
- res[<span style="color:#A60">:iter_a_b</span>] = [] <span style="color:#888"># ....</span>
1092
- res[<span style="color:#A60">:iter_b_a</span>] = [] <span style="color:#888"># ....</span>
1364
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should return enumerators if no block is applied</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1365
+ res = <span style="color:#036;font-weight:bold">Hash</span>.new {[]} <span style="color:#777"># TODO: why?</span>
1366
+ res[<span style="color:#A60">:iter_a_b</span>] = [] <span style="color:#777"># ....</span>
1367
+ res[<span style="color:#A60">:iter_b_a</span>] = [] <span style="color:#777"># ....</span>
1093
1368
 
1094
1369
  enumerator = iterate a,b
1095
- enumerator.should be_kind_of(<span style="color:#036;font-weight:bold">RUBY_VERSION</span> &lt; <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">1.9</span><span style="color:#710">'</span></span> ? <span style="color:#036;font-weight:bold">Enumerable</span>::<span style="color:#036;font-weight:bold">Enumerator</span> : <span style="color:#036;font-weight:bold">Enumerator</span>)
1096
- enumerator.to_a.should == [[<span style="color:#00D;font-weight:bold">1</span>,<span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">a</span><span style="color:#710">'</span></span>], [<span style="color:#00D;font-weight:bold">2</span>,<span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">b</span><span style="color:#710">'</span></span>], [<span style="color:#00D;font-weight:bold">3</span>,<span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">c</span><span style="color:#710">'</span></span>], [<span style="color:#038;font-weight:bold">nil</span>, <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">d</span><span style="color:#710">'</span></span>]]
1370
+ enumerator.should be_kind_of(<span style="color:#036;font-weight:bold">Enumerator</span>)
1371
+ enumerator.to_a.should == [[<span style="color:#00D">1</span>,<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">a</span><span style="color:#710">'</span></span>], [<span style="color:#00D">2</span>,<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">b</span><span style="color:#710">'</span></span>], [<span style="color:#00D">3</span>,<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">c</span><span style="color:#710">'</span></span>], [<span style="color:#069">nil</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">d</span><span style="color:#710">'</span></span>]]
1097
1372
  <span style="color:#080;font-weight:bold">end</span>
1098
1373
  <span style="color:#080;font-weight:bold">end</span></pre></div>
1099
1374
  </div>
1100
1375
  </div> </td></tr><tr><th>Source</th> <td> <span id="show_iterate_source">(<a href="javascript:show('iterate_source')">show</a>)</span>
1101
1376
  <div class="source" id="iterate_source"><div class="CodeRay">
1102
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker</span><span style="color:#710">'</span></span>
1377
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker</span><span style="color:#710">'</span></span>
1103
1378
 
1104
1379
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Zucker</span>
1105
1380
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Iterate</span>
1106
1381
  refine <span style="color:#036;font-weight:bold">Object</span> <span style="color:#080;font-weight:bold">do</span>
1107
1382
  <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">iterate</span>(*params)
1108
- <span style="color:#888"># params.shift.zip(*params).each{ |*elements| yield *elements }</span>
1109
- raise <span style="color:#036;font-weight:bold">ArgumentError</span>, <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">&quot;</span><span style="">wrong number of arguments (0)</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">if</span> params.empty?
1383
+ <span style="color:#777"># params.shift.zip(*params).each{ |*elements| yield *elements }</span>
1384
+ raise <span style="color:#036;font-weight:bold">ArgumentError</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">wrong number of arguments (0)</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">if</span> params.empty?
1110
1385
 
1111
1386
  first = params.shift
1112
- <span style="color:#080;font-weight:bold">if</span> params.empty? <span style="color:#888"># single param - like each</span>
1387
+ <span style="color:#080;font-weight:bold">if</span> params.empty? <span style="color:#777"># single param - like each</span>
1113
1388
  <span style="color:#080;font-weight:bold">if</span> block_given?
1114
1389
  first.map{|e| <span style="color:#080;font-weight:bold">yield</span> e }
1115
1390
  <span style="color:#080;font-weight:bold">else</span>
1116
1391
  first.map.to_enum
1117
1392
  <span style="color:#080;font-weight:bold">end</span>
1118
- <span style="color:#080;font-weight:bold">else</span> <span style="color:#888"># multiple params</span>
1393
+ <span style="color:#080;font-weight:bold">else</span> <span style="color:#777"># multiple params</span>
1119
1394
  max_size = [first, *params].max_by(&amp;<span style="color:#A60">:count</span>).size
1120
- padded_first = first.to_a + [<span style="color:#038;font-weight:bold">nil</span>]*(max_size - first.count) <span style="color:#888"># append nils</span>
1395
+ padded_first = first.to_a + [<span style="color:#069">nil</span>]*(max_size - first.count) <span style="color:#777"># append nils</span>
1121
1396
  obj = padded_first.zip(*params)
1122
1397
  <span style="color:#080;font-weight:bold">if</span> block_given?
1123
1398
  obj.map{|es| <span style="color:#080;font-weight:bold">yield</span>(*es) }
@@ -1137,36 +1412,36 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
1137
1412
  <div class="code"><pre>using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">MarshalCopy</span></pre></div>
1138
1413
  </div>
1139
1414
  </div></td></tr><tr><th>Usage</th> <td><h5>Object#marshal_copy</h5><div class="usage source" style="display:block"><div class="CodeRay">
1140
- <div class="code"><pre>a = <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">%w[</span><span style="">hello world</span><span style="color:#710">]</span></span>
1415
+ <div class="code"><pre>a = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">%w[</span><span style="color:#D20">hello world</span><span style="color:#710">]</span></span>
1141
1416
  b = a.mcopy
1142
1417
  </pre></div>
1143
1418
  </div>
1144
1419
  </div></td></tr><tr><th>Specification</th> <td> <span id="show_marshal_copy_spec">(<a href="javascript:show('marshal_copy_spec')">show</a>)</span>
1145
1420
  <div class="source" id="marshal_copy_spec"><div class="CodeRay">
1146
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker/marshal_copy</span><span style="color:#710">'</span></span>
1421
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker/marshal_copy</span><span style="color:#710">'</span></span>
1147
1422
  using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">MarshalCopy</span>
1148
1423
 
1149
1424
 
1150
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">Object#marshal_copy</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1151
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">create a (deep) copy via marshalling</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1152
- a = <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">%w[</span><span style="">hello world</span><span style="color:#710">]</span></span>
1425
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Object#marshal_copy</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1426
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">create a (deep) copy via marshalling</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1427
+ a = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">%w[</span><span style="color:#D20">hello world</span><span style="color:#710">]</span></span>
1153
1428
  b = a.marshal_copy
1154
1429
  b.should == a
1155
1430
 
1156
- b[<span style="color:#00D;font-weight:bold">0</span>][<span style="color:#00D;font-weight:bold">1</span>,<span style="color:#00D;font-weight:bold">1</span>] = <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="color:#710">'</span></span>
1431
+ b[<span style="color:#00D">0</span>][<span style="color:#00D">1</span>,<span style="color:#00D">1</span>] = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#710">'</span></span>
1157
1432
  b.should_not == a
1158
1433
  <span style="color:#080;font-weight:bold">end</span>
1159
1434
  <span style="color:#080;font-weight:bold">end</span></pre></div>
1160
1435
  </div>
1161
1436
  </div> </td></tr><tr><th>Source</th> <td> <span id="show_marshal_copy_source">(<a href="javascript:show('marshal_copy_source')">show</a>)</span>
1162
1437
  <div class="source" id="marshal_copy_source"><div class="CodeRay">
1163
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker</span><span style="color:#710">'</span></span>
1438
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker</span><span style="color:#710">'</span></span>
1164
1439
 
1165
1440
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Zucker</span>
1166
1441
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">MarshalCopy</span>
1167
1442
  refine <span style="color:#036;font-weight:bold">Object</span> <span style="color:#080;font-weight:bold">do</span>
1168
1443
  <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">marshal_copy</span>
1169
- <span style="color:#036;font-weight:bold">Marshal</span>.load <span style="color:#036;font-weight:bold">Marshal</span>.dump <span style="color:#038;font-weight:bold">self</span>
1444
+ <span style="color:#036;font-weight:bold">Marshal</span>.load <span style="color:#036;font-weight:bold">Marshal</span>.dump <span style="color:#069">self</span>
1170
1445
  <span style="color:#080;font-weight:bold">end</span>
1171
1446
  <span style="color:#080;font-weight:bold">end</span>
1172
1447
  <span style="color:#080;font-weight:bold">end</span>
@@ -1179,37 +1454,37 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
1179
1454
  <div class="code"><pre>using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">Mash</span></pre></div>
1180
1455
  </div>
1181
1456
  </div></td></tr><tr><th>Usage</th> <td><h5>Enumerable#mash</h5><div class="usage source" style="display:block"><div class="CodeRay">
1182
- <div class="code"><pre>[<span style="color:#00D;font-weight:bold">1</span>,<span style="color:#00D;font-weight:bold">2</span>,<span style="color:#00D;font-weight:bold">3</span>].mash{|e| [e, e.to_s] } <span style="color:#888"># =&gt; {1=&gt;'1',2=&gt;'2',3=&gt;'3'}</span></pre></div>
1457
+ <div class="code"><pre>[<span style="color:#00D">1</span>,<span style="color:#00D">2</span>,<span style="color:#00D">3</span>].mash{|e| [e, e.to_s] } <span style="color:#777"># =&gt; {1=&gt;'1',2=&gt;'2',3=&gt;'3'}</span></pre></div>
1183
1458
  </div>
1184
1459
  </div></td></tr><tr><th>Information</th> <td>Inspired by Ruby Facets' <code>mash</code>.</td></tr><tr><th>Specification</th> <td> <span id="show_mash_spec">(<a href="javascript:show('mash_spec')">show</a>)</span>
1185
1460
  <div class="source" id="mash_spec"><div class="CodeRay">
1186
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker/mash</span><span style="color:#710">'</span></span>
1461
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker/mash</span><span style="color:#710">'</span></span>
1187
1462
  using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">Mash</span>
1188
1463
 
1189
1464
 
1190
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">Array#mash</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1191
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should &quot;map&quot; a hash</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1192
- [<span style="color:#00D;font-weight:bold">1</span>,<span style="color:#00D;font-weight:bold">2</span>,<span style="color:#00D;font-weight:bold">3</span>].mash{|e| [e, e.to_s] }.should == {<span style="color:#00D;font-weight:bold">1</span>=&gt;<span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">1</span><span style="color:#710">'</span></span>,<span style="color:#00D;font-weight:bold">2</span>=&gt;<span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">2</span><span style="color:#710">'</span></span>,<span style="color:#00D;font-weight:bold">3</span>=&gt;<span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">3</span><span style="color:#710">'</span></span>,}
1465
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Array#mash</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1466
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should &quot;map&quot; a hash</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1467
+ [<span style="color:#00D">1</span>,<span style="color:#00D">2</span>,<span style="color:#00D">3</span>].mash{|e| [e, e.to_s] }.should == {<span style="color:#00D">1</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">1</span><span style="color:#710">'</span></span>,<span style="color:#00D">2</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">2</span><span style="color:#710">'</span></span>,<span style="color:#00D">3</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">3</span><span style="color:#710">'</span></span>,}
1193
1468
  <span style="color:#080;font-weight:bold">end</span>
1194
1469
  <span style="color:#080;font-weight:bold">end</span>
1195
1470
 
1196
1471
 
1197
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">Enumerator#mash</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1198
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should &quot;map&quot; a hash</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1199
- [<span style="color:#00D;font-weight:bold">1</span>,<span style="color:#00D;font-weight:bold">2</span>,<span style="color:#00D;font-weight:bold">3</span>].each.mash{|e| [e, e.to_s] }.should == {<span style="color:#00D;font-weight:bold">1</span>=&gt;<span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">1</span><span style="color:#710">'</span></span>,<span style="color:#00D;font-weight:bold">2</span>=&gt;<span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">2</span><span style="color:#710">'</span></span>,<span style="color:#00D;font-weight:bold">3</span>=&gt;<span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">3</span><span style="color:#710">'</span></span>,}
1472
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Enumerator#mash</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1473
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should &quot;map&quot; a hash</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1474
+ [<span style="color:#00D">1</span>,<span style="color:#00D">2</span>,<span style="color:#00D">3</span>].each.mash{|e| [e, e.to_s] }.should == {<span style="color:#00D">1</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">1</span><span style="color:#710">'</span></span>,<span style="color:#00D">2</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">2</span><span style="color:#710">'</span></span>,<span style="color:#00D">3</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">3</span><span style="color:#710">'</span></span>,}
1200
1475
  <span style="color:#080;font-weight:bold">end</span>
1201
1476
  <span style="color:#080;font-weight:bold">end</span></pre></div>
1202
1477
  </div>
1203
1478
  </div> </td></tr><tr><th>Source</th> <td> <span id="show_mash_source">(<a href="javascript:show('mash_source')">show</a>)</span>
1204
1479
  <div class="source" id="mash_source"><div class="CodeRay">
1205
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker</span><span style="color:#710">'</span></span>
1480
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker</span><span style="color:#710">'</span></span>
1206
1481
 
1207
1482
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Zucker</span>
1208
1483
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Mash</span>
1209
1484
  refine <span style="color:#036;font-weight:bold">Enumerator</span> <span style="color:#080;font-weight:bold">do</span>
1210
1485
  <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">mash</span>
1211
1486
  ret = {}
1212
- each{ |kv| ret.store( *(<span style="color:#080;font-weight:bold">yield</span>(kv)[<span style="color:#00D;font-weight:bold">0</span>,<span style="color:#00D;font-weight:bold">2</span>]) ) }
1487
+ each{ |kv| ret.store( *(<span style="color:#080;font-weight:bold">yield</span>(kv)[<span style="color:#00D">0</span>,<span style="color:#00D">2</span>]) ) }
1213
1488
  ret
1214
1489
  <span style="color:#080;font-weight:bold">end</span>
1215
1490
  <span style="color:#080;font-weight:bold">end</span>
@@ -1217,7 +1492,7 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
1217
1492
  refine <span style="color:#036;font-weight:bold">Array</span> <span style="color:#080;font-weight:bold">do</span>
1218
1493
  <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">mash</span>
1219
1494
  ret = {}
1220
- each{ |kv| ret.store( *(<span style="color:#080;font-weight:bold">yield</span>(kv)[<span style="color:#00D;font-weight:bold">0</span>,<span style="color:#00D;font-weight:bold">2</span>]) ) }
1495
+ each{ |kv| ret.store( *(<span style="color:#080;font-weight:bold">yield</span>(kv)[<span style="color:#00D">0</span>,<span style="color:#00D">2</span>]) ) }
1221
1496
  ret
1222
1497
  <span style="color:#080;font-weight:bold">end</span>
1223
1498
  <span style="color:#080;font-weight:bold">end</span>
@@ -1231,47 +1506,47 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
1231
1506
  <div class="code"><pre>using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">RegexpUnion</span></pre></div>
1232
1507
  </div>
1233
1508
  </div></td></tr><tr><th>Usage</th> <td><h5>Regexp#|, String#|</h5><div class="usage source" style="display:block"><div class="CodeRay">
1234
- <div class="code"><pre><span style="background-color:#fff0ff"><span style="color:#404">/</span><span style="color:#808">Ruby</span><span style="color:#04D">\d</span><span style="color:#404">/</span></span> | <span style="background-color:#fff0ff"><span style="color:#404">/</span><span style="color:#808">test</span><span style="color:#404">/</span><span style="color:#C2C">i</span></span> | <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">&quot;</span><span style="">cheat</span><span style="color:#710">&quot;</span></span>
1235
- <span style="color:#888"># creates a Regexp similar to:</span>
1236
- <span style="color:#888"># /(Ruby\d|[tT][eE][sS][tT]|cheat)/</span>
1509
+ <div class="code"><pre><span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#808">Ruby</span><span style="color:#D20">\d</span><span style="color:#404">/</span></span> | <span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#808">test</span><span style="color:#404">/</span><span style="color:#C2C">i</span></span> | <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">cheat</span><span style="color:#710">&quot;</span></span>
1510
+ <span style="color:#777"># creates a Regexp similar to:</span>
1511
+ <span style="color:#777"># /(Ruby\d|[tT][eE][sS][tT]|cheat)/</span>
1237
1512
  </pre></div>
1238
1513
  </div>
1239
1514
  </div></td></tr><tr><th>Specification</th> <td> <span id="show_regexp_union_spec">(<a href="javascript:show('regexp_union_spec')">show</a>)</span>
1240
1515
  <div class="source" id="regexp_union_spec"><div class="CodeRay">
1241
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker/regexp_union</span><span style="color:#710">'</span></span>
1516
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker/regexp_union</span><span style="color:#710">'</span></span>
1242
1517
  using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">RegexpUnion</span>
1243
1518
 
1244
1519
 
1245
- shared_examples_for <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">&quot;</span><span style="">Regexp.union operator</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
1246
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">&quot;</span><span style="">creates a Regexp.union of both operands</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
1247
- (<span style="background-color:#fff0ff"><span style="color:#404">/</span><span style="color:#808">Ruby</span><span style="color:#04D">\d</span><span style="color:#404">/</span></span> | <span style="background-color:#fff0ff"><span style="color:#404">/</span><span style="color:#808">test</span><span style="color:#404">/</span><span style="color:#C2C">i</span></span> | <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">&quot;</span><span style="">cheat</span><span style="color:#710">&quot;</span></span>).should ==
1248
- <span style="color:#036;font-weight:bold">Regexp</span>.union( <span style="color:#036;font-weight:bold">Regexp</span>.union( <span style="background-color:#fff0ff"><span style="color:#404">/</span><span style="color:#808">Ruby</span><span style="color:#04D">\d</span><span style="color:#404">/</span></span>, <span style="background-color:#fff0ff"><span style="color:#404">/</span><span style="color:#808">test</span><span style="color:#404">/</span><span style="color:#C2C">i</span></span> ), <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">&quot;</span><span style="">cheat</span><span style="color:#710">&quot;</span></span> )
1520
+ shared_examples_for <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Regexp.union operator</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
1521
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">creates a Regexp.union of both operands</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">do</span>
1522
+ (<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#808">Ruby</span><span style="color:#D20">\d</span><span style="color:#404">/</span></span> | <span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#808">test</span><span style="color:#404">/</span><span style="color:#C2C">i</span></span> | <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">cheat</span><span style="color:#710">&quot;</span></span>).should ==
1523
+ <span style="color:#036;font-weight:bold">Regexp</span>.union( <span style="color:#036;font-weight:bold">Regexp</span>.union( <span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#808">Ruby</span><span style="color:#D20">\d</span><span style="color:#404">/</span></span>, <span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#808">test</span><span style="color:#404">/</span><span style="color:#C2C">i</span></span> ), <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">cheat</span><span style="color:#710">&quot;</span></span> )
1249
1524
  <span style="color:#080;font-weight:bold">end</span>
1250
1525
  <span style="color:#080;font-weight:bold">end</span>
1251
1526
 
1252
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">Regexp#|</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1253
- it_should_behave_like <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">Regexp.union operator</span><span style="color:#710">'</span></span>
1527
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Regexp#|</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1528
+ it_should_behave_like <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Regexp.union operator</span><span style="color:#710">'</span></span>
1254
1529
  <span style="color:#080;font-weight:bold">end</span>
1255
1530
 
1256
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">String#|</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1257
- it_should_behave_like <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">Regexp.union operator</span><span style="color:#710">'</span></span>
1531
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">String#|</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1532
+ it_should_behave_like <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Regexp.union operator</span><span style="color:#710">'</span></span>
1258
1533
  <span style="color:#080;font-weight:bold">end</span></pre></div>
1259
1534
  </div>
1260
1535
  </div> </td></tr><tr><th>Source</th> <td> <span id="show_regexp_union_source">(<a href="javascript:show('regexp_union_source')">show</a>)</span>
1261
1536
  <div class="source" id="regexp_union_source"><div class="CodeRay">
1262
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker</span><span style="color:#710">'</span></span>
1537
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker</span><span style="color:#710">'</span></span>
1263
1538
 
1264
1539
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Zucker</span>
1265
1540
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">RegexpUnion</span>
1266
1541
  refine <span style="color:#036;font-weight:bold">Regexp</span> <span style="color:#080;font-weight:bold">do</span>
1267
1542
  <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">|</span>(arg)
1268
- <span style="color:#036;font-weight:bold">Regexp</span>.union <span style="color:#038;font-weight:bold">self</span>, arg.is_a?(<span style="color:#036;font-weight:bold">Regexp</span>) ? arg : arg.to_s
1543
+ <span style="color:#036;font-weight:bold">Regexp</span>.union <span style="color:#069">self</span>, arg.is_a?(<span style="color:#036;font-weight:bold">Regexp</span>) ? arg : arg.to_s
1269
1544
  <span style="color:#080;font-weight:bold">end</span>
1270
1545
  <span style="color:#080;font-weight:bold">end</span>
1271
1546
 
1272
1547
  refine <span style="color:#036;font-weight:bold">String</span> <span style="color:#080;font-weight:bold">do</span>
1273
1548
  <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">|</span>(arg)
1274
- <span style="color:#036;font-weight:bold">Regexp</span>.union <span style="color:#038;font-weight:bold">self</span>, arg.is_a?(<span style="color:#036;font-weight:bold">Regexp</span>) ? arg : arg.to_s
1549
+ <span style="color:#036;font-weight:bold">Regexp</span>.union <span style="color:#069">self</span>, arg.is_a?(<span style="color:#036;font-weight:bold">Regexp</span>) ? arg : arg.to_s
1275
1550
  <span style="color:#080;font-weight:bold">end</span>
1276
1551
  <span style="color:#080;font-weight:bold">end</span>
1277
1552
  <span style="color:#080;font-weight:bold">end</span>
@@ -1287,87 +1562,87 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
1287
1562
  <div class="code"><pre><span style="color:#080;font-weight:bold">class</span> <span style="color:#B06;font-weight:bold">Klass</span>
1288
1563
  <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">initialize</span>
1289
1564
  <span style="color:#33B">@var</span> = {
1290
- <span style="color:#A60">:a_key</span> =&gt; <span style="color:#00D;font-weight:bold">1</span>,
1291
- <span style="color:#A60">:another_one</span> =&gt; <span style="color:#00D;font-weight:bold">2</span>,
1565
+ <span style="color:#A60">:a_key</span> =&gt; <span style="color:#00D">1</span>,
1566
+ <span style="color:#A60">:another_one</span> =&gt; <span style="color:#00D">2</span>,
1292
1567
  }
1293
1568
  <span style="color:#080;font-weight:bold">end</span>
1294
1569
 
1295
- square_brackets_for <span style="color:#A60">:var</span> <span style="color:#888"># creates [] and []=</span>
1296
- <span style="color:#888"># square_brackets_for :var, false # would create only []</span>
1570
+ square_brackets_for <span style="color:#A60">:var</span> <span style="color:#777"># creates [] and []=</span>
1571
+ <span style="color:#777"># square_brackets_for :var, false # would create only []</span>
1297
1572
  <span style="color:#080;font-weight:bold">end</span>
1298
1573
 
1299
1574
  a = <span style="color:#036;font-weight:bold">Klass</span>.new
1300
- a[<span style="color:#A60">:a_key</span>] <span style="color:#888"># =&gt; 1</span>
1575
+ a[<span style="color:#A60">:a_key</span>] <span style="color:#777"># =&gt; 1</span>
1301
1576
  </pre></div>
1302
1577
  </div>
1303
1578
  </div></td></tr><tr><th>Specification</th> <td> <span id="show_square_brackets_for_spec">(<a href="javascript:show('square_brackets_for_spec')">show</a>)</span>
1304
1579
  <div class="source" id="square_brackets_for_spec"><div class="CodeRay">
1305
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker/square_brackets_for</span><span style="color:#710">'</span></span>
1580
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker/square_brackets_for</span><span style="color:#710">'</span></span>
1306
1581
  using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">SquareBracketsFor</span>
1307
1582
 
1308
1583
 
1309
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">square_brackets_for</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1584
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">square_brackets_for</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1310
1585
  before <span style="color:#080;font-weight:bold">do</span>
1311
1586
  <span style="color:#080;font-weight:bold">class</span> <span style="color:#B06;font-weight:bold">Klass</span>
1312
1587
  <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">initialize</span>
1313
- <span style="color:#33B">@var</span> = { <span style="color:#808">a_key</span>: <span style="color:#00D;font-weight:bold">1</span>, <span style="color:#808">another_one</span>: <span style="color:#00D;font-weight:bold">2</span> }
1588
+ <span style="color:#33B">@var</span> = { <span style="color:#606">a_key</span>: <span style="color:#00D">1</span>, <span style="color:#606">another_one</span>: <span style="color:#00D">2</span> }
1314
1589
  <span style="color:#080;font-weight:bold">end</span>
1315
1590
 
1316
- <span style="color:#33B">@eigenvar</span> = { <span style="color:#808">a_key</span>: <span style="color:#00D;font-weight:bold">99</span> }
1591
+ <span style="color:#33B">@eigenvar</span> = { <span style="color:#606">a_key</span>: <span style="color:#00D">99</span> }
1317
1592
  <span style="color:#080;font-weight:bold">end</span>
1318
1593
  <span style="color:#080;font-weight:bold">end</span>
1319
1594
 
1320
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should define a [] getter (not a setter) for an instance var, if the second parameter is false</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1595
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should define a [] getter (not a setter) for an instance var, if the second parameter is false</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1321
1596
  <span style="color:#080;font-weight:bold">class</span> <span style="color:#B06;font-weight:bold">Klass</span>
1322
- square_brackets_for <span style="color:#A60">:var</span>, <span style="color:#038;font-weight:bold">nil</span>
1597
+ square_brackets_for <span style="color:#A60">:var</span>, <span style="color:#069">nil</span>
1323
1598
  <span style="color:#080;font-weight:bold">end</span>
1324
1599
 
1325
1600
  a = <span style="color:#036;font-weight:bold">Klass</span>.new
1326
- a[<span style="color:#A60">:a_key</span>].should == <span style="color:#00D;font-weight:bold">1</span>
1601
+ a[<span style="color:#A60">:a_key</span>].should == <span style="color:#00D">1</span>
1327
1602
 
1328
1603
  proc <span style="color:#080;font-weight:bold">do</span>
1329
- a[<span style="color:#A60">:this_is</span>] = <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">not possible</span><span style="color:#710">'</span></span>
1604
+ a[<span style="color:#A60">:this_is</span>] = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">not possible</span><span style="color:#710">'</span></span>
1330
1605
  <span style="color:#080;font-weight:bold">end</span>.should raise_exception <span style="color:#036;font-weight:bold">NoMethodError</span>
1331
1606
  <span style="color:#080;font-weight:bold">end</span>
1332
1607
 
1333
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should define [] and []= for accessing an instance variable</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1608
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should define [] and []= for accessing an instance variable</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1334
1609
  <span style="color:#080;font-weight:bold">class</span> <span style="color:#B06;font-weight:bold">Klass</span>
1335
1610
  square_brackets_for <span style="color:#A60">:var</span>
1336
1611
  <span style="color:#080;font-weight:bold">end</span>
1337
1612
 
1338
1613
  a = <span style="color:#036;font-weight:bold">Klass</span>.new
1339
- a[<span style="color:#A60">:a_key</span>].should == <span style="color:#00D;font-weight:bold">1</span>
1614
+ a[<span style="color:#A60">:a_key</span>].should == <span style="color:#00D">1</span>
1340
1615
 
1341
- a[<span style="color:#A60">:this_is</span>] = <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">useful</span><span style="color:#710">'</span></span>
1342
- a[<span style="color:#A60">:this_is</span>].should == <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">useful</span><span style="color:#710">'</span></span>
1616
+ a[<span style="color:#A60">:this_is</span>] = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">useful</span><span style="color:#710">'</span></span>
1617
+ a[<span style="color:#A60">:this_is</span>].should == <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">useful</span><span style="color:#710">'</span></span>
1343
1618
  <span style="color:#080;font-weight:bold">end</span>
1344
1619
 
1345
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should also work for class-instance variables</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1620
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should also work for class-instance variables</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1346
1621
  <span style="color:#080;font-weight:bold">class</span> <span style="color:#B06;font-weight:bold">Klass</span>
1347
1622
  <span style="color:#080;font-weight:bold">class</span> &lt;&lt; <span style="color:#B06;font-weight:bold">Klass</span>
1348
1623
  square_brackets_for <span style="color:#A60">:eigenvar</span>
1349
1624
  <span style="color:#080;font-weight:bold">end</span>
1350
1625
  <span style="color:#080;font-weight:bold">end</span>
1351
1626
 
1352
- <span style="color:#036;font-weight:bold">Klass</span>[<span style="color:#A60">:a_key</span>].should == <span style="color:#00D;font-weight:bold">99</span>
1627
+ <span style="color:#036;font-weight:bold">Klass</span>[<span style="color:#A60">:a_key</span>].should == <span style="color:#00D">99</span>
1353
1628
  <span style="color:#080;font-weight:bold">end</span>
1354
1629
  <span style="color:#080;font-weight:bold">end</span></pre></div>
1355
1630
  </div>
1356
1631
  </div> </td></tr><tr><th>Source</th> <td> <span id="show_square_brackets_for_source">(<a href="javascript:show('square_brackets_for_source')">show</a>)</span>
1357
1632
  <div class="source" id="square_brackets_for_source"><div class="CodeRay">
1358
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker</span><span style="color:#710">'</span></span>
1633
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker</span><span style="color:#710">'</span></span>
1359
1634
 
1360
1635
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Zucker</span>
1361
1636
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">SquareBracketsFor</span>
1362
1637
  refine <span style="color:#036;font-weight:bold">Object</span> <span style="color:#080;font-weight:bold">do</span>
1363
- <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">square_brackets_for</span>(ivar, assignment = <span style="color:#038;font-weight:bold">true</span>)
1638
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">square_brackets_for</span>(ivar, assignment = <span style="color:#069">true</span>)
1364
1639
  define_method <span style="color:#A60">:[]</span> <span style="color:#080;font-weight:bold">do</span> |key|
1365
- (instance_variable_get <span style="color:#A60"><span style="color:#A60">:</span><span style="color:#630">&quot;</span><span style="color:#A60">@</span><span style="background:#ddd;color:black"><span style="background:#ddd;font-weight:bold;color:#666">#{</span>ivar<span style="background:#ddd;font-weight:bold;color:#666">}</span></span><span style="color:#630">&quot;</span></span>)[key]
1640
+ (instance_variable_get <span style="color:#A60"><span style="color:#A60">:</span><span style="color:#740">&quot;</span><span style="color:#A60">@</span><span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="font-weight:bold;color:#666">#{</span>ivar<span style="font-weight:bold;color:#666">}</span></span><span style="color:#740">&quot;</span></span>)[key]
1366
1641
  <span style="color:#080;font-weight:bold">end</span>
1367
1642
 
1368
1643
  <span style="color:#080;font-weight:bold">if</span> assignment
1369
1644
  define_method <span style="color:#A60">:[]=</span> <span style="color:#080;font-weight:bold">do</span> |key, value|
1370
- (instance_variable_get <span style="color:#A60"><span style="color:#A60">:</span><span style="color:#630">&quot;</span><span style="color:#A60">@</span><span style="background:#ddd;color:black"><span style="background:#ddd;font-weight:bold;color:#666">#{</span>ivar<span style="background:#ddd;font-weight:bold;color:#666">}</span></span><span style="color:#630">&quot;</span></span>)[key] = value
1645
+ (instance_variable_get <span style="color:#A60"><span style="color:#A60">:</span><span style="color:#740">&quot;</span><span style="color:#A60">@</span><span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="font-weight:bold;color:#666">#{</span>ivar<span style="font-weight:bold;color:#666">}</span></span><span style="color:#740">&quot;</span></span>)[key] = value
1371
1646
  <span style="color:#080;font-weight:bold">end</span>
1372
1647
  <span style="color:#080;font-weight:bold">end</span>
1373
1648
  <span style="color:#080;font-weight:bold">end</span>
@@ -1382,46 +1657,46 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
1382
1657
  <div class="code"><pre>using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">StringExtras</span></pre></div>
1383
1658
  </div>
1384
1659
  </div></td></tr><tr><th>Usage</th> <td><h5>String#lchomp</h5><div class="usage source" style="display:block"><div class="CodeRay">
1385
- <div class="code"><pre><span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style=""> Yes</span><span style="color:#710">'</span></span>.lchomp <span style="color:#888"># =&gt; ' Yes'</span></pre></div>
1660
+ <div class="code"><pre><span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20"> Yes</span><span style="color:#710">'</span></span>.lchomp <span style="color:#777"># =&gt; ' Yes'</span></pre></div>
1386
1661
  </div>
1387
1662
  </div><h5>String#lchomp!</h5><div class="usage source" style="display:block"><div class="CodeRay">
1388
- <div class="code"><pre><span style="color:#888"># mutable lchomp version</span></pre></div>
1663
+ <div class="code"><pre><span style="color:#777"># mutable lchomp version</span></pre></div>
1389
1664
  </div>
1390
1665
  </div></td></tr><tr><th>Specification</th> <td> <span id="show_string_extras_spec">(<a href="javascript:show('string_extras_spec')">show</a>)</span>
1391
1666
  <div class="source" id="string_extras_spec"><div class="CodeRay">
1392
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker/string_extras</span><span style="color:#710">'</span></span>
1667
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker/string_extras</span><span style="color:#710">'</span></span>
1393
1668
  using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">StringExtras</span>
1394
1669
 
1395
1670
  describe <span style="color:#036;font-weight:bold">String</span> <span style="color:#080;font-weight:bold">do</span>
1396
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">#lchomp</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1397
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should chomp on the left side</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1398
- string = <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">ameise</span><span style="color:#710">'</span></span>
1399
- expect( string.lchomp(<span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">a</span><span style="color:#710">'</span></span>) ).to eq <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">meise</span><span style="color:#710">'</span></span>
1400
- expect( string ).to eq <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">ameise</span><span style="color:#710">'</span></span>
1671
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">#lchomp</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1672
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should chomp on the left side</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1673
+ string = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">ameise</span><span style="color:#710">'</span></span>
1674
+ expect( string.lchomp(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">a</span><span style="color:#710">'</span></span>) ).to eq <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">meise</span><span style="color:#710">'</span></span>
1675
+ expect( string ).to eq <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">ameise</span><span style="color:#710">'</span></span>
1401
1676
  <span style="color:#080;font-weight:bold">end</span>
1402
1677
  <span style="color:#080;font-weight:bold">end</span>
1403
1678
 
1404
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">#lchomp!</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1405
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should chomp on the left side (mutating)</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1406
- string = <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">ameise</span><span style="color:#710">'</span></span>
1407
- expect( string.lchomp!(<span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">a</span><span style="color:#710">'</span></span>) ).to eq <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">meise</span><span style="color:#710">'</span></span>
1408
- expect( string ).to eq <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">meise</span><span style="color:#710">'</span></span>
1679
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">#lchomp!</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1680
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should chomp on the left side (mutating)</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1681
+ string = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">ameise</span><span style="color:#710">'</span></span>
1682
+ expect( string.lchomp!(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">a</span><span style="color:#710">'</span></span>) ).to eq <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">meise</span><span style="color:#710">'</span></span>
1683
+ expect( string ).to eq <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">meise</span><span style="color:#710">'</span></span>
1409
1684
  <span style="color:#080;font-weight:bold">end</span>
1410
1685
  <span style="color:#080;font-weight:bold">end</span>
1411
1686
  <span style="color:#080;font-weight:bold">end</span></pre></div>
1412
1687
  </div>
1413
1688
  </div> </td></tr><tr><th>Source</th> <td> <span id="show_string_extras_source">(<a href="javascript:show('string_extras_source')">show</a>)</span>
1414
1689
  <div class="source" id="string_extras_source"><div class="CodeRay">
1415
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker</span><span style="color:#710">'</span></span>
1690
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker</span><span style="color:#710">'</span></span>
1416
1691
 
1417
1692
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Zucker</span>
1418
1693
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">StringExtras</span>
1419
1694
  refine <span style="color:#036;font-weight:bold">String</span> <span style="color:#080;font-weight:bold">do</span>
1420
- <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">lchomp</span>(arg = <span style="color:#d70;font-weight:bold">$/</span>)
1695
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">lchomp</span>(arg = <span style="color:#d70">$/</span>)
1421
1696
  reverse.chomp(arg).reverse
1422
1697
  <span style="color:#080;font-weight:bold">end</span>
1423
1698
 
1424
- <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">lchomp!</span>(arg = <span style="color:#d70;font-weight:bold">$/</span>)
1699
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">lchomp!</span>(arg = <span style="color:#d70">$/</span>)
1425
1700
  replace reverse.chomp(arg).reverse
1426
1701
  <span style="color:#080;font-weight:bold">end</span>
1427
1702
  <span style="color:#080;font-weight:bold">end</span>
@@ -1435,53 +1710,53 @@ describe <span style="color:#036;font-weight:bold">String</span> <span style="co
1435
1710
  <div class="code"><pre>using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">StringOp</span></pre></div>
1436
1711
  </div>
1437
1712
  </div></td></tr><tr><th>Usage</th> <td><h5>String#-</h5><div class="usage source" style="display:block"><div class="CodeRay">
1438
- <div class="code"><pre><span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">1234abc5678</span><span style="color:#710">'</span></span> - <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">b</span><span style="color:#710">'</span></span> - <span style="background-color:#fff0ff"><span style="color:#404">/</span><span style="color:#04D">\d</span><span style="color:#404">/</span></span> <span style="color:#888"># =&gt; ac</span></pre></div>
1713
+ <div class="code"><pre><span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">1234abc5678</span><span style="color:#710">'</span></span> - <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">b</span><span style="color:#710">'</span></span> - <span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#D20">\d</span><span style="color:#404">/</span></span> <span style="color:#777"># =&gt; ac</span></pre></div>
1439
1714
  </div>
1440
1715
  </div><h5>String#^</h5><div class="usage source" style="display:block"><div class="CodeRay">
1441
- <div class="code"><pre><span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">Yes vs No</span><span style="color:#710">'</span></span>^<span style="color:#00D;font-weight:bold">2</span> <span style="color:#888"># =&gt; 's vs No'</span></pre></div>
1716
+ <div class="code"><pre><span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Yes vs No</span><span style="color:#710">'</span></span>^<span style="color:#00D">2</span> <span style="color:#777"># =&gt; 's vs No'</span></pre></div>
1442
1717
  </div>
1443
1718
  </div></td></tr><tr><th>Specification</th> <td> <span id="show_string_op_spec">(<a href="javascript:show('string_op_spec')">show</a>)</span>
1444
1719
  <div class="source" id="string_op_spec"><div class="CodeRay">
1445
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker/string_op</span><span style="color:#710">'</span></span>
1720
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker/string_op</span><span style="color:#710">'</span></span>
1446
1721
  using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">StringOp</span>
1447
1722
 
1448
1723
 
1449
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">String#-</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1450
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should remove the applied Regexp or String from self via gsub</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1451
- (<span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">1234abc5678</span><span style="color:#710">'</span></span> - <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">b</span><span style="color:#710">'</span></span> - <span style="background-color:#fff0ff"><span style="color:#404">/</span><span style="color:#04D">\d</span><span style="color:#404">/</span></span>).should == <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">ac</span><span style="color:#710">'</span></span>
1724
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">String#-</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1725
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should remove the applied Regexp or String from self via gsub</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1726
+ (<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">1234abc5678</span><span style="color:#710">'</span></span> - <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">b</span><span style="color:#710">'</span></span> - <span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#D20">\d</span><span style="color:#404">/</span></span>).should == <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">ac</span><span style="color:#710">'</span></span>
1452
1727
  <span style="color:#080;font-weight:bold">end</span>
1453
1728
  <span style="color:#080;font-weight:bold">end</span>
1454
1729
 
1455
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">String#^</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1456
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should give C-like substring access to strings</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1457
- string = <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">Theoretische Informatik ist voll geil!</span><span style="color:#710">'</span></span>
1730
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">String#^</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1731
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should give C-like substring access to strings</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1732
+ string = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Theoretische Informatik ist voll geil!</span><span style="color:#710">'</span></span>
1458
1733
 
1459
- (string^<span style="color:#00D;font-weight:bold">0</span>).should == <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">Theoretische Informatik ist voll geil!</span><span style="color:#710">'</span></span>
1460
- (string^<span style="color:#00D;font-weight:bold">1</span>).should == <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">heoretische Informatik ist voll geil!</span><span style="color:#710">'</span></span>
1461
- (string^<span style="color:#00D;font-weight:bold">13</span>).should == <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">Informatik ist voll geil!</span><span style="color:#710">'</span></span>
1462
- (string^<span style="color:#00D;font-weight:bold">-1</span>).should == <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">Theoretische Informatik ist voll geil</span><span style="color:#710">'</span></span>
1463
- (string^<span style="color:#00D;font-weight:bold">38</span>).should == <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="color:#710">'</span></span>
1464
- (string^<span style="color:#00D;font-weight:bold">99</span>).should == <span style="color:#038;font-weight:bold">nil</span>
1734
+ (string^<span style="color:#00D">0</span>).should == <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Theoretische Informatik ist voll geil!</span><span style="color:#710">'</span></span>
1735
+ (string^<span style="color:#00D">1</span>).should == <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">heoretische Informatik ist voll geil!</span><span style="color:#710">'</span></span>
1736
+ (string^<span style="color:#00D">13</span>).should == <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Informatik ist voll geil!</span><span style="color:#710">'</span></span>
1737
+ (string^<span style="color:#00D">-1</span>).should == <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Theoretische Informatik ist voll geil</span><span style="color:#710">'</span></span>
1738
+ (string^<span style="color:#00D">38</span>).should == <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#710">'</span></span>
1739
+ (string^<span style="color:#00D">99</span>).should == <span style="color:#069">nil</span>
1465
1740
  <span style="color:#080;font-weight:bold">end</span>
1466
1741
  <span style="color:#080;font-weight:bold">end</span></pre></div>
1467
1742
  </div>
1468
1743
  </div> </td></tr><tr><th>Source</th> <td> <span id="show_string_op_source">(<a href="javascript:show('string_op_source')">show</a>)</span>
1469
1744
  <div class="source" id="string_op_source"><div class="CodeRay">
1470
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker</span><span style="color:#710">'</span></span>
1745
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker</span><span style="color:#710">'</span></span>
1471
1746
 
1472
1747
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Zucker</span>
1473
1748
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">StringOp</span>
1474
1749
  refine <span style="color:#036;font-weight:bold">String</span> <span style="color:#080;font-weight:bold">do</span>
1475
1750
  <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">-</span>(rem)
1476
- gsub( <span style="color:#036;font-weight:bold">Regexp</span> === rem ? rem : rem.to_s, <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="color:#710">'</span></span> )
1751
+ gsub( <span style="color:#036;font-weight:bold">Regexp</span> === rem ? rem : rem.to_s, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#710">'</span></span> )
1477
1752
  <span style="color:#080;font-weight:bold">end</span>
1478
1753
 
1479
1754
  <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">^</span>(pos)
1480
1755
  pos = pos.to_i
1481
- <span style="color:#080;font-weight:bold">if</span> pos &gt;= <span style="color:#00D;font-weight:bold">0</span>
1482
- <span style="color:#038;font-weight:bold">self</span>[pos..<span style="color:#00D;font-weight:bold">-1</span>]
1756
+ <span style="color:#080;font-weight:bold">if</span> pos &gt;= <span style="color:#00D">0</span>
1757
+ <span style="color:#069">self</span>[pos..<span style="color:#00D">-1</span>]
1483
1758
  <span style="color:#080;font-weight:bold">else</span>
1484
- <span style="color:#038;font-weight:bold">self</span>[<span style="color:#00D;font-weight:bold">0</span>...pos]
1759
+ <span style="color:#069">self</span>[<span style="color:#00D">0</span>...pos]
1485
1760
  <span style="color:#080;font-weight:bold">end</span>
1486
1761
  <span style="color:#080;font-weight:bold">end</span>
1487
1762
  <span style="color:#080;font-weight:bold">end</span>
@@ -1495,43 +1770,43 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
1495
1770
  <div class="code"><pre>using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">Tap</span></pre></div>
1496
1771
  </div>
1497
1772
  </div></td></tr><tr><th>Usage</th> <td><h5>tap_on</h5><div class="usage source" style="display:block"><div class="CodeRay">
1498
- <div class="code"><pre>tap_on [<span style="color:#00D;font-weight:bold">1</span>,<span style="color:#00D;font-weight:bold">2</span>] <span style="color:#080;font-weight:bold">do</span> |obj|
1499
- obj[<span style="color:#00D;font-weight:bold">4</span>] = <span style="color:#00D;font-weight:bold">5</span>
1500
- <span style="color:#080;font-weight:bold">end</span> <span style="color:#888">#=&gt; [1, 2, nil, nil, 5]</span>
1773
+ <div class="code"><pre>tap_on [<span style="color:#00D">1</span>,<span style="color:#00D">2</span>] <span style="color:#080;font-weight:bold">do</span> |obj|
1774
+ obj[<span style="color:#00D">4</span>] = <span style="color:#00D">5</span>
1775
+ <span style="color:#080;font-weight:bold">end</span> <span style="color:#777">#=&gt; [1, 2, nil, nil, 5]</span>
1501
1776
  </pre></div>
1502
1777
  </div>
1503
1778
  </div><h5>make_new</h5><div class="usage source" style="display:block"><div class="CodeRay">
1504
1779
  <div class="code"><pre>make_new <span style="color:#036;font-weight:bold">Hash</span> <span style="color:#080;font-weight:bold">do</span> |obj|
1505
- obj[<span style="color:#00D;font-weight:bold">1</span>] = <span style="color:#00D;font-weight:bold">2</span>
1506
- <span style="color:#080;font-weight:bold">end</span> <span style="color:#888">#=&gt; {1 =&gt; 2}</span>
1780
+ obj[<span style="color:#00D">1</span>] = <span style="color:#00D">2</span>
1781
+ <span style="color:#080;font-weight:bold">end</span> <span style="color:#777">#=&gt; {1 =&gt; 2}</span>
1507
1782
  </pre></div>
1508
1783
  </div>
1509
1784
  </div></td></tr><tr><th>Information</th> <td>Read more about using tap on the <a href="http://blog.rubybestpractices.com/posts/gregory/011-tap-that-hash.html">ruby best practices</a> blog.</td></tr><tr><th>Specification</th> <td> <span id="show_tap_spec">(<a href="javascript:show('tap_spec')">show</a>)</span>
1510
1785
  <div class="source" id="tap_spec"><div class="CodeRay">
1511
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker/tap</span><span style="color:#710">'</span></span>
1786
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker/tap</span><span style="color:#710">'</span></span>
1512
1787
  using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">Tap</span>
1513
1788
 
1514
1789
 
1515
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">tap_on</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1516
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should call tap on the argument and apply the block</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1517
- obj = <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">&quot;</span><span style="">an_object</span><span style="color:#710">&quot;</span></span>
1790
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">tap_on</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1791
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should call tap on the argument and apply the block</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1792
+ obj = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">an_object</span><span style="color:#710">&quot;</span></span>
1518
1793
  block = <span style="color:#A60">:reverse</span>.to_proc
1519
1794
 
1520
1795
  tap_on( obj, &amp;block ).should == obj.tap( &amp;block )
1521
1796
  <span style="color:#080;font-weight:bold">end</span>
1522
1797
  <span style="color:#080;font-weight:bold">end</span>
1523
1798
 
1524
- describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">make_new</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1525
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should create a new instance of the class given as argument, apply the block on it and return result</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1799
+ describe <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">make_new</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1800
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should create a new instance of the class given as argument, apply the block on it and return result</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1526
1801
  make_new <span style="color:#036;font-weight:bold">Hash</span> <span style="color:#080;font-weight:bold">do</span> |obj|
1527
- obj[<span style="color:#00D;font-weight:bold">1</span>] = <span style="color:#00D;font-weight:bold">2</span>
1528
- <span style="color:#080;font-weight:bold">end</span>.should.send(<span style="color:#A60"><span style="color:#A60">:</span><span style="color:#630">'</span><span style="color:#A60">==</span><span style="color:#630">'</span></span>, { <span style="color:#00D;font-weight:bold">1</span> =&gt; <span style="color:#00D;font-weight:bold">2</span>})
1802
+ obj[<span style="color:#00D">1</span>] = <span style="color:#00D">2</span>
1803
+ <span style="color:#080;font-weight:bold">end</span>.should.send(<span style="color:#A60"><span style="color:#A60">:</span><span style="color:#740">'</span><span style="color:#A60">==</span><span style="color:#740">'</span></span>, { <span style="color:#00D">1</span> =&gt; <span style="color:#00D">2</span>})
1529
1804
  <span style="color:#080;font-weight:bold">end</span>
1530
1805
  <span style="color:#080;font-weight:bold">end</span></pre></div>
1531
1806
  </div>
1532
1807
  </div> </td></tr><tr><th>Source</th> <td> <span id="show_tap_source">(<a href="javascript:show('tap_source')">show</a>)</span>
1533
1808
  <div class="source" id="tap_source"><div class="CodeRay">
1534
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker</span><span style="color:#710">'</span></span>
1809
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker</span><span style="color:#710">'</span></span>
1535
1810
 
1536
1811
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Zucker</span>
1537
1812
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Tap</span>
@@ -1556,56 +1831,56 @@ describe <span style="background-color:#fff0f0;color:#D20"><span style="color:#7
1556
1831
  <div class="code"><pre>using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">UnaryConversion</span></pre></div>
1557
1832
  </div>
1558
1833
  </div></td></tr><tr><th>Usage</th> <td><h5>String#+@</h5><div class="usage source" style="display:block"><div class="CodeRay">
1559
- <div class="code"><pre>+<span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">was_string</span><span style="color:#710">'</span></span> <span style="color:#888"># =&gt; 'was_string'</span></pre></div>
1834
+ <div class="code"><pre>+<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">was_string</span><span style="color:#710">'</span></span> <span style="color:#777"># =&gt; 'was_string'</span></pre></div>
1560
1835
  </div>
1561
1836
  </div><h5>String#-@</h5><div class="usage source" style="display:block"><div class="CodeRay">
1562
- <div class="code"><pre>-<span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">was_string</span><span style="color:#710">'</span></span> <span style="color:#888"># =&gt; :was_string</span></pre></div>
1837
+ <div class="code"><pre>-<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">was_string</span><span style="color:#710">'</span></span> <span style="color:#777"># =&gt; :was_string</span></pre></div>
1563
1838
  </div>
1564
1839
  </div><h5>Symbol#+@</h5><div class="usage source" style="display:block"><div class="CodeRay">
1565
- <div class="code"><pre>+<span style="color:#A60">:was_symbol</span> <span style="color:#888"># =&gt; 'was_symbol'</span></pre></div>
1840
+ <div class="code"><pre>+<span style="color:#A60">:was_symbol</span> <span style="color:#777"># =&gt; 'was_symbol'</span></pre></div>
1566
1841
  </div>
1567
1842
  </div><h5>Symbol#-@</h5><div class="usage source" style="display:block"><div class="CodeRay">
1568
- <div class="code"><pre>-<span style="color:#A60">:was_symbol</span> <span style="color:#888"># =&gt; :was_symbol</span></pre></div>
1843
+ <div class="code"><pre>-<span style="color:#A60">:was_symbol</span> <span style="color:#777"># =&gt; :was_symbol</span></pre></div>
1569
1844
  </div>
1570
1845
  </div></td></tr><tr><th>Specification</th> <td> <span id="show_unary_conversion_spec">(<a href="javascript:show('unary_conversion_spec')">show</a>)</span>
1571
1846
  <div class="source" id="unary_conversion_spec"><div class="CodeRay">
1572
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker/unary_conversion</span><span style="color:#710">'</span></span>
1847
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker/unary_conversion</span><span style="color:#710">'</span></span>
1573
1848
  using <span style="color:#036;font-weight:bold">Zucker</span>::<span style="color:#036;font-weight:bold">UnaryConversion</span>
1574
1849
 
1575
1850
 
1576
- describe <span style="color:#036;font-weight:bold">Symbol</span>, <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">#+@</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1577
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should convert to_s</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1578
- +<span style="color:#A60">:matz</span> == <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">matz</span><span style="color:#710">'</span></span>
1851
+ describe <span style="color:#036;font-weight:bold">Symbol</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">#+@</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1852
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should convert to_s</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1853
+ +<span style="color:#A60">:matz</span> == <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">matz</span><span style="color:#710">'</span></span>
1579
1854
  <span style="color:#080;font-weight:bold">end</span>
1580
1855
  <span style="color:#080;font-weight:bold">end</span>
1581
1856
 
1582
- describe <span style="color:#036;font-weight:bold">Symbol</span>, <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">#-@</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1583
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should do nothing</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1857
+ describe <span style="color:#036;font-weight:bold">Symbol</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">#-@</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1858
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should do nothing</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1584
1859
  -<span style="color:#A60">:matz</span> == <span style="color:#A60">:matz</span>
1585
1860
  <span style="color:#080;font-weight:bold">end</span>
1586
1861
  <span style="color:#080;font-weight:bold">end</span>
1587
1862
 
1588
- describe <span style="color:#036;font-weight:bold">String</span>, <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">#+@</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1589
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should do nothing</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1590
- +<span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">matz</span><span style="color:#710">'</span></span> == <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">matz</span><span style="color:#710">'</span></span>
1863
+ describe <span style="color:#036;font-weight:bold">String</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">#+@</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1864
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should do nothing</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1865
+ +<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">matz</span><span style="color:#710">'</span></span> == <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">matz</span><span style="color:#710">'</span></span>
1591
1866
  <span style="color:#080;font-weight:bold">end</span>
1592
1867
  <span style="color:#080;font-weight:bold">end</span>
1593
1868
 
1594
- describe <span style="color:#036;font-weight:bold">String</span>, <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">#-@</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1595
- it <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">should convert to_sym</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1596
- -<span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">matz</span><span style="color:#710">'</span></span> == <span style="color:#A60">:matz</span>
1869
+ describe <span style="color:#036;font-weight:bold">String</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">#-@</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1870
+ it <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">should convert to_sym</span><span style="color:#710">'</span></span> <span style="color:#080;font-weight:bold">do</span>
1871
+ -<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">matz</span><span style="color:#710">'</span></span> == <span style="color:#A60">:matz</span>
1597
1872
  <span style="color:#080;font-weight:bold">end</span>
1598
1873
  <span style="color:#080;font-weight:bold">end</span></pre></div>
1599
1874
  </div>
1600
1875
  </div> </td></tr><tr><th>Source</th> <td> <span id="show_unary_conversion_source">(<a href="javascript:show('unary_conversion_source')">show</a>)</span>
1601
1876
  <div class="source" id="unary_conversion_source"><div class="CodeRay">
1602
- <div class="code"><pre>require <span style="background-color:#fff0f0;color:#D20"><span style="color:#710">'</span><span style="">zucker</span><span style="color:#710">'</span></span>
1877
+ <div class="code"><pre>require <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">zucker</span><span style="color:#710">'</span></span>
1603
1878
 
1604
1879
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">Zucker</span>
1605
1880
  <span style="color:#080;font-weight:bold">module</span> <span style="color:#B06;font-weight:bold">UnaryConversion</span>
1606
1881
  refine <span style="color:#036;font-weight:bold">String</span> <span style="color:#080;font-weight:bold">do</span>
1607
1882
  <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">+@</span>
1608
- <span style="color:#038;font-weight:bold">self</span>
1883
+ <span style="color:#069">self</span>
1609
1884
  <span style="color:#080;font-weight:bold">end</span>
1610
1885
 
1611
1886
  <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">-@</span>
@@ -1619,7 +1894,7 @@ describe <span style="color:#036;font-weight:bold">String</span>, <span style="b
1619
1894
  <span style="color:#080;font-weight:bold">end</span>
1620
1895
 
1621
1896
  <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">-@</span>
1622
- <span style="color:#038;font-weight:bold">self</span>
1897
+ <span style="color:#069">self</span>
1623
1898
  <span style="color:#080;font-weight:bold">end</span>
1624
1899
  <span style="color:#080;font-weight:bold">end</span>
1625
1900
  <span style="color:#080;font-weight:bold">end</span>
@@ -1629,7 +1904,15 @@ describe <span style="color:#036;font-weight:bold">String</span>, <span style="b
1629
1904
 
1630
1905
  <h2>Changelog</h2>
1631
1906
  <div class="cubes">
1632
- <pre class="scode">2014-04-01 | <a href="http://rubyzucker.info/100/">Zucker 100</a>.0
1907
+ <pre class="scode">2015-04-01 | <a href="http://rubyzucker.info/100/">Zucker 100</a>.1.0
1908
+ * drop Ruby 1.9 support
1909
+ * add float_extras for Float#same?
1910
+ * add chain_map
1911
+ * add inner_map
1912
+ * add array_stats
1913
+
1914
+
1915
+ 2014-04-01 | <a href="http://rubyzucker.info/100/">Zucker 100</a>.0.0
1633
1916
  * drop Ruby 1.8 support
1634
1917
  * rewrite zucker to use refinements!
1635
1918
  * use usual semantic versioning
@@ -1763,7 +2046,7 @@ describe <span style="color:#036;font-weight:bold">String</span>, <span style="b
1763
2046
 
1764
2047
  <div id="foot">
1765
2048
  <div id="smile"><a href="http://janlelis.de">J-_-L</a></div>
1766
- This is the Ruby Zucker 100.0.0 documentation (2014-04-01).
2049
+ This is the Ruby Zucker 100.1.0 documentation (2014-04-01).
1767
2050
  The current documentation is always available at <a href="http://rubyzucker.info">rubyzucker.info</a>.
1768
2051
  Source at <a href="https://github.com/janlelis/zucker">github</a>.
1769
2052
  Ruby Logo CC-BY-SA Yukihiro Matsumoto.