shenanigans 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/doc/Array.html +2 -0
- data/doc/Fixnum.html +2 -0
- data/doc/Hash.html +2 -0
- data/doc/Kernel.html +2 -0
- data/doc/Object.html +2 -0
- data/doc/README_rdoc.html +2 -0
- data/doc/String.html +191 -0
- data/doc/created.rid +4 -2
- data/doc/index.html +2 -0
- data/doc/js/search_index.js +1 -1
- data/doc/table_of_contents.html +5 -0
- data/lib/shenanigans/string.rb +1 -0
- data/lib/shenanigans/string/in_groups_of.rb +14 -0
- data/test/hash/test_to_ostruct.rb +2 -1
- data/test/string/test_display.rb +36 -0
- data/test/string/test_in_groups_of.rb +11 -0
- metadata +8 -3
data/doc/Array.html
CHANGED
data/doc/Fixnum.html
CHANGED
data/doc/Hash.html
CHANGED
data/doc/Kernel.html
CHANGED
data/doc/Object.html
CHANGED
data/doc/README_rdoc.html
CHANGED
data/doc/String.html
ADDED
@@ -0,0 +1,191 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
6
|
+
|
7
|
+
<title>class String - Shenanigans</title>
|
8
|
+
|
9
|
+
<link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">
|
10
|
+
|
11
|
+
<script type="text/javascript">
|
12
|
+
var rdoc_rel_prefix = "./";
|
13
|
+
</script>
|
14
|
+
|
15
|
+
<script type="text/javascript" charset="utf-8" src="./js/jquery.js"></script>
|
16
|
+
<script type="text/javascript" charset="utf-8" src="./js/navigation.js"></script>
|
17
|
+
<script type="text/javascript" charset="utf-8" src="./js/search_index.js"></script>
|
18
|
+
<script type="text/javascript" charset="utf-8" src="./js/search.js"></script>
|
19
|
+
<script type="text/javascript" charset="utf-8" src="./js/searcher.js"></script>
|
20
|
+
<script type="text/javascript" charset="utf-8" src="./js/darkfish.js"></script>
|
21
|
+
|
22
|
+
|
23
|
+
<body id="top" class="class">
|
24
|
+
<nav id="metadata">
|
25
|
+
<nav id="home-section" class="section">
|
26
|
+
<h3 class="section-header">
|
27
|
+
<a href="./index.html">Home</a>
|
28
|
+
<a href="./table_of_contents.html#classes">Classes</a>
|
29
|
+
<a href="./table_of_contents.html#methods">Methods</a>
|
30
|
+
</h3>
|
31
|
+
</nav>
|
32
|
+
|
33
|
+
|
34
|
+
<nav id="search-section" class="section project-section" class="initially-hidden">
|
35
|
+
<form action="#" method="get" accept-charset="utf-8">
|
36
|
+
<h3 class="section-header">
|
37
|
+
<input type="text" name="search" placeholder="Search" id="search-field"
|
38
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
39
|
+
</h3>
|
40
|
+
</form>
|
41
|
+
|
42
|
+
<ul id="search-results" class="initially-hidden"></ul>
|
43
|
+
</nav>
|
44
|
+
|
45
|
+
|
46
|
+
<div id="file-metadata">
|
47
|
+
<nav id="file-list-section" class="section">
|
48
|
+
<h3 class="section-header">Defined In</h3>
|
49
|
+
<ul>
|
50
|
+
<li>lib/shenanigans/string/in_groups_of.rb
|
51
|
+
</ul>
|
52
|
+
</nav>
|
53
|
+
|
54
|
+
|
55
|
+
</div>
|
56
|
+
|
57
|
+
<div id="class-metadata">
|
58
|
+
|
59
|
+
<nav id="parent-class-section" class="section">
|
60
|
+
<h3 class="section-header">Parent</h3>
|
61
|
+
|
62
|
+
<p class="link"><a href="Object.html">Object</a>
|
63
|
+
|
64
|
+
</nav>
|
65
|
+
|
66
|
+
|
67
|
+
<!-- Method Quickref -->
|
68
|
+
<nav id="method-list-section" class="section">
|
69
|
+
<h3 class="section-header">Methods</h3>
|
70
|
+
|
71
|
+
<ul class="link-list">
|
72
|
+
|
73
|
+
<li><a href="#method-i-in_groups_of">#in_groups_of</a>
|
74
|
+
|
75
|
+
</ul>
|
76
|
+
</nav>
|
77
|
+
|
78
|
+
</div>
|
79
|
+
|
80
|
+
<div id="project-metadata">
|
81
|
+
<nav id="fileindex-section" class="section project-section">
|
82
|
+
<h3 class="section-header">Pages</h3>
|
83
|
+
|
84
|
+
<ul>
|
85
|
+
|
86
|
+
<li class="file"><a href="./README_rdoc.html">README</a>
|
87
|
+
|
88
|
+
</ul>
|
89
|
+
</nav>
|
90
|
+
|
91
|
+
<nav id="classindex-section" class="section project-section">
|
92
|
+
<h3 class="section-header">Class and Module Index</h3>
|
93
|
+
|
94
|
+
<ul class="link-list">
|
95
|
+
|
96
|
+
<li><a href="./Array.html">Array</a>
|
97
|
+
|
98
|
+
<li><a href="./Fixnum.html">Fixnum</a>
|
99
|
+
|
100
|
+
<li><a href="./Hash.html">Hash</a>
|
101
|
+
|
102
|
+
<li><a href="./Kernel.html">Kernel</a>
|
103
|
+
|
104
|
+
<li><a href="./Object.html">Object</a>
|
105
|
+
|
106
|
+
<li><a href="./String.html">String</a>
|
107
|
+
|
108
|
+
</ul>
|
109
|
+
</nav>
|
110
|
+
|
111
|
+
</div>
|
112
|
+
</nav>
|
113
|
+
|
114
|
+
<div id="documentation">
|
115
|
+
<h1 class="class">class String</h1>
|
116
|
+
|
117
|
+
<div id="description" class="description">
|
118
|
+
|
119
|
+
</div><!-- description -->
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
<!-- Methods -->
|
134
|
+
|
135
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
|
136
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
137
|
+
|
138
|
+
|
139
|
+
<div id="method-i-in_groups_of" class="method-detail ">
|
140
|
+
|
141
|
+
<div class="method-heading">
|
142
|
+
<span class="method-name">in_groups_of</span><span
|
143
|
+
class="method-args">(size)</span>
|
144
|
+
<span class="method-click-advice">click to toggle source</span>
|
145
|
+
</div>
|
146
|
+
|
147
|
+
|
148
|
+
<div class="method-description">
|
149
|
+
|
150
|
+
<p>Returns an array of the string broken down into groups of <code>size</code>
|
151
|
+
characters.</p>
|
152
|
+
|
153
|
+
<pre class="ruby"><span class="ruby-string">"aabbcc"</span>.<span class="ruby-identifier">in_groups_of</span>(<span class="ruby-value">2</span>)
|
154
|
+
<span class="ruby-comment">#=> ['aa', 'bb', 'cc']</span>
|
155
|
+
<span class="ruby-string">""</span>.<span class="ruby-identifier">in_groups_of</span>(<span class="ruby-value">2</span>)
|
156
|
+
<span class="ruby-comment">#=> []</span>
|
157
|
+
<span class="ruby-string">""</span>.<span class="ruby-identifier">in_groups_of</span>(<span class="ruby-value">0</span>)
|
158
|
+
<span class="ruby-comment">#=> ArgumentError</span>
|
159
|
+
</pre>
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
<div class="method-source-code" id="in_groups_of-source">
|
164
|
+
<pre><span class="ruby-comment"># File lib/shenanigans/string/in_groups_of.rb, line 10</span>
|
165
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">in_groups_of</span>(<span class="ruby-identifier">size</span>)
|
166
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">"Size of group must be >= 1"</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">size</span> <span class="ruby-operator"><</span> <span class="ruby-value">1</span>
|
167
|
+
<span class="ruby-identifier">scan</span>(<span class="ruby-node">%r.{1,#{size}}/</span>)
|
168
|
+
<span class="ruby-keyword">end</span></pre>
|
169
|
+
</div><!-- in_groups_of-source -->
|
170
|
+
|
171
|
+
</div>
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
</div><!-- in_groups_of-method -->
|
177
|
+
|
178
|
+
|
179
|
+
</section><!-- public-instance-method-details -->
|
180
|
+
|
181
|
+
</section><!-- 5Buntitled-5D -->
|
182
|
+
|
183
|
+
</div><!-- documentation -->
|
184
|
+
|
185
|
+
|
186
|
+
<footer id="validator-badges">
|
187
|
+
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
188
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
|
189
|
+
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
190
|
+
</footer>
|
191
|
+
|
data/doc/created.rid
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
Mon, 20 Aug 2012 18:53:22 +0200
|
2
2
|
README.rdoc Thu, 17 May 2012 11:45:08 +0200
|
3
3
|
lib/shenanigans/array/caret.rb Thu, 28 Jun 2012 09:15:50 +0200
|
4
4
|
lib/shenanigans/array/random_subarray.rb Thu, 17 May 2012 00:03:23 +0200
|
@@ -8,7 +8,7 @@ lib/shenanigans/fixnum/string_length.rb Sun, 15 Jul 2012 00:00:21 +0200
|
|
8
8
|
lib/shenanigans/fixnum.rb Sat, 14 Jul 2012 23:49:59 +0200
|
9
9
|
lib/shenanigans/hash/extract.rb Thu, 09 Aug 2012 18:47:48 +0200
|
10
10
|
lib/shenanigans/hash/has_shape_pred.rb Tue, 19 Jun 2012 21:25:03 +0200
|
11
|
-
lib/shenanigans/hash/to_ostruct.rb
|
11
|
+
lib/shenanigans/hash/to_ostruct.rb Mon, 13 Aug 2012 17:56:35 +0200
|
12
12
|
lib/shenanigans/hash.rb Thu, 09 Aug 2012 18:32:30 +0200
|
13
13
|
lib/shenanigans/kernel/fn.rb Wed, 16 May 2012 23:57:36 +0200
|
14
14
|
lib/shenanigans/kernel/prompt.rb Thu, 17 May 2012 00:10:42 +0200
|
@@ -17,4 +17,6 @@ lib/shenanigans/kernel.rb Wed, 16 May 2012 20:49:22 +0200
|
|
17
17
|
lib/shenanigans/object/display.rb Fri, 25 May 2012 17:29:45 +0200
|
18
18
|
lib/shenanigans/object/it.rb Thu, 28 Jun 2012 09:07:56 +0200
|
19
19
|
lib/shenanigans/object.rb Thu, 28 Jun 2012 09:10:12 +0200
|
20
|
+
lib/shenanigans/string/in_groups_of.rb Mon, 20 Aug 2012 18:53:19 +0200
|
21
|
+
lib/shenanigans/string.rb Mon, 20 Aug 2012 18:29:46 +0200
|
20
22
|
lib/shenanigans.rb Sat, 14 Jul 2012 23:53:13 +0200
|
data/doc/index.html
CHANGED
data/doc/js/search_index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var search_data = {"index":{"searchIndex":["array","fixnum","hash","kernel","object","^()","d()","display()","extract()","fn()","has_shape?()","it()","prompt()","random_subarray()","string_length()","to_ostruct()","with()","zip_with()","readme"],"longSearchIndex":["array","fixnum","hash","kernel","object","array#^()","object#d()","object#display()","hash#extract()","kernel#fn()","hash#has_shape?()","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","",""],["^","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"],["it","Object","Object.html#method-i-it","()","<p>An identity method that provides access to an object’s <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-identifier\">it</span>)\n<span class=\"ruby-comment\">#=> {1=>[1, ...</span>\n</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"],["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>\n<span class=\"ruby-comment\">#=> ...</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"]]}}
|
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’s <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-identifier\">it</span>)\n<span class=\"ruby-comment\">#=> {1=>[1, ...</span>\n</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"],["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>\n<span class=\"ruby-comment\">#=> ...</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/table_of_contents.html
CHANGED
@@ -59,6 +59,9 @@
|
|
59
59
|
<li class="class">
|
60
60
|
<a href="Object.html">Object</a>
|
61
61
|
</li>
|
62
|
+
<li class="class">
|
63
|
+
<a href="String.html">String</a>
|
64
|
+
</li>
|
62
65
|
|
63
66
|
</ul>
|
64
67
|
|
@@ -77,6 +80,8 @@
|
|
77
80
|
|
78
81
|
<li class="method"><a href="Hash.html#method-i-has_shape-3F">#has_shape? — Hash</a>
|
79
82
|
|
83
|
+
<li class="method"><a href="String.html#method-i-in_groups_of">#in_groups_of — String</a>
|
84
|
+
|
80
85
|
<li class="method"><a href="Object.html#method-i-it">#it — Object</a>
|
81
86
|
|
82
87
|
<li class="method"><a href="Kernel.html#method-i-prompt">#prompt — Kernel</a>
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative "string/in_groups_of"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class String
|
2
|
+
# Returns an array of the string broken down into groups of
|
3
|
+
# <tt>size</tt> characters.
|
4
|
+
# "aabbcc".in_groups_of(2)
|
5
|
+
# #=> ['aa', 'bb', 'cc']
|
6
|
+
# "".in_groups_of(2)
|
7
|
+
# #=> []
|
8
|
+
# "".in_groups_of(0)
|
9
|
+
# #=> ArgumentError
|
10
|
+
def in_groups_of(size)
|
11
|
+
raise ArgumentError, "Size of group must be >= 1" if size < 1
|
12
|
+
scan(/.{1,#{size}}/)
|
13
|
+
end
|
14
|
+
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
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'shenanigans/string/in_groups_of'
|
3
|
+
|
4
|
+
class InGroupsOf < MiniTest::Unit::TestCase
|
5
|
+
def test_in_groups_of
|
6
|
+
str = "aabbcc"
|
7
|
+
assert str.in_groups_of(2) == ['aa', 'bb', 'cc']
|
8
|
+
assert "".in_groups_of(2) == []
|
9
|
+
assert_raises(ArgumentError) { "".in_groups_of(0) }
|
10
|
+
end
|
11
|
+
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.7
|
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-08-
|
12
|
+
date: 2012-08-20 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email: citizen428@gmail.com
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- doc/Object.html
|
60
60
|
- doc/rdoc.css
|
61
61
|
- doc/README_rdoc.html
|
62
|
+
- doc/String.html
|
62
63
|
- doc/table_of_contents.html
|
63
64
|
- lib/shenanigans/array/caret.rb
|
64
65
|
- lib/shenanigans/array/random_subarray.rb
|
@@ -78,6 +79,8 @@ files:
|
|
78
79
|
- lib/shenanigans/object/it.rb
|
79
80
|
- lib/shenanigans/object.rb
|
80
81
|
- lib/shenanigans/README.mdown
|
82
|
+
- lib/shenanigans/string/in_groups_of.rb
|
83
|
+
- lib/shenanigans/string.rb
|
81
84
|
- lib/shenanigans.rb
|
82
85
|
- test/array/test_caret.rb
|
83
86
|
- test/array/test_random_subarray.rb
|
@@ -91,7 +94,9 @@ files:
|
|
91
94
|
- test/kernel/test_with.rb
|
92
95
|
- test/object/test_display.rb
|
93
96
|
- test/object/test_it.rb
|
94
|
-
|
97
|
+
- test/string/test_display.rb
|
98
|
+
- test/string/test_in_groups_of.rb
|
99
|
+
homepage: http://rubydoc.info/gems/shenanigans/frames
|
95
100
|
licenses: []
|
96
101
|
post_install_message:
|
97
102
|
rdoc_options: []
|