marty 0.5.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (345) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +84 -0
  4. data/Rakefile +29 -0
  5. data/app/assets/javascripts/marty/application.js +15 -0
  6. data/app/assets/stylesheets/marty/application.css +13 -0
  7. data/app/components/marty/api_auth_view.rb +32 -0
  8. data/app/components/marty/auth_app.rb +55 -0
  9. data/app/components/marty/auth_app.rb~ +51 -0
  10. data/app/components/marty/auth_app/javascripts/auth_app.js +91 -0
  11. data/app/components/marty/auth_app/javascripts/auth_app.js~ +91 -0
  12. data/app/components/marty/cm_form_panel.rb~ +5 -0
  13. data/app/components/marty/cm_grid_panel.rb~ +35 -0
  14. data/app/components/marty/data_import_view.rb~ +142 -0
  15. data/app/components/marty/extras/layout.rb +46 -0
  16. data/app/components/marty/extras/layout.rb~ +46 -0
  17. data/app/components/marty/extras/misc.rb +18 -0
  18. data/app/components/marty/form.rb +6 -0
  19. data/app/components/marty/grid.rb +45 -0
  20. data/app/components/marty/grid_append_only.rb +12 -0
  21. data/app/components/marty/import_type_view.rb +53 -0
  22. data/app/components/marty/live_search_grid_panel.rb +46 -0
  23. data/app/components/marty/live_search_grid_panel.rb~ +49 -0
  24. data/app/components/marty/main_auth_app.rb +269 -0
  25. data/app/components/marty/main_auth_app.rb~ +238 -0
  26. data/app/components/marty/mcfly_grid_panel.rb +62 -0
  27. data/app/components/marty/mcfly_grid_panel.rb~ +80 -0
  28. data/app/components/marty/new_posting_form.rb +46 -0
  29. data/app/components/marty/new_posting_form.rb~ +46 -0
  30. data/app/components/marty/new_posting_window.rb +21 -0
  31. data/app/components/marty/new_posting_window.rb~ +21 -0
  32. data/app/components/marty/panel.rb +12 -0
  33. data/app/components/marty/pivot_grid.rb +52 -0
  34. data/app/components/marty/pivot_grid/endpoints.rb +45 -0
  35. data/app/components/marty/pivot_grid/javascripts/extensions.js +150 -0
  36. data/app/components/marty/pivot_grid/javascripts/pivot_grid.js +86 -0
  37. data/app/components/marty/pivot_grid/services.rb +44 -0
  38. data/app/components/marty/posting_grid.rb +139 -0
  39. data/app/components/marty/posting_grid.rb~ +140 -0
  40. data/app/components/marty/posting_window.rb +27 -0
  41. data/app/components/marty/promise_view.rb +177 -0
  42. data/app/components/marty/promise_view.rb~ +157 -0
  43. data/app/components/marty/promise_view/stylesheets/promise_view.css +26 -0
  44. data/app/components/marty/promise_view/stylesheets/promise_view.css~ +15 -0
  45. data/app/components/marty/report_form.rb +225 -0
  46. data/app/components/marty/report_form.rb~ +217 -0
  47. data/app/components/marty/report_select.rb +145 -0
  48. data/app/components/marty/report_select.rb~ +133 -0
  49. data/app/components/marty/reporting.rb +39 -0
  50. data/app/components/marty/reporting.rb~ +39 -0
  51. data/app/components/marty/script_detail.rb~ +430 -0
  52. data/app/components/marty/script_form.rb +233 -0
  53. data/app/components/marty/script_form.rb~ +233 -0
  54. data/app/components/marty/script_form/javascripts/Ext.ux.form.field.CodeMirror.js +698 -0
  55. data/app/components/marty/script_form/javascripts/Ext.ux.form.field.CodeMirror.js~ +909 -0
  56. data/app/components/marty/script_form/javascripts/codemirror.js +3130 -0
  57. data/app/components/marty/script_form/javascripts/mode/clike/clike.js +284 -0
  58. data/app/components/marty/script_form/javascripts/mode/clike/index.html +102 -0
  59. data/app/components/marty/script_form/javascripts/mode/clike/scala.html +766 -0
  60. data/app/components/marty/script_form/javascripts/mode/clojure/clojure.js +206 -0
  61. data/app/components/marty/script_form/javascripts/mode/clojure/index.html +67 -0
  62. data/app/components/marty/script_form/javascripts/mode/coffeescript/LICENSE +22 -0
  63. data/app/components/marty/script_form/javascripts/mode/coffeescript/coffeescript.js +346 -0
  64. data/app/components/marty/script_form/javascripts/mode/coffeescript/index.html +728 -0
  65. data/app/components/marty/script_form/javascripts/mode/commonlisp/commonlisp.js +101 -0
  66. data/app/components/marty/script_form/javascripts/mode/commonlisp/index.html +165 -0
  67. data/app/components/marty/script_form/javascripts/mode/css/css.js +448 -0
  68. data/app/components/marty/script_form/javascripts/mode/css/index.html +58 -0
  69. data/app/components/marty/script_form/javascripts/mode/css/test.js +501 -0
  70. data/app/components/marty/script_form/javascripts/mode/delorean/delorean.js +189 -0
  71. data/app/components/marty/script_form/javascripts/mode/diff/diff.js +32 -0
  72. data/app/components/marty/script_form/javascripts/mode/diff/index.html +105 -0
  73. data/app/components/marty/script_form/javascripts/mode/ecl/ecl.js +203 -0
  74. data/app/components/marty/script_form/javascripts/mode/ecl/index.html +42 -0
  75. data/app/components/marty/script_form/javascripts/mode/erlang/erlang.js +463 -0
  76. data/app/components/marty/script_form/javascripts/mode/erlang/index.html +63 -0
  77. data/app/components/marty/script_form/javascripts/mode/gfm/gfm.js +150 -0
  78. data/app/components/marty/script_form/javascripts/mode/gfm/index.html +48 -0
  79. data/app/components/marty/script_form/javascripts/mode/go/go.js +170 -0
  80. data/app/components/marty/script_form/javascripts/mode/go/index.html +73 -0
  81. data/app/components/marty/script_form/javascripts/mode/groovy/groovy.js +210 -0
  82. data/app/components/marty/script_form/javascripts/mode/groovy/index.html +72 -0
  83. data/app/components/marty/script_form/javascripts/mode/haskell/haskell.js +242 -0
  84. data/app/components/marty/script_form/javascripts/mode/haskell/index.html +61 -0
  85. data/app/components/marty/script_form/javascripts/mode/haxe/haxe.js +429 -0
  86. data/app/components/marty/script_form/javascripts/mode/haxe/index.html +91 -0
  87. data/app/components/marty/script_form/javascripts/mode/htmlembedded/htmlembedded.js +72 -0
  88. data/app/components/marty/script_form/javascripts/mode/htmlembedded/index.html +50 -0
  89. data/app/components/marty/script_form/javascripts/mode/htmlmixed/htmlmixed.js +84 -0
  90. data/app/components/marty/script_form/javascripts/mode/htmlmixed/index.html +52 -0
  91. data/app/components/marty/script_form/javascripts/mode/javascript/index.html +78 -0
  92. data/app/components/marty/script_form/javascripts/mode/javascript/javascript.js +361 -0
  93. data/app/components/marty/script_form/javascripts/mode/jinja2/index.html +38 -0
  94. data/app/components/marty/script_form/javascripts/mode/jinja2/jinja2.js +42 -0
  95. data/app/components/marty/script_form/javascripts/mode/less/index.html +740 -0
  96. data/app/components/marty/script_form/javascripts/mode/less/less.js +266 -0
  97. data/app/components/marty/script_form/javascripts/mode/lua/index.html +73 -0
  98. data/app/components/marty/script_form/javascripts/mode/lua/lua.js +140 -0
  99. data/app/components/marty/script_form/javascripts/mode/markdown/index.html +343 -0
  100. data/app/components/marty/script_form/javascripts/mode/markdown/markdown.js +382 -0
  101. data/app/components/marty/script_form/javascripts/mode/markdown/test.js +1084 -0
  102. data/app/components/marty/script_form/javascripts/mode/mysql/index.html +42 -0
  103. data/app/components/marty/script_form/javascripts/mode/mysql/mysql.js +186 -0
  104. data/app/components/marty/script_form/javascripts/mode/ntriples/index.html +33 -0
  105. data/app/components/marty/script_form/javascripts/mode/ntriples/ntriples.js +172 -0
  106. data/app/components/marty/script_form/javascripts/mode/ocaml/index.html +130 -0
  107. data/app/components/marty/script_form/javascripts/mode/ocaml/ocaml.js +114 -0
  108. data/app/components/marty/script_form/javascripts/mode/pascal/LICENSE +7 -0
  109. data/app/components/marty/script_form/javascripts/mode/pascal/index.html +49 -0
  110. data/app/components/marty/script_form/javascripts/mode/pascal/pascal.js +94 -0
  111. data/app/components/marty/script_form/javascripts/mode/perl/LICENSE +19 -0
  112. data/app/components/marty/script_form/javascripts/mode/perl/index.html +63 -0
  113. data/app/components/marty/script_form/javascripts/mode/perl/perl.js +816 -0
  114. data/app/components/marty/script_form/javascripts/mode/php/index.html +49 -0
  115. data/app/components/marty/script_form/javascripts/mode/php/php.js +148 -0
  116. data/app/components/marty/script_form/javascripts/mode/pig/index.html +43 -0
  117. data/app/components/marty/script_form/javascripts/mode/pig/pig.js +172 -0
  118. data/app/components/marty/script_form/javascripts/mode/plsql/index.html +63 -0
  119. data/app/components/marty/script_form/javascripts/mode/plsql/plsql.js +217 -0
  120. data/app/components/marty/script_form/javascripts/mode/properties/index.html +41 -0
  121. data/app/components/marty/script_form/javascripts/mode/properties/properties.js +63 -0
  122. data/app/components/marty/script_form/javascripts/mode/python/LICENSE.txt +21 -0
  123. data/app/components/marty/script_form/javascripts/mode/python/index.html +123 -0
  124. data/app/components/marty/script_form/javascripts/mode/python/python.js +338 -0
  125. data/app/components/marty/script_form/javascripts/mode/r/LICENSE +24 -0
  126. data/app/components/marty/script_form/javascripts/mode/r/index.html +74 -0
  127. data/app/components/marty/script_form/javascripts/mode/r/r.js +141 -0
  128. data/app/components/marty/script_form/javascripts/mode/rpm/changes/changes.js +19 -0
  129. data/app/components/marty/script_form/javascripts/mode/rpm/changes/index.html +54 -0
  130. data/app/components/marty/script_form/javascripts/mode/rpm/spec/index.html +100 -0
  131. data/app/components/marty/script_form/javascripts/mode/rpm/spec/spec.css +5 -0
  132. data/app/components/marty/script_form/javascripts/mode/rpm/spec/spec.js +66 -0
  133. data/app/components/marty/script_form/javascripts/mode/rst/index.html +526 -0
  134. data/app/components/marty/script_form/javascripts/mode/rst/rst.js +326 -0
  135. data/app/components/marty/script_form/javascripts/mode/ruby/LICENSE +24 -0
  136. data/app/components/marty/script_form/javascripts/mode/ruby/index.html +172 -0
  137. data/app/components/marty/script_form/javascripts/mode/ruby/ruby.js +195 -0
  138. data/app/components/marty/script_form/javascripts/mode/rust/index.html +49 -0
  139. data/app/components/marty/script_form/javascripts/mode/rust/rust.js +432 -0
  140. data/app/components/marty/script_form/javascripts/mode/scheme/index.html +65 -0
  141. data/app/components/marty/script_form/javascripts/mode/scheme/scheme.js +230 -0
  142. data/app/components/marty/script_form/javascripts/mode/shell/index.html +50 -0
  143. data/app/components/marty/script_form/javascripts/mode/shell/shell.js +118 -0
  144. data/app/components/marty/script_form/javascripts/mode/sieve/LICENSE +23 -0
  145. data/app/components/marty/script_form/javascripts/mode/sieve/index.html +81 -0
  146. data/app/components/marty/script_form/javascripts/mode/sieve/sieve.js +156 -0
  147. data/app/components/marty/script_form/javascripts/mode/smalltalk/index.html +56 -0
  148. data/app/components/marty/script_form/javascripts/mode/smalltalk/smalltalk.js +139 -0
  149. data/app/components/marty/script_form/javascripts/mode/smarty/index.html +83 -0
  150. data/app/components/marty/script_form/javascripts/mode/smarty/smarty.js +148 -0
  151. data/app/components/marty/script_form/javascripts/mode/sparql/index.html +41 -0
  152. data/app/components/marty/script_form/javascripts/mode/sparql/sparql.js +143 -0
  153. data/app/components/marty/script_form/javascripts/mode/stex/index.html +98 -0
  154. data/app/components/marty/script_form/javascripts/mode/stex/stex.js +182 -0
  155. data/app/components/marty/script_form/javascripts/mode/stex/test.js +343 -0
  156. data/app/components/marty/script_form/javascripts/mode/tiddlywiki/index.html +141 -0
  157. data/app/components/marty/script_form/javascripts/mode/tiddlywiki/tiddlywiki.css +14 -0
  158. data/app/components/marty/script_form/javascripts/mode/tiddlywiki/tiddlywiki.js +384 -0
  159. data/app/components/marty/script_form/javascripts/mode/tiki/index.html +83 -0
  160. data/app/components/marty/script_form/javascripts/mode/tiki/tiki.css +26 -0
  161. data/app/components/marty/script_form/javascripts/mode/tiki/tiki.js +309 -0
  162. data/app/components/marty/script_form/javascripts/mode/vb/LICENSE.txt +21 -0
  163. data/app/components/marty/script_form/javascripts/mode/vb/index.html +89 -0
  164. data/app/components/marty/script_form/javascripts/mode/vb/vb.js +260 -0
  165. data/app/components/marty/script_form/javascripts/mode/vbscript/index.html +43 -0
  166. data/app/components/marty/script_form/javascripts/mode/vbscript/vbscript.js +26 -0
  167. data/app/components/marty/script_form/javascripts/mode/velocity/index.html +104 -0
  168. data/app/components/marty/script_form/javascripts/mode/velocity/velocity.js +146 -0
  169. data/app/components/marty/script_form/javascripts/mode/verilog/index.html +211 -0
  170. data/app/components/marty/script_form/javascripts/mode/verilog/verilog.js +194 -0
  171. data/app/components/marty/script_form/javascripts/mode/xml/index.html +45 -0
  172. data/app/components/marty/script_form/javascripts/mode/xml/xml.js +318 -0
  173. data/app/components/marty/script_form/javascripts/mode/xquery/LICENSE +20 -0
  174. data/app/components/marty/script_form/javascripts/mode/xquery/index.html +223 -0
  175. data/app/components/marty/script_form/javascripts/mode/xquery/test/index.html +27 -0
  176. data/app/components/marty/script_form/javascripts/mode/xquery/test/testBase.js +42 -0
  177. data/app/components/marty/script_form/javascripts/mode/xquery/test/testEmptySequenceKeyword.js +16 -0
  178. data/app/components/marty/script_form/javascripts/mode/xquery/test/testMultiAttr.js +16 -0
  179. data/app/components/marty/script_form/javascripts/mode/xquery/test/testNamespaces.js +91 -0
  180. data/app/components/marty/script_form/javascripts/mode/xquery/test/testProcessingInstructions.js +16 -0
  181. data/app/components/marty/script_form/javascripts/mode/xquery/test/testQuotes.js +19 -0
  182. data/app/components/marty/script_form/javascripts/mode/xquery/xquery.js +451 -0
  183. data/app/components/marty/script_form/javascripts/mode/yaml/index.html +68 -0
  184. data/app/components/marty/script_form/javascripts/mode/yaml/yaml.js +95 -0
  185. data/app/components/marty/script_form/javascripts/util/closetag.js +164 -0
  186. data/app/components/marty/script_form/javascripts/util/dialog.css +27 -0
  187. data/app/components/marty/script_form/javascripts/util/dialog.js +70 -0
  188. data/app/components/marty/script_form/javascripts/util/foldcode.js +196 -0
  189. data/app/components/marty/script_form/javascripts/util/formatting.js +193 -0
  190. data/app/components/marty/script_form/javascripts/util/javascript-hint.js +134 -0
  191. data/app/components/marty/script_form/javascripts/util/loadmode.js +51 -0
  192. data/app/components/marty/script_form/javascripts/util/match-highlighter.js +44 -0
  193. data/app/components/marty/script_form/javascripts/util/multiplex.js +77 -0
  194. data/app/components/marty/script_form/javascripts/util/overlay.js +54 -0
  195. data/app/components/marty/script_form/javascripts/util/pig-hint.js +123 -0
  196. data/app/components/marty/script_form/javascripts/util/runmode-standalone.js +90 -0
  197. data/app/components/marty/script_form/javascripts/util/runmode.js +53 -0
  198. data/app/components/marty/script_form/javascripts/util/search.js +118 -0
  199. data/app/components/marty/script_form/javascripts/util/searchcursor.js +119 -0
  200. data/app/components/marty/script_form/javascripts/util/simple-hint.css +16 -0
  201. data/app/components/marty/script_form/javascripts/util/simple-hint.js +97 -0
  202. data/app/components/marty/script_form/javascripts/util/xml-hint.js +137 -0
  203. data/app/components/marty/script_form/stylesheets/codemirror.css +172 -0
  204. data/app/components/marty/script_form/stylesheets/delorean.css +10 -0
  205. data/app/components/marty/script_form/stylesheets/theme/ambiance.css +81 -0
  206. data/app/components/marty/script_form/stylesheets/theme/blackboard.css +25 -0
  207. data/app/components/marty/script_form/stylesheets/theme/cobalt.css +18 -0
  208. data/app/components/marty/script_form/stylesheets/theme/eclipse.css +25 -0
  209. data/app/components/marty/script_form/stylesheets/theme/elegant.css +10 -0
  210. data/app/components/marty/script_form/stylesheets/theme/erlang-dark.css +21 -0
  211. data/app/components/marty/script_form/stylesheets/theme/lesser-dark.css +44 -0
  212. data/app/components/marty/script_form/stylesheets/theme/monokai.css +28 -0
  213. data/app/components/marty/script_form/stylesheets/theme/neat.css +9 -0
  214. data/app/components/marty/script_form/stylesheets/theme/night.css +21 -0
  215. data/app/components/marty/script_form/stylesheets/theme/rubyblue.css +21 -0
  216. data/app/components/marty/script_form/stylesheets/theme/vibrant-ink.css +27 -0
  217. data/app/components/marty/script_form/stylesheets/theme/xq-dark.css +46 -0
  218. data/app/components/marty/script_grid.rb +104 -0
  219. data/app/components/marty/script_grid.rb~ +99 -0
  220. data/app/components/marty/script_tester.rb +114 -0
  221. data/app/components/marty/script_tester.rb~ +213 -0
  222. data/app/components/marty/scripting.rb +132 -0
  223. data/app/components/marty/scripting.rb~ +124 -0
  224. data/app/components/marty/select_report.rb~ +143 -0
  225. data/app/components/marty/simple_app.rb +97 -0
  226. data/app/components/marty/simple_app.rb~ +101 -0
  227. data/app/components/marty/simple_app/javascripts/simple_app.js +50 -0
  228. data/app/components/marty/simple_app/javascripts/statusbar_ext.js +8 -0
  229. data/app/components/marty/tag_grid.rb +83 -0
  230. data/app/components/marty/tag_grid.rb~ +89 -0
  231. data/app/components/marty/tree_panel.rb~ +256 -0
  232. data/app/components/marty/tree_panel/javascripts/tree_panel.js~ +317 -0
  233. data/app/components/marty/user_pivot.rb +128 -0
  234. data/app/components/marty/user_view.rb +181 -0
  235. data/app/components/marty/user_view.rb~ +188 -0
  236. data/app/controllers/marty/application_controller.rb +124 -0
  237. data/app/controllers/marty/application_controller.rb~ +133 -0
  238. data/app/controllers/marty/components_controller.rb +41 -0
  239. data/app/controllers/marty/components_controller.rb~ +37 -0
  240. data/app/controllers/marty/job_controller.rb +28 -0
  241. data/app/controllers/marty/job_controller.rb~ +28 -0
  242. data/app/controllers/marty/rpc_controller.rb +64 -0
  243. data/app/controllers/marty/rpc_controller.rb~ +61 -0
  244. data/app/helpers/marty/application_helper.rb +4 -0
  245. data/app/helpers/marty/script_set.rb +57 -0
  246. data/app/helpers/marty/script_set.rb~ +59 -0
  247. data/app/models/marty/api_auth.rb +44 -0
  248. data/app/models/marty/api_auth.rb~ +48 -0
  249. data/app/models/marty/base.rb +4 -0
  250. data/app/models/marty/data_change.rb +179 -0
  251. data/app/models/marty/data_change.rb~ +141 -0
  252. data/app/models/marty/enum.rb +22 -0
  253. data/app/models/marty/enum.rb~ +16 -0
  254. data/app/models/marty/import_type.rb +44 -0
  255. data/app/models/marty/import_type.rb~ +48 -0
  256. data/app/models/marty/poop.rb~ +169 -0
  257. data/app/models/marty/posting.rb +101 -0
  258. data/app/models/marty/posting.rb~ +86 -0
  259. data/app/models/marty/posting_type.rb +12 -0
  260. data/app/models/marty/posting_type.rb~ +21 -0
  261. data/app/models/marty/promise.rb +252 -0
  262. data/app/models/marty/promise.rb~ +196 -0
  263. data/app/models/marty/role.rb +6 -0
  264. data/app/models/marty/role.rb~ +10 -0
  265. data/app/models/marty/script.rb +144 -0
  266. data/app/models/marty/script.rb~ +62 -0
  267. data/app/models/marty/tag.rb +96 -0
  268. data/app/models/marty/tag.rb~ +91 -0
  269. data/app/models/marty/token.rb +30 -0
  270. data/app/models/marty/user.rb +146 -0
  271. data/app/models/marty/user.rb~ +148 -0
  272. data/app/models/marty/user_role.rb +7 -0
  273. data/app/models/marty/user_role.rb~ +13 -0
  274. data/app/views/layouts/marty/application.html.erb +12 -0
  275. data/app/views/layouts/marty/application.html.erb~ +11 -0
  276. data/config/locales/en.yml +134 -0
  277. data/config/routes.rb +6 -0
  278. data/config/routes.rb~ +10 -0
  279. data/db/migrate/001_create_marty_scripts.rb +14 -0
  280. data/db/migrate/003_create_marty_users.rb +12 -0
  281. data/db/migrate/004_create_marty_roles.rb +7 -0
  282. data/db/migrate/005_create_marty_user_roles.rb +14 -0
  283. data/db/migrate/006_create_marty_tokens.rb +14 -0
  284. data/db/migrate/008_create_marty_posting_types.rb +7 -0
  285. data/db/migrate/019_create_marty_postings.rb +18 -0
  286. data/db/migrate/019_create_marty_postings.rb~ +19 -0
  287. data/db/migrate/068_create_marty_import_types.rb +12 -0
  288. data/db/migrate/069_create_marty_import_synonyms.rb +15 -0
  289. data/db/migrate/070_create_versions.rb +18 -0
  290. data/db/migrate/071_add_object_changes_column_to_versions.rb +9 -0
  291. data/db/migrate/072_add_validation_function_to_import_types.rb +6 -0
  292. data/db/migrate/073_add_preprocess_function_to_import_types.rb +5 -0
  293. data/db/migrate/090_create_delayed_jobs.rb +22 -0
  294. data/db/migrate/091_create_marty_promises.rb +36 -0
  295. data/db/migrate/095_create_marty_tags.rb +14 -0
  296. data/db/migrate/095_create_marty_tags.rb~ +19 -0
  297. data/db/migrate/096_add_user_roles_to_import_types.rb +11 -0
  298. data/db/migrate/097_drop_versions.rb +9 -0
  299. data/db/migrate/098_create_marty_api_auths.rb +20 -0
  300. data/db/seeds.rb +48 -0
  301. data/lib/marty.rb +18 -0
  302. data/lib/marty.rb~ +13 -0
  303. data/lib/marty/content_handler.rb +97 -0
  304. data/lib/marty/content_handler.rb~ +93 -0
  305. data/lib/marty/data_conversion.rb +298 -0
  306. data/lib/marty/data_exporter.rb +150 -0
  307. data/lib/marty/data_exporter.rb~ +137 -0
  308. data/lib/marty/data_importer.rb +122 -0
  309. data/lib/marty/data_importer.rb~ +114 -0
  310. data/lib/marty/data_row_processor.rb~ +206 -0
  311. data/lib/marty/drop_folder_hook.rb~ +17 -0
  312. data/lib/marty/engine.rb +10 -0
  313. data/lib/marty/folder_hook.rb~ +9 -0
  314. data/lib/marty/lazy_column_loader.rb +57 -0
  315. data/lib/marty/lazy_column_loader.rb~ +47 -0
  316. data/lib/marty/mcfly_query.rb +189 -0
  317. data/lib/marty/mcfly_query.rb~ +188 -0
  318. data/lib/marty/migrations.rb +108 -0
  319. data/lib/marty/migrations.rb~ +65 -0
  320. data/lib/marty/monkey.rb +163 -0
  321. data/lib/marty/monkey.rb~ +160 -0
  322. data/lib/marty/permissions.rb +64 -0
  323. data/lib/marty/permissions.rb~ +69 -0
  324. data/lib/marty/promise.rb~ +41 -0
  325. data/lib/marty/promise_job.rb +123 -0
  326. data/lib/marty/promise_job.rb~ +121 -0
  327. data/lib/marty/promise_proxy.rb +94 -0
  328. data/lib/marty/promise_proxy.rb~ +69 -0
  329. data/lib/marty/railtie.rb +5 -0
  330. data/lib/marty/relation.rb +39 -0
  331. data/lib/marty/util.rb +110 -0
  332. data/lib/marty/util.rb~ +80 -0
  333. data/lib/marty/version.rb +3 -0
  334. data/lib/marty/version.rb~ +3 -0
  335. data/lib/marty/xl.rb +527 -0
  336. data/lib/marty/xl.rb~ +526 -0
  337. data/lib/pyxll/README.txt +19 -0
  338. data/lib/pyxll/README.txt~ +16 -0
  339. data/lib/pyxll/gemini.py +155 -0
  340. data/lib/pyxll/gemini.py~ +110 -0
  341. data/lib/pyxll/pyxll.cfg +12 -0
  342. data/lib/pyxll/pyxll.cfg~ +12 -0
  343. data/lib/pyxll/sample.xlsx +0 -0
  344. data/lib/tasks/marty_tasks.rake +37 -0
  345. metadata +517 -0
@@ -0,0 +1,284 @@
1
+ CodeMirror.defineMode("clike", function(config, parserConfig) {
2
+ var indentUnit = config.indentUnit,
3
+ keywords = parserConfig.keywords || {},
4
+ builtin = parserConfig.builtin || {},
5
+ blockKeywords = parserConfig.blockKeywords || {},
6
+ atoms = parserConfig.atoms || {},
7
+ hooks = parserConfig.hooks || {},
8
+ multiLineStrings = parserConfig.multiLineStrings;
9
+ var isOperatorChar = /[+\-*&%=<>!?|\/]/;
10
+
11
+ var curPunc;
12
+
13
+ function tokenBase(stream, state) {
14
+ var ch = stream.next();
15
+ if (hooks[ch]) {
16
+ var result = hooks[ch](stream, state);
17
+ if (result !== false) return result;
18
+ }
19
+ if (ch == '"' || ch == "'") {
20
+ state.tokenize = tokenString(ch);
21
+ return state.tokenize(stream, state);
22
+ }
23
+ if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
24
+ curPunc = ch;
25
+ return null;
26
+ }
27
+ if (/\d/.test(ch)) {
28
+ stream.eatWhile(/[\w\.]/);
29
+ return "number";
30
+ }
31
+ if (ch == "/") {
32
+ if (stream.eat("*")) {
33
+ state.tokenize = tokenComment;
34
+ return tokenComment(stream, state);
35
+ }
36
+ if (stream.eat("/")) {
37
+ stream.skipToEnd();
38
+ return "comment";
39
+ }
40
+ }
41
+ if (isOperatorChar.test(ch)) {
42
+ stream.eatWhile(isOperatorChar);
43
+ return "operator";
44
+ }
45
+ stream.eatWhile(/[\w\$_]/);
46
+ var cur = stream.current();
47
+ if (keywords.propertyIsEnumerable(cur)) {
48
+ if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
49
+ return "keyword";
50
+ }
51
+ if (builtin.propertyIsEnumerable(cur)) {
52
+ if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
53
+ return "builtin";
54
+ }
55
+ if (atoms.propertyIsEnumerable(cur)) return "atom";
56
+ return "variable";
57
+ }
58
+
59
+ function tokenString(quote) {
60
+ return function(stream, state) {
61
+ var escaped = false, next, end = false;
62
+ while ((next = stream.next()) != null) {
63
+ if (next == quote && !escaped) {end = true; break;}
64
+ escaped = !escaped && next == "\\";
65
+ }
66
+ if (end || !(escaped || multiLineStrings))
67
+ state.tokenize = null;
68
+ return "string";
69
+ };
70
+ }
71
+
72
+ function tokenComment(stream, state) {
73
+ var maybeEnd = false, ch;
74
+ while (ch = stream.next()) {
75
+ if (ch == "/" && maybeEnd) {
76
+ state.tokenize = null;
77
+ break;
78
+ }
79
+ maybeEnd = (ch == "*");
80
+ }
81
+ return "comment";
82
+ }
83
+
84
+ function Context(indented, column, type, align, prev) {
85
+ this.indented = indented;
86
+ this.column = column;
87
+ this.type = type;
88
+ this.align = align;
89
+ this.prev = prev;
90
+ }
91
+ function pushContext(state, col, type) {
92
+ return state.context = new Context(state.indented, col, type, null, state.context);
93
+ }
94
+ function popContext(state) {
95
+ var t = state.context.type;
96
+ if (t == ")" || t == "]" || t == "}")
97
+ state.indented = state.context.indented;
98
+ return state.context = state.context.prev;
99
+ }
100
+
101
+ // Interface
102
+
103
+ return {
104
+ startState: function(basecolumn) {
105
+ return {
106
+ tokenize: null,
107
+ context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
108
+ indented: 0,
109
+ startOfLine: true
110
+ };
111
+ },
112
+
113
+ token: function(stream, state) {
114
+ var ctx = state.context;
115
+ if (stream.sol()) {
116
+ if (ctx.align == null) ctx.align = false;
117
+ state.indented = stream.indentation();
118
+ state.startOfLine = true;
119
+ }
120
+ if (stream.eatSpace()) return null;
121
+ curPunc = null;
122
+ var style = (state.tokenize || tokenBase)(stream, state);
123
+ if (style == "comment" || style == "meta") return style;
124
+ if (ctx.align == null) ctx.align = true;
125
+
126
+ if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
127
+ else if (curPunc == "{") pushContext(state, stream.column(), "}");
128
+ else if (curPunc == "[") pushContext(state, stream.column(), "]");
129
+ else if (curPunc == "(") pushContext(state, stream.column(), ")");
130
+ else if (curPunc == "}") {
131
+ while (ctx.type == "statement") ctx = popContext(state);
132
+ if (ctx.type == "}") ctx = popContext(state);
133
+ while (ctx.type == "statement") ctx = popContext(state);
134
+ }
135
+ else if (curPunc == ctx.type) popContext(state);
136
+ else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
137
+ pushContext(state, stream.column(), "statement");
138
+ state.startOfLine = false;
139
+ return style;
140
+ },
141
+
142
+ indent: function(state, textAfter) {
143
+ if (state.tokenize != tokenBase && state.tokenize != null) return 0;
144
+ var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
145
+ if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
146
+ var closing = firstChar == ctx.type;
147
+ if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
148
+ else if (ctx.align) return ctx.column + (closing ? 0 : 1);
149
+ else return ctx.indented + (closing ? 0 : indentUnit);
150
+ },
151
+
152
+ electricChars: "{}"
153
+ };
154
+ });
155
+
156
+ (function() {
157
+ function words(str) {
158
+ var obj = {}, words = str.split(" ");
159
+ for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
160
+ return obj;
161
+ }
162
+ var cKeywords = "auto if break int case long char register continue return default short do sizeof " +
163
+ "double static else struct entry switch extern typedef float union for unsigned " +
164
+ "goto while enum void const signed volatile";
165
+
166
+ function cppHook(stream, state) {
167
+ if (!state.startOfLine) return false;
168
+ stream.skipToEnd();
169
+ return "meta";
170
+ }
171
+
172
+ // C#-style strings where "" escapes a quote.
173
+ function tokenAtString(stream, state) {
174
+ var next;
175
+ while ((next = stream.next()) != null) {
176
+ if (next == '"' && !stream.eat('"')) {
177
+ state.tokenize = null;
178
+ break;
179
+ }
180
+ }
181
+ return "string";
182
+ }
183
+
184
+ function mimes(ms, mode) {
185
+ for (var i = 0; i < ms.length; ++i) CodeMirror.defineMIME(ms[i], mode);
186
+ }
187
+
188
+ mimes(["text/x-csrc", "text/x-c", "text/x-chdr"], {
189
+ name: "clike",
190
+ keywords: words(cKeywords),
191
+ blockKeywords: words("case do else for if switch while struct"),
192
+ atoms: words("null"),
193
+ hooks: {"#": cppHook}
194
+ });
195
+ mimes(["text/x-c++src", "text/x-c++hdr"], {
196
+ name: "clike",
197
+ keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try bool explicit new " +
198
+ "static_cast typeid catch operator template typename class friend private " +
199
+ "this using const_cast inline public throw virtual delete mutable protected " +
200
+ "wchar_t"),
201
+ blockKeywords: words("catch class do else finally for if struct switch try while"),
202
+ atoms: words("true false null"),
203
+ hooks: {"#": cppHook}
204
+ });
205
+ CodeMirror.defineMIME("text/x-java", {
206
+ name: "clike",
207
+ keywords: words("abstract assert boolean break byte case catch char class const continue default " +
208
+ "do double else enum extends final finally float for goto if implements import " +
209
+ "instanceof int interface long native new package private protected public " +
210
+ "return short static strictfp super switch synchronized this throw throws transient " +
211
+ "try void volatile while"),
212
+ blockKeywords: words("catch class do else finally for if switch try while"),
213
+ atoms: words("true false null"),
214
+ hooks: {
215
+ "@": function(stream, state) {
216
+ stream.eatWhile(/[\w\$_]/);
217
+ return "meta";
218
+ }
219
+ }
220
+ });
221
+ CodeMirror.defineMIME("text/x-csharp", {
222
+ name: "clike",
223
+ keywords: words("abstract as base break case catch checked class const continue" +
224
+ " default delegate do else enum event explicit extern finally fixed for" +
225
+ " foreach goto if implicit in interface internal is lock namespace new" +
226
+ " operator out override params private protected public readonly ref return sealed" +
227
+ " sizeof stackalloc static struct switch this throw try typeof unchecked" +
228
+ " unsafe using virtual void volatile while add alias ascending descending dynamic from get" +
229
+ " global group into join let orderby partial remove select set value var yield"),
230
+ blockKeywords: words("catch class do else finally for foreach if struct switch try while"),
231
+ builtin: words("Boolean Byte Char DateTime DateTimeOffset Decimal Double" +
232
+ " Guid Int16 Int32 Int64 Object SByte Single String TimeSpan UInt16 UInt32" +
233
+ " UInt64 bool byte char decimal double short int long object" +
234
+ " sbyte float string ushort uint ulong"),
235
+ atoms: words("true false null"),
236
+ hooks: {
237
+ "@": function(stream, state) {
238
+ if (stream.eat('"')) {
239
+ state.tokenize = tokenAtString;
240
+ return tokenAtString(stream, state);
241
+ }
242
+ stream.eatWhile(/[\w\$_]/);
243
+ return "meta";
244
+ }
245
+ }
246
+ });
247
+ CodeMirror.defineMIME("text/x-scala", {
248
+ name: "clike",
249
+ keywords: words(
250
+
251
+ /* scala */
252
+ "abstract case catch class def do else extends false final finally for forSome if " +
253
+ "implicit import lazy match new null object override package private protected return " +
254
+ "sealed super this throw trait try trye type val var while with yield _ : = => <- <: " +
255
+ "<% >: # @ " +
256
+
257
+ /* package scala */
258
+ "assert assume require print println printf readLine readBoolean readByte readShort " +
259
+ "readChar readInt readLong readFloat readDouble " +
260
+
261
+ "AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either " +
262
+ "Enumeration Equiv Error Exception Fractional Function IndexedSeq Integral Iterable " +
263
+ "Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering " +
264
+ "Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder " +
265
+ "StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector :: #:: " +
266
+
267
+ /* package java.lang */
268
+ "Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +
269
+ "Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +
270
+ "Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +
271
+ "StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"
272
+
273
+
274
+ ),
275
+ blockKeywords: words("catch class do else finally for forSome if match switch try while"),
276
+ atoms: words("true false null"),
277
+ hooks: {
278
+ "@": function(stream, state) {
279
+ stream.eatWhile(/[\w\$_]/);
280
+ return "meta";
281
+ }
282
+ }
283
+ });
284
+ }());
@@ -0,0 +1,102 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>CodeMirror: C-like mode</title>
6
+ <link rel="stylesheet" href="../../lib/codemirror.css">
7
+ <script src="../../lib/codemirror.js"></script>
8
+ <script src="clike.js"></script>
9
+ <link rel="stylesheet" href="../../doc/docs.css">
10
+ <style>.CodeMirror {border: 2px inset #dee;}</style>
11
+ </head>
12
+ <body>
13
+ <h1>CodeMirror: C-like mode</h1>
14
+
15
+ <form><textarea id="code" name="code">
16
+ /* C demo code */
17
+
18
+ #include <zmq.h>
19
+ #include <pthread.h>
20
+ #include <semaphore.h>
21
+ #include <time.h>
22
+ #include <stdio.h>
23
+ #include <fcntl.h>
24
+ #include <malloc.h>
25
+
26
+ typedef struct {
27
+ void* arg_socket;
28
+ zmq_msg_t* arg_msg;
29
+ char* arg_string;
30
+ unsigned long arg_len;
31
+ int arg_int, arg_command;
32
+
33
+ int signal_fd;
34
+ int pad;
35
+ void* context;
36
+ sem_t sem;
37
+ } acl_zmq_context;
38
+
39
+ #define p(X) (context->arg_##X)
40
+
41
+ void* zmq_thread(void* context_pointer) {
42
+ acl_zmq_context* context = (acl_zmq_context*)context_pointer;
43
+ char ok = 'K', err = 'X';
44
+ int res;
45
+
46
+ while (1) {
47
+ while ((res = sem_wait(&amp;context->sem)) == EINTR);
48
+ if (res) {write(context->signal_fd, &amp;err, 1); goto cleanup;}
49
+ switch(p(command)) {
50
+ case 0: goto cleanup;
51
+ case 1: p(socket) = zmq_socket(context->context, p(int)); break;
52
+ case 2: p(int) = zmq_close(p(socket)); break;
53
+ case 3: p(int) = zmq_bind(p(socket), p(string)); break;
54
+ case 4: p(int) = zmq_connect(p(socket), p(string)); break;
55
+ case 5: p(int) = zmq_getsockopt(p(socket), p(int), (void*)p(string), &amp;p(len)); break;
56
+ case 6: p(int) = zmq_setsockopt(p(socket), p(int), (void*)p(string), p(len)); break;
57
+ case 7: p(int) = zmq_send(p(socket), p(msg), p(int)); break;
58
+ case 8: p(int) = zmq_recv(p(socket), p(msg), p(int)); break;
59
+ case 9: p(int) = zmq_poll(p(socket), p(int), p(len)); break;
60
+ }
61
+ p(command) = errno;
62
+ write(context->signal_fd, &amp;ok, 1);
63
+ }
64
+ cleanup:
65
+ close(context->signal_fd);
66
+ free(context_pointer);
67
+ return 0;
68
+ }
69
+
70
+ void* zmq_thread_init(void* zmq_context, int signal_fd) {
71
+ acl_zmq_context* context = malloc(sizeof(acl_zmq_context));
72
+ pthread_t thread;
73
+
74
+ context->context = zmq_context;
75
+ context->signal_fd = signal_fd;
76
+ sem_init(&amp;context->sem, 1, 0);
77
+ pthread_create(&amp;thread, 0, &amp;zmq_thread, context);
78
+ pthread_detach(thread);
79
+ return context;
80
+ }
81
+ </textarea></form>
82
+
83
+ <script>
84
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
85
+ lineNumbers: true,
86
+ matchBrackets: true,
87
+ mode: "text/x-csrc"
88
+ });
89
+ </script>
90
+
91
+ <p>Simple mode that tries to handle C-like languages as well as it
92
+ can. Takes two configuration parameters: <code>keywords</code>, an
93
+ object whose property names are the keywords in the language,
94
+ and <code>useCPP</code>, which determines whether C preprocessor
95
+ directives are recognized.</p>
96
+
97
+ <p><strong>MIME types defined:</strong> <code>text/x-csrc</code>
98
+ (C code), <code>text/x-c++src</code> (C++
99
+ code), <code>text/x-java</code> (Java
100
+ code), <code>text/x-csharp</code> (C#).</p>
101
+ </body>
102
+ </html>
@@ -0,0 +1,766 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>CodeMirror: C-like mode</title>
6
+ <link rel="stylesheet" href="../../lib/codemirror.css">
7
+ <link rel="stylesheet" href="../../theme/ambiance.css">
8
+ <script src="../../lib/codemirror.js"></script>
9
+ <script src="clike.js"></script>
10
+ <link rel="stylesheet" href="../../doc/docs.css">
11
+ <style>
12
+ body
13
+ {
14
+ margin: 0;
15
+ padding: 0;
16
+ max-width:inherit;
17
+ height: 100%;
18
+ }
19
+ html, form, .CodeMirror, .CodeMirror-scroll
20
+ {
21
+ height: 100%;
22
+ }
23
+ </style>
24
+ </head>
25
+ <body>
26
+ <form>
27
+ <textarea id="code" name="code">
28
+
29
+ /* __ *\
30
+ ** ________ ___ / / ___ Scala API **
31
+ ** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL **
32
+ ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
33
+ ** /____/\___/_/ |_/____/_/ | | **
34
+ ** |/ **
35
+ \* */
36
+
37
+ package scala.collection
38
+
39
+ import generic._
40
+ import mutable.{ Builder, ListBuffer }
41
+ import annotation.{tailrec, migration, bridge}
42
+ import annotation.unchecked.{ uncheckedVariance => uV }
43
+ import parallel.ParIterable
44
+
45
+ /** A template trait for traversable collections of type `Traversable[A]`.
46
+ *
47
+ * $traversableInfo
48
+ * @define mutability
49
+ * @define traversableInfo
50
+ * This is a base trait of all kinds of $mutability Scala collections. It
51
+ * implements the behavior common to all collections, in terms of a method
52
+ * `foreach` with signature:
53
+ * {{{
54
+ * def foreach[U](f: Elem => U): Unit
55
+ * }}}
56
+ * Collection classes mixing in this trait provide a concrete
57
+ * `foreach` method which traverses all the
58
+ * elements contained in the collection, applying a given function to each.
59
+ * They also need to provide a method `newBuilder`
60
+ * which creates a builder for collections of the same kind.
61
+ *
62
+ * A traversable class might or might not have two properties: strictness
63
+ * and orderedness. Neither is represented as a type.
64
+ *
65
+ * The instances of a strict collection class have all their elements
66
+ * computed before they can be used as values. By contrast, instances of
67
+ * a non-strict collection class may defer computation of some of their
68
+ * elements until after the instance is available as a value.
69
+ * A typical example of a non-strict collection class is a
70
+ * <a href="../immutable/Stream.html" target="ContentFrame">
71
+ * `scala.collection.immutable.Stream`</a>.
72
+ * A more general class of examples are `TraversableViews`.
73
+ *
74
+ * If a collection is an instance of an ordered collection class, traversing
75
+ * its elements with `foreach` will always visit elements in the
76
+ * same order, even for different runs of the program. If the class is not
77
+ * ordered, `foreach` can visit elements in different orders for
78
+ * different runs (but it will keep the same order in the same run).'
79
+ *
80
+ * A typical example of a collection class which is not ordered is a
81
+ * `HashMap` of objects. The traversal order for hash maps will
82
+ * depend on the hash codes of its elements, and these hash codes might
83
+ * differ from one run to the next. By contrast, a `LinkedHashMap`
84
+ * is ordered because it's `foreach` method visits elements in the
85
+ * order they were inserted into the `HashMap`.
86
+ *
87
+ * @author Martin Odersky
88
+ * @version 2.8
89
+ * @since 2.8
90
+ * @tparam A the element type of the collection
91
+ * @tparam Repr the type of the actual collection containing the elements.
92
+ *
93
+ * @define Coll Traversable
94
+ * @define coll traversable collection
95
+ */
96
+ trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr]
97
+ with FilterMonadic[A, Repr]
98
+ with TraversableOnce[A]
99
+ with GenTraversableLike[A, Repr]
100
+ with Parallelizable[A, ParIterable[A]]
101
+ {
102
+ self =>
103
+
104
+ import Traversable.breaks._
105
+
106
+ /** The type implementing this traversable */
107
+ protected type Self = Repr
108
+
109
+ /** The collection of type $coll underlying this `TraversableLike` object.
110
+ * By default this is implemented as the `TraversableLike` object itself,
111
+ * but this can be overridden.
112
+ */
113
+ def repr: Repr = this.asInstanceOf[Repr]
114
+
115
+ /** The underlying collection seen as an instance of `$Coll`.
116
+ * By default this is implemented as the current collection object itself,
117
+ * but this can be overridden.
118
+ */
119
+ protected[this] def thisCollection: Traversable[A] = this.asInstanceOf[Traversable[A]]
120
+
121
+ /** A conversion from collections of type `Repr` to `$Coll` objects.
122
+ * By default this is implemented as just a cast, but this can be overridden.
123
+ */
124
+ protected[this] def toCollection(repr: Repr): Traversable[A] = repr.asInstanceOf[Traversable[A]]
125
+
126
+ /** Creates a new builder for this collection type.
127
+ */
128
+ protected[this] def newBuilder: Builder[A, Repr]
129
+
130
+ protected[this] def parCombiner = ParIterable.newCombiner[A]
131
+
132
+ /** Applies a function `f` to all elements of this $coll.
133
+ *
134
+ * Note: this method underlies the implementation of most other bulk operations.
135
+ * It's important to implement this method in an efficient way.
136
+ *
137
+ *
138
+ * @param f the function that is applied for its side-effect to every element.
139
+ * The result of function `f` is discarded.
140
+ *
141
+ * @tparam U the type parameter describing the result of function `f`.
142
+ * This result will always be ignored. Typically `U` is `Unit`,
143
+ * but this is not necessary.
144
+ *
145
+ * @usecase def foreach(f: A => Unit): Unit
146
+ */
147
+ def foreach[U](f: A => U): Unit
148
+
149
+ /** Tests whether this $coll is empty.
150
+ *
151
+ * @return `true` if the $coll contain no elements, `false` otherwise.
152
+ */
153
+ def isEmpty: Boolean = {
154
+ var result = true
155
+ breakable {
156
+ for (x <- this) {
157
+ result = false
158
+ break
159
+ }
160
+ }
161
+ result
162
+ }
163
+
164
+ /** Tests whether this $coll is known to have a finite size.
165
+ * All strict collections are known to have finite size. For a non-strict collection
166
+ * such as `Stream`, the predicate returns `true` if all elements have been computed.
167
+ * It returns `false` if the stream is not yet evaluated to the end.
168
+ *
169
+ * Note: many collection methods will not work on collections of infinite sizes.
170
+ *
171
+ * @return `true` if this collection is known to have finite size, `false` otherwise.
172
+ */
173
+ def hasDefiniteSize = true
174
+
175
+ def ++[B >: A, That](that: GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
176
+ val b = bf(repr)
177
+ if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.seq.size)
178
+ b ++= thisCollection
179
+ b ++= that.seq
180
+ b.result
181
+ }
182
+
183
+ @bridge
184
+ def ++[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That =
185
+ ++(that: GenTraversableOnce[B])(bf)
186
+
187
+ /** Concatenates this $coll with the elements of a traversable collection.
188
+ * It differs from ++ in that the right operand determines the type of the
189
+ * resulting collection rather than the left one.
190
+ *
191
+ * @param that the traversable to append.
192
+ * @tparam B the element type of the returned collection.
193
+ * @tparam That $thatinfo
194
+ * @param bf $bfinfo
195
+ * @return a new collection of type `That` which contains all elements
196
+ * of this $coll followed by all elements of `that`.
197
+ *
198
+ * @usecase def ++:[B](that: TraversableOnce[B]): $Coll[B]
199
+ *
200
+ * @return a new $coll which contains all elements of this $coll
201
+ * followed by all elements of `that`.
202
+ */
203
+ def ++:[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
204
+ val b = bf(repr)
205
+ if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.size)
206
+ b ++= that
207
+ b ++= thisCollection
208
+ b.result
209
+ }
210
+
211
+ /** This overload exists because: for the implementation of ++: we should reuse
212
+ * that of ++ because many collections override it with more efficient versions.
213
+ * Since TraversableOnce has no '++' method, we have to implement that directly,
214
+ * but Traversable and down can use the overload.
215
+ */
216
+ def ++:[B >: A, That](that: Traversable[B])(implicit bf: CanBuildFrom[Repr, B, That]): That =
217
+ (that ++ seq)(breakOut)
218
+
219
+ def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
220
+ val b = bf(repr)
221
+ b.sizeHint(this)
222
+ for (x <- this) b += f(x)
223
+ b.result
224
+ }
225
+
226
+ def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
227
+ val b = bf(repr)
228
+ for (x <- this) b ++= f(x).seq
229
+ b.result
230
+ }
231
+
232
+ /** Selects all elements of this $coll which satisfy a predicate.
233
+ *
234
+ * @param p the predicate used to test elements.
235
+ * @return a new $coll consisting of all elements of this $coll that satisfy the given
236
+ * predicate `p`. The order of the elements is preserved.
237
+ */
238
+ def filter(p: A => Boolean): Repr = {
239
+ val b = newBuilder
240
+ for (x <- this)
241
+ if (p(x)) b += x
242
+ b.result
243
+ }
244
+
245
+ /** Selects all elements of this $coll which do not satisfy a predicate.
246
+ *
247
+ * @param p the predicate used to test elements.
248
+ * @return a new $coll consisting of all elements of this $coll that do not satisfy the given
249
+ * predicate `p`. The order of the elements is preserved.
250
+ */
251
+ def filterNot(p: A => Boolean): Repr = filter(!p(_))
252
+
253
+ def collect[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
254
+ val b = bf(repr)
255
+ for (x <- this) if (pf.isDefinedAt(x)) b += pf(x)
256
+ b.result
257
+ }
258
+
259
+ /** Builds a new collection by applying an option-valued function to all
260
+ * elements of this $coll on which the function is defined.
261
+ *
262
+ * @param f the option-valued function which filters and maps the $coll.
263
+ * @tparam B the element type of the returned collection.
264
+ * @tparam That $thatinfo
265
+ * @param bf $bfinfo
266
+ * @return a new collection of type `That` resulting from applying the option-valued function
267
+ * `f` to each element and collecting all defined results.
268
+ * The order of the elements is preserved.
269
+ *
270
+ * @usecase def filterMap[B](f: A => Option[B]): $Coll[B]
271
+ *
272
+ * @param pf the partial function which filters and maps the $coll.
273
+ * @return a new $coll resulting from applying the given option-valued function
274
+ * `f` to each element and collecting all defined results.
275
+ * The order of the elements is preserved.
276
+ def filterMap[B, That](f: A => Option[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
277
+ val b = bf(repr)
278
+ for (x <- this)
279
+ f(x) match {
280
+ case Some(y) => b += y
281
+ case _ =>
282
+ }
283
+ b.result
284
+ }
285
+ */
286
+
287
+ /** Partitions this $coll in two ${coll}s according to a predicate.
288
+ *
289
+ * @param p the predicate on which to partition.
290
+ * @return a pair of ${coll}s: the first $coll consists of all elements that
291
+ * satisfy the predicate `p` and the second $coll consists of all elements
292
+ * that don't. The relative order of the elements in the resulting ${coll}s
293
+ * is the same as in the original $coll.
294
+ */
295
+ def partition(p: A => Boolean): (Repr, Repr) = {
296
+ val l, r = newBuilder
297
+ for (x <- this) (if (p(x)) l else r) += x
298
+ (l.result, r.result)
299
+ }
300
+
301
+ def groupBy[K](f: A => K): immutable.Map[K, Repr] = {
302
+ val m = mutable.Map.empty[K, Builder[A, Repr]]
303
+ for (elem <- this) {
304
+ val key = f(elem)
305
+ val bldr = m.getOrElseUpdate(key, newBuilder)
306
+ bldr += elem
307
+ }
308
+ val b = immutable.Map.newBuilder[K, Repr]
309
+ for ((k, v) <- m)
310
+ b += ((k, v.result))
311
+
312
+ b.result
313
+ }
314
+
315
+ /** Tests whether a predicate holds for all elements of this $coll.
316
+ *
317
+ * $mayNotTerminateInf
318
+ *
319
+ * @param p the predicate used to test elements.
320
+ * @return `true` if the given predicate `p` holds for all elements
321
+ * of this $coll, otherwise `false`.
322
+ */
323
+ def forall(p: A => Boolean): Boolean = {
324
+ var result = true
325
+ breakable {
326
+ for (x <- this)
327
+ if (!p(x)) { result = false; break }
328
+ }
329
+ result
330
+ }
331
+
332
+ /** Tests whether a predicate holds for some of the elements of this $coll.
333
+ *
334
+ * $mayNotTerminateInf
335
+ *
336
+ * @param p the predicate used to test elements.
337
+ * @return `true` if the given predicate `p` holds for some of the
338
+ * elements of this $coll, otherwise `false`.
339
+ */
340
+ def exists(p: A => Boolean): Boolean = {
341
+ var result = false
342
+ breakable {
343
+ for (x <- this)
344
+ if (p(x)) { result = true; break }
345
+ }
346
+ result
347
+ }
348
+
349
+ /** Finds the first element of the $coll satisfying a predicate, if any.
350
+ *
351
+ * $mayNotTerminateInf
352
+ * $orderDependent
353
+ *
354
+ * @param p the predicate used to test elements.
355
+ * @return an option value containing the first element in the $coll
356
+ * that satisfies `p`, or `None` if none exists.
357
+ */
358
+ def find(p: A => Boolean): Option[A] = {
359
+ var result: Option[A] = None
360
+ breakable {
361
+ for (x <- this)
362
+ if (p(x)) { result = Some(x); break }
363
+ }
364
+ result
365
+ }
366
+
367
+ def scan[B >: A, That](z: B)(op: (B, B) => B)(implicit cbf: CanBuildFrom[Repr, B, That]): That = scanLeft(z)(op)
368
+
369
+ def scanLeft[B, That](z: B)(op: (B, A) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
370
+ val b = bf(repr)
371
+ b.sizeHint(this, 1)
372
+ var acc = z
373
+ b += acc
374
+ for (x <- this) { acc = op(acc, x); b += acc }
375
+ b.result
376
+ }
377
+
378
+ @migration(2, 9,
379
+ "This scanRight definition has changed in 2.9.\n" +
380
+ "The previous behavior can be reproduced with scanRight.reverse."
381
+ )
382
+ def scanRight[B, That](z: B)(op: (A, B) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
383
+ var scanned = List(z)
384
+ var acc = z
385
+ for (x <- reversed) {
386
+ acc = op(x, acc)
387
+ scanned ::= acc
388
+ }
389
+ val b = bf(repr)
390
+ for (elem <- scanned) b += elem
391
+ b.result
392
+ }
393
+
394
+ /** Selects the first element of this $coll.
395
+ * $orderDependent
396
+ * @return the first element of this $coll.
397
+ * @throws `NoSuchElementException` if the $coll is empty.
398
+ */
399
+ def head: A = {
400
+ var result: () => A = () => throw new NoSuchElementException
401
+ breakable {
402
+ for (x <- this) {
403
+ result = () => x
404
+ break
405
+ }
406
+ }
407
+ result()
408
+ }
409
+
410
+ /** Optionally selects the first element.
411
+ * $orderDependent
412
+ * @return the first element of this $coll if it is nonempty, `None` if it is empty.
413
+ */
414
+ def headOption: Option[A] = if (isEmpty) None else Some(head)
415
+
416
+ /** Selects all elements except the first.
417
+ * $orderDependent
418
+ * @return a $coll consisting of all elements of this $coll
419
+ * except the first one.
420
+ * @throws `UnsupportedOperationException` if the $coll is empty.
421
+ */
422
+ override def tail: Repr = {
423
+ if (isEmpty) throw new UnsupportedOperationException("empty.tail")
424
+ drop(1)
425
+ }
426
+
427
+ /** Selects the last element.
428
+ * $orderDependent
429
+ * @return The last element of this $coll.
430
+ * @throws NoSuchElementException If the $coll is empty.
431
+ */
432
+ def last: A = {
433
+ var lst = head
434
+ for (x <- this)
435
+ lst = x
436
+ lst
437
+ }
438
+
439
+ /** Optionally selects the last element.
440
+ * $orderDependent
441
+ * @return the last element of this $coll$ if it is nonempty, `None` if it is empty.
442
+ */
443
+ def lastOption: Option[A] = if (isEmpty) None else Some(last)
444
+
445
+ /** Selects all elements except the last.
446
+ * $orderDependent
447
+ * @return a $coll consisting of all elements of this $coll
448
+ * except the last one.
449
+ * @throws `UnsupportedOperationException` if the $coll is empty.
450
+ */
451
+ def init: Repr = {
452
+ if (isEmpty) throw new UnsupportedOperationException("empty.init")
453
+ var lst = head
454
+ var follow = false
455
+ val b = newBuilder
456
+ b.sizeHint(this, -1)
457
+ for (x <- this.seq) {
458
+ if (follow) b += lst
459
+ else follow = true
460
+ lst = x
461
+ }
462
+ b.result
463
+ }
464
+
465
+ def take(n: Int): Repr = slice(0, n)
466
+
467
+ def drop(n: Int): Repr =
468
+ if (n <= 0) {
469
+ val b = newBuilder
470
+ b.sizeHint(this)
471
+ b ++= thisCollection result
472
+ }
473
+ else sliceWithKnownDelta(n, Int.MaxValue, -n)
474
+
475
+ def slice(from: Int, until: Int): Repr = sliceWithKnownBound(math.max(from, 0), until)
476
+
477
+ // Precondition: from >= 0, until > 0, builder already configured for building.
478
+ private[this] def sliceInternal(from: Int, until: Int, b: Builder[A, Repr]): Repr = {
479
+ var i = 0
480
+ breakable {
481
+ for (x <- this.seq) {
482
+ if (i >= from) b += x
483
+ i += 1
484
+ if (i >= until) break
485
+ }
486
+ }
487
+ b.result
488
+ }
489
+ // Precondition: from >= 0
490
+ private[scala] def sliceWithKnownDelta(from: Int, until: Int, delta: Int): Repr = {
491
+ val b = newBuilder
492
+ if (until <= from) b.result
493
+ else {
494
+ b.sizeHint(this, delta)
495
+ sliceInternal(from, until, b)
496
+ }
497
+ }
498
+ // Precondition: from >= 0
499
+ private[scala] def sliceWithKnownBound(from: Int, until: Int): Repr = {
500
+ val b = newBuilder
501
+ if (until <= from) b.result
502
+ else {
503
+ b.sizeHintBounded(until - from, this)
504
+ sliceInternal(from, until, b)
505
+ }
506
+ }
507
+
508
+ def takeWhile(p: A => Boolean): Repr = {
509
+ val b = newBuilder
510
+ breakable {
511
+ for (x <- this) {
512
+ if (!p(x)) break
513
+ b += x
514
+ }
515
+ }
516
+ b.result
517
+ }
518
+
519
+ def dropWhile(p: A => Boolean): Repr = {
520
+ val b = newBuilder
521
+ var go = false
522
+ for (x <- this) {
523
+ if (!p(x)) go = true
524
+ if (go) b += x
525
+ }
526
+ b.result
527
+ }
528
+
529
+ def span(p: A => Boolean): (Repr, Repr) = {
530
+ val l, r = newBuilder
531
+ var toLeft = true
532
+ for (x <- this) {
533
+ toLeft = toLeft && p(x)
534
+ (if (toLeft) l else r) += x
535
+ }
536
+ (l.result, r.result)
537
+ }
538
+
539
+ def splitAt(n: Int): (Repr, Repr) = {
540
+ val l, r = newBuilder
541
+ l.sizeHintBounded(n, this)
542
+ if (n >= 0) r.sizeHint(this, -n)
543
+ var i = 0
544
+ for (x <- this) {
545
+ (if (i < n) l else r) += x
546
+ i += 1
547
+ }
548
+ (l.result, r.result)
549
+ }
550
+
551
+ /** Iterates over the tails of this $coll. The first value will be this
552
+ * $coll and the final one will be an empty $coll, with the intervening
553
+ * values the results of successive applications of `tail`.
554
+ *
555
+ * @return an iterator over all the tails of this $coll
556
+ * @example `List(1,2,3).tails = Iterator(List(1,2,3), List(2,3), List(3), Nil)`
557
+ */
558
+ def tails: Iterator[Repr] = iterateUntilEmpty(_.tail)
559
+
560
+ /** Iterates over the inits of this $coll. The first value will be this
561
+ * $coll and the final one will be an empty $coll, with the intervening
562
+ * values the results of successive applications of `init`.
563
+ *
564
+ * @return an iterator over all the inits of this $coll
565
+ * @example `List(1,2,3).inits = Iterator(List(1,2,3), List(1,2), List(1), Nil)`
566
+ */
567
+ def inits: Iterator[Repr] = iterateUntilEmpty(_.init)
568
+
569
+ /** Copies elements of this $coll to an array.
570
+ * Fills the given array `xs` with at most `len` elements of
571
+ * this $coll, starting at position `start`.
572
+ * Copying will stop once either the end of the current $coll is reached,
573
+ * or the end of the array is reached, or `len` elements have been copied.
574
+ *
575
+ * $willNotTerminateInf
576
+ *
577
+ * @param xs the array to fill.
578
+ * @param start the starting index.
579
+ * @param len the maximal number of elements to copy.
580
+ * @tparam B the type of the elements of the array.
581
+ *
582
+ *
583
+ * @usecase def copyToArray(xs: Array[A], start: Int, len: Int): Unit
584
+ */
585
+ def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) {
586
+ var i = start
587
+ val end = (start + len) min xs.length
588
+ breakable {
589
+ for (x <- this) {
590
+ if (i >= end) break
591
+ xs(i) = x
592
+ i += 1
593
+ }
594
+ }
595
+ }
596
+
597
+ def toTraversable: Traversable[A] = thisCollection
598
+ def toIterator: Iterator[A] = toStream.iterator
599
+ def toStream: Stream[A] = toBuffer.toStream
600
+
601
+ /** Converts this $coll to a string.
602
+ *
603
+ * @return a string representation of this collection. By default this
604
+ * string consists of the `stringPrefix` of this $coll,
605
+ * followed by all elements separated by commas and enclosed in parentheses.
606
+ */
607
+ override def toString = mkString(stringPrefix + "(", ", ", ")")
608
+
609
+ /** Defines the prefix of this object's `toString` representation.
610
+ *
611
+ * @return a string representation which starts the result of `toString`
612
+ * applied to this $coll. By default the string prefix is the
613
+ * simple name of the collection class $coll.
614
+ */
615
+ def stringPrefix : String = {
616
+ var string = repr.asInstanceOf[AnyRef].getClass.getName
617
+ val idx1 = string.lastIndexOf('.' : Int)
618
+ if (idx1 != -1) string = string.substring(idx1 + 1)
619
+ val idx2 = string.indexOf('$')
620
+ if (idx2 != -1) string = string.substring(0, idx2)
621
+ string
622
+ }
623
+
624
+ /** Creates a non-strict view of this $coll.
625
+ *
626
+ * @return a non-strict view of this $coll.
627
+ */
628
+ def view = new TraversableView[A, Repr] {
629
+ protected lazy val underlying = self.repr
630
+ override def foreach[U](f: A => U) = self foreach f
631
+ }
632
+
633
+ /** Creates a non-strict view of a slice of this $coll.
634
+ *
635
+ * Note: the difference between `view` and `slice` is that `view` produces
636
+ * a view of the current $coll, whereas `slice` produces a new $coll.
637
+ *
638
+ * Note: `view(from, to)` is equivalent to `view.slice(from, to)`
639
+ * $orderDependent
640
+ *
641
+ * @param from the index of the first element of the view
642
+ * @param until the index of the element following the view
643
+ * @return a non-strict view of a slice of this $coll, starting at index `from`
644
+ * and extending up to (but not including) index `until`.
645
+ */
646
+ def view(from: Int, until: Int): TraversableView[A, Repr] = view.slice(from, until)
647
+
648
+ /** Creates a non-strict filter of this $coll.
649
+ *
650
+ * Note: the difference between `c filter p` and `c withFilter p` is that
651
+ * the former creates a new collection, whereas the latter only
652
+ * restricts the domain of subsequent `map`, `flatMap`, `foreach`,
653
+ * and `withFilter` operations.
654
+ * $orderDependent
655
+ *
656
+ * @param p the predicate used to test elements.
657
+ * @return an object of class `WithFilter`, which supports
658
+ * `map`, `flatMap`, `foreach`, and `withFilter` operations.
659
+ * All these operations apply to those elements of this $coll which
660
+ * satisfy the predicate `p`.
661
+ */
662
+ def withFilter(p: A => Boolean): FilterMonadic[A, Repr] = new WithFilter(p)
663
+
664
+ /** A class supporting filtered operations. Instances of this class are
665
+ * returned by method `withFilter`.
666
+ */
667
+ class WithFilter(p: A => Boolean) extends FilterMonadic[A, Repr] {
668
+
669
+ /** Builds a new collection by applying a function to all elements of the
670
+ * outer $coll containing this `WithFilter` instance that satisfy predicate `p`.
671
+ *
672
+ * @param f the function to apply to each element.
673
+ * @tparam B the element type of the returned collection.
674
+ * @tparam That $thatinfo
675
+ * @param bf $bfinfo
676
+ * @return a new collection of type `That` resulting from applying
677
+ * the given function `f` to each element of the outer $coll
678
+ * that satisfies predicate `p` and collecting the results.
679
+ *
680
+ * @usecase def map[B](f: A => B): $Coll[B]
681
+ *
682
+ * @return a new $coll resulting from applying the given function
683
+ * `f` to each element of the outer $coll that satisfies
684
+ * predicate `p` and collecting the results.
685
+ */
686
+ def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
687
+ val b = bf(repr)
688
+ for (x <- self)
689
+ if (p(x)) b += f(x)
690
+ b.result
691
+ }
692
+
693
+ /** Builds a new collection by applying a function to all elements of the
694
+ * outer $coll containing this `WithFilter` instance that satisfy
695
+ * predicate `p` and concatenating the results.
696
+ *
697
+ * @param f the function to apply to each element.
698
+ * @tparam B the element type of the returned collection.
699
+ * @tparam That $thatinfo
700
+ * @param bf $bfinfo
701
+ * @return a new collection of type `That` resulting from applying
702
+ * the given collection-valued function `f` to each element
703
+ * of the outer $coll that satisfies predicate `p` and
704
+ * concatenating the results.
705
+ *
706
+ * @usecase def flatMap[B](f: A => TraversableOnce[B]): $Coll[B]
707
+ *
708
+ * @return a new $coll resulting from applying the given collection-valued function
709
+ * `f` to each element of the outer $coll that satisfies predicate `p` and concatenating the results.
710
+ */
711
+ def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
712
+ val b = bf(repr)
713
+ for (x <- self)
714
+ if (p(x)) b ++= f(x).seq
715
+ b.result
716
+ }
717
+
718
+ /** Applies a function `f` to all elements of the outer $coll containing
719
+ * this `WithFilter` instance that satisfy predicate `p`.
720
+ *
721
+ * @param f the function that is applied for its side-effect to every element.
722
+ * The result of function `f` is discarded.
723
+ *
724
+ * @tparam U the type parameter describing the result of function `f`.
725
+ * This result will always be ignored. Typically `U` is `Unit`,
726
+ * but this is not necessary.
727
+ *
728
+ * @usecase def foreach(f: A => Unit): Unit
729
+ */
730
+ def foreach[U](f: A => U): Unit =
731
+ for (x <- self)
732
+ if (p(x)) f(x)
733
+
734
+ /** Further refines the filter for this $coll.
735
+ *
736
+ * @param q the predicate used to test elements.
737
+ * @return an object of class `WithFilter`, which supports
738
+ * `map`, `flatMap`, `foreach`, and `withFilter` operations.
739
+ * All these operations apply to those elements of this $coll which
740
+ * satisfy the predicate `q` in addition to the predicate `p`.
741
+ */
742
+ def withFilter(q: A => Boolean): WithFilter =
743
+ new WithFilter(x => p(x) && q(x))
744
+ }
745
+
746
+ // A helper for tails and inits.
747
+ private def iterateUntilEmpty(f: Traversable[A @uV] => Traversable[A @uV]): Iterator[Repr] = {
748
+ val it = Iterator.iterate(thisCollection)(f) takeWhile (x => !x.isEmpty)
749
+ it ++ Iterator(Nil) map (newBuilder ++= _ result)
750
+ }
751
+ }
752
+
753
+
754
+ </textarea>
755
+ </form>
756
+
757
+ <script>
758
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
759
+ lineNumbers: true,
760
+ matchBrackets: true,
761
+ theme: "ambiance",
762
+ mode: "text/x-scala"
763
+ });
764
+ </script>
765
+ </body>
766
+ </html>