corl 0.5.1 → 0.5.2

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.
Files changed (241) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/Gemfile.lock +8 -6
  4. data/VERSION +1 -1
  5. data/bootstrap/os/ubuntu/00_base.sh +2 -2
  6. data/bootstrap/os/ubuntu/05_ruby.sh +14 -2
  7. data/corl.gemspec +175 -5
  8. data/lib/CORL/builder/identity.rb +1 -1
  9. data/lib/CORL/builder/package.rb +1 -1
  10. data/lib/CORL/configuration/file.rb +7 -13
  11. data/lib/CORL/machine/physical.rb +1 -1
  12. data/lib/CORL/machine/vagrant.rb +12 -4
  13. data/lib/CORL/network/CORL.rb +1 -1
  14. data/lib/CORL/node/AWS.rb +25 -23
  15. data/lib/CORL/node/local.rb +1 -1
  16. data/lib/CORL/node/rackspace.rb +13 -15
  17. data/lib/CORL/node/vagrant.rb +1 -1
  18. data/lib/CORL/provisioner/puppetnode.rb +1 -1
  19. data/lib/core/mixin/action/keypair.rb +6 -6
  20. data/lib/core/mixin/action/registration.rb +39 -11
  21. data/lib/core/mod/fog_aws_server.rb +1 -3
  22. data/lib/core/plugin/builder.rb +1 -1
  23. data/lib/core/plugin/cloud_action.rb +59 -49
  24. data/lib/core/plugin/configuration.rb +4 -3
  25. data/lib/core/plugin/fog_machine.rb +10 -2
  26. data/lib/core/plugin/fog_node.rb +10 -4
  27. data/lib/core/plugin/machine.rb +2 -8
  28. data/lib/core/plugin/network.rb +9 -3
  29. data/lib/core/plugin/node.rb +30 -31
  30. data/lib/core/plugin/provisioner.rb +1 -1
  31. data/lib/core/vagrant/Vagrantfile +4 -1
  32. data/lib/core/vagrant/plugins.rb +6 -4
  33. data/lib/corl.rb +1 -1
  34. data/lib/nucleon/action/cloud/config.rb +167 -100
  35. data/lib/nucleon/action/cloud/create.rb +5 -1
  36. data/lib/nucleon/action/cloud/images.rb +10 -7
  37. data/lib/nucleon/action/cloud/inspect.rb +8 -6
  38. data/lib/nucleon/action/cloud/machines.rb +10 -7
  39. data/lib/nucleon/action/cloud/regions.rb +13 -8
  40. data/lib/nucleon/action/cloud/remote.rb +68 -0
  41. data/lib/nucleon/action/cloud/settings.rb +33 -47
  42. data/lib/nucleon/action/cloud/vagrantfile.rb +34 -17
  43. data/lib/nucleon/action/node/IP.rb +2 -2
  44. data/lib/nucleon/action/node/SSH.rb +3 -3
  45. data/lib/nucleon/action/node/authorize.rb +2 -2
  46. data/lib/nucleon/action/node/bootstrap.rb +17 -30
  47. data/lib/nucleon/action/node/build.rb +4 -4
  48. data/lib/nucleon/action/node/cache.rb +2 -4
  49. data/lib/nucleon/action/node/destroy.rb +25 -26
  50. data/lib/nucleon/action/node/exec.rb +2 -2
  51. data/lib/nucleon/action/node/fact.rb +10 -5
  52. data/lib/nucleon/action/node/group.rb +10 -5
  53. data/lib/nucleon/action/node/identity.rb +6 -8
  54. data/lib/nucleon/action/node/image.rb +3 -3
  55. data/lib/nucleon/action/node/keypair.rb +2 -2
  56. data/lib/nucleon/action/node/lookup.rb +2 -4
  57. data/lib/nucleon/action/node/provision.rb +2 -2
  58. data/lib/nucleon/action/node/reboot.rb +3 -3
  59. data/lib/nucleon/action/node/revoke.rb +2 -2
  60. data/lib/nucleon/action/node/seed.rb +28 -43
  61. data/lib/nucleon/action/node/spawn.rb +19 -14
  62. data/lib/nucleon/action/node/start.rb +3 -3
  63. data/lib/nucleon/action/node/status.rb +8 -8
  64. data/lib/nucleon/action/node/stop.rb +3 -3
  65. data/lib/nucleon/action/plugin/create.rb +10 -13
  66. data/lib/nucleon/action/plugin/list.rb +7 -7
  67. data/lib/nucleon/action/plugin/template/nucleon.action.erb +2 -2
  68. data/lib/nucleon/action/plugins.rb +12 -1
  69. data/lib/nucleon/event/puppet.rb +1 -1
  70. data/lib/nucleon/extension/corl_config.rb +26 -0
  71. data/lib/nucleon/template/environment.rb +1 -1
  72. data/locales/en.yml +483 -90
  73. data/rdoc/site/0.5.1/CORL/Build.html +781 -0
  74. data/rdoc/site/0.5.1/CORL/Builder/Identity.html +596 -0
  75. data/rdoc/site/0.5.1/CORL/Builder/Package.html +600 -0
  76. data/rdoc/site/0.5.1/CORL/Builder.html +384 -0
  77. data/rdoc/site/0.5.1/CORL/Configuration/File.html +1186 -0
  78. data/rdoc/site/0.5.1/CORL/Configuration.html +383 -0
  79. data/rdoc/site/0.5.1/CORL/Errors.html +383 -0
  80. data/rdoc/site/0.5.1/CORL/Facade.html +927 -0
  81. data/rdoc/site/0.5.1/CORL/Machine/AWS.html +777 -0
  82. data/rdoc/site/0.5.1/CORL/Machine/Fog.html +1313 -0
  83. data/rdoc/site/0.5.1/CORL/Machine/Physical.html +1083 -0
  84. data/rdoc/site/0.5.1/CORL/Machine/Rackspace.html +558 -0
  85. data/rdoc/site/0.5.1/CORL/Machine/Vagrant.html +1344 -0
  86. data/rdoc/site/0.5.1/CORL/Machine.html +387 -0
  87. data/rdoc/site/0.5.1/CORL/Mixin/Action/Keypair.html +616 -0
  88. data/rdoc/site/0.5.1/CORL/Mixin/Action/Registration.html +469 -0
  89. data/rdoc/site/0.5.1/CORL/Mixin/Action.html +384 -0
  90. data/rdoc/site/0.5.1/CORL/Mixin/Builder/Global.html +628 -0
  91. data/rdoc/site/0.5.1/CORL/Mixin/Builder/Instance.html +720 -0
  92. data/rdoc/site/0.5.1/CORL/Mixin/Builder.html +383 -0
  93. data/rdoc/site/0.5.1/CORL/Mixin/Lookup.html +1315 -0
  94. data/rdoc/site/0.5.1/CORL/Mixin/Machine/SSH.html +699 -0
  95. data/rdoc/site/0.5.1/CORL/Mixin/Machine.html +383 -0
  96. data/rdoc/site/0.5.1/CORL/Mixin/Macro/NetworkSettings.html +508 -0
  97. data/rdoc/site/0.5.1/CORL/Mixin/Macro.html +383 -0
  98. data/rdoc/site/0.5.1/CORL/Mixin.html +388 -0
  99. data/rdoc/site/0.5.1/CORL/Network/CORL.html +435 -0
  100. data/rdoc/site/0.5.1/CORL/Network.html +383 -0
  101. data/rdoc/site/0.5.1/CORL/Node/AWS.html +760 -0
  102. data/rdoc/site/0.5.1/CORL/Node/Fog.html +1268 -0
  103. data/rdoc/site/0.5.1/CORL/Node/Local.html +468 -0
  104. data/rdoc/site/0.5.1/CORL/Node/Rackspace.html +753 -0
  105. data/rdoc/site/0.5.1/CORL/Node/Vagrant.html +1497 -0
  106. data/rdoc/site/0.5.1/CORL/Node.html +387 -0
  107. data/rdoc/site/0.5.1/CORL/Plugin/Builder.html +524 -0
  108. data/rdoc/site/0.5.1/CORL/Plugin/Configuration.html +1294 -0
  109. data/rdoc/site/0.5.1/CORL/Plugin/Machine.html +1323 -0
  110. data/rdoc/site/0.5.1/CORL/Plugin/Network.html +1766 -0
  111. data/rdoc/site/0.5.1/CORL/Plugin/Node.html +4263 -0
  112. data/rdoc/site/0.5.1/CORL/Plugin/Provisioner.html +1139 -0
  113. data/rdoc/site/0.5.1/CORL/Plugin.html +673 -0
  114. data/rdoc/site/0.5.1/CORL/Provisioner/Puppetnode.html +1201 -0
  115. data/rdoc/site/0.5.1/CORL/Provisioner.html +383 -0
  116. data/rdoc/site/0.5.1/CORL/Util/Puppet/Resource.html +1082 -0
  117. data/rdoc/site/0.5.1/CORL/Util/Puppet/ResourceGroup.html +964 -0
  118. data/rdoc/site/0.5.1/CORL/Util/Puppet.html +1131 -0
  119. data/rdoc/site/0.5.1/CORL/Util.html +385 -0
  120. data/rdoc/site/0.5.1/CORL/Vagrant/Config.html +967 -0
  121. data/rdoc/site/0.5.1/CORL/Vagrant.html +462 -0
  122. data/rdoc/site/0.5.1/CORL.html +496 -0
  123. data/rdoc/site/0.5.1/Fog/Compute/AWS/Server.html +467 -0
  124. data/rdoc/site/0.5.1/Fog/Compute/AWS.html +389 -0
  125. data/rdoc/site/0.5.1/Fog/Compute/RackspaceV2/Server.html +452 -0
  126. data/rdoc/site/0.5.1/Fog/Compute/RackspaceV2.html +389 -0
  127. data/rdoc/site/0.5.1/Fog/Compute.html +384 -0
  128. data/rdoc/site/0.5.1/Fog.html +384 -0
  129. data/rdoc/site/0.5.1/Hiera/Backend.html +466 -0
  130. data/rdoc/site/0.5.1/Hiera/Corl_logger.html +493 -0
  131. data/rdoc/site/0.5.1/Hiera.html +390 -0
  132. data/rdoc/site/0.5.1/Nucleon/Action/Cloud/Config.html +978 -0
  133. data/rdoc/site/0.5.1/Nucleon/Action/Cloud/Create.html +562 -0
  134. data/rdoc/site/0.5.1/Nucleon/Action/Cloud/Images.html +596 -0
  135. data/rdoc/site/0.5.1/Nucleon/Action/Cloud/Inspect.html +567 -0
  136. data/rdoc/site/0.5.1/Nucleon/Action/Cloud/Machines.html +591 -0
  137. data/rdoc/site/0.5.1/Nucleon/Action/Cloud/Regions.html +591 -0
  138. data/rdoc/site/0.5.1/Nucleon/Action/Cloud/Settings.html +878 -0
  139. data/rdoc/site/0.5.1/Nucleon/Action/Cloud/Vagrantfile.html +539 -0
  140. data/rdoc/site/0.5.1/Nucleon/Action/Cloud.html +390 -0
  141. data/rdoc/site/0.5.1/Nucleon/Action/Node/Authorize.html +567 -0
  142. data/rdoc/site/0.5.1/Nucleon/Action/Node/Bootstrap.html +628 -0
  143. data/rdoc/site/0.5.1/Nucleon/Action/Node/Build.html +550 -0
  144. data/rdoc/site/0.5.1/Nucleon/Action/Node/Cache.html +773 -0
  145. data/rdoc/site/0.5.1/Nucleon/Action/Node/Destroy.html +597 -0
  146. data/rdoc/site/0.5.1/Nucleon/Action/Node/Exec.html +554 -0
  147. data/rdoc/site/0.5.1/Nucleon/Action/Node/Fact.html +733 -0
  148. data/rdoc/site/0.5.1/Nucleon/Action/Node/Facts.html +505 -0
  149. data/rdoc/site/0.5.1/Nucleon/Action/Node/Group.html +729 -0
  150. data/rdoc/site/0.5.1/Nucleon/Action/Node/Groups.html +505 -0
  151. data/rdoc/site/0.5.1/Nucleon/Action/Node/IP.html +477 -0
  152. data/rdoc/site/0.5.1/Nucleon/Action/Node/Identity.html +614 -0
  153. data/rdoc/site/0.5.1/Nucleon/Action/Node/Image.html +597 -0
  154. data/rdoc/site/0.5.1/Nucleon/Action/Node/Keypair.html +596 -0
  155. data/rdoc/site/0.5.1/Nucleon/Action/Node/Lookup.html +579 -0
  156. data/rdoc/site/0.5.1/Nucleon/Action/Node/Provision.html +577 -0
  157. data/rdoc/site/0.5.1/Nucleon/Action/Node/Reboot.html +597 -0
  158. data/rdoc/site/0.5.1/Nucleon/Action/Node/Revoke.html +565 -0
  159. data/rdoc/site/0.5.1/Nucleon/Action/Node/SSH.html +607 -0
  160. data/rdoc/site/0.5.1/Nucleon/Action/Node/Seed.html +626 -0
  161. data/rdoc/site/0.5.1/Nucleon/Action/Node/Spawn.html +699 -0
  162. data/rdoc/site/0.5.1/Nucleon/Action/Node/Start.html +597 -0
  163. data/rdoc/site/0.5.1/Nucleon/Action/Node/Status.html +615 -0
  164. data/rdoc/site/0.5.1/Nucleon/Action/Node/Stop.html +597 -0
  165. data/rdoc/site/0.5.1/Nucleon/Action/Node.html +406 -0
  166. data/rdoc/site/0.5.1/Nucleon/Action/Plugin/Create.html +736 -0
  167. data/rdoc/site/0.5.1/Nucleon/Action/Plugin/List.html +570 -0
  168. data/rdoc/site/0.5.1/Nucleon/Action/Plugin.html +384 -0
  169. data/rdoc/site/0.5.1/Nucleon/Action/Plugins.html +435 -0
  170. data/rdoc/site/0.5.1/Nucleon/Action.html +417 -0
  171. data/rdoc/site/0.5.1/Nucleon/Config.html +401 -0
  172. data/rdoc/site/0.5.1/Nucleon/Event/Puppet.html +717 -0
  173. data/rdoc/site/0.5.1/Nucleon/Event.html +383 -0
  174. data/rdoc/site/0.5.1/Nucleon/Plugin/Base.html +389 -0
  175. data/rdoc/site/0.5.1/Nucleon/Plugin/CloudAction.html +894 -0
  176. data/rdoc/site/0.5.1/Nucleon/Plugin.html +384 -0
  177. data/rdoc/site/0.5.1/Nucleon/Template/Environment.html +572 -0
  178. data/rdoc/site/0.5.1/Nucleon/Template.html +383 -0
  179. data/rdoc/site/0.5.1/Nucleon.html +421 -0
  180. data/rdoc/site/0.5.1/Object.html +402 -0
  181. data/rdoc/site/0.5.1/Puppet/DataBinding/Corl.html +389 -0
  182. data/rdoc/site/0.5.1/Puppet/DataBinding.html +382 -0
  183. data/rdoc/site/0.5.1/Puppet/Indirector/Corl.html +501 -0
  184. data/rdoc/site/0.5.1/Puppet/Indirector.html +382 -0
  185. data/rdoc/site/0.5.1/Puppet/Parser/Functions.html +524 -0
  186. data/rdoc/site/0.5.1/Puppet/Parser.html +382 -0
  187. data/rdoc/site/0.5.1/Puppet.html +382 -0
  188. data/rdoc/site/0.5.1/README_rdoc.html +384 -0
  189. data/rdoc/site/0.5.1/Vagrant/Config/Loader.html +443 -0
  190. data/rdoc/site/0.5.1/Vagrant/Config.html +383 -0
  191. data/rdoc/site/0.5.1/Vagrant/Vagrantfile.html +436 -0
  192. data/rdoc/site/0.5.1/Vagrant.html +390 -0
  193. data/rdoc/site/0.5.1/VagrantPlugins/CORL/Action/DeleteCache.html +446 -0
  194. data/rdoc/site/0.5.1/VagrantPlugins/CORL/Action/InitKeys.html +452 -0
  195. data/rdoc/site/0.5.1/VagrantPlugins/CORL/Action/LinkNetwork.html +450 -0
  196. data/rdoc/site/0.5.1/VagrantPlugins/CORL/Action.html +385 -0
  197. data/rdoc/site/0.5.1/VagrantPlugins/CORL/BaseAction.html +535 -0
  198. data/rdoc/site/0.5.1/VagrantPlugins/CORL/Command/Launcher.html +577 -0
  199. data/rdoc/site/0.5.1/VagrantPlugins/CORL/Command.html +383 -0
  200. data/rdoc/site/0.5.1/VagrantPlugins/CORL/Config/CORL.html +776 -0
  201. data/rdoc/site/0.5.1/VagrantPlugins/CORL/Config.html +383 -0
  202. data/rdoc/site/0.5.1/VagrantPlugins/CORL/Plugin.html +389 -0
  203. data/rdoc/site/0.5.1/VagrantPlugins/CORL/Provisioner/CORL.html +580 -0
  204. data/rdoc/site/0.5.1/VagrantPlugins/CORL/Provisioner.html +383 -0
  205. data/rdoc/site/0.5.1/VagrantPlugins/CORL.html +390 -0
  206. data/rdoc/site/0.5.1/VagrantPlugins.html +390 -0
  207. data/rdoc/site/0.5.1/created.rid +114 -0
  208. data/rdoc/site/0.5.1/images/add.png +0 -0
  209. data/rdoc/site/0.5.1/images/brick.png +0 -0
  210. data/rdoc/site/0.5.1/images/brick_link.png +0 -0
  211. data/rdoc/site/0.5.1/images/bug.png +0 -0
  212. data/rdoc/site/0.5.1/images/bullet_black.png +0 -0
  213. data/rdoc/site/0.5.1/images/bullet_toggle_minus.png +0 -0
  214. data/rdoc/site/0.5.1/images/bullet_toggle_plus.png +0 -0
  215. data/rdoc/site/0.5.1/images/date.png +0 -0
  216. data/rdoc/site/0.5.1/images/delete.png +0 -0
  217. data/rdoc/site/0.5.1/images/find.png +0 -0
  218. data/rdoc/site/0.5.1/images/loadingAnimation.gif +0 -0
  219. data/rdoc/site/0.5.1/images/macFFBgHack.png +0 -0
  220. data/rdoc/site/0.5.1/images/package.png +0 -0
  221. data/rdoc/site/0.5.1/images/page_green.png +0 -0
  222. data/rdoc/site/0.5.1/images/page_white_text.png +0 -0
  223. data/rdoc/site/0.5.1/images/page_white_width.png +0 -0
  224. data/rdoc/site/0.5.1/images/plugin.png +0 -0
  225. data/rdoc/site/0.5.1/images/ruby.png +0 -0
  226. data/rdoc/site/0.5.1/images/tag_blue.png +0 -0
  227. data/rdoc/site/0.5.1/images/tag_green.png +0 -0
  228. data/rdoc/site/0.5.1/images/transparent.png +0 -0
  229. data/rdoc/site/0.5.1/images/wrench.png +0 -0
  230. data/rdoc/site/0.5.1/images/wrench_orange.png +0 -0
  231. data/rdoc/site/0.5.1/images/zoom.png +0 -0
  232. data/rdoc/site/0.5.1/index.html +383 -0
  233. data/rdoc/site/0.5.1/js/darkfish.js +155 -0
  234. data/rdoc/site/0.5.1/js/jquery.js +18 -0
  235. data/rdoc/site/0.5.1/js/navigation.js +142 -0
  236. data/rdoc/site/0.5.1/js/search.js +94 -0
  237. data/rdoc/site/0.5.1/js/search_index.js +1 -0
  238. data/rdoc/site/0.5.1/js/searcher.js +228 -0
  239. data/rdoc/site/0.5.1/rdoc.css +543 -0
  240. data/rdoc/site/0.5.1/table_of_contents.html +2005 -0
  241. metadata +174 -4
@@ -0,0 +1,228 @@
1
+ Searcher = function(data) {
2
+ this.data = data;
3
+ this.handlers = [];
4
+ }
5
+
6
+ Searcher.prototype = new function() {
7
+ // search is performed in chunks of 1000 for non-blocking user input
8
+ var CHUNK_SIZE = 1000;
9
+ // do not try to find more than 100 results
10
+ var MAX_RESULTS = 100;
11
+ var huid = 1;
12
+ var suid = 1;
13
+ var runs = 0;
14
+
15
+ this.find = function(query) {
16
+ var queries = splitQuery(query);
17
+ var regexps = buildRegexps(queries);
18
+ var highlighters = buildHilighters(queries);
19
+ var state = { from: 0, pass: 0, limit: MAX_RESULTS, n: suid++};
20
+ var _this = this;
21
+
22
+ this.currentSuid = state.n;
23
+
24
+ if (!query) return;
25
+
26
+ var run = function() {
27
+ // stop current search thread if new search started
28
+ if (state.n != _this.currentSuid) return;
29
+
30
+ var results =
31
+ performSearch(_this.data, regexps, queries, highlighters, state);
32
+ var hasMore = (state.limit > 0 && state.pass < 4);
33
+
34
+ triggerResults.call(_this, results, !hasMore);
35
+ if (hasMore) {
36
+ setTimeout(run, 2);
37
+ }
38
+ runs++;
39
+ };
40
+ runs = 0;
41
+
42
+ // start search thread
43
+ run();
44
+ }
45
+
46
+ /* ----- Events ------ */
47
+ this.ready = function(fn) {
48
+ fn.huid = huid;
49
+ this.handlers.push(fn);
50
+ }
51
+
52
+ /* ----- Utilities ------ */
53
+ function splitQuery(query) {
54
+ return jQuery.grep(query.split(/(\s+|::?|\(\)?)/), function(string) {
55
+ return string.match(/\S/)
56
+ });
57
+ }
58
+
59
+ function buildRegexps(queries) {
60
+ return jQuery.map(queries, function(query) {
61
+ return new RegExp(query.replace(/(.)/g, '([$1])([^$1]*?)'), 'i')
62
+ });
63
+ }
64
+
65
+ function buildHilighters(queries) {
66
+ return jQuery.map(queries, function(query) {
67
+ return jQuery.map(query.split(''), function(l, i) {
68
+ return '\u0001$' + (i*2+1) + '\u0002$' + (i*2+2);
69
+ }).join('');
70
+ });
71
+ }
72
+
73
+ // function longMatchRegexp(index, longIndex, regexps) {
74
+ // for (var i = regexps.length - 1; i >= 0; i--){
75
+ // if (!index.match(regexps[i]) && !longIndex.match(regexps[i])) return false;
76
+ // };
77
+ // return true;
78
+ // }
79
+
80
+
81
+ /* ----- Mathchers ------ */
82
+
83
+ /*
84
+ * This record matches if the index starts with queries[0] and the record
85
+ * matches all of the regexps
86
+ */
87
+ function matchPassBeginning(index, longIndex, queries, regexps) {
88
+ if (index.indexOf(queries[0]) != 0) return false;
89
+ for (var i=1, l = regexps.length; i < l; i++) {
90
+ if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
91
+ return false;
92
+ };
93
+ return true;
94
+ }
95
+
96
+ /*
97
+ * This record matches if the longIndex starts with queries[0] and the
98
+ * longIndex matches all of the regexps
99
+ */
100
+ function matchPassLongIndex(index, longIndex, queries, regexps) {
101
+ if (longIndex.indexOf(queries[0]) != 0) return false;
102
+ for (var i=1, l = regexps.length; i < l; i++) {
103
+ if (!longIndex.match(regexps[i]))
104
+ return false;
105
+ };
106
+ return true;
107
+ }
108
+
109
+ /*
110
+ * This record matches if the index contains queries[0] and the record
111
+ * matches all of the regexps
112
+ */
113
+ function matchPassContains(index, longIndex, queries, regexps) {
114
+ if (index.indexOf(queries[0]) == -1) return false;
115
+ for (var i=1, l = regexps.length; i < l; i++) {
116
+ if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
117
+ return false;
118
+ };
119
+ return true;
120
+ }
121
+
122
+ /*
123
+ * This record matches if regexps[0] matches the index and the record
124
+ * matches all of the regexps
125
+ */
126
+ function matchPassRegexp(index, longIndex, queries, regexps) {
127
+ if (!index.match(regexps[0])) return false;
128
+ for (var i=1, l = regexps.length; i < l; i++) {
129
+ if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
130
+ return false;
131
+ };
132
+ return true;
133
+ }
134
+
135
+
136
+ /* ----- Highlighters ------ */
137
+ function highlightRegexp(info, queries, regexps, highlighters) {
138
+ var result = createResult(info);
139
+ for (var i=0, l = regexps.length; i < l; i++) {
140
+ result.title = result.title.replace(regexps[i], highlighters[i]);
141
+ result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
142
+ };
143
+ return result;
144
+ }
145
+
146
+ function hltSubstring(string, pos, length) {
147
+ return string.substring(0, pos) + '\u0001' + string.substring(pos, pos + length) + '\u0002' + string.substring(pos + length);
148
+ }
149
+
150
+ function highlightQuery(info, queries, regexps, highlighters) {
151
+ var result = createResult(info);
152
+ var pos = 0;
153
+ var lcTitle = result.title.toLowerCase();
154
+
155
+ pos = lcTitle.indexOf(queries[0]);
156
+ if (pos != -1) {
157
+ result.title = hltSubstring(result.title, pos, queries[0].length);
158
+ }
159
+
160
+ result.namespace = result.namespace.replace(regexps[0], highlighters[0]);
161
+ for (var i=1, l = regexps.length; i < l; i++) {
162
+ result.title = result.title.replace(regexps[i], highlighters[i]);
163
+ result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
164
+ };
165
+ return result;
166
+ }
167
+
168
+ function createResult(info) {
169
+ var result = {};
170
+ result.title = info[0];
171
+ result.namespace = info[1];
172
+ result.path = info[2];
173
+ result.params = info[3];
174
+ result.snippet = info[4];
175
+ return result;
176
+ }
177
+
178
+ /* ----- Searching ------ */
179
+ function performSearch(data, regexps, queries, highlighters, state) {
180
+ var searchIndex = data.searchIndex;
181
+ var longSearchIndex = data.longSearchIndex;
182
+ var info = data.info;
183
+ var result = [];
184
+ var i = state.from;
185
+ var l = searchIndex.length;
186
+ var togo = CHUNK_SIZE;
187
+ var matchFunc, hltFunc;
188
+
189
+ while (state.pass < 4 && state.limit > 0 && togo > 0) {
190
+ if (state.pass == 0) {
191
+ matchFunc = matchPassBeginning;
192
+ hltFunc = highlightQuery;
193
+ } else if (state.pass == 1) {
194
+ matchFunc = matchPassLongIndex;
195
+ hltFunc = highlightQuery;
196
+ } else if (state.pass == 2) {
197
+ matchFunc = matchPassContains;
198
+ hltFunc = highlightQuery;
199
+ } else if (state.pass == 3) {
200
+ matchFunc = matchPassRegexp;
201
+ hltFunc = highlightRegexp;
202
+ }
203
+
204
+ for (; togo > 0 && i < l && state.limit > 0; i++, togo--) {
205
+ if (info[i].n == state.n) continue;
206
+ if (matchFunc(searchIndex[i], longSearchIndex[i], queries, regexps)) {
207
+ info[i].n = state.n;
208
+ result.push(hltFunc(info[i], queries, regexps, highlighters));
209
+ state.limit--;
210
+ }
211
+ };
212
+ if (searchIndex.length <= i) {
213
+ state.pass++;
214
+ i = state.from = 0;
215
+ } else {
216
+ state.from = i;
217
+ }
218
+ }
219
+ return result;
220
+ }
221
+
222
+ function triggerResults(results, isLast) {
223
+ jQuery.each(this.handlers, function(i, fn) {
224
+ fn.call(this, results, isLast)
225
+ })
226
+ }
227
+ }
228
+