shenanigans 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/doc/Object.html +77 -0
- data/doc/created.rid +3 -2
- data/doc/js/search_index.js +1 -1
- data/doc/table_of_contents.html +4 -0
- data/lib/shenanigans/object.rb +1 -0
- data/lib/shenanigans/object/display.rb +17 -0
- data/test/object/test_display.rb +36 -0
- metadata +5 -2
data/doc/Object.html
CHANGED
@@ -47,6 +47,7 @@
|
|
47
47
|
<nav id="file-list-section" class="section">
|
48
48
|
<h3 class="section-header">Defined In</h3>
|
49
49
|
<ul>
|
50
|
+
<li>lib/shenanigans/object/display.rb
|
50
51
|
<li>lib/shenanigans/object/identity.rb
|
51
52
|
</ul>
|
52
53
|
</nav>
|
@@ -70,6 +71,10 @@
|
|
70
71
|
|
71
72
|
<ul class="link-list">
|
72
73
|
|
74
|
+
<li><a href="#method-i-d">#d</a>
|
75
|
+
|
76
|
+
<li><a href="#method-i-display">#display</a>
|
77
|
+
|
73
78
|
<li><a href="#method-i-identity">#identity</a>
|
74
79
|
|
75
80
|
</ul>
|
@@ -130,6 +135,78 @@
|
|
130
135
|
<h3 class="section-header">Public Instance Methods</h3>
|
131
136
|
|
132
137
|
|
138
|
+
<div id="method-i-d" class="method-detail method-alias">
|
139
|
+
|
140
|
+
<div class="method-heading">
|
141
|
+
<span class="method-name">d</span><span
|
142
|
+
class="method-args">(new_line = true)</span>
|
143
|
+
<span class="method-click-advice">click to toggle source</span>
|
144
|
+
</div>
|
145
|
+
|
146
|
+
|
147
|
+
<div class="method-description">
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
</div>
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
<div class="aliases">
|
159
|
+
Alias for: <a href="Object.html#method-i-display">display</a>
|
160
|
+
</div>
|
161
|
+
|
162
|
+
</div><!-- d-method -->
|
163
|
+
|
164
|
+
|
165
|
+
<div id="method-i-display" class="method-detail ">
|
166
|
+
|
167
|
+
<div class="method-heading">
|
168
|
+
<span class="method-name">display</span><span
|
169
|
+
class="method-args">(new_line = true)</span>
|
170
|
+
<span class="method-click-advice">click to toggle source</span>
|
171
|
+
</div>
|
172
|
+
|
173
|
+
|
174
|
+
<div class="method-description">
|
175
|
+
|
176
|
+
<p>Outputs the object and also returns it. Will use <code>puts</code> if
|
177
|
+
<code>new_line</code> is <code>true</code> and <code>print</code>
|
178
|
+
otherwise.</p>
|
179
|
+
|
180
|
+
<pre class="ruby"><span class="ruby-string">"foo"</span>.<span class="ruby-identifier">display</span>
|
181
|
+
<span class="ruby-identifier">foo</span>
|
182
|
+
<span class="ruby-comment">#=> "foo"</span>
|
183
|
+
|
184
|
+
<span class="ruby-string">"foo"</span>.<span class="ruby-identifier">display</span>(<span class="ruby-keyword">false</span>)
|
185
|
+
<span class="ruby-identifier">foo</span><span class="ruby-comment">#=> "foo"</span>
|
186
|
+
</pre>
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
<div class="method-source-code" id="display-source">
|
191
|
+
<pre><span class="ruby-comment"># File lib/shenanigans/object/display.rb, line 11</span>
|
192
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">display</span>(<span class="ruby-identifier">new_line</span> = <span class="ruby-keyword">true</span>)
|
193
|
+
<span class="ruby-identifier">m</span> = <span class="ruby-identifier">new_line</span> <span class="ruby-operator">?</span> <span class="ruby-value">:puts</span> <span class="ruby-operator">:</span> <span class="ruby-value">:print</span>
|
194
|
+
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">tap</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">o</span><span class="ruby-operator">|</span> <span class="ruby-identifier">send</span>(<span class="ruby-identifier">m</span>, <span class="ruby-identifier">o</span>) }
|
195
|
+
<span class="ruby-keyword">end</span></pre>
|
196
|
+
</div><!-- display-source -->
|
197
|
+
|
198
|
+
</div>
|
199
|
+
|
200
|
+
|
201
|
+
<div class="aliases">
|
202
|
+
Also aliased as: <a href="Object.html#method-i-d">d</a>
|
203
|
+
</div>
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
</div><!-- display-method -->
|
208
|
+
|
209
|
+
|
133
210
|
<div id="method-i-identity" class="method-detail ">
|
134
211
|
|
135
212
|
<div class="method-heading">
|
data/doc/created.rid
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
Fri, 25 May 2012 17:35:20 +0200
|
2
2
|
README.rdoc Thu, 17 May 2012 11:45:08 +0200
|
3
3
|
lib/shenanigans/array/random_subarray.rb Thu, 17 May 2012 00:03:23 +0200
|
4
4
|
lib/shenanigans/array/zip_with.rb Thu, 17 May 2012 00:12:10 +0200
|
@@ -7,6 +7,7 @@ lib/shenanigans/kernel/fn.rb Wed, 16 May 2012 23:57:36 +0200
|
|
7
7
|
lib/shenanigans/kernel/prompt.rb Thu, 17 May 2012 00:10:42 +0200
|
8
8
|
lib/shenanigans/kernel/with.rb Thu, 17 May 2012 00:00:08 +0200
|
9
9
|
lib/shenanigans/kernel.rb Wed, 16 May 2012 20:49:22 +0200
|
10
|
+
lib/shenanigans/object/display.rb Fri, 25 May 2012 17:29:45 +0200
|
10
11
|
lib/shenanigans/object/identity.rb Wed, 16 May 2012 23:51:07 +0200
|
11
|
-
lib/shenanigans/object.rb
|
12
|
+
lib/shenanigans/object.rb Fri, 25 May 2012 15:31:08 +0200
|
12
13
|
lib/shenanigans.rb Wed, 16 May 2012 21:04:23 +0200
|
data/doc/js/search_index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var search_data = {"index":{"searchIndex":["array","kernel","object","fn()","identity()","prompt()","random_subarray()","with()","zip_with()","readme"],"longSearchIndex":["array","kernel","object","kernel#fn()","object#identity()","kernel#prompt()","array#random_subarray()","kernel#with()","array#zip_with()",""],"info":[["Array","","Array.html","",""],["Kernel","","Kernel.html","",""],["Object","","Object.html","",""],["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"],["identity","Object","Object.html#method-i-identity","()","<p>An identity method that provides access to an object’s <code>self</code>.\n\n<pre>[1,2,3,4,5,1,2,2,3].group_by(&:identity) ...</pre>\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"],["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"]]}}
|
1
|
+
var search_data = {"index":{"searchIndex":["array","kernel","object","d()","display()","fn()","identity()","prompt()","random_subarray()","with()","zip_with()","readme"],"longSearchIndex":["array","kernel","object","object#d()","object#display()","kernel#fn()","object#identity()","kernel#prompt()","array#random_subarray()","kernel#with()","array#zip_with()",""],"info":[["Array","","Array.html","",""],["Kernel","","Kernel.html","",""],["Object","","Object.html","",""],["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"],["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"],["identity","Object","Object.html#method-i-identity","()","<p>An identity method that provides access to an object’s <code>self</code>.\n\n<pre>[1,2,3,4,5,1,2,2,3].group_by(&:identity) ...</pre>\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"],["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/table_of_contents.html
CHANGED
@@ -59,6 +59,10 @@
|
|
59
59
|
<h2 id="methods">Methods</h2>
|
60
60
|
<ul>
|
61
61
|
|
62
|
+
<li class="method"><a href="Object.html#method-i-d">#d — Object</a>
|
63
|
+
|
64
|
+
<li class="method"><a href="Object.html#method-i-display">#display — Object</a>
|
65
|
+
|
62
66
|
<li class="method"><a href="Kernel.html#method-i-fn">#fn — Kernel</a>
|
63
67
|
|
64
68
|
<li class="method"><a href="Object.html#method-i-identity">#identity — Object</a>
|
data/lib/shenanigans/object.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
class Object
|
2
|
+
# Outputs the object and also returns it.
|
3
|
+
# Will use <tt>puts</tt> if <tt>new_line</tt> is <tt>true</tt> and
|
4
|
+
# <tt>print</tt> otherwise.
|
5
|
+
# "foo".display
|
6
|
+
# foo
|
7
|
+
# #=> "foo"
|
8
|
+
#
|
9
|
+
# "foo".display(false)
|
10
|
+
# foo#=> "foo"
|
11
|
+
def display(new_line = true)
|
12
|
+
m = new_line ? :puts : :print
|
13
|
+
self.tap { |o| send(m, o) }
|
14
|
+
end
|
15
|
+
|
16
|
+
alias :d :display
|
17
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'shenanigans/object/display'
|
3
|
+
require 'stringio'
|
4
|
+
|
5
|
+
class Display < MiniTest::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
@orig_stdout = $stdout
|
8
|
+
$stdout = StringIO.new("", "r+")
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
$stdout = @orig_stdout
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_display
|
16
|
+
str = "foo"
|
17
|
+
assert str.display == str
|
18
|
+
$stdout.rewind
|
19
|
+
assert $stdout.gets.chomp == str
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_display_alias
|
23
|
+
str = "foo"
|
24
|
+
assert str.d == str
|
25
|
+
$stdout.rewind
|
26
|
+
assert $stdout.gets.chomp == str
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_display_no_new_line
|
30
|
+
str = "foo"
|
31
|
+
assert str.display(false) == str
|
32
|
+
$stdout.rewind
|
33
|
+
assert $stdout.gets == str
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-25 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email: citizen428@gmail.com
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- lib/shenanigans/kernel/prompt.rb
|
66
66
|
- lib/shenanigans/kernel/with.rb
|
67
67
|
- lib/shenanigans/kernel.rb
|
68
|
+
- lib/shenanigans/object/display.rb
|
68
69
|
- lib/shenanigans/object/identity.rb
|
69
70
|
- lib/shenanigans/object.rb
|
70
71
|
- lib/shenanigans/README.mdown
|
@@ -75,6 +76,7 @@ files:
|
|
75
76
|
- test/kernel/test_fn.rb
|
76
77
|
- test/kernel/test_prompt.rb
|
77
78
|
- test/kernel/test_with.rb
|
79
|
+
- test/object/test_display.rb
|
78
80
|
- test/object/test_identity.rb
|
79
81
|
homepage: https://github.com/citizen428/shenanigans
|
80
82
|
licenses: []
|
@@ -101,3 +103,4 @@ signing_key:
|
|
101
103
|
specification_version: 3
|
102
104
|
summary: Think Facets, just less useful
|
103
105
|
test_files: []
|
106
|
+
has_rdoc:
|