spoonerize 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/ruby.yml +24 -0
- data/.gitignore +1 -0
- data/Gemfile +7 -0
- data/LICENSE +21 -0
- data/README.md +106 -0
- data/Rakefile +19 -0
- data/_config.yml +1 -0
- data/bin/spoonerize +5 -0
- data/doc/README_md.html +200 -0
- data/doc/Spoonerize/Bumper.html +287 -0
- data/doc/Spoonerize/Cli.html +544 -0
- data/doc/Spoonerize/Log.html +362 -0
- data/doc/Spoonerize/Spoonerism.html +590 -0
- data/doc/Spoonerize.html +125 -0
- data/doc/created.rid +8 -0
- data/doc/css/fonts.css +167 -0
- data/doc/css/rdoc.css +619 -0
- data/doc/fonts/Lato-Light.ttf +0 -0
- data/doc/fonts/Lato-LightItalic.ttf +0 -0
- data/doc/fonts/Lato-Regular.ttf +0 -0
- data/doc/fonts/Lato-RegularItalic.ttf +0 -0
- data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +203 -0
- data/doc/js/darkfish.js +84 -0
- data/doc/js/navigation.js +105 -0
- data/doc/js/navigation.js.gz +0 -0
- data/doc/js/search.js +110 -0
- data/doc/js/search_index.js +1 -0
- data/doc/js/search_index.js.gz +0 -0
- data/doc/js/searcher.js +229 -0
- data/doc/js/searcher.js.gz +0 -0
- data/doc/table_of_contents.html +242 -0
- data/lib/config/lazy_words.yml +21 -0
- data/lib/spoonerize/bumper.rb +61 -0
- data/lib/spoonerize/cli.rb +158 -0
- data/lib/spoonerize/log.rb +68 -0
- data/lib/spoonerize/spoonerism.rb +166 -0
- data/lib/spoonerize/version.rb +5 -0
- data/lib/spoonerize.rb +21 -0
- data/pkg/spoonerize-0.0.7.gem +0 -0
- data/spoonerize.gemspec +38 -0
- metadata +154 -0
data/doc/index.html
ADDED
@@ -0,0 +1,203 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "./";
|
11
|
+
var index_rel_prefix = "./";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="./js/navigation.js" defer></script>
|
15
|
+
<script src="./js/search.js" defer></script>
|
16
|
+
<script src="./js/search_index.js" defer></script>
|
17
|
+
<script src="./js/searcher.js" defer></script>
|
18
|
+
<script src="./js/darkfish.js" defer></script>
|
19
|
+
|
20
|
+
<link href="./css/fonts.css" rel="stylesheet">
|
21
|
+
<link href="./css/rdoc.css" rel="stylesheet">
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
<body id="top" role="document" class="file">
|
27
|
+
<nav role="navigation">
|
28
|
+
<div id="project-navigation">
|
29
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
30
|
+
<h2>
|
31
|
+
<a href="./index.html" rel="home">Home</a>
|
32
|
+
</h2>
|
33
|
+
|
34
|
+
<div id="table-of-contents-navigation">
|
35
|
+
<a href="./table_of_contents.html#pages">Pages</a>
|
36
|
+
<a href="./table_of_contents.html#classes">Classes</a>
|
37
|
+
<a href="./table_of_contents.html#methods">Methods</a>
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
|
41
|
+
|
42
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
43
|
+
<form action="#" method="get" accept-charset="utf-8">
|
44
|
+
<div id="search-field-wrapper">
|
45
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
46
|
+
aria-autocomplete="list" aria-controls="search-results"
|
47
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
48
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
49
|
+
</div>
|
50
|
+
|
51
|
+
<ul id="search-results" aria-label="Search Results"
|
52
|
+
aria-busy="false" aria-expanded="false"
|
53
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
54
|
+
</form>
|
55
|
+
</div>
|
56
|
+
|
57
|
+
</div>
|
58
|
+
|
59
|
+
<div id="project-metadata">
|
60
|
+
<div id="fileindex-section" class="nav-section">
|
61
|
+
<h3>Pages</h3>
|
62
|
+
|
63
|
+
<ul class="link-list">
|
64
|
+
|
65
|
+
<li><a href="./README_md.html">README</a>
|
66
|
+
|
67
|
+
</ul>
|
68
|
+
</div>
|
69
|
+
|
70
|
+
<div id="classindex-section" class="nav-section">
|
71
|
+
<h3>Class and Module Index</h3>
|
72
|
+
|
73
|
+
<ul class="link-list">
|
74
|
+
|
75
|
+
<li><a href="./Spoonerize.html">Spoonerize</a>
|
76
|
+
|
77
|
+
<li><a href="./Spoonerize/Bumper.html">Spoonerize::Bumper</a>
|
78
|
+
|
79
|
+
<li><a href="./Spoonerize/Cli.html">Spoonerize::Cli</a>
|
80
|
+
|
81
|
+
<li><a href="./Spoonerize/Log.html">Spoonerize::Log</a>
|
82
|
+
|
83
|
+
<li><a href="./Spoonerize/Spoonerism.html">Spoonerize::Spoonerism</a>
|
84
|
+
|
85
|
+
</ul>
|
86
|
+
</div>
|
87
|
+
|
88
|
+
</div>
|
89
|
+
</nav>
|
90
|
+
|
91
|
+
<main role="main">
|
92
|
+
|
93
|
+
|
94
|
+
<h1 id="label-Welcome+to+Spoonerize+--+a+word+game">Welcome to <a href="https://evanthegrayt.github.io/spoonerize">Spoonerize</a> – a word game<span><a href="#label-Welcome+to+Spoonerize+--+a+word+game">¶</a> <a href="#top">↑</a></span></h1>
|
95
|
+
|
96
|
+
<blockquote>
|
97
|
+
<p>Sponerism <em>noun</em> a verbal error in which a speaker accidentally transposes the initial sounds or letters of two or more words, often to humorous effect.</p>
|
98
|
+
</blockquote>
|
99
|
+
|
100
|
+
<p>We've all done it; someone says a phrase, and you flip the first few letters around, and sometimes, it makes an even funnier phrase. For example: “Tomb Raider” becomes “Romb Taider”. Well, when I was in high school, we took it further – probably too far – and made a rule set. This program follows those rules, which are listed below.</p>
|
101
|
+
|
102
|
+
<h2 id="label-Table+of+Contents">Table of Contents<span><a href="#label-Table+of+Contents">¶</a> <a href="#top">↑</a></span></h2>
|
103
|
+
<ul><li>
|
104
|
+
<p><a href="#installation">Installation</a></p>
|
105
|
+
</li><li>
|
106
|
+
<p><a href="#automated">Automated</a></p>
|
107
|
+
</li><li>
|
108
|
+
<p><a href="#manual">Manual</a></p>
|
109
|
+
</li><li>
|
110
|
+
<p><a href="#command-line-usage">Command Line Usage</a></p>
|
111
|
+
</li><li>
|
112
|
+
<p><a href="#api">API</a></p>
|
113
|
+
</li><li>
|
114
|
+
<p><a href="#rules-of-the-game">Rules of the Game</a></p>
|
115
|
+
</li><li>
|
116
|
+
<p><a href="#self-promotion">Self-Promotion</a></p>
|
117
|
+
</li></ul>
|
118
|
+
|
119
|
+
<h2 id="label-Installation">Installation<span><a href="#label-Installation">¶</a> <a href="#top">↑</a></span></h2>
|
120
|
+
|
121
|
+
<h3 id="label-Automated">Automated<span><a href="#label-Automated">¶</a> <a href="#top">↑</a></span></h3>
|
122
|
+
|
123
|
+
<p>Just install the gem!</p>
|
124
|
+
|
125
|
+
<pre class="ruby"><span class="ruby-identifier">gem</span> <span class="ruby-identifier">install</span> <span class="ruby-identifier">spoonerize</span>
|
126
|
+
</pre>
|
127
|
+
|
128
|
+
<p>If you don't have permission on your system to install ruby or gems, I recommend using <a href="http://www.rubyinside.com/rbenv-a-simple-new-ruby-version-management-tool-5302.html">rbenv</a>, or you can try the manual methods below.</p>
|
129
|
+
|
130
|
+
<h3 id="label-Manual">Manual<span><a href="#label-Manual">¶</a> <a href="#top">↑</a></span></h3>
|
131
|
+
|
132
|
+
<p>From your terminal, clone the repository where you want it. From there, you have a couple of installation options.</p>
|
133
|
+
|
134
|
+
<pre>git clone https://github.com/evanthegrayt/spoonerize.git
|
135
|
+
cd spoonerize
|
136
|
+
|
137
|
+
# Use rake to build and install the gem.
|
138
|
+
rake install
|
139
|
+
|
140
|
+
# OR manually link the executable somewhere. If you use this method, you cannot
|
141
|
+
# move the repository after you link it!
|
142
|
+
ln -s $PWD/bin/spoonerize /usr/local/bin/spoonerize</pre>
|
143
|
+
|
144
|
+
<h2 id="label-Command+Line+Usage">Command Line Usage<span><a href="#label-Command+Line+Usage">¶</a> <a href="#top">↑</a></span></h2>
|
145
|
+
|
146
|
+
<p>Call the executable and pass a phrase as arguments:</p>
|
147
|
+
|
148
|
+
<pre>$ spoonerize not too shabby # => tot shoo nabby</pre>
|
149
|
+
|
150
|
+
<p>If it didn't flip the way you wanted it to, you can reverse it:</p>
|
151
|
+
|
152
|
+
<pre>$ spoonerize -r not too shabby # => shot noo tabby</pre>
|
153
|
+
|
154
|
+
<p>If you find a phrase funny enough to save, you can pass the <code>-s</code> flag. This will write the results to the logfile. You can print your log file with the <code>-p</code> flag. It will show the original phrase, the end result, and the options used to get the results. For example:</p>
|
155
|
+
|
156
|
+
<pre>$ spoonerize -s not too shabby
|
157
|
+
Saving [tot shoo nabby] to /Users/evan.gray/workflow/spoonerize/log/spoonerize.csv
|
158
|
+
|
159
|
+
$ spoonerize -rs not too shabby
|
160
|
+
Saving [shot noo tabby] to /Users/evan.gray/workflow/spoonerize/log/spoonerize.csv
|
161
|
+
|
162
|
+
$ spoonerize -p
|
163
|
+
not too shabby | tot shoo nabby | No Options
|
164
|
+
not too shabby | shot noo tabby | Reverse</pre>
|
165
|
+
|
166
|
+
<p>To get a list of all available options, run with <code>-h</code>.</p>
|
167
|
+
|
168
|
+
<h2 id="label-API">API<span><a href="#label-API">¶</a> <a href="#top">↑</a></span></h2>
|
169
|
+
|
170
|
+
<p>This readme isn't finished, but you can view <a href="https://evanthegrayt.github.io/spoonerize/doc/index.html">API documentation</a>.</p>
|
171
|
+
|
172
|
+
<h2 id="label-Rules+of+the+Game">Rules of the Game<span><a href="#label-Rules+of+the+Game">¶</a> <a href="#top">↑</a></span></h2>
|
173
|
+
<ul><li>
|
174
|
+
<p>Each word drops its leading consonant group and takes the leading consonant group of the next word.</p>
|
175
|
+
</li><li>
|
176
|
+
<p>If the word has no leading consonants, nothing is dropped, but it still receives the next word's leading consonants if it has any.</p>
|
177
|
+
</li><li>
|
178
|
+
<p>If the next word has no leading consonants, the current word receives no consonants, but will still lose its own if it has any.</p>
|
179
|
+
</li><li>
|
180
|
+
<p>When being “lazy”, common words (“the”, “his”, etc.) remain unchanged.</p>
|
181
|
+
</li><li>
|
182
|
+
<p>If the word to pull from is excluded, that word is skipped, and you pull the leading consonants from the next non-excluded word.</p>
|
183
|
+
</li><li>
|
184
|
+
<p>“Q” and “U” should stay together (like “queen”).</p>
|
185
|
+
</li><li>
|
186
|
+
<p>A lot of the time, the words won't look how they're supposed to sound, as you go by how the word <em>used</em> to sound, not how it's spelled. For instance, <code>$ spoonerize two new cuties</code> becomes “no cew twuties”, but it would be pronounced “new coo tooties”, as the words retain their original sounds.</p>
|
187
|
+
</li></ul>
|
188
|
+
|
189
|
+
<h2 id="label-Self+Promotion">Self Promotion<span><a href="#label-Self+Promotion">¶</a> <a href="#top">↑</a></span></h2>
|
190
|
+
|
191
|
+
<p>I do these projects for fun, and I enjoy knowing that they're helpful to people. Consider starring <a href="https://github.com/evanthegrayt/spoonerize">the repository</a> if you like it! If you love it, follow me <a href="https://github.com/evanthegrayt">on github</a>!</p>
|
192
|
+
|
193
|
+
|
194
|
+
</main>
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
<footer id="validator-badges" role="contentinfo">
|
199
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
200
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.1.
|
201
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
202
|
+
</footer>
|
203
|
+
|
data/doc/js/darkfish.js
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
* Darkfish Page Functions
|
4
|
+
* $Id: darkfish.js 53 2009-01-07 02:52:03Z deveiant $
|
5
|
+
*
|
6
|
+
* Author: Michael Granger <mgranger@laika.com>
|
7
|
+
*
|
8
|
+
*/
|
9
|
+
|
10
|
+
/* Provide console simulation for firebug-less environments */
|
11
|
+
/*
|
12
|
+
if (!("console" in window) || !("firebug" in console)) {
|
13
|
+
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
|
14
|
+
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
|
15
|
+
|
16
|
+
window.console = {};
|
17
|
+
for (var i = 0; i < names.length; ++i)
|
18
|
+
window.console[names[i]] = function() {};
|
19
|
+
};
|
20
|
+
*/
|
21
|
+
|
22
|
+
|
23
|
+
function showSource( e ) {
|
24
|
+
var target = e.target;
|
25
|
+
while (!target.classList.contains('method-detail')) {
|
26
|
+
target = target.parentNode;
|
27
|
+
}
|
28
|
+
if (typeof target !== "undefined" && target !== null) {
|
29
|
+
target = target.querySelector('.method-source-code');
|
30
|
+
}
|
31
|
+
if (typeof target !== "undefined" && target !== null) {
|
32
|
+
target.classList.toggle('active-menu')
|
33
|
+
}
|
34
|
+
};
|
35
|
+
|
36
|
+
function hookSourceViews() {
|
37
|
+
document.querySelectorAll('.method-heading').forEach(function (codeObject) {
|
38
|
+
codeObject.addEventListener('click', showSource);
|
39
|
+
});
|
40
|
+
};
|
41
|
+
|
42
|
+
function hookSearch() {
|
43
|
+
var input = document.querySelector('#search-field');
|
44
|
+
var result = document.querySelector('#search-results');
|
45
|
+
result.classList.remove("initially-hidden");
|
46
|
+
|
47
|
+
var search_section = document.querySelector('#search-section');
|
48
|
+
search_section.classList.remove("initially-hidden");
|
49
|
+
|
50
|
+
var search = new Search(search_data, input, result);
|
51
|
+
|
52
|
+
search.renderItem = function(result) {
|
53
|
+
var li = document.createElement('li');
|
54
|
+
var html = '';
|
55
|
+
|
56
|
+
// TODO add relative path to <script> per-page
|
57
|
+
html += '<p class="search-match"><a href="' + index_rel_prefix + result.path + '">' + this.hlt(result.title);
|
58
|
+
if (result.params)
|
59
|
+
html += '<span class="params">' + result.params + '</span>';
|
60
|
+
html += '</a>';
|
61
|
+
|
62
|
+
|
63
|
+
if (result.namespace)
|
64
|
+
html += '<p class="search-namespace">' + this.hlt(result.namespace);
|
65
|
+
|
66
|
+
if (result.snippet)
|
67
|
+
html += '<div class="search-snippet">' + result.snippet + '</div>';
|
68
|
+
|
69
|
+
li.innerHTML = html;
|
70
|
+
|
71
|
+
return li;
|
72
|
+
}
|
73
|
+
|
74
|
+
search.select = function(result) {
|
75
|
+
window.location.href = result.firstChild.firstChild.href;
|
76
|
+
}
|
77
|
+
|
78
|
+
search.scrollIntoView = search.scrollInWindow;
|
79
|
+
};
|
80
|
+
|
81
|
+
document.addEventListener('DOMContentLoaded', function() {
|
82
|
+
hookSourceViews();
|
83
|
+
hookSearch();
|
84
|
+
});
|
@@ -0,0 +1,105 @@
|
|
1
|
+
/*
|
2
|
+
* Navigation allows movement using the arrow keys through the search results.
|
3
|
+
*
|
4
|
+
* When using this library you will need to set scrollIntoView to the
|
5
|
+
* appropriate function for your layout. Use scrollInWindow if the container
|
6
|
+
* is not scrollable and scrollInElement if the container is a separate
|
7
|
+
* scrolling region.
|
8
|
+
*/
|
9
|
+
Navigation = new function() {
|
10
|
+
this.initNavigation = function() {
|
11
|
+
var _this = this;
|
12
|
+
|
13
|
+
document.addEventListener('keydown', function(e) {
|
14
|
+
_this.onkeydown(e);
|
15
|
+
});
|
16
|
+
|
17
|
+
this.navigationActive = true;
|
18
|
+
}
|
19
|
+
|
20
|
+
this.setNavigationActive = function(state) {
|
21
|
+
this.navigationActive = state;
|
22
|
+
}
|
23
|
+
|
24
|
+
this.onkeydown = function(e) {
|
25
|
+
if (!this.navigationActive) return;
|
26
|
+
switch(e.keyCode) {
|
27
|
+
case 37: //Event.KEY_LEFT:
|
28
|
+
if (this.moveLeft()) e.preventDefault();
|
29
|
+
break;
|
30
|
+
case 38: //Event.KEY_UP:
|
31
|
+
if (e.keyCode == 38 || e.ctrlKey) {
|
32
|
+
if (this.moveUp()) e.preventDefault();
|
33
|
+
}
|
34
|
+
break;
|
35
|
+
case 39: //Event.KEY_RIGHT:
|
36
|
+
if (this.moveRight()) e.preventDefault();
|
37
|
+
break;
|
38
|
+
case 40: //Event.KEY_DOWN:
|
39
|
+
if (e.keyCode == 40 || e.ctrlKey) {
|
40
|
+
if (this.moveDown()) e.preventDefault();
|
41
|
+
}
|
42
|
+
break;
|
43
|
+
case 13: //Event.KEY_RETURN:
|
44
|
+
if (this.current) e.preventDefault();
|
45
|
+
this.select(this.current);
|
46
|
+
break;
|
47
|
+
}
|
48
|
+
if (e.ctrlKey && e.shiftKey) this.select(this.current);
|
49
|
+
}
|
50
|
+
|
51
|
+
this.moveRight = function() {
|
52
|
+
}
|
53
|
+
|
54
|
+
this.moveLeft = function() {
|
55
|
+
}
|
56
|
+
|
57
|
+
this.move = function(isDown) {
|
58
|
+
}
|
59
|
+
|
60
|
+
this.moveUp = function() {
|
61
|
+
return this.move(false);
|
62
|
+
}
|
63
|
+
|
64
|
+
this.moveDown = function() {
|
65
|
+
return this.move(true);
|
66
|
+
}
|
67
|
+
|
68
|
+
/*
|
69
|
+
* Scrolls to the given element in the scrollable element view.
|
70
|
+
*/
|
71
|
+
this.scrollInElement = function(element, view) {
|
72
|
+
var offset, viewHeight, viewScroll, height;
|
73
|
+
offset = element.offsetTop;
|
74
|
+
height = element.offsetHeight;
|
75
|
+
viewHeight = view.offsetHeight;
|
76
|
+
viewScroll = view.scrollTop;
|
77
|
+
|
78
|
+
if (offset - viewScroll + height > viewHeight) {
|
79
|
+
view.scrollTop = offset - viewHeight + height;
|
80
|
+
}
|
81
|
+
if (offset < viewScroll) {
|
82
|
+
view.scrollTop = offset;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
/*
|
87
|
+
* Scrolls to the given element in the window. The second argument is
|
88
|
+
* ignored
|
89
|
+
*/
|
90
|
+
this.scrollInWindow = function(element, ignored) {
|
91
|
+
var offset, viewHeight, viewScroll, height;
|
92
|
+
offset = element.offsetTop;
|
93
|
+
height = element.offsetHeight;
|
94
|
+
viewHeight = window.innerHeight;
|
95
|
+
viewScroll = window.scrollY;
|
96
|
+
|
97
|
+
if (offset - viewScroll + height > viewHeight) {
|
98
|
+
window.scrollTo(window.scrollX, offset - viewHeight + height);
|
99
|
+
}
|
100
|
+
if (offset < viewScroll) {
|
101
|
+
window.scrollTo(window.scrollX, offset);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
Binary file
|
data/doc/js/search.js
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
Search = function(data, input, result) {
|
2
|
+
this.data = data;
|
3
|
+
this.input = input;
|
4
|
+
this.result = result;
|
5
|
+
|
6
|
+
this.current = null;
|
7
|
+
this.view = this.result.parentNode;
|
8
|
+
this.searcher = new Searcher(data.index);
|
9
|
+
this.init();
|
10
|
+
}
|
11
|
+
|
12
|
+
Search.prototype = Object.assign({}, Navigation, new function() {
|
13
|
+
var suid = 1;
|
14
|
+
|
15
|
+
this.init = function() {
|
16
|
+
var _this = this;
|
17
|
+
var observer = function(e) {
|
18
|
+
switch(e.keyCode) {
|
19
|
+
case 38: // Event.KEY_UP
|
20
|
+
case 40: // Event.KEY_DOWN
|
21
|
+
return;
|
22
|
+
}
|
23
|
+
_this.search(_this.input.value);
|
24
|
+
};
|
25
|
+
this.input.addEventListener('keyup', observer);
|
26
|
+
this.input.addEventListener('click', observer); // mac's clear field
|
27
|
+
|
28
|
+
this.searcher.ready(function(results, isLast) {
|
29
|
+
_this.addResults(results, isLast);
|
30
|
+
})
|
31
|
+
|
32
|
+
this.initNavigation();
|
33
|
+
this.setNavigationActive(false);
|
34
|
+
}
|
35
|
+
|
36
|
+
this.search = function(value, selectFirstMatch) {
|
37
|
+
value = value.trim().toLowerCase();
|
38
|
+
if (value) {
|
39
|
+
this.setNavigationActive(true);
|
40
|
+
} else {
|
41
|
+
this.setNavigationActive(false);
|
42
|
+
}
|
43
|
+
|
44
|
+
if (value == '') {
|
45
|
+
this.lastQuery = value;
|
46
|
+
this.result.innerHTML = '';
|
47
|
+
this.result.setAttribute('aria-expanded', 'false');
|
48
|
+
this.setNavigationActive(false);
|
49
|
+
} else if (value != this.lastQuery) {
|
50
|
+
this.lastQuery = value;
|
51
|
+
this.result.setAttribute('aria-busy', 'true');
|
52
|
+
this.result.setAttribute('aria-expanded', 'true');
|
53
|
+
this.firstRun = true;
|
54
|
+
this.searcher.find(value);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
this.addResults = function(results, isLast) {
|
59
|
+
var target = this.result;
|
60
|
+
if (this.firstRun && (results.length > 0 || isLast)) {
|
61
|
+
this.current = null;
|
62
|
+
this.result.innerHTML = '';
|
63
|
+
}
|
64
|
+
|
65
|
+
for (var i=0, l = results.length; i < l; i++) {
|
66
|
+
var item = this.renderItem.call(this, results[i]);
|
67
|
+
item.setAttribute('id', 'search-result-' + target.childElementCount);
|
68
|
+
target.appendChild(item);
|
69
|
+
};
|
70
|
+
|
71
|
+
if (this.firstRun && results.length > 0) {
|
72
|
+
this.firstRun = false;
|
73
|
+
this.current = target.firstChild;
|
74
|
+
this.current.classList.add('search-selected');
|
75
|
+
}
|
76
|
+
//TODO: ECMAScript
|
77
|
+
//if (jQuery.browser.msie) this.$element[0].className += '';
|
78
|
+
|
79
|
+
if (isLast) this.result.setAttribute('aria-busy', 'false');
|
80
|
+
}
|
81
|
+
|
82
|
+
this.move = function(isDown) {
|
83
|
+
if (!this.current) return;
|
84
|
+
var next = isDown ? this.current.nextElementSibling : this.current.previousElementSibling;
|
85
|
+
if (next) {
|
86
|
+
this.current.classList.remove('search-selected');
|
87
|
+
next.classList.add('search-selected');
|
88
|
+
this.input.setAttribute('aria-activedescendant', next.getAttribute('id'));
|
89
|
+
this.scrollIntoView(next, this.view);
|
90
|
+
this.current = next;
|
91
|
+
this.input.value = next.firstChild.firstChild.text;
|
92
|
+
this.input.select();
|
93
|
+
}
|
94
|
+
return true;
|
95
|
+
}
|
96
|
+
|
97
|
+
this.hlt = function(html) {
|
98
|
+
return this.escapeHTML(html).
|
99
|
+
replace(/\u0001/g, '<em>').
|
100
|
+
replace(/\u0002/g, '</em>');
|
101
|
+
}
|
102
|
+
|
103
|
+
this.escapeHTML = function(html) {
|
104
|
+
return html.replace(/[&<>]/g, function(c) {
|
105
|
+
return '&#' + c.charCodeAt(0) + ';';
|
106
|
+
});
|
107
|
+
}
|
108
|
+
|
109
|
+
});
|
110
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
var search_data = {"index":{"searchIndex":["spoonerize","bumper","cli","log","spoonerism","all_excluded_words()","bump()","contents()","each()","enough_flippable_words?()","execute()","lazy?()","longest_word_length()","map?()","new()","new()","new()","new()","print?()","print_log()","print_mappings()","reverse?()","reverse?()","save()","save?()","size()","spoonerism()","spoonerize()","to_h()","to_json()","to_s()","write()","readme"],"longSearchIndex":["spoonerize","spoonerize::bumper","spoonerize::cli","spoonerize::log","spoonerize::spoonerism","spoonerize::spoonerism#all_excluded_words()","spoonerize::bumper#bump()","spoonerize::log#contents()","spoonerize::log#each()","spoonerize::spoonerism#enough_flippable_words?()","spoonerize::cli::execute()","spoonerize::spoonerism#lazy?()","spoonerize::cli#longest_word_length()","spoonerize::cli#map?()","spoonerize::bumper::new()","spoonerize::cli::new()","spoonerize::log::new()","spoonerize::spoonerism::new()","spoonerize::cli#print?()","spoonerize::cli#print_log()","spoonerize::cli#print_mappings()","spoonerize::bumper#reverse?()","spoonerize::spoonerism#reverse?()","spoonerize::spoonerism#save()","spoonerize::cli#save?()","spoonerize::log#size()","spoonerize::cli#spoonerism()","spoonerize::spoonerism#spoonerize()","spoonerize::spoonerism#to_h()","spoonerize::spoonerism#to_json()","spoonerize::spoonerism#to_s()","spoonerize::log#write()",""],"info":[["Spoonerize","","Spoonerize.html","","<p>The main namespace for the gem.\n"],["Spoonerize::Bumper","","Spoonerize/Bumper.html","","<p>Class that handles bumping an index.\n"],["Spoonerize::Cli","","Spoonerize/Cli.html","","<p>The class for handling the command-line interface.\n"],["Spoonerize::Log","","Spoonerize/Log.html","","<p>Class that handles reading/writing logs.\n"],["Spoonerize::Spoonerism","","Spoonerize/Spoonerism.html","","<p>The main word-flipper.\n"],["all_excluded_words","Spoonerize::Spoonerism","Spoonerize/Spoonerism.html#method-i-all_excluded_words","()","<p>Returns an array of words to exclude by combining three arrays:\n<p>Any word in the passed arguments that's …\n"],["bump","Spoonerize::Bumper","Spoonerize/Bumper.html#method-i-bump","()","<p>Increments/Decrements the bumper. If on the last element of the words array, sets the bumper to 0. We …\n"],["contents","Spoonerize::Log","Spoonerize/Log.html#method-i-contents","()","<p>The contents of the log file.\n<p>@return [Array]\n"],["each","Spoonerize::Log","Spoonerize/Log.html#method-i-each","()","<p>Iterate through each line of the file.\n<p>@return [Array]\n"],["enough_flippable_words?","Spoonerize::Spoonerism","Spoonerize/Spoonerism.html#method-i-enough_flippable_words-3F","()","<p>Returns true if there are more than one non-excluded word to flip\n"],["execute","Spoonerize::Cli","Spoonerize/Cli.html#method-c-execute","(options = [])","<p>Creates an instance of <code>StandupMD</code> and runs what the user requested.\n<p>@param [Array] options\n"],["lazy?","Spoonerize::Spoonerism","Spoonerize/Spoonerism.html#method-i-lazy-3F","()","<p>Should the lazy words be excluded?\n"],["longest_word_length","Spoonerize::Cli","Spoonerize/Cli.html#method-i-longest_word_length","()","<p>The length of the longest word in the phrase.\n<p>@return [Integer]\n"],["map?","Spoonerize::Cli","Spoonerize/Cli.html#method-i-map-3F","()","<p>Should we print the mappings to the command line?\n<p>@return [Boolean]\n"],["new","Spoonerize::Bumper","Spoonerize/Bumper.html#method-c-new","(initial_value, max_value, reverse = false)","<p>Sets the bumper relative to the current index of words array. The value is automatically bumped once …\n"],["new","Spoonerize::Cli","Spoonerize/Cli.html#method-c-new","(options)","<p>Create instance of <code>Cli</code>\n<p>@param [Array] options\n<p>@return [self]\n"],["new","Spoonerize::Log","Spoonerize/Log.html#method-c-new","(file)","<p>Constructor for Log.\n<p>@param [String] file\n<p>@return [Spoonerize::Log]\n"],["new","Spoonerize::Spoonerism","Spoonerize/Spoonerism.html#method-c-new","(words)","<p>Initialize instance and raise if there aren't enough words to flip.\n<p>@param [Array] words\n"],["print?","Spoonerize::Cli","Spoonerize/Cli.html#method-i-print-3F","()","<p>Should we print to the command line?\n<p>@return [Boolean]\n"],["print_log","Spoonerize::Cli","Spoonerize/Cli.html#method-i-print_log","()","<p>Print the log file contents to the command line.\n<p>@return [nil]\n"],["print_mappings","Spoonerize::Cli","Spoonerize/Cli.html#method-i-print_mappings","()","<p>Print the hash of mappings to the command line.\n<p>@return [nil]\n"],["reverse?","Spoonerize::Bumper","Spoonerize/Bumper.html#method-i-reverse-3F","()","<p>Should we decrement instead of increment?\n<p>@return [Boolean]\n"],["reverse?","Spoonerize::Spoonerism","Spoonerize/Spoonerism.html#method-i-reverse-3F","()","<p>Should the words flip the other direction?\n"],["save","Spoonerize::Spoonerism","Spoonerize/Spoonerism.html#method-i-save","()","<p>Saves the flipped words to the log file, along with the options\n"],["save?","Spoonerize::Cli","Spoonerize/Cli.html#method-i-save-3F","()","<p>Should we save to the log file?\n<p>@return [Boolean]\n"],["size","Spoonerize::Log","Spoonerize/Log.html#method-i-size","()","<p>Number of entries in the file.\n<p>@return [Integer]\n"],["spoonerism","Spoonerize::Cli","Spoonerize/Cli.html#method-i-spoonerism","()","<p>Sets up an instance of <code>Spoonerize::Spoonerism</code> and passes all user preferences.\n<p>@return [Spoonerize::Spoonerism] …\n"],["spoonerize","Spoonerize::Spoonerism","Spoonerize/Spoonerism.html#method-i-spoonerize","()","<p>Iterates through words array, and maps its elements to the output of flip_words. Returns results as an …\n"],["to_h","Spoonerize::Spoonerism","Spoonerize/Spoonerism.html#method-i-to_h","()","<p>Returns hash of the original words mapped to their flipped counterparts.\n"],["to_json","Spoonerize::Spoonerism","Spoonerize/Spoonerism.html#method-i-to_json","()","<p>Same as to_h, but as json.\n"],["to_s","Spoonerize::Spoonerism","Spoonerize/Spoonerism.html#method-i-to_s","()","<p>Returns spoonerize array as a joined string.\n"],["write","Spoonerize::Log","Spoonerize/Log.html#method-i-write","(row)","<p>Writes a line to the log.\n<p>@param [Array] row\n<p>@return [Array]\n"],["README","","README_md.html","","<p>Welcome to Spoonerize – a word game\n\n<blockquote><p>Sponerism <em>noun</em> a verbal error in which a speaker accidentally transposes …\n</blockquote>\n"]]}}
|
Binary file
|