shenanigans 1.0.8 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/Array.html +20 -6
- data/doc/Fixnum.html +11 -3
- data/doc/Hash.html +26 -11
- data/doc/Kernel.html +75 -13
- data/doc/Module.html +208 -0
- data/doc/Object.html +20 -7
- data/doc/README_rdoc.html +31 -12
- data/doc/String.html +12 -4
- data/doc/created.rid +25 -22
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/index.html +15 -14
- data/doc/js/darkfish.js +9 -7
- data/doc/js/search_index.js +1 -1
- data/doc/rdoc.css +52 -0
- data/doc/table_of_contents.html +8 -1
- data/lib/shenanigans/kernel.rb +1 -0
- data/lib/shenanigans/kernel/fn.rb +2 -0
- data/lib/shenanigans/kernel/prompt.rb +1 -0
- data/lib/shenanigans/kernel/require_optional.rb +19 -0
- data/lib/shenanigans/kernel/with.rb +2 -0
- data/lib/shenanigans/module/private_accessor.rb +4 -2
- data/test/kernel/test_require_optional.rb +17 -0
- metadata +7 -3
- data/lib/shenanigans/README.mdown +0 -57
data/doc/created.rid
CHANGED
@@ -1,22 +1,25 @@
|
|
1
|
-
|
2
|
-
README.rdoc Thu, 17 May 2012
|
3
|
-
lib/shenanigans
|
4
|
-
lib/shenanigans/array
|
5
|
-
lib/shenanigans/array/
|
6
|
-
lib/shenanigans/array.rb Thu,
|
7
|
-
lib/shenanigans/
|
8
|
-
lib/shenanigans/fixnum.rb
|
9
|
-
lib/shenanigans/
|
10
|
-
lib/shenanigans/hash
|
11
|
-
lib/shenanigans/hash/
|
12
|
-
lib/shenanigans/hash.rb
|
13
|
-
lib/shenanigans/
|
14
|
-
lib/shenanigans/kernel
|
15
|
-
lib/shenanigans/kernel/
|
16
|
-
lib/shenanigans/kernel.rb Wed,
|
17
|
-
lib/shenanigans/
|
18
|
-
lib/shenanigans/
|
19
|
-
lib/shenanigans/
|
20
|
-
lib/shenanigans/
|
21
|
-
lib/shenanigans/
|
22
|
-
lib/shenanigans.rb
|
1
|
+
Wed, 06 Nov 2013 11:32:26 +0630
|
2
|
+
README.rdoc Thu, 17 May 2012 16:15:08 +0630
|
3
|
+
lib/shenanigans.rb Sun, 15 Jul 2012 04:23:13 +0630
|
4
|
+
lib/shenanigans/array.rb Thu, 28 Jun 2012 13:30:29 +0630
|
5
|
+
lib/shenanigans/array/caret.rb Thu, 28 Jun 2012 13:45:50 +0630
|
6
|
+
lib/shenanigans/array/random_subarray.rb Thu, 17 May 2012 04:33:23 +0630
|
7
|
+
lib/shenanigans/array/zip_with.rb Wed, 20 Jun 2012 01:53:27 +0630
|
8
|
+
lib/shenanigans/fixnum.rb Sun, 15 Jul 2012 04:19:59 +0630
|
9
|
+
lib/shenanigans/fixnum/string_length.rb Sun, 15 Jul 2012 04:30:21 +0630
|
10
|
+
lib/shenanigans/hash.rb Thu, 09 Aug 2012 23:02:30 +0630
|
11
|
+
lib/shenanigans/hash/extract.rb Thu, 09 Aug 2012 23:17:48 +0630
|
12
|
+
lib/shenanigans/hash/has_shape_pred.rb Wed, 20 Jun 2012 01:55:03 +0630
|
13
|
+
lib/shenanigans/hash/to_ostruct.rb Thu, 10 Oct 2013 23:47:27 +0630
|
14
|
+
lib/shenanigans/kernel.rb Wed, 06 Nov 2013 10:47:33 +0630
|
15
|
+
lib/shenanigans/kernel/fn.rb Wed, 06 Nov 2013 10:54:54 +0630
|
16
|
+
lib/shenanigans/kernel/prompt.rb Wed, 06 Nov 2013 10:55:11 +0630
|
17
|
+
lib/shenanigans/kernel/require_optional.rb Wed, 06 Nov 2013 10:54:41 +0630
|
18
|
+
lib/shenanigans/kernel/with.rb Wed, 06 Nov 2013 10:56:14 +0630
|
19
|
+
lib/shenanigans/module.rb Thu, 10 Oct 2013 21:59:25 +0630
|
20
|
+
lib/shenanigans/module/private_accessor.rb Wed, 06 Nov 2013 11:23:15 +0630
|
21
|
+
lib/shenanigans/object.rb Thu, 28 Jun 2012 13:40:12 +0630
|
22
|
+
lib/shenanigans/object/display.rb Fri, 25 May 2012 21:59:45 +0630
|
23
|
+
lib/shenanigans/object/it.rb Thu, 28 Jun 2012 13:37:56 +0630
|
24
|
+
lib/shenanigans/string.rb Mon, 20 Aug 2012 22:59:46 +0630
|
25
|
+
lib/shenanigans/string/in_groups_of.rb Mon, 20 Aug 2012 23:23:19 +0630
|
data/doc/images/add.png
CHANGED
File without changes
|
Binary file
|
data/doc/images/delete.png
CHANGED
File without changes
|
data/doc/images/tag_blue.png
CHANGED
File without changes
|
data/doc/index.html
CHANGED
@@ -67,6 +67,8 @@
|
|
67
67
|
|
68
68
|
<li><a href="./Kernel.html">Kernel</a>
|
69
69
|
|
70
|
+
<li><a href="./Module.html">Module</a>
|
71
|
+
|
70
72
|
<li><a href="./Object.html">Object</a>
|
71
73
|
|
72
74
|
<li><a href="./String.html">String</a>
|
@@ -78,8 +80,8 @@
|
|
78
80
|
</nav>
|
79
81
|
|
80
82
|
<div id="documentation" class="description">
|
81
|
-
|
82
|
-
<h1 id="label-Shenanigans">Shenanigans
|
83
|
+
|
84
|
+
<h1 id="label-Shenanigans">Shenanigans<span><a href="#label-Shenanigans">¶</a> <a href="#documentation">↑</a></span></h1>
|
83
85
|
|
84
86
|
<p><strong>shenanigan</strong> (plural shenanigans):</p>
|
85
87
|
<ol><li>
|
@@ -99,7 +101,7 @@ but in reality, it is simply a complaint.</p>
|
|
99
101
|
<p>Source: <a
|
100
102
|
href="http://en.wiktionary.org/wiki/shenanigan#English">Wiktionary</a></p>
|
101
103
|
|
102
|
-
<h2 id="label-Introduction">Introduction
|
104
|
+
<h2 id="label-Introduction">Introduction<span><a href="#label-Introduction">¶</a> <a href="#documentation">↑</a></span></h2>
|
103
105
|
|
104
106
|
<p>Ruby Facets is the premiere collection of general purpose method extensions
|
105
107
|
and standard additions for the Ruby programming language. This is not Ruby
|
@@ -108,7 +110,7 @@ because I found them interesting and/or useful. Some of them I actually
|
|
108
110
|
also contributed to Facets, although sometimes they have different names or
|
109
111
|
slightly different implementations.</p>
|
110
112
|
|
111
|
-
<h2 id="label-Installation">Installation
|
113
|
+
<h2 id="label-Installation">Installation<span><a href="#label-Installation">¶</a> <a href="#documentation">↑</a></span></h2>
|
112
114
|
|
113
115
|
<p>Shenanigans can be installed via <a
|
114
116
|
href="http://rubygems.org/">RubyGems</a>.</p>
|
@@ -118,35 +120,35 @@ href="http://rubygems.org/">RubyGems</a>.</p>
|
|
118
120
|
<p>I only works on 1.9.3 and I generally only test it with the most current
|
119
121
|
Ruby release.</p>
|
120
122
|
|
121
|
-
<h2 id="label-Usage">Usage
|
123
|
+
<h2 id="label-Usage">Usage<span><a href="#label-Usage">¶</a> <a href="#documentation">↑</a></span></h2>
|
122
124
|
|
123
125
|
<p>If you really want the whole shebang, you can get it this way:</p>
|
124
126
|
|
125
|
-
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string"
|
127
|
+
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'shenanigans'</span>
|
126
128
|
</pre>
|
127
129
|
|
128
130
|
<p>Requiring a single method works as follows:</p>
|
129
131
|
|
130
|
-
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string"
|
132
|
+
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'shenanigans/<class|module>/<method>'</span>
|
131
133
|
</pre>
|
132
134
|
|
133
135
|
<p>Requiring all the extensions of a class or module also works:</p>
|
134
136
|
|
135
|
-
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string"
|
137
|
+
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'shenanigans/kernel'</span>
|
136
138
|
</pre>
|
137
139
|
|
138
|
-
<h2 id="label-Contribute">Contribute
|
140
|
+
<h2 id="label-Contribute">Contribute<span><a href="#label-Contribute">¶</a> <a href="#documentation">↑</a></span></h2>
|
139
141
|
|
140
142
|
<p>If you have something you want to contribute to Shenanigans, you shoud
|
141
143
|
reconsider and add it to Facets instead. This is a library for my own wonky
|
142
|
-
ideas and I don
|
144
|
+
ideas and I don't think it will ever see any real usage.</p>
|
143
145
|
|
144
|
-
<h2 id="label-Authors">Authors
|
146
|
+
<h2 id="label-Authors">Authors<span><a href="#label-Authors">¶</a> <a href="#documentation">↑</a></span></h2>
|
145
147
|
|
146
148
|
<p>This project was created by Michael Kohl. He can be reached via email at
|
147
149
|
citizen428 at gmail.com.</p>
|
148
150
|
|
149
|
-
<h2 id="label-License">License
|
151
|
+
<h2 id="label-License">License<span><a href="#label-License">¶</a> <a href="#documentation">↑</a></span></h2>
|
150
152
|
|
151
153
|
<p>Copyright © 2012 Michael Kohl</p>
|
152
154
|
|
@@ -167,13 +169,12 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
167
169
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
168
170
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
169
171
|
DEALINGS IN THE SOFTWARE.</p>
|
170
|
-
|
171
172
|
</div>
|
172
173
|
|
173
174
|
|
174
175
|
<footer id="validator-badges">
|
175
176
|
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
176
|
-
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a>
|
177
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 4.0.0.
|
177
178
|
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
178
179
|
</footer>
|
179
180
|
|
data/doc/js/darkfish.js
CHANGED
@@ -109,13 +109,15 @@ function hookSearch() {
|
|
109
109
|
function highlightTarget( anchor ) {
|
110
110
|
console.debug( "Highlighting target '%s'.", anchor );
|
111
111
|
|
112
|
-
$("a[name
|
113
|
-
if (
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
112
|
+
$("a[name]").each( function() {
|
113
|
+
if ( $(this).attr("name") == anchor ) {
|
114
|
+
if ( !$(this).parent().parent().hasClass('target-section') ) {
|
115
|
+
console.debug( "Wrapping the target-section" );
|
116
|
+
$('div.method-detail').unwrap( 'div.target-section' );
|
117
|
+
$(this).parent().wrap( '<div class="target-section"></div>' );
|
118
|
+
} else {
|
119
|
+
console.debug( "Already wrapped." );
|
120
|
+
}
|
119
121
|
}
|
120
122
|
});
|
121
123
|
};
|
data/doc/js/search_index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var search_data = {"index":{"searchIndex":["array","fixnum","hash","kernel","object","string","^()","d()","display()","extract()","fn()","has_shape?()","in_groups_of()","it()","prompt()","random_subarray()","string_length()","to_ostruct()","with()","zip_with()","readme"],"longSearchIndex":["array","fixnum","hash","kernel","object","string","array#^()","object#d()","object#display()","hash#extract()","kernel#fn()","hash#has_shape?()","string#in_groups_of()","object#it()","kernel#prompt()","array#random_subarray()","fixnum#string_length()","hash#to_ostruct()","kernel#with()","array#zip_with()",""],"info":[["Array","","Array.html","",""],["Fixnum","","Fixnum.html","",""],["Hash","","Hash.html","",""],["Kernel","","Kernel.html","",""],["Object","","Object.html","",""],["String","","String.html","",""],["^","Array","Array.html#method-i-5E","(other)","<p>Returns an array containing elements exclusive between two arrays.\n\n<pre class=\"ruby\">[<span class=\"ruby-value\">1</span>, <span class=\"ruby-value\">2</span>, <span class=\"ruby-value\">3</span>] <span class=\"ruby-operator\">^</span> [<span class=\"ruby-value\">1</span>, <span class=\"ruby-value\">2</span>, <span class=\"ruby-value\">4</span>]\n<span class=\"ruby-comment\">#=> [3, 4]</span>\n</pre>\n"],["d","Object","Object.html#method-i-d","(new_line = true)",""],["display","Object","Object.html#method-i-display","(new_line = true)","<p>Outputs the object and also returns it. Will use <code>puts</code> if\n<code>new_line</code> is <code>true</code> and <code>print</code>\notherwise.\n\n<pre>"foo".display ...</pre>\n"],["extract","Hash","Hash.html#method-i-extract","(*ks)","<p>Returns a new hash only with the specified keys (if present).\n\n<pre>hash = { a: 1, b: 2, c: 3 }\nhash.extract(:b, ...</pre>\n"],["fn","Kernel","Kernel.html#method-i-fn","(*funs)","<p>Composes a list of functions. Functions can be specified as symbols or\nlambdas.\n\n<pre>["foo bar", "baz qux"].map ...</pre>\n"],["has_shape?","Hash","Hash.html#method-i-has_shape-3F","(shape)","<p>Checks if a hash has a certain structure.\n\n<pre>h = { k1: 1, k2: "1" }\nh.has_shape?(k1: Fixnum, k2: String) ...</pre>\n"],["in_groups_of","String","String.html#method-i-in_groups_of","(size)","<p>Returns an array of the string broken down into groups of <code>size</code>\ncharacters.\n\n<pre class=\"ruby\"><span class=\"ruby-string\">"aabbcc"</span>.<span class=\"ruby-identifier\">in_groups_of</span>(<span class=\"ruby-value\">2</span>)\n<span class=\"ruby-comment\">#=> ...</span>\n</pre>\n"],["it","Object","Object.html#method-i-it","()","<p>An identity method that provides access to an object
|
1
|
+
var search_data = {"index":{"searchIndex":["array","fixnum","hash","kernel","module","object","string","^()","d()","display()","extract()","fn()","has_shape?()","in_groups_of()","it()","private_accessor()","prompt()","random_subarray()","require_optional()","string_length()","to_ostruct()","with()","zip_with()","readme"],"longSearchIndex":["array","fixnum","hash","kernel","module","object","string","array#^()","object#d()","object#display()","hash#extract()","kernel#fn()","hash#has_shape?()","string#in_groups_of()","object#it()","module#private_accessor()","kernel#prompt()","array#random_subarray()","kernel#require_optional()","fixnum#string_length()","hash#to_ostruct()","kernel#with()","array#zip_with()",""],"info":[["Array","","Array.html","",""],["Fixnum","","Fixnum.html","",""],["Hash","","Hash.html","",""],["Kernel","","Kernel.html","",""],["Module","","Module.html","",""],["Object","","Object.html","",""],["String","","String.html","",""],["^","Array","Array.html#method-i-5E","(other)","<p>Returns an array containing elements exclusive between two arrays.\n\n<pre class=\"ruby\">[<span class=\"ruby-value\">1</span>, <span class=\"ruby-value\">2</span>, <span class=\"ruby-value\">3</span>] <span class=\"ruby-operator\">^</span> [<span class=\"ruby-value\">1</span>, <span class=\"ruby-value\">2</span>, <span class=\"ruby-value\">4</span>]\n<span class=\"ruby-comment\">#=> [3, 4]</span>\n</pre>\n"],["d","Object","Object.html#method-i-d","(new_line = true)",""],["display","Object","Object.html#method-i-display","(new_line = true)","<p>Outputs the object and also returns it. Will use <code>puts</code> if\n<code>new_line</code> is <code>true</code> and <code>print</code>\notherwise.\n\n<pre>"foo".display ...</pre>\n"],["extract","Hash","Hash.html#method-i-extract","(*ks)","<p>Returns a new hash only with the specified keys (if present).\n\n<pre>hash = { a: 1, b: 2, c: 3 }\nhash.extract(:b, ...</pre>\n"],["fn","Kernel","Kernel.html#method-i-fn","(*funs)","<p>Composes a list of functions. Functions can be specified as symbols or\nlambdas.\n\n<pre>["foo bar", "baz qux"].map ...</pre>\n"],["has_shape?","Hash","Hash.html#method-i-has_shape-3F","(shape)","<p>Checks if a hash has a certain structure.\n\n<pre>h = { k1: 1, k2: "1" }\nh.has_shape?(k1: Fixnum, k2: String) ...</pre>\n"],["in_groups_of","String","String.html#method-i-in_groups_of","(size)","<p>Returns an array of the string broken down into groups of <code>size</code>\ncharacters.\n\n<pre class=\"ruby\"><span class=\"ruby-string\">"aabbcc"</span>.<span class=\"ruby-identifier\">in_groups_of</span>(<span class=\"ruby-value\">2</span>)\n<span class=\"ruby-comment\">#=> ...</span>\n</pre>\n"],["it","Object","Object.html#method-i-it","()","<p>An identity method that provides access to an object's\n<code>self</code>.\n\n<pre class=\"ruby\">[<span class=\"ruby-value\">1</span>,<span class=\"ruby-value\">2</span>,<span class=\"ruby-value\">3</span>,<span class=\"ruby-value\">4</span>,<span class=\"ruby-value\">5</span>,<span class=\"ruby-value\">1</span>,<span class=\"ruby-value\">2</span>,<span class=\"ruby-value\">2</span>,<span class=\"ruby-value\">3</span>].<span class=\"ruby-identifier\">group_by</span>(<span class=\"ruby-operator\">&</span>:<span class=\"ruby-identifier\">it</span>)\n<span class=\"ruby-comment\">#=> ...</span>\n</pre>\n"],["private_accessor","Module","Module.html#method-i-private_accessor","(*names)","<p>Works like <code>attr_accessor</code> but generates private getter/setter\nmethods for class internal use only. Useful …\n"],["prompt","Kernel","Kernel.html#method-i-prompt","(text='', conversion=nil)","<p>Displays a prompt and returns chomped input. Modelled after the Python\nmethod <code>raw_input</code>, but also can …\n"],["random_subarray","Array","Array.html#method-i-random_subarray","(n=1)","<p>Generates random subarrays. Uses random numbers and bit-fiddling to assure\nperformant uniform distributions …\n"],["require_optional","Kernel","Kernel.html#method-i-require_optional","(gem, &block)","<p>Optionally require a gem. If it is not available, <code>nil</code> will be\nreturned. Alternatively, a block can be …\n"],["string_length","Fixnum","Fixnum.html#method-i-string_length","()","<p>Returns the length of the number's string representation.\n\n<pre class=\"ruby\"><span class=\"ruby-value\">0</span>.<span class=\"ruby-identifier\">string_length</span>\n<span class=\"ruby-comment\">#=> 1</span>\n<span class=\"ruby-value\">123</span>.<span class=\"ruby-identifier\">string_length</span> <span class=\"ruby-operator\">...</span>\n</pre>\n"],["to_ostruct","Hash","Hash.html#method-i-to_ostruct","()","<p>Recursively converts a <code>Hash</code> and all nested <code>Hash</code>es\nto <code>OpenStruct</code>s. Especially useful for parsing YAML …\n"],["with","Kernel","Kernel.html#method-i-with","(o, &blk)","<p>A Pascal/ActionScript like <code>with</code> method. Yields its argument to\nthe provided block and then returns it. …\n"],["zip_with","Array","Array.html#method-i-zip_with","(other, op=nil)","<p>Zip <code>self</code> with <code>other</code>, combining the elements with\nthe provided block or symbol. The resulting array will …\n"],["README","","README_rdoc.html","","<p>Shenanigans\n<p><strong>shenanigan</strong> (plural shenanigans):\n<p>Trickery, games; skulduggery. To “call”, “claim” …\n"]]}}
|
data/doc/rdoc.css
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
*
|
7
7
|
*/
|
8
8
|
|
9
|
+
/* vim: ft=css et sw=2 ts=2 sts=2 */
|
9
10
|
/* Base Green is: #6C8C22 */
|
10
11
|
|
11
12
|
* { padding: 0; margin: 0; }
|
@@ -27,6 +28,27 @@ h1 {
|
|
27
28
|
}
|
28
29
|
h2,h3,h4 { margin-top: 1.5em; }
|
29
30
|
|
31
|
+
h1 span,
|
32
|
+
h2 span,
|
33
|
+
h3 span,
|
34
|
+
h4 span,
|
35
|
+
h5 span,
|
36
|
+
h6 span {
|
37
|
+
display: none;
|
38
|
+
padding-left: 1em;
|
39
|
+
font-size: 50%;
|
40
|
+
vertical-align: super;
|
41
|
+
}
|
42
|
+
|
43
|
+
h1:hover span,
|
44
|
+
h2:hover span,
|
45
|
+
h3:hover span,
|
46
|
+
h4:hover span,
|
47
|
+
h5:hover span,
|
48
|
+
h6:hover span {
|
49
|
+
display: inline;
|
50
|
+
}
|
51
|
+
|
30
52
|
:link,
|
31
53
|
:visited {
|
32
54
|
color: #6C8C22;
|
@@ -42,6 +64,16 @@ pre {
|
|
42
64
|
padding: 0.5em 0;
|
43
65
|
}
|
44
66
|
|
67
|
+
blockquote {
|
68
|
+
background: #ddd;
|
69
|
+
margin: 1em;
|
70
|
+
padding: 0.25em;
|
71
|
+
}
|
72
|
+
|
73
|
+
blockquote > :first-child {
|
74
|
+
margin-top: 0 !important;
|
75
|
+
}
|
76
|
+
|
45
77
|
/* @group Generic Classes */
|
46
78
|
|
47
79
|
.initially-hidden {
|
@@ -193,6 +225,15 @@ pre {
|
|
193
225
|
list-style-image: url(images/page_green.png);
|
194
226
|
}
|
195
227
|
|
228
|
+
#table-of-contents {
|
229
|
+
margin-top: 2em;
|
230
|
+
}
|
231
|
+
|
232
|
+
#table-of-contents ul {
|
233
|
+
padding-left: 28px;
|
234
|
+
list-style-image: url(images/tag_blue.png);
|
235
|
+
}
|
236
|
+
|
196
237
|
dl.svninfo {
|
197
238
|
color: #666;
|
198
239
|
margin: 0;
|
@@ -203,7 +244,9 @@ dl.svninfo dt {
|
|
203
244
|
|
204
245
|
ul.link-list li {
|
205
246
|
white-space: nowrap;
|
247
|
+
line-height: 20px;
|
206
248
|
}
|
249
|
+
|
207
250
|
ul.link-list .type {
|
208
251
|
font-size: 8px;
|
209
252
|
text-transform: uppercase;
|
@@ -213,6 +256,10 @@ ul.link-list .type {
|
|
213
256
|
-webkit-border-radius: 5px;
|
214
257
|
}
|
215
258
|
|
259
|
+
.calls-super {
|
260
|
+
background: url(images/arrow_up.png) no-repeat right center;
|
261
|
+
}
|
262
|
+
|
216
263
|
/* @end */
|
217
264
|
|
218
265
|
/* @group Class Metadata Section */
|
@@ -385,6 +432,11 @@ ul.link-list .type {
|
|
385
432
|
display: none;
|
386
433
|
}
|
387
434
|
|
435
|
+
#documentation .method-description .method-calls-super {
|
436
|
+
color: #333;
|
437
|
+
font-weight: bolder;
|
438
|
+
}
|
439
|
+
|
388
440
|
#documentation .method-detail {
|
389
441
|
margin: 0.5em 0;
|
390
442
|
padding: 0.5em 0;
|
data/doc/table_of_contents.html
CHANGED
@@ -55,6 +55,9 @@
|
|
55
55
|
</li>
|
56
56
|
<li class="module">
|
57
57
|
<a href="Kernel.html">Kernel</a>
|
58
|
+
</li>
|
59
|
+
<li class="class">
|
60
|
+
<a href="Module.html">Module</a>
|
58
61
|
</li>
|
59
62
|
<li class="class">
|
60
63
|
<a href="Object.html">Object</a>
|
@@ -84,10 +87,14 @@
|
|
84
87
|
|
85
88
|
<li class="method"><a href="Object.html#method-i-it">#it — Object</a>
|
86
89
|
|
90
|
+
<li class="method"><a href="Module.html#method-i-private_accessor">#private_accessor — Module</a>
|
91
|
+
|
87
92
|
<li class="method"><a href="Kernel.html#method-i-prompt">#prompt — Kernel</a>
|
88
93
|
|
89
94
|
<li class="method"><a href="Array.html#method-i-random_subarray">#random_subarray — Array</a>
|
90
95
|
|
96
|
+
<li class="method"><a href="Kernel.html#method-i-require_optional">#require_optional — Kernel</a>
|
97
|
+
|
91
98
|
<li class="method"><a href="Fixnum.html#method-i-string_length">#string_length — Fixnum</a>
|
92
99
|
|
93
100
|
<li class="method"><a href="Hash.html#method-i-to_ostruct">#to_ostruct — Hash</a>
|
@@ -101,7 +108,7 @@
|
|
101
108
|
|
102
109
|
<footer id="validator-badges">
|
103
110
|
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
104
|
-
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a>
|
111
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 4.0.0.
|
105
112
|
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
106
113
|
</footer>
|
107
114
|
|
data/lib/shenanigans/kernel.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Kernel
|
2
|
+
# Optionally require a gem. If it is not available, <tt>nil</tt>
|
3
|
+
# will be returned. Alternatively, a block can be provided with code
|
4
|
+
# to run.
|
5
|
+
# require 'non_existent'
|
6
|
+
# #=> nil
|
7
|
+
#
|
8
|
+
# require 'non_existent' do
|
9
|
+
# puts 'Something went wrong'
|
10
|
+
# end
|
11
|
+
# #=> Outputs 'Something went wrong'
|
12
|
+
def require_optional(gem, &block)
|
13
|
+
require gem
|
14
|
+
rescue LoadError
|
15
|
+
block.call if block
|
16
|
+
end
|
17
|
+
|
18
|
+
private :require_optional
|
19
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
class Module
|
2
|
-
private
|
3
|
-
|
4
2
|
# Works like <tt>attr_accessor</tt> but generates private
|
5
3
|
# getter/setter methods for class internal use only. Useful
|
6
4
|
# for enforcing Smalltalk-style internal encapsulation.
|
5
|
+
#
|
6
|
+
# For a more complete implementation of a similar feature see {ivar_encapsulation}[https://github.com/citizen428/ivar_encapsulation].
|
7
7
|
def private_accessor(*names)
|
8
8
|
names.each do |name|
|
9
9
|
instance_var_name = "@#{name}"
|
@@ -21,4 +21,6 @@ class Module
|
|
21
21
|
end
|
22
22
|
nil # like attr_accessor
|
23
23
|
end
|
24
|
+
|
25
|
+
private :private_accessor
|
24
26
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'shenanigans/kernel/require_optional'
|
3
|
+
require 'stringio'
|
4
|
+
|
5
|
+
class RequireOptional < MiniTest::Unit::TestCase
|
6
|
+
def test_require_optional
|
7
|
+
assert_equal require_optional('non_existent'), nil
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_require_optional_with_block
|
11
|
+
res = require_optional 'non_existent' do
|
12
|
+
42
|
13
|
+
end
|
14
|
+
|
15
|
+
assert_equal res, 42
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shenanigans
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Kohl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A collection of extensions for various Ruby core classes.
|
14
14
|
email: citizen428@gmail.com
|
@@ -45,7 +45,9 @@ files:
|
|
45
45
|
- doc/images/bullet_toggle_plus.png
|
46
46
|
- doc/images/loadingAnimation.gif
|
47
47
|
- doc/images/add.png
|
48
|
+
- doc/images/arrow_up.png
|
48
49
|
- doc/images/macFFBgHack.png
|
50
|
+
- doc/Module.html
|
49
51
|
- doc/index.html
|
50
52
|
- doc/table_of_contents.html
|
51
53
|
- doc/rdoc.css
|
@@ -64,11 +66,11 @@ files:
|
|
64
66
|
- lib/shenanigans/fixnum/string_length.rb
|
65
67
|
- lib/shenanigans/object.rb
|
66
68
|
- lib/shenanigans/kernel.rb
|
67
|
-
- lib/shenanigans/README.mdown
|
68
69
|
- lib/shenanigans/string.rb
|
69
70
|
- lib/shenanigans/kernel/prompt.rb
|
70
71
|
- lib/shenanigans/kernel/fn.rb
|
71
72
|
- lib/shenanigans/kernel/with.rb
|
73
|
+
- lib/shenanigans/kernel/require_optional.rb
|
72
74
|
- lib/shenanigans/array.rb
|
73
75
|
- lib/shenanigans/array/zip_with.rb
|
74
76
|
- lib/shenanigans/array/caret.rb
|
@@ -87,6 +89,7 @@ files:
|
|
87
89
|
- test/kernel/test_prompt.rb
|
88
90
|
- test/kernel/test_with.rb
|
89
91
|
- test/kernel/test_fn.rb
|
92
|
+
- test/kernel/test_require_optional.rb
|
90
93
|
- test/array/test_zip_with.rb
|
91
94
|
- test/array/test_random_subarray.rb
|
92
95
|
- test/array/test_caret.rb
|
@@ -123,3 +126,4 @@ signing_key:
|
|
123
126
|
specification_version: 4
|
124
127
|
summary: Think Facets, just less useful
|
125
128
|
test_files: []
|
129
|
+
has_rdoc:
|