zucker 10 → 11
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +10 -0
- data/Rakefile +2 -2
- data/desc/binding.yaml +2 -2
- data/desc/kernel.yaml +2 -1
- data/desc/string.yaml +2 -2
- data/doc/zucker_doc.html +107 -42
- data/lib/zucker.rb +5 -5
- data/lib/zucker/alias_for.rb +1 -0
- data/lib/zucker/aliases.rb +1 -0
- data/lib/zucker/array.rb +1 -0
- data/lib/zucker/array_to_proc.rb +2 -1
- data/lib/zucker/binding.rb +18 -15
- data/lib/zucker/blank.rb +1 -0
- data/lib/zucker/cc.rb +1 -0
- data/lib/zucker/class_to_proc.rb +2 -1
- data/lib/zucker/dd.rb +1 -0
- data/lib/zucker/egonil.rb +1 -0
- data/lib/zucker/engine.rb +1 -0
- data/lib/zucker/enumerable.rb +2 -1
- data/lib/zucker/file.rb +6 -0
- data/lib/zucker/hash.rb +1 -0
- data/lib/zucker/hash_to_proc.rb +1 -0
- data/lib/zucker/info.rb +1 -0
- data/lib/zucker/iterate.rb +3 -2
- data/lib/zucker/ivars.rb +1 -0
- data/lib/zucker/kernel.rb +7 -1
- data/lib/zucker/mcopy.rb +1 -0
- data/lib/zucker/mm.rb +1 -0
- data/lib/zucker/not.rb +1 -0
- data/lib/zucker/oo.rb +1 -0
- data/lib/zucker/os.rb +1 -0
- data/lib/zucker/qq.rb +1 -0
- data/lib/zucker/regexp_to_proc.rb +1 -0
- data/lib/zucker/regexp_visualize.rb +6 -1
- data/lib/zucker/sandbox.rb +2 -0
- data/lib/zucker/square_brackets_for.rb +1 -0
- data/lib/zucker/string.rb +1 -0
- data/lib/zucker/tap.rb +3 -2
- data/lib/zucker/unary.rb +1 -0
- data/lib/zucker/union.rb +1 -0
- data/lib/zucker/version.rb +1 -0
- data/spec/kernel_spec.rb +6 -1
- data/spec/regexp_visualize_spec.rb +1 -1
- data/spec/sandbox_spec.rb +1 -1
- data/spec/version_spec.rb +2 -2
- data/zucker.gemspec +12 -3
- metadata +6 -6
data/CHANGELOG
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
2011-05-25 | Zucker 11
|
2
|
+
* add Zucker::constants to check if cube has been required (e.g. Zucker::AliasFor if 'zucker/alias_for' is loaded)
|
3
|
+
* rbx tweaks
|
4
|
+
* don't define Binding#vars on rbx (prevent endless recursion)
|
5
|
+
* sandbox-not-working warning
|
6
|
+
* add Kernel#ignore_sigquit!
|
7
|
+
* fix warnings
|
8
|
+
* doc tweaks
|
9
|
+
|
10
|
+
|
1
11
|
2011-04-29 | Zucker 10
|
2
12
|
* doc/spec tweaks
|
3
13
|
* make test.rubygems.org-testable
|
data/Rakefile
CHANGED
@@ -42,7 +42,7 @@ end
|
|
42
42
|
|
43
43
|
desc "Install the gem locally"
|
44
44
|
task :install => :gem do
|
45
|
-
sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}}
|
45
|
+
sh %{gem install pkg/#{gemspec.name}-#{gemspec.version} --no-rdoc --no-ri}
|
46
46
|
end
|
47
47
|
|
48
48
|
desc "Validate the gemspec"
|
@@ -60,7 +60,7 @@ task 'prepare_release' => %w[spec] do # run specs
|
|
60
60
|
# bump version and date
|
61
61
|
require 'date'
|
62
62
|
zucker_rb = File.read('lib/zucker.rb')
|
63
|
-
zucker_rb.sub! /VERSION\s
|
63
|
+
zucker_rb.sub! /VERSION\s*=.*?(\d+).*?$/ do "VERSION = '#{ @v = $1.to_i + 1 }'" end
|
64
64
|
zucker_rb.sub! /DATE\s*=.*$/, "DATE = '#{Date.today}'"
|
65
65
|
File.open 'lib/zucker.rb','w' do |f| f.write zucker_rb end
|
66
66
|
|
data/desc/binding.yaml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
binding:
|
2
|
-
summary: Adds
|
2
|
+
summary: Adds ⇧Binding#vars⇧. It gives you information about the current environment variables.
|
3
3
|
methods:
|
4
4
|
Binding#variables, Binding#vars: |
|
5
5
|
# shows your current environment's variables, irb example:
|
@@ -18,5 +18,5 @@ binding:
|
|
18
18
|
- false
|
19
19
|
versions:
|
20
20
|
- 1.9
|
21
|
-
- 1.8
|
21
|
+
- 1.8 (no rbx support)
|
22
22
|
|
data/desc/kernel.yaml
CHANGED
@@ -4,10 +4,11 @@ kernel:
|
|
4
4
|
methods:
|
5
5
|
activate_warnings!: "activate_warnings! # sets $VERBOSE to 1"
|
6
6
|
deactivate_warnings!: "deactivate_warnings! # sets $VERBOSE to 0"
|
7
|
-
executed_directly?, directly_executed
|
7
|
+
executed_directly?, directly_executed?, standalone?: "executed_directly? # checks, if the current file is run directly -> true"
|
8
8
|
library?: "library? # checks, if the current file is run directly -> false"
|
9
9
|
irb?: "irb? # returns false if not called from IRB or RIPL"
|
10
10
|
ignore_sigint!: "ignore_sigint! # blocks CTRL+C"
|
11
|
+
ignore_sigquit!: "ignore_sigquit! # blocks CTRL+\\"
|
11
12
|
versions:
|
12
13
|
- 1.9
|
13
14
|
- 1.8
|
data/desc/string.yaml
CHANGED
@@ -3,8 +3,8 @@ string:
|
|
3
3
|
why: Strings cannot be comfortable enough ;).
|
4
4
|
methods:
|
5
5
|
String#-: "'1234abc5678' - 'b' - /\d/ # => ac"
|
6
|
-
String#^: "'Yes vs No'^
|
7
|
-
String#lchomp: "'
|
6
|
+
String#^: "'Yes vs No'^2 # => 's vs No'"
|
7
|
+
String#lchomp: "' Yes'.lchomp # => ' Yes'"
|
8
8
|
String#lchomp!: "# mutable lchomp version"
|
9
9
|
String#ords: "'Hallo'.ords # => [72, 97, 108, 108, 111]"
|
10
10
|
String#constantize: |
|
data/doc/zucker_doc.html
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
<head>
|
6
6
|
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
|
7
7
|
|
8
|
-
<title>Ruby Zucker
|
8
|
+
<title>Ruby Zucker 11</title>
|
9
9
|
<script type="text/javascript">
|
10
10
|
var show = function(snippet){
|
11
11
|
document.getElementById( snippet ).style.display = 'block'
|
@@ -281,7 +281,7 @@ table.source td { padding: 2px 4px; vertical-align: top; }
|
|
281
281
|
<body>
|
282
282
|
<div id="world">
|
283
283
|
<img class="rubylogo" alt="ruby" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAADAVgAAwFYBgeEOVwAAAAd0SU1FB9oIHxY1C2ozXR0AABglSURBVGjevZt/sGVVdec/a+9z7q/3o1830N00DQiCQkoQiPgj0UiG8UcyMZNSC82PkdIEqYlaISkTMTPlVEw5IdHRqKEURQ2JSZwaiYijJimnxohMVH42Aml+2dD9ul//fP1+9Lv3nnP23mv+2Puce25DTOI4dtepe+5+7913vnut9V1rfdd+wo/wn/cea+3UWlBFIFfVDOdCsbi/Gj7+CMWePRQH9lEsLlItLjLav0h1fAX1ivqKUDq08njnkNKzYZXDsyb86qoH4KNzXd6xXjztGbIfBdAQAsYYjDFT66q6E7gQeJWIBDXmmKpfN1k2kl4P040X3S6m08FYIyH4TBEQASMYhGGOGWY4CSx+fC5fqZD971gv9gH8wVyHd6+XPxrAJwMVEVR1AFwBnFsdWrrKrSy/TIcbSJ6Tb9tBftpWqiNHML0uptfH9vqYfh/b7+OzHPUBSZ9Ziae0gaGBwggKKBBU7vvAfOfDTuW+69eLBwDes9DjvStj5P8n0JOs+VzgZzcevP9la//wjZ8qnnjslHLP41QH9irjITbLpXP6TmZf+BJmf+Z1VBtjhg/uojx4kGJxkWJxL+X+RdzKKq5yjIoNxtWYEaqViJQqWolIpUZLRBxQij7shPf8l9XyVoDfme/8cAGrKiKTj6zKcpDl+U8A7167+1vP3vvhG7aNdj/UC8cOEdbWMYoai1gBAyoByXoZg4svZ+t7P0i1NuTEvXdTHDigxYH94pYO6OqeJ2Rt9RhOHUHRUkQqIsgK0VKNVBDBo1RC4eGX3rda/PUP1aVDCA1Y59yCMea/icjri4MHOrve/PrOxv13GQkBVLGgYkUUEQXUgBURmyk+KBv3/gMrf34TZ/zxZwiuUn9iXdzan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5z7XHx8si3ORh5OJBTLygTkM87ImwatCRq6QqKi2LUp0LGuq+vonf5M46LefU3VIQyLKMhZkeric8ZUYsmYKjUrJCyQn1lKJURnGiOIFKFIfiUYLRqHyaCLxjLF2b07U5eadL3u9CJ9Ptc1v4xfNfQifLOV6O1piZW52uZoG/ODXPV6v8fU75ba2rVGkOzUgQ6JdeTx15PCDZrGK7ErQSL46gHi+OgMPjpyorL0KwBnILJvKAikzYfbJVqGpsKDCSiSFDyEwkr44YcolAOyajI5aOzehkGXmWkWU53Syn2+nR73TZ8CW7jjx555b+/Btf+eAji41Lf2Khxy8fHVcf35S9TxDv0OtrsAGadLPWMZwy8ipiRaRDSB7QWDlNEppzW5nBpRaN1pRSRJrTc4a6AZaUS9NWCzj1VJL0+jCp3NLw7JCiB71yyAoHBzY/ONvpL83nvY3Ngzl/6sy8O212i7/49HOXrvnmnUeeZuEb5/u8bW3EJxf6vTXPC7yRLwV0QacUfmGu8n77EKvdzSGok4CXoA5PRRBPYQNlZmL8Szrkrc80cdSYN+EYsFeERZB9Jt7vG6s/DuriX+Roc25FwVkRZ0QKIzLOxIy7WTae6wzGb3jyUPlPnb96/2kZv33ETT/Hn8z3efvaCIA/2tSfVfQFCq9T5OeAs1SQTNGz1jOv+SAvpaKUSivjjnqjh73RIwqHgSMicgg4AqwIsiawboQ1i1nvYlaPhaLITdQB4iVqjYQuJsxl3XCwOqEztsfFM9u4/MlH/3V/YfOW/4T59Pue8Wv/F9jGEQFesRfqAAAAAElFTkSuQmCC" />
|
284
|
-
<h1>Ruby Zucker
|
284
|
+
<h1>Ruby Zucker 11</h1>
|
285
285
|
<h2 style="clear:both">What is it?</h2>
|
286
286
|
<p class="text">Zucker (<a href="http://www.forvo.com/word/zucker/">pronunciation</a>) is the German word for sugar. It adds syntactic sugar in the form of independent, small scripts that make Ruby even more sweet. It adds a lot of useful helper methods for an improved readability and usage. Almost every Zucker feature comes with specs. Everything is documented on this page. The source is available at <a href="http://github.com/janlelis/zucker">github</a>.</p>
|
287
287
|
|
@@ -361,6 +361,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">egonil</span><
|
|
361
361
|
<span class="r">end</span>
|
362
362
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_egonil_source">(<a href="javascript:show('egonil_source')">show</a>)</span>
|
363
363
|
<pre class="source" id="egonil_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
364
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">Egonil</span> = <span class="pc">true</span> <span class="r">end</span>
|
364
365
|
|
365
366
|
<span class="c"># code by Yohan, slightly edited and comments by me</span>
|
366
367
|
<span class="r">def</span> <span class="fu">egonil</span>(&block)
|
@@ -456,6 +457,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">Object#iterate
|
|
456
457
|
<span class="r">end</span>
|
457
458
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_iterate_source">(<a href="javascript:show('iterate_source')">show</a>)</span>
|
458
459
|
<pre class="source" id="iterate_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
460
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">Iterate</span> = <span class="pc">true</span> <span class="r">end</span>
|
459
461
|
|
460
462
|
<span class="r">def</span> <span class="fu">iterate</span>(*params)
|
461
463
|
<span class="c"># params.shift.zip(*params).each{ |*elements| yield *elements }</span>
|
@@ -471,9 +473,9 @@ describe <span class="s"><span class="dl">'</span><span class="k">Object#iterate
|
|
471
473
|
<span class="r">else</span> <span class="c"># multiple params</span>
|
472
474
|
max_size = [first, *params].max_by(&<span class="sy">:count</span>).size
|
473
475
|
padded_first = first.to_a + [<span class="pc">nil</span>]*(max_size - first.count) <span class="c"># append nils</span>
|
474
|
-
obj = padded_first.zip
|
476
|
+
obj = padded_first.zip(*params)
|
475
477
|
<span class="r">if</span> block_given?
|
476
|
-
obj.map{|es| <span class="r">yield</span>
|
478
|
+
obj.map{|es| <span class="r">yield</span>(*es) }
|
477
479
|
<span class="r">else</span>
|
478
480
|
obj.map.to_enum
|
479
481
|
<span class="r">end</span>
|
@@ -483,7 +485,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">Object#iterate
|
|
483
485
|
<span class="c"># J-_-L</span></pre> </td></tr><tr><th>Compatibility</th> <td>1.9, 1.8</td></tr><tr><th>Discussion</th> <td><a href="http://wiki.github.com/janlelis/zucker/iterate">github wiki</a></td></tr></table> <h3 title="require 'zucker/kernel'" id="kernel">kernel</h3>
|
484
486
|
<table class="cube_table"
|
485
487
|
id="kernel_cube"
|
486
|
-
title="require 'zucker/kernel'"> <tr><th>Summary</th> <td>Some useful general shortcut methods.</td></tr><tr><th>Why?</th> <td>Readability.</td></tr><tr><th>Methods/Usage</th> <td><h5>activate_warnings!</h5><pre class="usage source" style="display:block">activate_warnings! <span class="c"># sets $VERBOSE to 1</span></pre><h5>deactivate_warnings!</h5><pre class="usage source" style="display:block">deactivate_warnings! <span class="c"># sets $VERBOSE to 0</span></pre><h5>executed_directly?, directly_executed
|
488
|
+
title="require 'zucker/kernel'"> <tr><th>Summary</th> <td>Some useful general shortcut methods.</td></tr><tr><th>Why?</th> <td>Readability.</td></tr><tr><th>Methods/Usage</th> <td><h5>activate_warnings!</h5><pre class="usage source" style="display:block">activate_warnings! <span class="c"># sets $VERBOSE to 1</span></pre><h5>deactivate_warnings!</h5><pre class="usage source" style="display:block">deactivate_warnings! <span class="c"># sets $VERBOSE to 0</span></pre><h5>executed_directly?, directly_executed?, standalone?</h5><pre class="usage source" style="display:block">executed_directly? <span class="c"># checks, if the current file is run directly -> true</span></pre><h5>library?</h5><pre class="usage source" style="display:block">library? <span class="c"># checks, if the current file is run directly -> false</span></pre><h5>irb?</h5><pre class="usage source" style="display:block">irb? <span class="c"># returns false if not called from IRB or RIPL</span></pre><h5>ignore_sigint!</h5><pre class="usage source" style="display:block">ignore_sigint! <span class="c"># blocks CTRL+C</span></pre><h5>ignore_sigquit!</h5><pre class="usage source" style="display:block">ignore_sigquit! <span class="c"># blocks CTRL+\</span></pre></td></tr><tr><th>Specification</th> <td> <span id="show_kernel_spec">(<a href="javascript:show('kernel_spec')">show</a>)</span>
|
487
489
|
<pre class="source" id="kernel_spec">require <span class="s"><span class="dl">'</span><span class="k">zucker/kernel</span><span class="dl">'</span></span>
|
488
490
|
|
489
491
|
describe <span class="s"><span class="dl">'</span><span class="k">activate_warnings!</span><span class="dl">'</span></span> <span class="r">do</span>
|
@@ -513,15 +515,21 @@ describe <span class="s"><span class="dl">'</span><span class="k">executed_direc
|
|
513
515
|
<span class="r">end</span>
|
514
516
|
|
515
517
|
describe <span class="s"><span class="dl">'</span><span class="k">irb?</span><span class="dl">'</span></span> <span class="r">do</span>
|
516
|
-
it <span class="s"><span class="dl">'</span><span class="k">should return true if called in IRB</span><span class="dl">'</span></span> <span class="r">do</span>; <span class="r">end</span>
|
518
|
+
it <span class="s"><span class="dl">'</span><span class="k">should return true if called in IRB or RIPL</span><span class="dl">'</span></span> <span class="r">do</span>; <span class="r">end</span>
|
517
519
|
<span class="r">end</span>
|
518
520
|
|
519
521
|
describe <span class="s"><span class="dl">'</span><span class="k">ignore_sigint!</span><span class="dl">'</span></span> <span class="r">do</span>
|
520
522
|
it <span class="s"><span class="dl">'</span><span class="k">should catch ctrl+c signals</span><span class="dl">'</span></span> <span class="r">do</span>; <span class="r">end</span>
|
521
523
|
<span class="r">end</span>
|
522
524
|
|
525
|
+
describe <span class="s"><span class="dl">'</span><span class="k">ignore_sigquit!</span><span class="dl">'</span></span> <span class="r">do</span>
|
526
|
+
it <span class="s"><span class="dl">'</span><span class="k">should catch ctrl+</span><span class="k">\ </span><span class="k">signals</span><span class="dl">'</span></span> <span class="r">do</span>; <span class="r">end</span>
|
527
|
+
<span class="r">end</span>
|
528
|
+
|
529
|
+
|
523
530
|
<span class="c"># J-_-L</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_kernel_source">(<a href="javascript:show('kernel_source')">show</a>)</span>
|
524
531
|
<pre class="source" id="kernel_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
532
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">Kernel</span> = <span class="pc">true</span> <span class="r">end</span>
|
525
533
|
|
526
534
|
<span class="r">module</span> <span class="cl">Kernel</span>
|
527
535
|
private
|
@@ -551,7 +559,12 @@ describe <span class="s"><span class="dl">'</span><span class="k">ignore_sigint!
|
|
551
559
|
<span class="r">end</span>
|
552
560
|
|
553
561
|
<span class="r">def</span> <span class="fu">ignore_sigint!</span> <span class="c"># ctrl+c</span>
|
554
|
-
<span class="co">Signal</span>.trap
|
562
|
+
<span class="co">Signal</span>.trap(*<span class="s"><span class="dl">%w|</span><span class="k">SIGINT IGNORE</span><span class="dl">|</span></span>)
|
563
|
+
<span class="pc">true</span>
|
564
|
+
<span class="r">end</span>
|
565
|
+
|
566
|
+
<span class="r">def</span> <span class="fu">ignore_sigquit!</span> <span class="c"># ctrl+\</span>
|
567
|
+
<span class="co">Signal</span>.trap(*<span class="s"><span class="dl">%w|</span><span class="k">SIGQUIT IGNORE</span><span class="dl">|</span></span>)
|
555
568
|
<span class="pc">true</span>
|
556
569
|
<span class="r">end</span>
|
557
570
|
<span class="r">end</span>
|
@@ -567,7 +580,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">ignore_sigint!
|
|
567
580
|
<pre class="source" id="sandbox_spec">require <span class="s"><span class="dl">'</span><span class="k">zucker/sandbox</span><span class="dl">'</span></span>
|
568
581
|
|
569
582
|
describe <span class="s"><span class="dl">'</span><span class="k">sandbox</span><span class="dl">'</span></span> <span class="r">do</span>
|
570
|
-
<span class="r">unless</span> <span class="r">defined?</span>(<span class="co">RUBY_ENGINE</span>) && <span class="co">RUBY_ENGINE</span> == <span class="s"><span class="dl">'</span><span class="k">jruby</span><span class="dl">'</span></span>
|
583
|
+
<span class="r">unless</span> <span class="r">defined?</span>(<span class="co">RUBY_ENGINE</span>) && ( <span class="co">RUBY_ENGINE</span> == <span class="s"><span class="dl">'</span><span class="k">jruby</span><span class="dl">'</span></span> || <span class="co">RUBY_ENGINE</span> == <span class="s"><span class="dl">'</span><span class="k">rbx</span><span class="dl">'</span></span> )
|
571
584
|
it <span class="s"><span class="dl">'</span><span class="k">should throw a SecurityError if bad commands are issued</span><span class="dl">'</span></span> <span class="r">do</span>
|
572
585
|
proc <span class="r">do</span>
|
573
586
|
sandbox <span class="r">do</span>
|
@@ -578,11 +591,13 @@ describe <span class="s"><span class="dl">'</span><span class="k">sandbox</span>
|
|
578
591
|
<span class="r">end</span>
|
579
592
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_sandbox_source">(<a href="javascript:show('sandbox_source')">show</a>)</span>
|
580
593
|
<pre class="source" id="sandbox_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
594
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">Sandbox</span> = <span class="pc">true</span> <span class="r">end</span>
|
581
595
|
|
582
596
|
<span class="r">module</span> <span class="cl">Kernel</span>
|
583
597
|
private
|
584
598
|
|
585
599
|
<span class="r">def</span> <span class="fu">sandbox</span>
|
600
|
+
warn <span class="s"><span class="dl">"</span><span class="k">zucker: sandbox does not work in rbx and jruby</span><span class="dl">"</span></span> <span class="r">if</span> <span class="r">defined?</span>(<span class="co">RUBY_ENGINE</span>) && ( <span class="co">RUBY_ENGINE</span> == <span class="s"><span class="dl">'</span><span class="k">jruby</span><span class="dl">'</span></span> || <span class="co">RUBY_ENGINE</span> == <span class="s"><span class="dl">'</span><span class="k">rbx</span><span class="dl">'</span></span> )
|
586
601
|
<span class="co">Thread</span>.start <span class="r">do</span>
|
587
602
|
<span class="gv">$SAFE</span> = <span class="i">4</span>
|
588
603
|
<span class="r">yield</span>
|
@@ -619,13 +634,14 @@ describe <span class="s"><span class="dl">'</span><span class="k">make_new</span
|
|
619
634
|
<span class="r">end</span>
|
620
635
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_tap_source">(<a href="javascript:show('tap_source')">show</a>)</span>
|
621
636
|
<pre class="source" id="tap_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
637
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">Tap</span> = <span class="pc">true</span> <span class="r">end</span>
|
622
638
|
|
623
639
|
<span class="r">def</span> <span class="fu">tap_on</span>(obj, &block)
|
624
|
-
obj.tap
|
640
|
+
obj.tap(&block)
|
625
641
|
<span class="r">end</span>
|
626
642
|
|
627
643
|
<span class="r">def</span> <span class="fu">make_new</span>(what, *args, &block)
|
628
|
-
what.new(*args).tap
|
644
|
+
what.new(*args).tap(&block)
|
629
645
|
<span class="r">end</span>
|
630
646
|
|
631
647
|
<span class="c"># J-_-L</span></pre> </td></tr><tr><th>Compatibility</th> <td>1.9, 1.8</td></tr><tr><th>Discussion</th> <td><a href="http://wiki.github.com/janlelis/zucker/tap">github wiki</a></td></tr></table>
|
@@ -649,6 +665,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">RubyEngine</sp
|
|
649
665
|
<span class="r">end</span>
|
650
666
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_engine_source">(<a href="javascript:show('engine_source')">show</a>)</span>
|
651
667
|
<pre class="source" id="engine_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
668
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">Engine</span> = <span class="pc">true</span> <span class="r">end</span>
|
652
669
|
|
653
670
|
<span class="r">module</span> <span class="cl">RubyEngine</span>
|
654
671
|
<span class="c"># try to guess the interpreter</span>
|
@@ -737,6 +754,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">Info</span><sp
|
|
737
754
|
<pre class="source" id="info_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
738
755
|
require <span class="s"><span class="dl">'</span><span class="k">rbconfig</span><span class="dl">'</span></span>
|
739
756
|
require <span class="s"><span class="dl">'</span><span class="k">etc</span><span class="dl">'</span></span>
|
757
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">Info</span> = <span class="pc">true</span> <span class="r">end</span>
|
740
758
|
|
741
759
|
<span class="r">module</span> <span class="cl">Info</span>
|
742
760
|
<span class="r">class</span> << <span class="cl">self</span>
|
@@ -966,6 +984,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">OS.is?</span><
|
|
966
984
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_os_source">(<a href="javascript:show('os_source')">show</a>)</span>
|
967
985
|
<pre class="source" id="os_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
968
986
|
require <span class="s"><span class="dl">'</span><span class="k">rbconfig</span><span class="dl">'</span></span>
|
987
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">Os</span> = <span class="pc">true</span> <span class="r">end</span>
|
969
988
|
|
970
989
|
<span class="r">module</span> <span class="cl">OS</span>
|
971
990
|
<span class="r">class</span> << <span class="cl">self</span>
|
@@ -1053,7 +1072,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">RubyVersion</s
|
|
1053
1072
|
<span class="co">RubyVersion</span>.to_s.should == <span class="s"><span class="dl">'</span><span class="k">1.8.7</span><span class="dl">'</span></span>
|
1054
1073
|
<span class="r">end</span>
|
1055
1074
|
|
1056
|
-
context <span class="s"><span class="dl">'</span><span class="k">
|
1075
|
+
context <span class="s"><span class="dl">'</span><span class="k">with "is" method, with parameter</span><span class="dl">'</span></span> <span class="r">do</span>
|
1057
1076
|
it <span class="s"><span class="dl">'</span><span class="k">should check for main version (1.8 or 1.9) when Float paramater is given</span><span class="dl">'</span></span> <span class="r">do</span>
|
1058
1077
|
<span class="co">RubyVersion</span>.is?( <span class="fl">1.8</span> ).should == <span class="pc">true</span>
|
1059
1078
|
<span class="co">RubyVersion</span>.is?( <span class="fl">1.9</span> ).should == <span class="pc">false</span>
|
@@ -1064,7 +1083,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">RubyVersion</s
|
|
1064
1083
|
<span class="r">end</span>
|
1065
1084
|
<span class="r">end</span>
|
1066
1085
|
|
1067
|
-
context <span class="s"><span class="dl">'</span><span class="k">
|
1086
|
+
context <span class="s"><span class="dl">'</span><span class="k">with "is" method, without parameter, but method chaining</span><span class="dl">'</span></span> <span class="r">do</span>
|
1068
1087
|
it <span class="s"><span class="dl">'</span><span class="k">should return a string for usage with comparison operators</span><span class="dl">'</span></span> <span class="r">do</span>
|
1069
1088
|
(<span class="co">RubyVersion</span>.is > <span class="s"><span class="dl">'</span><span class="k">1.8.7</span><span class="dl">'</span></span>).should == <span class="pc">false</span>
|
1070
1089
|
(<span class="co">RubyVersion</span> <= <span class="s"><span class="dl">'</span><span class="k">1.8.7</span><span class="dl">'</span></span>).should == <span class="pc">true</span>
|
@@ -1098,6 +1117,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">RubyVersion</s
|
|
1098
1117
|
<pre class="source" id="version_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
1099
1118
|
require <span class="s"><span class="dl">'</span><span class="k">date</span><span class="dl">'</span></span>
|
1100
1119
|
require <span class="s"><span class="dl">'</span><span class="k">time</span><span class="dl">'</span></span>
|
1120
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">Version</span> = <span class="pc">true</span> <span class="r">end</span>
|
1101
1121
|
|
1102
1122
|
<span class="r">module</span> <span class="cl">RubyVersion</span>
|
1103
1123
|
<span class="r">class</span> << <span class="cl">self</span>
|
@@ -1244,6 +1264,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">Array#chrs</sp
|
|
1244
1264
|
<span class="r">end</span>
|
1245
1265
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_array_source">(<a href="javascript:show('array_source')">show</a>)</span>
|
1246
1266
|
<pre class="source" id="array_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
1267
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">Array</span> = <span class="pc">true</span> <span class="r">end</span>
|
1247
1268
|
|
1248
1269
|
<span class="r">class</span> <span class="cl">Array</span>
|
1249
1270
|
<span class="r">def</span> <span class="fu">^</span>(other) <span class="c"># TODO: more efficient</span>
|
@@ -1278,12 +1299,13 @@ describe <span class="s"><span class="dl">'</span><span class="k">Enumerable#mas
|
|
1278
1299
|
<span class="r">end</span>
|
1279
1300
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_enumerable_source">(<a href="javascript:show('enumerable_source')">show</a>)</span>
|
1280
1301
|
<pre class="source" id="enumerable_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
1302
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">Enumerable</span> = <span class="pc">true</span> <span class="r">end</span>
|
1281
1303
|
|
1282
1304
|
<span class="r">module</span> <span class="cl">Enumerable</span>
|
1283
1305
|
<span class="r">def</span> <span class="fu">mash</span>
|
1284
1306
|
ret = {}
|
1285
1307
|
each{ |kv|
|
1286
|
-
ret.store *(
|
1308
|
+
ret.store( *(<span class="r">yield</span>(kv)[<span class="i">0</span>,<span class="i">2</span>]) )
|
1287
1309
|
}
|
1288
1310
|
ret
|
1289
1311
|
<span class="r">end</span>
|
@@ -1341,7 +1363,10 @@ describe <span class="s"><span class="dl">'</span><span class="k">File.delete!</
|
|
1341
1363
|
res.should be_false
|
1342
1364
|
<span class="r">end</span>
|
1343
1365
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_file_source">(<a href="javascript:show('file_source')">show</a>)</span>
|
1344
|
-
<pre class="source" id="file_source"><span class="
|
1366
|
+
<pre class="source" id="file_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
1367
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">File</span> = <span class="pc">true</span> <span class="r">end</span>
|
1368
|
+
|
1369
|
+
<span class="r">class</span> << <span class="cl">File</span>
|
1345
1370
|
<span class="r">def</span> <span class="fu">gsub</span>(filename, regex_hash)
|
1346
1371
|
data = <span class="co">File</span>.read filename
|
1347
1372
|
<span class="co">File</span>.open(filename,<span class="s"><span class="dl">'</span><span class="k">w</span><span class="dl">'</span></span>){ |file|
|
@@ -1362,7 +1387,9 @@ describe <span class="s"><span class="dl">'</span><span class="k">File.delete!</
|
|
1362
1387
|
<span class="r">return</span> <span class="pc">nil</span> <span class="r">if</span> !<span class="co">File</span>.exist?(filename)
|
1363
1388
|
<span class="co">File</span>.delete filename
|
1364
1389
|
<span class="r">end</span>
|
1365
|
-
<span class="r">end</span
|
1390
|
+
<span class="r">end</span>
|
1391
|
+
|
1392
|
+
<span class="c"># J-_-L</span></pre> </td></tr><tr><th>Compatibility</th> <td>1.9, 1.8</td></tr><tr><th>Discussion</th> <td><a href="http://wiki.github.com/janlelis/zucker/file">github wiki</a></td></tr></table> <h3 title="require 'zucker/hash'" id="hash">hash</h3>
|
1366
1393
|
<table class="cube_table"
|
1367
1394
|
id="hash_cube"
|
1368
1395
|
title="require 'zucker/hash'"> <tr><th>Summary</th> <td>Some sugar for dealing with hashes.</td></tr><tr><th>Methods/Usage</th> <td><h5>Hash.zip</h5><pre class="usage source" style="display:block"><span class="co">Hash</span>.zip [<span class="i">1</span>,<span class="i">2</span>,<span class="i">3</span>], [<span class="i">4</span>,<span class="i">5</span>,<span class="i">6</span>] <span class="c"># => {1=>4, 2=>5, 3=>6}</span></pre><h5>Hash#<<</h5><pre class="usage source" style="display:block">{<span class="i">1</span>=><span class="i">2</span>} << [<span class="i">3</span>, <span class="i">4</span>] <span class="c"># => { 1=>2, 3=>4 }</span>
|
@@ -1393,6 +1420,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">Hash#&</sp
|
|
1393
1420
|
<span class="r">end</span>
|
1394
1421
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_hash_source">(<a href="javascript:show('hash_source')">show</a>)</span>
|
1395
1422
|
<pre class="source" id="hash_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
1423
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">Hash</span> = <span class="pc">true</span> <span class="r">end</span>
|
1396
1424
|
|
1397
1425
|
<span class="r">class</span> <span class="cl">Hash</span>
|
1398
1426
|
<span class="r">def</span> <span class="pc">self</span>.<span class="fu">zip</span>(keys,values)
|
@@ -1420,7 +1448,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">Hash#&</sp
|
|
1420
1448
|
<span class="c"># J-_-L</span></pre> </td></tr><tr><th>Compatibility</th> <td>1.9, 1.8</td></tr><tr><th>Discussion</th> <td><a href="http://wiki.github.com/janlelis/zucker/hash">github wiki</a></td></tr></table> <h3 title="require 'zucker/string'" id="string">string</h3>
|
1421
1449
|
<table class="cube_table"
|
1422
1450
|
id="string_cube"
|
1423
|
-
title="require 'zucker/string'"> <tr><th>Summary</th> <td><code>String</code> extensions.</td></tr><tr><th>Why?</th> <td>Strings cannot be comfortable enough ;).</td></tr><tr><th>Methods/Usage</th> <td><h5>String#-</h5><pre class="usage source" style="display:block"><span class="s"><span class="dl">'</span><span class="k">1234abc5678</span><span class="dl">'</span></span> - <span class="s"><span class="dl">'</span><span class="k">b</span><span class="dl">'</span></span> - <span class="rx"><span class="dl">/</span><span class="ch">\d</span><span class="dl">/</span></span> <span class="c"># => ac</span></pre><h5>String#^</h5><pre class="usage source" style="display:block"><span class="s"><span class="dl">'</span><span class="k">Yes vs No</span><span class="dl">'</span></span>^<span class="i">
|
1451
|
+
title="require 'zucker/string'"> <tr><th>Summary</th> <td><code>String</code> extensions.</td></tr><tr><th>Why?</th> <td>Strings cannot be comfortable enough ;).</td></tr><tr><th>Methods/Usage</th> <td><h5>String#-</h5><pre class="usage source" style="display:block"><span class="s"><span class="dl">'</span><span class="k">1234abc5678</span><span class="dl">'</span></span> - <span class="s"><span class="dl">'</span><span class="k">b</span><span class="dl">'</span></span> - <span class="rx"><span class="dl">/</span><span class="ch">\d</span><span class="dl">/</span></span> <span class="c"># => ac</span></pre><h5>String#^</h5><pre class="usage source" style="display:block"><span class="s"><span class="dl">'</span><span class="k">Yes vs No</span><span class="dl">'</span></span>^<span class="i">2</span> <span class="c"># => 's vs No'</span></pre><h5>String#lchomp</h5><pre class="usage source" style="display:block"><span class="s"><span class="dl">'</span><span class="k"> Yes</span><span class="dl">'</span></span>.lchomp <span class="c"># => ' Yes'</span></pre><h5>String#lchomp!</h5><pre class="usage source" style="display:block"><span class="c"># mutable lchomp version</span></pre><h5>String#ords</h5><pre class="usage source" style="display:block"><span class="s"><span class="dl">'</span><span class="k">Hallo</span><span class="dl">'</span></span>.ords <span class="c"># => [72, 97, 108, 108, 111]</span></pre><h5>String#constantize</h5><pre class="usage source" style="display:block"><span class="s"><span class="dl">'</span><span class="k">Object</span><span class="dl">'</span></span>.constantize <span class="c"># => Object</span>
|
1424
1452
|
<span class="s"><span class="dl">'</span><span class="k">Spec::VERSION</span><span class="dl">'</span></span>.constantize <span class="c"># => Spec::VERSION if rspec is loaded</span>
|
1425
1453
|
<span class="c"># you can also pass a parameter or block to define what happens, when constant does not exist</span>
|
1426
1454
|
<span class="s"><span class="dl">'</span><span class="k">IdontExist</span><span class="dl">'</span></span>.constantize(<span class="co">Array</span>) <span class="c"># => Array</span>
|
@@ -1493,6 +1521,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">String#ords</s
|
|
1493
1521
|
<span class="r">end</span>
|
1494
1522
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_string_source">(<a href="javascript:show('string_source')">show</a>)</span>
|
1495
1523
|
<pre class="source" id="string_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
1524
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">String</span> = <span class="pc">true</span> <span class="r">end</span>
|
1496
1525
|
|
1497
1526
|
<span class="r">class</span> <span class="cl">String</span>
|
1498
1527
|
<span class="r">def</span> <span class="fu">-</span>(rem)
|
@@ -1574,6 +1603,7 @@ describe <span class="co">String</span>, <span class="s"><span class="dl">'</spa
|
|
1574
1603
|
<span class="r">end</span>
|
1575
1604
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_unary_source">(<a href="javascript:show('unary_source')">show</a>)</span>
|
1576
1605
|
<pre class="source" id="unary_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
1606
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">Unary</span> = <span class="pc">true</span> <span class="r">end</span>
|
1577
1607
|
|
1578
1608
|
<span class="r">class</span> <span class="cl">String</span>
|
1579
1609
|
<span class="r">def</span> <span class="fu">+@</span>
|
@@ -1619,6 +1649,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">String#|</span
|
|
1619
1649
|
it_should_behave_like <span class="s"><span class="dl">'</span><span class="k">Regexp.union operator</span><span class="dl">'</span></span>
|
1620
1650
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_union_source">(<a href="javascript:show('union_source')">show</a>)</span>
|
1621
1651
|
<pre class="source" id="union_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
1652
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">Union</span> = <span class="pc">true</span> <span class="r">end</span>
|
1622
1653
|
|
1623
1654
|
<span class="r">class</span> <span class="cl">Regexp</span>
|
1624
1655
|
<span class="r">def</span> <span class="fu">|</span>(arg)
|
@@ -1661,6 +1692,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">Object#blank?<
|
|
1661
1692
|
<span class="r">end</span>
|
1662
1693
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_blank_source">(<a href="javascript:show('blank_source')">show</a>)</span>
|
1663
1694
|
<pre class="source" id="blank_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
1695
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">Blank</span> = <span class="pc">true</span> <span class="r">end</span>
|
1664
1696
|
|
1665
1697
|
<span class="r">class</span> <span class="cl">Object</span>
|
1666
1698
|
<span class="r">def</span> <span class="fu">blank?</span>
|
@@ -1705,6 +1737,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">Object#mcopy</
|
|
1705
1737
|
<span class="r">end</span>
|
1706
1738
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_mcopy_source">(<a href="javascript:show('mcopy_source')">show</a>)</span>
|
1707
1739
|
<pre class="source" id="mcopy_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
1740
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">Mcopy</span> = <span class="pc">true</span> <span class="r">end</span>
|
1708
1741
|
|
1709
1742
|
<span class="r">class</span> <span class="cl">Object</span>
|
1710
1743
|
<span class="r">def</span> <span class="fu">mcopy</span>
|
@@ -1730,6 +1763,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">Object#mcopy</
|
|
1730
1763
|
|
1731
1764
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_not_source">(<a href="javascript:show('not_source')">show</a>)</span>
|
1732
1765
|
<pre class="source" id="not_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
1766
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">Not</span> = <span class="pc">true</span> <span class="r">end</span>
|
1733
1767
|
|
1734
1768
|
<span class="r">class</span> <span class="cl">Object</span>
|
1735
1769
|
<span class="r">def</span> <span class="fu">not</span>
|
@@ -1771,6 +1805,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">Array#to_proc<
|
|
1771
1805
|
<span class="r">end</span>
|
1772
1806
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_array_to_proc_source">(<a href="javascript:show('array_to_proc_source')">show</a>)</span>
|
1773
1807
|
<pre class="source" id="array_to_proc_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
1808
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">ArrayToProc</span> = <span class="pc">true</span> <span class="r">end</span>
|
1774
1809
|
|
1775
1810
|
<span class="r">class</span> <span class="cl">Array</span>
|
1776
1811
|
<span class="r">def</span> <span class="fu">to_proc</span>
|
@@ -1780,7 +1815,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">Array#to_proc<
|
|
1780
1815
|
nested_array.to_proc.call result
|
1781
1816
|
}
|
1782
1817
|
<span class="r">else</span>
|
1783
|
-
obj.send
|
1818
|
+
obj.send(*<span class="pc">self</span>)
|
1784
1819
|
<span class="r">end</span>
|
1785
1820
|
}
|
1786
1821
|
<span class="r">end</span>
|
@@ -1799,11 +1834,12 @@ describe <span class="s"><span class="dl">'</span><span class="k">Class#to_proc<
|
|
1799
1834
|
<span class="r">end</span>
|
1800
1835
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_class_to_proc_source">(<a href="javascript:show('class_to_proc_source')">show</a>)</span>
|
1801
1836
|
<pre class="source" id="class_to_proc_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
1837
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">ClassToProc</span> = <span class="pc">true</span> <span class="r">end</span>
|
1802
1838
|
|
1803
1839
|
<span class="r">class</span> <span class="cl">Class</span>
|
1804
1840
|
<span class="r">def</span> <span class="fu">to_proc</span>
|
1805
1841
|
<span class="co">Proc</span>.new <span class="r">do</span> |*args|
|
1806
|
-
<span class="pc">self</span>.new
|
1842
|
+
<span class="pc">self</span>.new(*args)
|
1807
1843
|
<span class="r">end</span>
|
1808
1844
|
<span class="r">end</span>
|
1809
1845
|
<span class="r">end</span>
|
@@ -1827,6 +1863,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">Hash#to_proc</
|
|
1827
1863
|
<span class="r">end</span>
|
1828
1864
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_hash_to_proc_source">(<a href="javascript:show('hash_to_proc_source')">show</a>)</span>
|
1829
1865
|
<pre class="source" id="hash_to_proc_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
1866
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">HashToProc</span> = <span class="pc">true</span> <span class="r">end</span>
|
1830
1867
|
|
1831
1868
|
<span class="r">class</span> <span class="cl">Hash</span>
|
1832
1869
|
<span class="r">def</span> <span class="fu">to_proc</span>
|
@@ -1855,6 +1892,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">Regexp#to_proc
|
|
1855
1892
|
<span class="r">end</span>
|
1856
1893
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_regexp_to_proc_source">(<a href="javascript:show('regexp_to_proc_source')">show</a>)</span>
|
1857
1894
|
<pre class="source" id="regexp_to_proc_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
1895
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">RegexpToProc</span> = <span class="pc">true</span> <span class="r">end</span>
|
1858
1896
|
|
1859
1897
|
<span class="r">class</span> <span class="cl">Regexp</span>
|
1860
1898
|
<span class="r">def</span> <span class="fu">to_proc</span>
|
@@ -1996,6 +2034,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">alias_methods_
|
|
1996
2034
|
<span class="r">end</span>
|
1997
2035
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_alias_for_source">(<a href="javascript:show('alias_for_source')">show</a>)</span>
|
1998
2036
|
<pre class="source" id="alias_for_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
2037
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">AliasFor</span> = <span class="pc">true</span> <span class="r">end</span>
|
1999
2038
|
|
2000
2039
|
<span class="r">def</span> <span class="fu">alias_for</span>(m, *aliases)
|
2001
2040
|
aliases.each{ |a|
|
@@ -2032,6 +2071,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">(aliases)</spa
|
|
2032
2071
|
<span class="r">end</span>
|
2033
2072
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_aliases_source">(<a href="javascript:show('aliases_source')">show</a>)</span>
|
2034
2073
|
<pre class="source" id="aliases_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
2074
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">Aliases</span> = <span class="pc">true</span> <span class="r">end</span>
|
2035
2075
|
|
2036
2076
|
<span class="r">class</span> <span class="cl">Object</span>
|
2037
2077
|
<span class="r">alias</span> <span class="fu">is_an?</span> <span class="fu">is_a?</span> <span class="c"># thanks to utility_belt</span>
|
@@ -2110,6 +2150,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">instance_varia
|
|
2110
2150
|
<span class="r">end</span>
|
2111
2151
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_ivars_source">(<a href="javascript:show('ivars_source')">show</a>)</span>
|
2112
2152
|
<pre class="source" id="ivars_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
2153
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">Ivars</span> = <span class="pc">true</span> <span class="r">end</span>
|
2113
2154
|
|
2114
2155
|
<span class="r">def</span> <span class="fu">instance_variables_from</span>(obj, *only)
|
2115
2156
|
iter =
|
@@ -2212,6 +2253,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">square_bracket
|
|
2212
2253
|
|
2213
2254
|
<span class="r">end</span></pre> </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>
|
2214
2255
|
<pre class="source" id="square_brackets_for_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
2256
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">SquareBracketsFor</span> = <span class="pc">true</span> <span class="r">end</span>
|
2215
2257
|
|
2216
2258
|
<span class="r">class</span> <span class="cl">Module</span>
|
2217
2259
|
<span class="r">def</span> <span class="fu">square_brackets_for</span>(ivar, assignment = <span class="pc">true</span>)
|
@@ -2238,7 +2280,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">square_bracket
|
|
2238
2280
|
<h3 title="require 'zucker/binding'" id="binding">binding</h3>
|
2239
2281
|
<table class="cube_table"
|
2240
2282
|
id="binding_cube"
|
2241
|
-
title="require 'zucker/binding'"> <tr><th>Summary</th> <td>Adds
|
2283
|
+
title="require 'zucker/binding'"> <tr><th>Summary</th> <td>Adds <code>Binding#vars</code>. It gives you information about the current environment variables.</td></tr><tr><th>Methods/Usage</th> <td><h5>Binding#variables, Binding#vars</h5><pre class="usage source" style="display:block"><span class="c"># shows your current environment's variables, irb example:</span>
|
2242
2284
|
>> a=<span class="i">3</span>
|
2243
2285
|
=> <span class="i">3</span>
|
2244
2286
|
>> binding.vars
|
@@ -2259,21 +2301,23 @@ describe <span class="s"><span class="dl">'</span><span class="k">Binding#variab
|
|
2259
2301
|
it <span class="s"><span class="dl">'</span><span class="k">should output information about the current environment</span><span class="dl">'</span></span> <span class="r">do</span>; <span class="r">end</span>
|
2260
2302
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_binding_source">(<a href="javascript:show('binding_source')">show</a>)</span>
|
2261
2303
|
<pre class="source" id="binding_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
2304
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">Binding</span> = <span class="pc">true</span> <span class="r">end</span>
|
2305
|
+
|
2306
|
+
<span class="r">unless</span> <span class="r">defined?</span>(<span class="co">RUBY_ENGINE</span>) && <span class="co">RUBY_ENGINE</span> == <span class="s"><span class="dl">'</span><span class="k">rbx</span><span class="dl">'</span></span>
|
2307
|
+
<span class="r">class</span> <span class="cl">Binding</span>
|
2308
|
+
<span class="r">def</span> <span class="fu">variables</span>
|
2309
|
+
put_vars = lambda { |array|
|
2310
|
+
<span class="r">if</span> array.empty?
|
2311
|
+
<span class="s"><span class="dl">'</span><span class="k"> - none</span><span class="dl">'</span></span>
|
2312
|
+
<span class="r">else</span>
|
2313
|
+
array.map{|e|
|
2314
|
+
val = (<span class="pc">self</span>.eval <span class="s"><span class="dl">"</span><span class="il"><span class="idl">#{</span>e<span class="idl">}</span></span><span class="dl">"</span></span>).inspect
|
2315
|
+
<span class="s"><span class="dl">"</span><span class="k"> - </span><span class="il"><span class="idl">#{</span>e<span class="idl">}</span></span><span class="k">: </span><span class="il"><span class="idl">#{</span> val <span class="idl">}</span></span><span class="dl">"</span></span>
|
2316
|
+
}.join <span class="s"><span class="dl">"</span><span class="ch">\n</span><span class="dl">"</span></span>
|
2317
|
+
<span class="r">end</span>
|
2318
|
+
}
|
2262
2319
|
|
2263
|
-
<span class="
|
2264
|
-
<span class="r">def</span> <span class="fu">variables</span>
|
2265
|
-
put_vars = lambda { |array|
|
2266
|
-
<span class="r">if</span> array.empty?
|
2267
|
-
<span class="s"><span class="dl">'</span><span class="k"> - none</span><span class="dl">'</span></span>
|
2268
|
-
<span class="r">else</span>
|
2269
|
-
array.map{|e|
|
2270
|
-
val = (<span class="pc">self</span>.eval <span class="s"><span class="dl">"</span><span class="il"><span class="idl">#{</span>e<span class="idl">}</span></span><span class="dl">"</span></span>).inspect
|
2271
|
-
<span class="s"><span class="dl">"</span><span class="k"> - </span><span class="il"><span class="idl">#{</span>e<span class="idl">}</span></span><span class="k">: </span><span class="il"><span class="idl">#{</span> val <span class="idl">}</span></span><span class="dl">"</span></span>
|
2272
|
-
}.join <span class="s"><span class="dl">"</span><span class="ch">\n</span><span class="dl">"</span></span>
|
2273
|
-
<span class="r">end</span>
|
2274
|
-
}
|
2275
|
-
|
2276
|
-
puts <span class="s"><span class="dl">"</span><span class="il"><span class="idl">#{</span><span class="pc">self</span>.to_s<span class="idl">}</span></span><span class="k">
|
2320
|
+
puts <span class="s"><span class="dl">"</span><span class="il"><span class="idl">#{</span><span class="pc">self</span>.to_s<span class="idl">}</span></span><span class="k">
|
2277
2321
|
local variables
|
2278
2322
|
</span><span class="il"><span class="idl">#{</span> put_vars[ <span class="pc">self</span>.eval <span class="s"><span class="dl">'</span><span class="k">local_variables</span><span class="dl">'</span></span> ] <span class="idl">}</span></span><span class="k">
|
2279
2323
|
(instance variables)
|
@@ -2283,12 +2327,13 @@ self
|
|
2283
2327
|
block_given?
|
2284
2328
|
- </span><span class="il"><span class="idl">#{</span><span class="pc">self</span>.eval <span class="s"><span class="dl">'</span><span class="k">block_given?</span><span class="dl">'</span></span><span class="idl">}</span></span><span class="dl">"</span></span>
|
2285
2329
|
|
2286
|
-
|
2330
|
+
<span class="r">end</span>
|
2287
2331
|
|
2288
|
-
|
2332
|
+
<span class="r">alias</span> <span class="fu">vars</span> <span class="fu">variables</span>
|
2333
|
+
<span class="r">end</span>
|
2289
2334
|
<span class="r">end</span>
|
2290
2335
|
|
2291
|
-
<span class="c"># J-_-L</span></pre> </td></tr><tr><th>Compatibility</th> <td>1.9, 1.8</td></tr><tr><th>Discussion</th> <td><a href="http://wiki.github.com/janlelis/zucker/binding">github wiki</a></td></tr></table> <h3 title="require 'zucker/cc'" id="cc">cc</h3>
|
2336
|
+
<span class="c"># J-_-L</span></pre> </td></tr><tr><th>Compatibility</th> <td>1.9, 1.8 (no rbx support)</td></tr><tr><th>Discussion</th> <td><a href="http://wiki.github.com/janlelis/zucker/binding">github wiki</a></td></tr></table> <h3 title="require 'zucker/cc'" id="cc">cc</h3>
|
2292
2337
|
<table class="cube_table"
|
2293
2338
|
id="cc_cube"
|
2294
2339
|
title="require 'zucker/cc'"> <tr><th>Summary</th> <td><code>c</code> outputs the current method callstack.</td></tr><tr><th>Methods/Usage</th> <td><h5>c, cc</h5><pre class="usage source" style="display:block">c <span class="c"># shows the method callstack</span>
|
@@ -2300,6 +2345,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">c</span><span
|
|
2300
2345
|
it <span class="s"><span class="dl">'</span><span class="k">should output the method callstack</span><span class="dl">'</span></span> <span class="r">do</span>; <span class="r">end</span>
|
2301
2346
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_cc_source">(<a href="javascript:show('cc_source')">show</a>)</span>
|
2302
2347
|
<pre class="source" id="cc_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
2348
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">Cc</span> = <span class="pc">true</span> <span class="r">end</span>
|
2303
2349
|
|
2304
2350
|
<span class="r">module</span> <span class="cl">Kernel</span>
|
2305
2351
|
private
|
@@ -2381,6 +2427,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">Object#d</span
|
|
2381
2427
|
<span class="r">end</span>
|
2382
2428
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_dd_source">(<a href="javascript:show('dd_source')">show</a>)</span>
|
2383
2429
|
<pre class="source" id="dd_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
2430
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">Dd</span> = <span class="pc">true</span> <span class="r">end</span>
|
2384
2431
|
|
2385
2432
|
<span class="r">module</span> <span class="cl">Kernel</span>
|
2386
2433
|
<span class="r">def</span> <span class="fu">d</span>(*args, &block)
|
@@ -2416,6 +2463,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">Object#mm</spa
|
|
2416
2463
|
it <span class="s"><span class="dl">'</span><span class="k">should display an ordered method list</span><span class="dl">'</span></span> <span class="r">do</span>; <span class="r">end</span>
|
2417
2464
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_mm_source">(<a href="javascript:show('mm_source')">show</a>)</span>
|
2418
2465
|
<pre class="source" id="mm_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
2466
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">Mm</span> = <span class="pc">true</span> <span class="r">end</span>
|
2419
2467
|
|
2420
2468
|
<span class="r">module</span> <span class="cl">Kernel</span>
|
2421
2469
|
<span class="r">def</span> <span class="fu">m</span>(levels = <span class="i">1</span>)
|
@@ -2465,6 +2513,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">o</span><span
|
|
2465
2513
|
it <span class="s"><span class="dl">'</span><span class="k">should output the current line, file, method and label (if given)</span><span class="dl">'</span></span> <span class="r">do</span>; <span class="r">end</span>
|
2466
2514
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_oo_source">(<a href="javascript:show('oo_source')">show</a>)</span>
|
2467
2515
|
<pre class="source" id="oo_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
2516
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">Oo</span> = <span class="pc">true</span> <span class="r">end</span>
|
2468
2517
|
|
2469
2518
|
<span class="r">module</span> <span class="cl">Kernel</span>
|
2470
2519
|
private
|
@@ -2504,6 +2553,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">q</span><span
|
|
2504
2553
|
<span class="r">end</span>
|
2505
2554
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_qq_source">(<a href="javascript:show('qq_source')">show</a>)</span>
|
2506
2555
|
<pre class="source" id="qq_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
2556
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">Qq</span> = <span class="pc">true</span> <span class="r">end</span>
|
2507
2557
|
|
2508
2558
|
<span class="r">module</span> <span class="cl">Kernel</span>
|
2509
2559
|
private
|
@@ -2556,7 +2606,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">Regexp#visuali
|
|
2556
2606
|
<span class="r">end</span>.chomp.should == <span class="s"><span class="dl">'</span><span class="k">1: >mail< @example.com</span><span class="dl">'</span></span>
|
2557
2607
|
<span class="r">end</span>
|
2558
2608
|
|
2559
|
-
it <span class="s"><span class="dl">'</span><span class="k">should display "group identifier: no match" the arg2 group could not be matched</span><span class="dl">'</span></span> <span class="r">do</span>
|
2609
|
+
it <span class="s"><span class="dl">'</span><span class="k">should display "group identifier: no match" if the arg2 group could not be matched</span><span class="dl">'</span></span> <span class="r">do</span>
|
2560
2610
|
capture_stdout <span class="r">do</span>
|
2561
2611
|
regex.vis <span class="s"><span class="dl">'</span><span class="k">mail@example.com</span><span class="dl">'</span></span>, <span class="i">3</span>
|
2562
2612
|
<span class="r">end</span>.chomp.should == <span class="s"><span class="dl">'</span><span class="k">3: no match</span><span class="dl">'</span></span>
|
@@ -2570,7 +2620,10 @@ describe <span class="s"><span class="dl">'</span><span class="k">Regexp#visuali
|
|
2570
2620
|
<span class="s"><span class="dl">"</span><span class="k">2: mail@ >example.com< </span><span class="dl">"</span></span>
|
2571
2621
|
<span class="r">end</span>
|
2572
2622
|
<span class="r">end</span></pre> </td></tr><tr><th>Source</th> <td> <span id="show_regexp_visualize_source">(<a href="javascript:show('regexp_visualize_source')">show</a>)</span>
|
2573
|
-
<pre class="source" id="regexp_visualize_source"><span class="
|
2623
|
+
<pre class="source" id="regexp_visualize_source">require <span class="s"><span class="dl">'</span><span class="k">zucker</span><span class="dl">'</span></span>
|
2624
|
+
<span class="r">module</span> <span class="cl">Zucker</span> <span class="co">RegexpVisualize</span> = <span class="pc">true</span> <span class="r">end</span>
|
2625
|
+
|
2626
|
+
<span class="r">class</span> <span class="cl">Regexp</span>
|
2574
2627
|
<span class="r">def</span> <span class="fu">visualize</span>(string, groups = <span class="pc">nil</span>)
|
2575
2628
|
<span class="r">if</span> <span class="pc">self</span> =~ string
|
2576
2629
|
<span class="r">if</span> !groups
|
@@ -2582,7 +2635,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">Regexp#visuali
|
|
2582
2635
|
gr_string[ <span class="gv">$~</span>.end( group ), <span class="i">0</span> ] = <span class="s"><span class="dl">'</span><span class="k">< </span><span class="dl">'</span></span>
|
2583
2636
|
gr_string[ <span class="gv">$~</span>.begin( group ), <span class="i">0</span> ] = <span class="s"><span class="dl">'</span><span class="k"> ></span><span class="dl">'</span></span>
|
2584
2637
|
puts group.to_s + <span class="s"><span class="dl">'</span><span class="k">: </span><span class="dl">'</span></span> + gr_string
|
2585
|
-
<span class="r">rescue</span> <span class="co">IndexError</span>
|
2638
|
+
<span class="r">rescue</span> <span class="co">IndexError</span>, <span class="r">defined?</span>(<span class="co">Rubinius</span>) && <span class="co">Rubinius</span>::<span class="co">ObjectBoundsExceededError</span>
|
2586
2639
|
puts group.to_s + <span class="s"><span class="dl">'</span><span class="k">: no match</span><span class="dl">'</span></span>
|
2587
2640
|
<span class="r">end</span>
|
2588
2641
|
}
|
@@ -2595,7 +2648,9 @@ describe <span class="s"><span class="dl">'</span><span class="k">Regexp#visuali
|
|
2595
2648
|
<span class="r">end</span>
|
2596
2649
|
|
2597
2650
|
<span class="r">alias</span> <span class="fu">vis</span> <span class="fu">visualize</span>
|
2598
|
-
<span class="r">end</span
|
2651
|
+
<span class="r">end</span>
|
2652
|
+
|
2653
|
+
<span class="c"># J-_-L</span></pre> </td></tr><tr><th>Compatibility</th> <td>1.9, 1.8</td></tr><tr><th>Discussion</th> <td><a href="http://wiki.github.com/janlelis/zucker/regexp_visualize">github wiki</a></td></tr></table>
|
2599
2654
|
</div>
|
2600
2655
|
<h2>Extras</h2>
|
2601
2656
|
<p class="text">
|
@@ -2605,7 +2660,17 @@ describe <span class="s"><span class="dl">'</span><span class="k">Regexp#visuali
|
|
2605
2660
|
|
2606
2661
|
<h2>Changelog</h2>
|
2607
2662
|
<div class="cubes">
|
2608
|
-
<pre class="scode">2011-
|
2663
|
+
<pre class="scode">2011-05-25 | <a href="http://rubyzucker.info/11/">Zucker 11</a>
|
2664
|
+
* add Zucker::constants to check if cube has been required (e.g. Zucker::AliasFor if 'zucker/alias_for' is loaded)
|
2665
|
+
* rbx tweaks
|
2666
|
+
* don't define Binding#vars on rbx (prevent endless recursion)
|
2667
|
+
* sandbox-not-working warning
|
2668
|
+
* add Kernel#ignore_sigquit!
|
2669
|
+
* fix warnings
|
2670
|
+
* doc tweaks
|
2671
|
+
|
2672
|
+
|
2673
|
+
2011-04-29 | <a href="http://rubyzucker.info/10/">Zucker 10</a>
|
2609
2674
|
* doc/spec tweaks
|
2610
2675
|
* make test.rubygems.org-testable
|
2611
2676
|
* fix zucker 9 permission issue
|
@@ -2699,7 +2764,7 @@ describe <span class="s"><span class="dl">'</span><span class="k">Regexp#visuali
|
|
2699
2764
|
</div>
|
2700
2765
|
<div id="foot">
|
2701
2766
|
<div id="smile"><a href="http://rbjl.net">J-_-L</a></div>
|
2702
|
-
This is the Ruby Zucker
|
2767
|
+
This is the Ruby Zucker 11 documentation (2011-05-25).
|
2703
2768
|
The current version is always available at <a href="http://rubyzucker.info">rubyzucker.info</a>.
|
2704
2769
|
Source at <a href="http://github.com/janlelis/zucker">github</a>.
|
2705
2770
|
Ruby Logo CC-BY-SA Yukihiro Matsumoto.
|