chess 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +1 -1
  3. data/Rakefile +3 -4
  4. data/chess.gemspec +5 -0
  5. data/doc/Chess.html +112 -0
  6. data/doc/Chess/BadNotationError.html +107 -0
  7. data/doc/Chess/Board.html +703 -0
  8. data/doc/Chess/CGame.html +1005 -0
  9. data/doc/Chess/Game.html +684 -0
  10. data/doc/Chess/Gnuchess.html +215 -0
  11. data/doc/Chess/IllegalMoveError.html +105 -0
  12. data/doc/Chess/InvalidFenFormatError.html +105 -0
  13. data/doc/Chess/InvalidPgnFormatError.html +105 -0
  14. data/doc/Chess/Pgn.html +309 -0
  15. data/doc/Chess/UTF8Notation.html +174 -0
  16. data/doc/README_rdoc.html +143 -0
  17. data/doc/created.rid +15 -15
  18. data/doc/css/fonts.css +167 -0
  19. data/doc/css/rdoc.css +590 -0
  20. data/doc/fonts/Lato-Light.ttf +0 -0
  21. data/doc/fonts/Lato-LightItalic.ttf +0 -0
  22. data/doc/fonts/Lato-Regular.ttf +0 -0
  23. data/doc/fonts/Lato-RegularItalic.ttf +0 -0
  24. data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
  25. data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
  26. data/doc/images/add.png +0 -0
  27. data/doc/images/arrow_up.png +0 -0
  28. data/doc/images/brick.png +0 -0
  29. data/doc/images/brick_link.png +0 -0
  30. data/doc/images/bug.png +0 -0
  31. data/doc/images/bullet_black.png +0 -0
  32. data/doc/images/bullet_toggle_minus.png +0 -0
  33. data/doc/images/bullet_toggle_plus.png +0 -0
  34. data/doc/images/date.png +0 -0
  35. data/doc/images/delete.png +0 -0
  36. data/doc/images/find.png +0 -0
  37. data/doc/images/loadingAnimation.gif +0 -0
  38. data/doc/images/macFFBgHack.png +0 -0
  39. data/doc/images/package.png +0 -0
  40. data/doc/images/page_green.png +0 -0
  41. data/doc/images/page_white_text.png +0 -0
  42. data/doc/images/page_white_width.png +0 -0
  43. data/doc/images/plugin.png +0 -0
  44. data/doc/images/ruby.png +0 -0
  45. data/doc/images/tag_blue.png +0 -0
  46. data/doc/images/tag_green.png +0 -0
  47. data/doc/images/transparent.png +0 -0
  48. data/doc/images/wrench.png +0 -0
  49. data/doc/images/wrench_orange.png +0 -0
  50. data/doc/images/zoom.png +0 -0
  51. data/doc/index.html +159 -12
  52. data/doc/js/darkfish.js +161 -0
  53. data/doc/js/jquery.js +4 -0
  54. data/doc/js/navigation.js.gz +0 -0
  55. data/doc/js/search.js +109 -0
  56. data/doc/js/search_index.js +1 -1
  57. data/doc/js/search_index.js.gz +0 -0
  58. data/doc/js/searcher.js +1 -0
  59. data/doc/js/searcher.js.gz +0 -0
  60. data/doc/table_of_contents.html +331 -0
  61. data/ext/chess.c +5 -2
  62. data/ext/game.c +1 -1
  63. data/ext/game.h +1 -1
  64. data/lib/chess/game.rb +1 -1
  65. data/lib/chess/pgn.rb +5 -1
  66. data/lib/chess/version.rb +1 -1
  67. metadata +112 -46
  68. data/doc/apple-touch-icon.png +0 -0
  69. data/doc/classes/Chess.html +0 -162
  70. data/doc/classes/Chess/BadNotationError.html +0 -84
  71. data/doc/classes/Chess/Board.html +0 -795
  72. data/doc/classes/Chess/CGame.html +0 -1168
  73. data/doc/classes/Chess/Game.html +0 -775
  74. data/doc/classes/Chess/Gnuchess.html +0 -206
  75. data/doc/classes/Chess/IllegalMoveError.html +0 -82
  76. data/doc/classes/Chess/InvalidFenFormatError.html +0 -82
  77. data/doc/classes/Chess/InvalidPgnFormatError.html +0 -82
  78. data/doc/classes/Chess/Pgn.html +0 -332
  79. data/doc/classes/Chess/UTF8Notation.html +0 -175
  80. data/doc/css/github.css +0 -123
  81. data/doc/css/main.css +0 -323
  82. data/doc/css/panel.css +0 -384
  83. data/doc/css/reset.css +0 -48
  84. data/doc/favicon.ico +0 -0
  85. data/doc/files/README_rdoc.html +0 -122
  86. data/doc/files/ext/bitboard_c.html +0 -68
  87. data/doc/files/ext/board_c.html +0 -68
  88. data/doc/files/ext/chess_c.html +0 -68
  89. data/doc/files/ext/common_c.html +0 -68
  90. data/doc/files/ext/game_c.html +0 -68
  91. data/doc/files/ext/special_c.html +0 -68
  92. data/doc/files/lib/chess/exceptions_rb.html +0 -94
  93. data/doc/files/lib/chess/game_rb.html +0 -84
  94. data/doc/files/lib/chess/gnuchess_rb.html +0 -84
  95. data/doc/files/lib/chess/pgn_rb.html +0 -84
  96. data/doc/files/lib/chess/utf8_notation_rb.html +0 -84
  97. data/doc/files/lib/chess/version_rb.html +0 -85
  98. data/doc/files/lib/chess_rb.html +0 -84
  99. data/doc/i/arrows.png +0 -0
  100. data/doc/i/results_bg.png +0 -0
  101. data/doc/i/tree_bg.png +0 -0
  102. data/doc/js/highlight.pack.js +0 -1
  103. data/doc/js/jquery-1.3.2.min.js +0 -19
  104. data/doc/js/jquery-effect.js +0 -593
  105. data/doc/js/main.js +0 -24
  106. data/doc/js/searchdoc.js +0 -449
  107. data/doc/panel/index.html +0 -73
  108. data/doc/panel/links.html +0 -34
  109. data/doc/panel/tree.js +0 -1
@@ -1,24 +0,0 @@
1
- function toggleSource(id)
2
- {
3
- var src = $('#' + id).toggle();
4
- var isVisible = src.is(':visible');
5
- $('#l_' + id).html(isVisible ? 'hide' : 'show');
6
- if (!src.data('syntax-higlighted')) {
7
- src.data('syntax-higlighted', 1);
8
- hljs.highlightBlock(src[0]);
9
- }
10
- }
11
-
12
- window.highlight = function(url) {
13
- var hash = url.match(/#([^#]+)$/)
14
- if(hash) {
15
- $('a[name=' + hash[1] + ']').parent().effect('highlight', {}, 'slow')
16
- }
17
- }
18
-
19
- $(function() {
20
- highlight('#' + location.hash);
21
- $('.description pre').each(function() {
22
- hljs.highlightBlock(this);
23
- });
24
- });
@@ -1,449 +0,0 @@
1
- Searchdoc = {};
2
-
3
- // navigation.js ------------------------------------------
4
-
5
- Searchdoc.Navigation = new function() {
6
- this.initNavigation = function() {
7
- var _this = this;
8
-
9
- $(document).keydown(function(e) {
10
- _this.onkeydown(e);
11
- }).keyup(function(e) {
12
- _this.onkeyup(e);
13
- });
14
-
15
- this.navigationActive = true;
16
- }
17
-
18
- this.setNavigationActive = function(state) {
19
- this.navigationActive = state;
20
- this.clearMoveTimeout();
21
- }
22
-
23
-
24
- this.onkeyup = function(e) {
25
- if (!this.navigationActive) return;
26
- switch(e.keyCode) {
27
- case 37: //Event.KEY_LEFT:
28
- case 38: //Event.KEY_UP:
29
- case 39: //Event.KEY_RIGHT:
30
- case 40: //Event.KEY_DOWN:
31
- case 73: // i - qwerty
32
- case 74: // j
33
- case 75: // k
34
- case 76: // l
35
- case 67: // c - dvorak
36
- case 72: // h
37
- case 84: // t
38
- case 78: // n
39
- this.clearMoveTimeout();
40
- break;
41
- }
42
- }
43
-
44
- this.onkeydown = function(e) {
45
- if (!this.navigationActive) return;
46
- switch(e.keyCode) {
47
- case 37: //Event.KEY_LEFT:
48
- case 74: // j (qwerty)
49
- case 72: // h (dvorak)
50
- if (this.moveLeft()) e.preventDefault();
51
- break;
52
- case 38: //Event.KEY_UP:
53
- case 73: // i (qwerty)
54
- case 67: // c (dvorak)
55
- if (e.keyCode == 38 || e.ctrlKey) {
56
- if (this.moveUp()) e.preventDefault();
57
- this.startMoveTimeout(false);
58
- }
59
- break;
60
- case 39: //Event.KEY_RIGHT:
61
- case 76: // l (qwerty)
62
- case 78: // n (dvorak)
63
- if (this.moveRight()) e.preventDefault();
64
- break;
65
- case 40: //Event.KEY_DOWN:
66
- case 75: // k (qwerty)
67
- case 84: // t (dvorak)
68
- if (e.keyCode == 40 || e.ctrlKey) {
69
- if (this.moveDown()) e.preventDefault();
70
- this.startMoveTimeout(true);
71
- }
72
- break;
73
- case 9: //Event.KEY_TAB:
74
- case 13: //Event.KEY_RETURN:
75
- if (this.$current) this.select(this.$current);
76
- break;
77
- case 83: // s (qwerty)
78
- case 79: // o (dvorak)
79
- if (e.ctrlKey) {
80
- $('#search').focus();
81
- e.preventDefault();
82
- }
83
- break;
84
- }
85
- if (e.ctrlKey && e.shiftKey) this.select(this.$current);
86
- }
87
-
88
- this.clearMoveTimeout = function() {
89
- clearTimeout(this.moveTimeout);
90
- this.moveTimeout = null;
91
- }
92
-
93
- this.startMoveTimeout = function(isDown) {
94
- if (!$.browser.mozilla && !$.browser.opera) return;
95
- if (this.moveTimeout) this.clearMoveTimeout();
96
- var _this = this;
97
-
98
- var go = function() {
99
- if (!_this.moveTimeout) return;
100
- _this[isDown ? 'moveDown' : 'moveUp']();
101
- _this.moveTimout = setTimeout(go, 100);
102
- }
103
- this.moveTimeout = setTimeout(go, 200);
104
- }
105
-
106
- this.moveRight = function() {
107
- }
108
-
109
- this.moveLeft = function() {
110
- }
111
-
112
- this.move = function(isDown) {
113
- }
114
-
115
- this.moveUp = function() {
116
- return this.move(false);
117
- }
118
-
119
- this.moveDown = function() {
120
- return this.move(true);
121
- }
122
- }
123
-
124
-
125
- // scrollIntoView.js --------------------------------------
126
-
127
- function scrollIntoView(element, view) {
128
- var offset, viewHeight, viewScroll, height;
129
- offset = element.offsetTop;
130
- height = element.offsetHeight;
131
- viewHeight = view.offsetHeight;
132
- viewScroll = view.scrollTop;
133
- if (offset - viewScroll + height > viewHeight) {
134
- view.scrollTop = offset - viewHeight + height;
135
- }
136
- if (offset < viewScroll) {
137
- view.scrollTop = offset;
138
- }
139
- }
140
-
141
- // panel.js -----------------------------------------------
142
-
143
- Searchdoc.Panel = function(element, data, tree, frame) {
144
- this.$element = $(element);
145
- this.$input = $('input', element).eq(0);
146
- this.$result = $('.result ul', element).eq(0);
147
- this.frame = frame;
148
- this.$current = null;
149
- this.$view = this.$result.parent();
150
- this.data = data;
151
- this.searcher = new Searcher(data.index);
152
-
153
- this.tree = new Searchdoc.Tree($('.tree', element), tree, this);
154
- this.init();
155
- }
156
-
157
- Searchdoc.Panel.prototype = $.extend({}, Searchdoc.Navigation, new function() {
158
- var suid = 1;
159
-
160
- this.init = function() {
161
- var _this = this;
162
- var observer = function() {
163
- _this.search(_this.$input[0].value);
164
- };
165
- this.$input.keyup(observer);
166
- this.$input.click(observer); // mac's clear field
167
-
168
- this.searcher.ready(function(results, isLast) {
169
- _this.addResults(results, isLast);
170
- })
171
-
172
- this.$result.click(function(e) {
173
- _this.$current.removeClass('current');
174
- _this.$current = $(e.target).closest('li').addClass('current');
175
- _this.select();
176
- _this.$input.focus();
177
- });
178
-
179
- this.initNavigation();
180
- this.setNavigationActive(false);
181
- }
182
-
183
- this.search = function(value, selectFirstMatch) {
184
- value = jQuery.trim(value).toLowerCase();
185
- this.selectFirstMatch = selectFirstMatch;
186
- if (value) {
187
- this.$element.removeClass('panel_tree').addClass('panel_results');
188
- this.tree.setNavigationActive(false);
189
- this.setNavigationActive(true);
190
- } else {
191
- this.$element.addClass('panel_tree').removeClass('panel_results');
192
- this.tree.setNavigationActive(true);
193
- this.setNavigationActive(false);
194
- }
195
- if (value != this.lastQuery) {
196
- this.lastQuery = value;
197
- this.firstRun = true;
198
- this.searcher.find(value);
199
- }
200
- }
201
-
202
- this.addResults = function(results, isLast) {
203
- var target = this.$result.get(0);
204
- if (this.firstRun && (results.length > 0 || isLast)) {
205
- this.$current = null;
206
- this.$result.empty();
207
- }
208
- for (var i=0, l = results.length; i < l; i++) {
209
- target.appendChild(renderItem.call(this, results[i]));
210
- };
211
- if (this.firstRun && results.length > 0) {
212
- this.firstRun = false;
213
- this.$current = $(target.firstChild);
214
- this.$current.addClass('current');
215
- if (this.selectFirstMatch) this.select();
216
- scrollIntoView(this.$current[0], this.$view[0])
217
- }
218
- if (jQuery.browser.msie) this.$element[0].className += '';
219
- }
220
-
221
- this.open = function(src) {
222
- this.frame.location.href = '../' + src;
223
- if (this.frame.highlight) this.frame.highlight(src);
224
- }
225
-
226
- this.select = function() {
227
- this.open(this.$current.data('path'));
228
- }
229
-
230
- this.move = function(isDown) {
231
- if (!this.$current) return;
232
- var $next = this.$current[isDown ? 'next' : 'prev']();
233
- if ($next.length) {
234
- this.$current.removeClass('current');
235
- $next.addClass('current');
236
- scrollIntoView($next[0], this.$view[0]);
237
- this.$current = $next;
238
- }
239
- return true;
240
- }
241
-
242
- function renderItem(result) {
243
- var li = document.createElement('li'),
244
- html = '', badge = result.badge;
245
- html += '<h1>' + hlt(result.title);
246
- if (result.params) html += '<i>' + result.params + '</i>';
247
- html += '</h1>';
248
- html += '<p>';
249
- if (typeof badge != 'undefined') {
250
- html += '<span class="badge badge_' + (badge % 6 + 1) + '">' + escapeHTML(this.data.badges[badge] || 'unknown') + '</span>';
251
- }
252
- html += hlt(result.namespace) + '</p>';
253
- if (result.snippet) html += '<p class="snippet">' + escapeHTML(result.snippet.replace(/^<p>/, '')) + '</p>';
254
- li.innerHTML = html;
255
- jQuery.data(li, 'path', result.path);
256
- return li;
257
- }
258
-
259
- function hlt(html) {
260
- return escapeHTML(html).replace(/\u0001/g, '<b>').replace(/\u0002/g, '</b>')
261
- }
262
-
263
- function escapeHTML(html) {
264
- return html.replace(/[&<>]/g, function(c) {
265
- return '&#' + c.charCodeAt(0) + ';';
266
- });
267
- }
268
-
269
- });
270
-
271
- // tree.js ------------------------------------------------
272
-
273
- Searchdoc.Tree = function(element, tree, panel) {
274
- this.$element = $(element);
275
- this.$list = $('ul', element);
276
- this.tree = tree;
277
- this.panel = panel;
278
- this.init();
279
- }
280
-
281
- Searchdoc.Tree.prototype = $.extend({}, Searchdoc.Navigation, new function() {
282
- this.init = function() {
283
- var stopper = document.createElement('li');
284
- stopper.className = 'stopper';
285
- this.$list[0].appendChild(stopper);
286
- for (var i=0, l = this.tree.length; i < l; i++) {
287
- buildAndAppendItem.call(this, this.tree[i], 0, stopper);
288
- };
289
- var _this = this;
290
- this.$list.click(function(e) {
291
- var $target = $(e.target),
292
- $li = $target.closest('li');
293
- if ($target.hasClass('icon')) {
294
- _this.toggle($li);
295
- } else {
296
- _this.select($li);
297
- }
298
- })
299
-
300
- this.initNavigation();
301
- if (jQuery.browser.msie) document.body.className += '';
302
- }
303
-
304
- this.select = function($li) {
305
- this.highlight($li);
306
- var path = $li[0].searchdoc_tree_data.path;
307
- if (path) this.panel.open(path);
308
- }
309
-
310
- this.highlight = function($li) {
311
- if (this.$current) this.$current.removeClass('current');
312
- this.$current = $li.addClass('current');
313
- }
314
-
315
- this.toggle = function($li) {
316
- var closed = !$li.hasClass('closed'),
317
- children = $li[0].searchdoc_tree_data.children;
318
- $li.toggleClass('closed');
319
- for (var i=0, l = children.length; i < l; i++) {
320
- toggleVis.call(this, $(children[i].li), !closed);
321
- };
322
- }
323
-
324
- this.moveRight = function() {
325
- if (!this.$current) {
326
- this.highlight(this.$list.find('li:first'));
327
- return;
328
- }
329
- if (this.$current.hasClass('closed')) {
330
- this.toggle(this.$current);
331
- }
332
- }
333
-
334
- this.moveLeft = function() {
335
- if (!this.$current) {
336
- this.highlight(this.$list.find('li:first'));
337
- return;
338
- }
339
- if (!this.$current.hasClass('closed')) {
340
- this.toggle(this.$current);
341
- } else {
342
- var level = this.$current[0].searchdoc_tree_data.level;
343
- if (level == 0) return;
344
- var $next = this.$current.prevAll('li.level_' + (level - 1) + ':visible:first');
345
- this.$current.removeClass('current');
346
- $next.addClass('current');
347
- scrollIntoView($next[0], this.$element[0]);
348
- this.$current = $next;
349
- }
350
- }
351
-
352
- this.move = function(isDown) {
353
- if (!this.$current) {
354
- this.highlight(this.$list.find('li:first'));
355
- return true;
356
- }
357
- var next = this.$current[0];
358
- if (isDown) {
359
- do {
360
- next = next.nextSibling;
361
- if (next && next.style && next.style.display != 'none') break;
362
- } while(next);
363
- } else {
364
- do {
365
- next = next.previousSibling;
366
- if (next && next.style && next.style.display != 'none') break;
367
- } while(next);
368
- }
369
- if (next && next.className.indexOf('stopper') == -1) {
370
- this.$current.removeClass('current');
371
- $(next).addClass('current');
372
- scrollIntoView(next, this.$element[0]);
373
- this.$current = $(next);
374
- }
375
- return true;
376
- }
377
-
378
- function toggleVis($li, show) {
379
- var closed = $li.hasClass('closed'),
380
- children = $li[0].searchdoc_tree_data.children;
381
- $li.css('display', show ? '' : 'none')
382
- if (!show && this.$current && $li[0] == this.$current[0]) {
383
- this.$current.removeClass('current');
384
- this.$current = null;
385
- }
386
- for (var i=0, l = children.length; i < l; i++) {
387
- toggleVis.call(this, $(children[i].li), show && !closed);
388
- };
389
- }
390
-
391
- function buildAndAppendItem(item, level, before) {
392
- var li = renderItem(item, level),
393
- list = this.$list[0];
394
- item.li = li;
395
- list.insertBefore(li, before);
396
- for (var i=0, l = item[3].length; i < l; i++) {
397
- buildAndAppendItem.call(this, item[3][i], level + 1, before);
398
- };
399
- return li;
400
- }
401
-
402
- function renderItem(item, level) {
403
- var li = document.createElement('li'),
404
- cnt = document.createElement('div'),
405
- h1 = document.createElement('h1'),
406
- p = document.createElement('p'),
407
- icon, i;
408
-
409
- li.appendChild(cnt);
410
- li.style.paddingLeft = getOffset(level);
411
- cnt.className = 'content';
412
- if (!item[1]) li.className = 'empty ';
413
- cnt.appendChild(h1);
414
- // cnt.appendChild(p);
415
- h1.appendChild(document.createTextNode(item[0]));
416
- // p.appendChild(document.createTextNode(item[4]));
417
- if (item[2]) {
418
- i = document.createElement('i');
419
- i.appendChild(document.createTextNode(item[2]));
420
- h1.appendChild(i);
421
- }
422
- if (item[3].length > 0) {
423
- icon = document.createElement('div');
424
- icon.className = 'icon';
425
- cnt.appendChild(icon);
426
- }
427
-
428
- // user direct assignement instead of $()
429
- // it's 8x faster
430
- // $(li).data('path', item[1])
431
- // .data('children', item[3])
432
- // .data('level', level)
433
- // .css('display', level == 0 ? '' : 'none')
434
- // .addClass('level_' + level)
435
- // .addClass('closed');
436
- li.searchdoc_tree_data = {
437
- path: item[1],
438
- children: item[3],
439
- level: level
440
- }
441
- li.style.display = level == 0 ? '' : 'none';
442
- li.className += 'level_' + level + ' closed';
443
- return li;
444
- }
445
-
446
- function getOffset(level) {
447
- return 5 + 18*level + 'px';
448
- }
449
- });