postrest 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (234) hide show
  1. checksums.yaml +4 -4
  2. data/lib/app.rb +1 -1
  3. data/public/index.htm +116 -0
  4. data/public/node_modules/pivottable/CONTRIBUTING.md +19 -0
  5. data/public/node_modules/pivottable/LICENSE.md +9 -0
  6. data/public/node_modules/pivottable/ReadMe.md +155 -0
  7. data/public/node_modules/pivottable/bower.json +31 -0
  8. data/public/node_modules/pivottable/c3_renderers.coffee +155 -0
  9. data/public/node_modules/pivottable/d3_renderers.coffee +73 -0
  10. data/public/node_modules/pivottable/dist/c3_renderers.js +256 -0
  11. data/public/node_modules/pivottable/dist/c3_renderers.js.map +1 -0
  12. data/public/node_modules/pivottable/dist/c3_renderers.min.js +2 -0
  13. data/public/node_modules/pivottable/dist/c3_renderers.min.js.map +1 -0
  14. data/public/node_modules/pivottable/dist/d3_renderers.js +105 -0
  15. data/public/node_modules/pivottable/dist/d3_renderers.js.map +1 -0
  16. data/public/node_modules/pivottable/dist/d3_renderers.min.js +2 -0
  17. data/public/node_modules/pivottable/dist/d3_renderers.min.js.map +1 -0
  18. data/public/node_modules/pivottable/dist/export_renderers.js +80 -0
  19. data/public/node_modules/pivottable/dist/export_renderers.js.map +1 -0
  20. data/public/node_modules/pivottable/dist/export_renderers.min.js +2 -0
  21. data/public/node_modules/pivottable/dist/export_renderers.min.js.map +1 -0
  22. data/public/node_modules/pivottable/dist/gchart_renderers.js +183 -0
  23. data/public/node_modules/pivottable/dist/gchart_renderers.js.map +1 -0
  24. data/public/node_modules/pivottable/dist/gchart_renderers.min.js +2 -0
  25. data/public/node_modules/pivottable/dist/gchart_renderers.min.js.map +1 -0
  26. data/public/node_modules/pivottable/dist/pivot.css +97 -0
  27. data/public/node_modules/pivottable/dist/pivot.es.js +78 -0
  28. data/public/node_modules/pivottable/dist/pivot.es.js.map +1 -0
  29. data/public/node_modules/pivottable/dist/pivot.es.min.js +2 -0
  30. data/public/node_modules/pivottable/dist/pivot.es.min.js.map +1 -0
  31. data/public/node_modules/pivottable/dist/pivot.fr.js +78 -0
  32. data/public/node_modules/pivottable/dist/pivot.fr.js.map +1 -0
  33. data/public/node_modules/pivottable/dist/pivot.fr.min.js +2 -0
  34. data/public/node_modules/pivottable/dist/pivot.fr.min.js.map +1 -0
  35. data/public/node_modules/pivottable/dist/pivot.js +1511 -0
  36. data/public/node_modules/pivottable/dist/pivot.js.map +1 -0
  37. data/public/node_modules/pivottable/dist/pivot.min.css +1 -0
  38. data/public/node_modules/pivottable/dist/pivot.min.js +2 -0
  39. data/public/node_modules/pivottable/dist/pivot.min.js.map +1 -0
  40. data/public/node_modules/pivottable/dist/pivot.nl.js +78 -0
  41. data/public/node_modules/pivottable/dist/pivot.nl.js.map +1 -0
  42. data/public/node_modules/pivottable/dist/pivot.nl.min.js +2 -0
  43. data/public/node_modules/pivottable/dist/pivot.nl.min.js.map +1 -0
  44. data/public/node_modules/pivottable/dist/pivot.pt.js +104 -0
  45. data/public/node_modules/pivottable/dist/pivot.pt.js.map +1 -0
  46. data/public/node_modules/pivottable/dist/pivot.pt.min.js +2 -0
  47. data/public/node_modules/pivottable/dist/pivot.pt.min.js.map +1 -0
  48. data/public/node_modules/pivottable/dist/pivot.ru.js +78 -0
  49. data/public/node_modules/pivottable/dist/pivot.ru.js.map +1 -0
  50. data/public/node_modules/pivottable/dist/pivot.ru.min.js +2 -0
  51. data/public/node_modules/pivottable/dist/pivot.ru.min.js.map +1 -0
  52. data/public/node_modules/pivottable/dist/pivot.tr.js +104 -0
  53. data/public/node_modules/pivottable/dist/pivot.tr.js.map +1 -0
  54. data/public/node_modules/pivottable/dist/pivot.tr.min.js +2 -0
  55. data/public/node_modules/pivottable/dist/pivot.tr.min.js.map +1 -0
  56. data/public/node_modules/pivottable/dist/tips_data.min.js +247 -0
  57. data/public/node_modules/pivottable/examples/c3.html +61 -0
  58. data/public/node_modules/pivottable/examples/d3.html +49 -0
  59. data/public/node_modules/pivottable/examples/fully_loaded.html +80 -0
  60. data/public/node_modules/pivottable/examples/gchart.html +53 -0
  61. data/public/node_modules/pivottable/examples/gh-fork-ribbon.css +140 -0
  62. data/public/node_modules/pivottable/examples/gh-fork-ribbon.ie.css +78 -0
  63. data/public/node_modules/pivottable/examples/index.html +85 -0
  64. data/public/node_modules/pivottable/examples/local.html +74 -0
  65. data/public/node_modules/pivottable/examples/montreal_2014.csv +366 -0
  66. data/public/node_modules/pivottable/examples/montreal_2014.html +106 -0
  67. data/public/node_modules/pivottable/examples/mps.csv +309 -0
  68. data/public/node_modules/pivottable/examples/mps.html +45 -0
  69. data/public/node_modules/pivottable/examples/mps.json +1 -0
  70. data/public/node_modules/pivottable/examples/mps_agg.html +44 -0
  71. data/public/node_modules/pivottable/examples/mps_csv.html +42 -0
  72. data/public/node_modules/pivottable/examples/mps_export.html +44 -0
  73. data/public/node_modules/pivottable/examples/mps_fr.html +40 -0
  74. data/public/node_modules/pivottable/examples/mps_prepop.html +42 -0
  75. data/public/node_modules/pivottable/examples/onrefresh.html +52 -0
  76. data/public/node_modules/pivottable/examples/rcsvs.html +87 -0
  77. data/public/node_modules/pivottable/examples/scatter.html +53 -0
  78. data/public/node_modules/pivottable/examples/show_code.js +17 -0
  79. data/public/node_modules/pivottable/examples/simple.html +41 -0
  80. data/public/node_modules/pivottable/examples/simple_agg.html +51 -0
  81. data/public/node_modules/pivottable/examples/simple_function.html +57 -0
  82. data/public/node_modules/pivottable/examples/simple_ui.html +42 -0
  83. data/public/node_modules/pivottable/examples/simple_ui_from_table.html +60 -0
  84. data/public/node_modules/pivottable/export_renderers.coffee +57 -0
  85. data/public/node_modules/pivottable/gchart_renderers.coffee +111 -0
  86. data/public/node_modules/pivottable/gulpFile.js +95 -0
  87. data/public/node_modules/pivottable/images/animation.gif +0 -0
  88. data/public/node_modules/pivottable/images/filters.png +0 -0
  89. data/public/node_modules/pivottable/images/gender_age_bins.png +0 -0
  90. data/public/node_modules/pivottable/images/gender_imbalance.png +0 -0
  91. data/public/node_modules/pivottable/images/gender_imbalance_instructions.png +0 -0
  92. data/public/node_modules/pivottable/images/initial_state.png +0 -0
  93. data/public/node_modules/pivottable/images/province_x_party_heatmap.png +0 -0
  94. data/public/node_modules/pivottable/images/province_x_party_heatmap_instructions.png +0 -0
  95. data/public/node_modules/pivottable/images/simple.png +0 -0
  96. data/public/node_modules/pivottable/images/simple_ui.png +0 -0
  97. data/public/node_modules/pivottable/images/whats_what.png +0 -0
  98. data/public/node_modules/pivottable/index.html +14 -0
  99. data/public/node_modules/pivottable/node_modules/jquery/AUTHORS.txt +278 -0
  100. data/public/node_modules/pivottable/node_modules/jquery/LICENSE.txt +36 -0
  101. data/public/node_modules/pivottable/node_modules/jquery/README.md +65 -0
  102. data/public/node_modules/pivottable/node_modules/jquery/bower.json +14 -0
  103. data/public/node_modules/pivottable/node_modules/jquery/dist/jquery.js +9842 -0
  104. data/public/node_modules/pivottable/node_modules/jquery/dist/jquery.min.js +4 -0
  105. data/public/node_modules/pivottable/node_modules/jquery/dist/jquery.min.map +1 -0
  106. data/public/node_modules/pivottable/node_modules/jquery/dist/jquery.slim.js +7877 -0
  107. data/public/node_modules/pivottable/node_modules/jquery/dist/jquery.slim.min.js +4 -0
  108. data/public/node_modules/pivottable/node_modules/jquery/dist/jquery.slim.min.map +1 -0
  109. data/public/node_modules/pivottable/node_modules/jquery/package.json +122 -0
  110. data/public/node_modules/pivottable/node_modules/jquery/sizzle/LICENSE.txt +36 -0
  111. data/public/node_modules/pivottable/node_modules/jquery/sizzle/dist/sizzle.js +2143 -0
  112. data/public/node_modules/pivottable/node_modules/jquery/sizzle/dist/sizzle.min.js +3 -0
  113. data/public/node_modules/pivottable/node_modules/jquery/sizzle/dist/sizzle.min.map +1 -0
  114. data/public/node_modules/pivottable/node_modules/jquery/src/ajax.js +845 -0
  115. data/public/node_modules/pivottable/node_modules/jquery/src/ajax/jsonp.js +100 -0
  116. data/public/node_modules/pivottable/node_modules/jquery/src/ajax/load.js +83 -0
  117. data/public/node_modules/pivottable/node_modules/jquery/src/ajax/parseJSON.js +13 -0
  118. data/public/node_modules/pivottable/node_modules/jquery/src/ajax/parseXML.js +27 -0
  119. data/public/node_modules/pivottable/node_modules/jquery/src/ajax/script.js +68 -0
  120. data/public/node_modules/pivottable/node_modules/jquery/src/ajax/var/location.js +3 -0
  121. data/public/node_modules/pivottable/node_modules/jquery/src/ajax/var/nonce.js +5 -0
  122. data/public/node_modules/pivottable/node_modules/jquery/src/ajax/var/rquery.js +3 -0
  123. data/public/node_modules/pivottable/node_modules/jquery/src/ajax/xhr.js +167 -0
  124. data/public/node_modules/pivottable/node_modules/jquery/src/attributes.js +11 -0
  125. data/public/node_modules/pivottable/node_modules/jquery/src/attributes/attr.js +142 -0
  126. data/public/node_modules/pivottable/node_modules/jquery/src/attributes/classes.js +177 -0
  127. data/public/node_modules/pivottable/node_modules/jquery/src/attributes/prop.js +125 -0
  128. data/public/node_modules/pivottable/node_modules/jquery/src/attributes/support.js +36 -0
  129. data/public/node_modules/pivottable/node_modules/jquery/src/attributes/val.js +177 -0
  130. data/public/node_modules/pivottable/node_modules/jquery/src/callbacks.js +232 -0
  131. data/public/node_modules/pivottable/node_modules/jquery/src/core.js +494 -0
  132. data/public/node_modules/pivottable/node_modules/jquery/src/core/DOMEval.js +14 -0
  133. data/public/node_modules/pivottable/node_modules/jquery/src/core/access.js +65 -0
  134. data/public/node_modules/pivottable/node_modules/jquery/src/core/init.js +134 -0
  135. data/public/node_modules/pivottable/node_modules/jquery/src/core/parseHTML.js +41 -0
  136. data/public/node_modules/pivottable/node_modules/jquery/src/core/ready.js +103 -0
  137. data/public/node_modules/pivottable/node_modules/jquery/src/core/support.js +18 -0
  138. data/public/node_modules/pivottable/node_modules/jquery/src/core/var/rsingleTag.js +5 -0
  139. data/public/node_modules/pivottable/node_modules/jquery/src/css.js +515 -0
  140. data/public/node_modules/pivottable/node_modules/jquery/src/css/addGetHookIf.js +24 -0
  141. data/public/node_modules/pivottable/node_modules/jquery/src/css/adjustCSS.js +65 -0
  142. data/public/node_modules/pivottable/node_modules/jquery/src/css/curCSS.js +60 -0
  143. data/public/node_modules/pivottable/node_modules/jquery/src/css/defaultDisplay.js +72 -0
  144. data/public/node_modules/pivottable/node_modules/jquery/src/css/hiddenVisibleSelectors.js +18 -0
  145. data/public/node_modules/pivottable/node_modules/jquery/src/css/showHide.js +48 -0
  146. data/public/node_modules/pivottable/node_modules/jquery/src/css/support.js +121 -0
  147. data/public/node_modules/pivottable/node_modules/jquery/src/css/var/cssExpand.js +3 -0
  148. data/public/node_modules/pivottable/node_modules/jquery/src/css/var/getStyles.js +15 -0
  149. data/public/node_modules/pivottable/node_modules/jquery/src/css/var/isHidden.js +16 -0
  150. data/public/node_modules/pivottable/node_modules/jquery/src/css/var/rmargin.js +3 -0
  151. data/public/node_modules/pivottable/node_modules/jquery/src/css/var/rnumnonpx.js +5 -0
  152. data/public/node_modules/pivottable/node_modules/jquery/src/css/var/swap.js +24 -0
  153. data/public/node_modules/pivottable/node_modules/jquery/src/data.js +187 -0
  154. data/public/node_modules/pivottable/node_modules/jquery/src/data/Data.js +200 -0
  155. data/public/node_modules/pivottable/node_modules/jquery/src/data/accepts.js +20 -0
  156. data/public/node_modules/pivottable/node_modules/jquery/src/data/support.js +23 -0
  157. data/public/node_modules/pivottable/node_modules/jquery/src/data/var/acceptData.js +18 -0
  158. data/public/node_modules/pivottable/node_modules/jquery/src/data/var/dataPriv.js +5 -0
  159. data/public/node_modules/pivottable/node_modules/jquery/src/data/var/dataUser.js +5 -0
  160. data/public/node_modules/pivottable/node_modules/jquery/src/deferred.js +158 -0
  161. data/public/node_modules/pivottable/node_modules/jquery/src/deferred/exceptionHook.js +19 -0
  162. data/public/node_modules/pivottable/node_modules/jquery/src/deprecated.js +32 -0
  163. data/public/node_modules/pivottable/node_modules/jquery/src/dimensions.js +54 -0
  164. data/public/node_modules/pivottable/node_modules/jquery/src/effects.js +629 -0
  165. data/public/node_modules/pivottable/node_modules/jquery/src/effects/Tween.js +121 -0
  166. data/public/node_modules/pivottable/node_modules/jquery/src/effects/animatedSelector.js +13 -0
  167. data/public/node_modules/pivottable/node_modules/jquery/src/effects/support.js +58 -0
  168. data/public/node_modules/pivottable/node_modules/jquery/src/event.js +710 -0
  169. data/public/node_modules/pivottable/node_modules/jquery/src/event/ajax.js +20 -0
  170. data/public/node_modules/pivottable/node_modules/jquery/src/event/alias.js +27 -0
  171. data/public/node_modules/pivottable/node_modules/jquery/src/event/focusin.js +53 -0
  172. data/public/node_modules/pivottable/node_modules/jquery/src/event/support.js +9 -0
  173. data/public/node_modules/pivottable/node_modules/jquery/src/event/trigger.js +199 -0
  174. data/public/node_modules/pivottable/node_modules/jquery/src/exports/amd.js +24 -0
  175. data/public/node_modules/pivottable/node_modules/jquery/src/exports/global.js +26 -0
  176. data/public/node_modules/pivottable/node_modules/jquery/src/intro.js +44 -0
  177. data/public/node_modules/pivottable/node_modules/jquery/src/jquery.js +37 -0
  178. data/public/node_modules/pivottable/node_modules/jquery/src/manipulation.js +481 -0
  179. data/public/node_modules/pivottable/node_modules/jquery/src/manipulation/_evalUrl.js +20 -0
  180. data/public/node_modules/pivottable/node_modules/jquery/src/manipulation/buildFragment.js +102 -0
  181. data/public/node_modules/pivottable/node_modules/jquery/src/manipulation/createSafeFragment.js +20 -0
  182. data/public/node_modules/pivottable/node_modules/jquery/src/manipulation/getAll.js +21 -0
  183. data/public/node_modules/pivottable/node_modules/jquery/src/manipulation/setGlobalEval.js +20 -0
  184. data/public/node_modules/pivottable/node_modules/jquery/src/manipulation/support.js +33 -0
  185. data/public/node_modules/pivottable/node_modules/jquery/src/manipulation/var/nodeNames.js +5 -0
  186. data/public/node_modules/pivottable/node_modules/jquery/src/manipulation/var/rcheckableType.js +3 -0
  187. data/public/node_modules/pivottable/node_modules/jquery/src/manipulation/var/rleadingWhitespace.js +3 -0
  188. data/public/node_modules/pivottable/node_modules/jquery/src/manipulation/var/rscriptType.js +3 -0
  189. data/public/node_modules/pivottable/node_modules/jquery/src/manipulation/var/rtagName.js +3 -0
  190. data/public/node_modules/pivottable/node_modules/jquery/src/manipulation/wrapMap.js +27 -0
  191. data/public/node_modules/pivottable/node_modules/jquery/src/offset.js +218 -0
  192. data/public/node_modules/pivottable/node_modules/jquery/src/outro.js +2 -0
  193. data/public/node_modules/pivottable/node_modules/jquery/src/queue.js +143 -0
  194. data/public/node_modules/pivottable/node_modules/jquery/src/queue/delay.js +22 -0
  195. data/public/node_modules/pivottable/node_modules/jquery/src/selector-native.js +211 -0
  196. data/public/node_modules/pivottable/node_modules/jquery/src/selector-sizzle.js +14 -0
  197. data/public/node_modules/pivottable/node_modules/jquery/src/selector.js +1 -0
  198. data/public/node_modules/pivottable/node_modules/jquery/src/serialize.js +125 -0
  199. data/public/node_modules/pivottable/node_modules/jquery/src/support.js +63 -0
  200. data/public/node_modules/pivottable/node_modules/jquery/src/traversing.js +175 -0
  201. data/public/node_modules/pivottable/node_modules/jquery/src/traversing/findFilter.js +100 -0
  202. data/public/node_modules/pivottable/node_modules/jquery/src/traversing/var/dir.js +20 -0
  203. data/public/node_modules/pivottable/node_modules/jquery/src/traversing/var/rneedsContext.js +6 -0
  204. data/public/node_modules/pivottable/node_modules/jquery/src/traversing/var/siblings.js +15 -0
  205. data/public/node_modules/pivottable/node_modules/jquery/src/var/arr.js +3 -0
  206. data/public/node_modules/pivottable/node_modules/jquery/src/var/class2type.js +5 -0
  207. data/public/node_modules/pivottable/node_modules/jquery/src/var/concat.js +5 -0
  208. data/public/node_modules/pivottable/node_modules/jquery/src/var/deletedIds.js +3 -0
  209. data/public/node_modules/pivottable/node_modules/jquery/src/var/document.js +3 -0
  210. data/public/node_modules/pivottable/node_modules/jquery/src/var/documentElement.js +5 -0
  211. data/public/node_modules/pivottable/node_modules/jquery/src/var/hasOwn.js +5 -0
  212. data/public/node_modules/pivottable/node_modules/jquery/src/var/indexOf.js +5 -0
  213. data/public/node_modules/pivottable/node_modules/jquery/src/var/pnum.js +3 -0
  214. data/public/node_modules/pivottable/node_modules/jquery/src/var/push.js +5 -0
  215. data/public/node_modules/pivottable/node_modules/jquery/src/var/rcssNum.js +7 -0
  216. data/public/node_modules/pivottable/node_modules/jquery/src/var/rnotwhite.js +3 -0
  217. data/public/node_modules/pivottable/node_modules/jquery/src/var/slice.js +5 -0
  218. data/public/node_modules/pivottable/node_modules/jquery/src/var/support.js +5 -0
  219. data/public/node_modules/pivottable/node_modules/jquery/src/var/toString.js +5 -0
  220. data/public/node_modules/pivottable/node_modules/jquery/src/wrap.js +79 -0
  221. data/public/node_modules/pivottable/package.json +70 -0
  222. data/public/node_modules/pivottable/pivot.coffee +957 -0
  223. data/public/node_modules/pivottable/pivot.es.coffee +57 -0
  224. data/public/node_modules/pivottable/pivot.fr.coffee +57 -0
  225. data/public/node_modules/pivottable/pivot.nl.coffee +55 -0
  226. data/public/node_modules/pivottable/pivot.pt.coffee +80 -0
  227. data/public/node_modules/pivottable/pivot.ru.coffee +56 -0
  228. data/public/node_modules/pivottable/pivot.tr.coffee +80 -0
  229. data/public/node_modules/pivottable/pivottable.jquery.json +33 -0
  230. data/public/node_modules/pivottable/tests/boot.js +152 -0
  231. data/public/node_modules/pivottable/tests/index.html +35 -0
  232. data/public/node_modules/pivottable/tests/pivot_spec.coffee +458 -0
  233. data/public/vendor.js +5 -0
  234. metadata +232 -1
@@ -0,0 +1,35 @@
1
+
2
+ <!DOCTYPE html>
3
+ <html>
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <title>Jasmine Spec Runner</title>
7
+
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.4.1/jasmine.css">
9
+
10
+ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.4.1/jasmine.js"></script>
11
+ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.4.1/jasmine-html.js"></script>
12
+
13
+ <!-- boot.js is patched to not execute env, so we can execute after compilation of tests -->
14
+ <script type="text/javascript" src="boot.js"></script>
15
+
16
+ <script type="text/javascript" src="http://coffeescript.org/extras/coffee-script.js"></script>
17
+
18
+ <!-- include source files here... -->
19
+
20
+ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
21
+ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
22
+ <script src="../dist/pivot.js"></script>
23
+
24
+ <!-- include spec files here... -->
25
+ <script type="text/coffeescript" src="pivot_spec.coffee"></script>
26
+
27
+ <script type="text/coffeescript">
28
+ $ -> jasmine.getEnv().execute()
29
+ </script>
30
+
31
+ </head>
32
+
33
+ <body>
34
+ </body>
35
+ </html>
@@ -0,0 +1,458 @@
1
+ fixtureData = [
2
+ ["name", "gender", "colour", "birthday", "trials", "successes"],
3
+ ["Nick", "male", "blue", "1982-11-07", 103, 12],
4
+ ["Jane", "female", "red", "1982-11-08", 95, 25],
5
+ ["John", "male", "blue", "1982-12-08", 112, 30],
6
+ ["Carol", "female", "yellow", "1983-12-08", 102, 14]
7
+ ]
8
+
9
+
10
+ describe "$.pivotUI()", ->
11
+ describe "with no rows/cols, default count aggregator, default TableRenderer", ->
12
+ table = null
13
+
14
+ beforeEach (done) ->
15
+ table = $("<div>").pivotUI fixtureData, onRefresh: done
16
+ it "has all the basic UI elements", (done) ->
17
+ expect table.find("td.pvtAxisContainer").length
18
+ .toBe 3
19
+ expect table.find("td.pvtRendererArea").length
20
+ .toBe 1
21
+ expect table.find("td.pvtVals").length
22
+ .toBe 1
23
+ expect table.find("select.pvtRenderer").length
24
+ .toBe 1
25
+ expect table.find("select.pvtAggregator").length
26
+ .toBe 1
27
+ expect table.find("span.pvtAttr").length
28
+ .toBe 6
29
+ done()
30
+
31
+ it "reflects its inputs", (done) ->
32
+ expect table.find("td.pvtUnused span.pvtAttr").length
33
+ .toBe 6
34
+ expect table.find("select.pvtRenderer").val()
35
+ .toBe "Table"
36
+ expect table.find("select.pvtAggregator").val()
37
+ .toBe "Count"
38
+ done()
39
+
40
+ it "renders a table", (done) ->
41
+ expect table.find("table.pvtTable").length
42
+ .toBe 1
43
+ done()
44
+
45
+
46
+ describe "its renderer output", ->
47
+ it "has the correct type and number of cells", (done) ->
48
+ expect table.find("th.pvtTotalLabel").length
49
+ .toBe 1
50
+ expect table.find("td.pvtGrandTotal").length
51
+ .toBe 1
52
+ done()
53
+
54
+ it "has the correct textual representation", (done) ->
55
+ expect table.find("table.pvtTable").text()
56
+ .toBe ["Totals", "4"].join("")
57
+ done()
58
+
59
+ it "has a correct grand total with data value", (done) ->
60
+ expect table.find("td.pvtGrandTotal").text()
61
+ .toBe "4"
62
+ expect table.find("td.pvtGrandTotal").data("value")
63
+ .toBe 4
64
+ done()
65
+
66
+ describe "with rows/cols, sum-over-sum aggregator, Heatmap renderer", ->
67
+ table = null
68
+
69
+ beforeEach (done) ->
70
+ table = $("<div>").pivotUI fixtureData,
71
+ rows: ["gender"], cols: ["colour"]
72
+ aggregatorName: "Sum over Sum"
73
+ vals: ["successes", "trials"]
74
+ rendererName: "Heatmap"
75
+ onRefresh: done
76
+
77
+ it "has all the basic UI elements", (done) ->
78
+ expect table.find("td.pvtAxisContainer").length
79
+ .toBe 3
80
+ expect table.find("td.pvtRendererArea").length
81
+ .toBe 1
82
+ expect table.find("td.pvtVals").length
83
+ .toBe 1
84
+ expect table.find("select.pvtRenderer").length
85
+ .toBe 1
86
+ expect table.find("select.pvtAggregator").length
87
+ .toBe 1
88
+ expect table.find("span.pvtAttr").length
89
+ .toBe 6
90
+ done()
91
+
92
+ it "reflects its inputs", (done) ->
93
+ expect table.find("td.pvtUnused span.pvtAttr").length
94
+ .toBe 4
95
+ expect table.find("td.pvtRows span.pvtAttr").length
96
+ .toBe 1
97
+ expect table.find("td.pvtCols span.pvtAttr").length
98
+ .toBe 1
99
+ expect table.find("select.pvtRenderer").val()
100
+ .toBe "Heatmap"
101
+ expect table.find("select.pvtAggregator").val()
102
+ .toBe "Sum over Sum"
103
+ done()
104
+
105
+ it "renders a table", (done) ->
106
+ expect table.find("table.pvtTable").length
107
+ .toBe 1
108
+ done()
109
+
110
+ describe "its renderer output", ->
111
+ it "has the correct type and number of cells", (done) ->
112
+ expect table.find("th.pvtAxisLabel").length
113
+ .toBe 2
114
+ expect table.find("th.pvtRowLabel").length
115
+ .toBe 2
116
+ expect table.find("th.pvtColLabel").length
117
+ .toBe 3
118
+ expect table.find("th.pvtTotalLabel").length
119
+ .toBe 2
120
+ expect table.find("td.pvtVal").length
121
+ .toBe 6
122
+ expect table.find("td.pvtTotal").length
123
+ .toBe 5
124
+ expect table.find("td.pvtGrandTotal").length
125
+ .toBe 1
126
+ done()
127
+
128
+ it "has the correct textual representation", (done) ->
129
+ expect table.find("table.pvtTable").text()
130
+ .toBe [
131
+ "colour", "blue", "red", "yellow", "Totals",
132
+ "gender",
133
+ "female", "0.26", "0.14", "0.20",
134
+ "male", "0.20", "0.20",
135
+ "Totals", "0.20", "0.26", "0.14", "0.20"
136
+ ].join("")
137
+ done()
138
+
139
+ it "has a correct spot-checked cell with data value", (done) ->
140
+ expect table.find("td.col0.row1").text()
141
+ .toBe "0.20"
142
+ expect table.find("td.col0.row1").data("value")
143
+ .toBe (12+30)/(103+112)
144
+ done()
145
+
146
+ describe "$.pivot()", ->
147
+
148
+ describe "with no rows/cols, default count aggregator, default TableRenderer", ->
149
+ table = $("<div>").pivot fixtureData
150
+
151
+ it "renders a table", ->
152
+ expect table.find("table.pvtTable").length
153
+ .toBe 1
154
+
155
+ describe "its renderer output", ->
156
+
157
+ it "has the correct textual representation", ->
158
+ expect table.find("table.pvtTable").text()
159
+ .toBe ["Totals", "4"].join("")
160
+
161
+ it "has a correct grand total with data value", ->
162
+ expect table.find("td.pvtGrandTotal").text()
163
+ .toBe "4"
164
+ expect table.find("td.pvtGrandTotal").data("value")
165
+ .toBe 4
166
+
167
+ describe "with rows/cols, sum aggregator, derivedAttributes, filter and sorters", ->
168
+ {sortAs, derivers, aggregators} = $.pivotUtilities
169
+ table = $("<div>").pivot fixtureData,
170
+ rows: ["gender"], cols: ["birthyear"], aggregator: aggregators["Sum"](["trialbins"])
171
+ filter: (record) -> record.name != "Nick"
172
+ derivedAttributes:
173
+ birthyear: derivers.dateFormat "birthday", "%y"
174
+ trialbins: derivers.bin "trials", 10
175
+ sorters: (attr) ->
176
+ if attr == "gender" then return sortAs(["male", "female"])
177
+
178
+ it "renders a table with the correct textual representation", ->
179
+ expect table.find("table.pvtTable").text()
180
+ .toBe [
181
+ "birthyear", "1982", "1983", "Totals"
182
+ "gender",
183
+ "male", "110.00", "110.00"
184
+ "female", "90.00", "100.00", "190.00"
185
+ "Totals", "200.00", "100.00", "300.00"
186
+ ].join("")
187
+
188
+ describe "with rows/cols, fraction-of aggregator", ->
189
+ {aggregators} = $.pivotUtilities
190
+ table = $("<div>").pivot fixtureData,
191
+ rows: ["gender"]
192
+ aggregator: aggregators["Sum as Fraction of Total"](["trials"])
193
+
194
+ it "renders a table with the correct textual representation", ->
195
+ expect table.find("table.pvtTable").text()
196
+ .toBe [
197
+ "gender", "Totals"
198
+ "female", "47.8%"
199
+ "male", "52.2%"
200
+ "Totals", "100.0%"
201
+ ].join("")
202
+
203
+ describe "with rows/cols, custom aggregator, custom renderer with options", ->
204
+ received_PivotData = null
205
+ received_rendererOptions = null
206
+
207
+ table = $("<div>").pivot fixtureData,
208
+ rows: ["name", "colour"], cols: ["trials", "successes"]
209
+ aggregator: ->
210
+ count2x: 0
211
+ push: -> @count2x +=2
212
+ value: -> @count2x
213
+ format: (x) -> "formatted " + x
214
+ renderer: (a,b) ->
215
+ received_PivotData = a
216
+ received_rendererOptions = b
217
+ return $("<div>").addClass(b.greeting).text("world")
218
+ rendererOptions: {greeting:"hithere"}
219
+
220
+ it "renders the custom renderer as per options", ->
221
+ expect table.find("div.hithere").length
222
+ .toBe 1
223
+
224
+ describe "its received PivotData object", ->
225
+ it "has a correct grand total value and format for custom aggregator", ->
226
+ agg = received_PivotData.getAggregator([],[])
227
+ val = agg.value()
228
+ expect(val).toBe 8
229
+ expect(agg.format(val)).toBe "formatted 8"
230
+
231
+ describe "$.pivotUtilities", ->
232
+
233
+ describe ".PivotData()", ->
234
+ sumOverSumOpts =
235
+ rows: [], cols: []
236
+ aggregator: $.pivotUtilities.aggregators["Sum over Sum"](["a","b"])
237
+ filter: -> true
238
+ sorters: ->
239
+
240
+ describe "with array-of-array input", ->
241
+ aoaInput = [ ["a","b"], [1,2], [3,4] ]
242
+ pd = new $.pivotUtilities.PivotData aoaInput, sumOverSumOpts
243
+
244
+ it "has the correct grand total value", ->
245
+ expect pd.getAggregator([],[]).value()
246
+ .toBe (1+3)/(2+4)
247
+
248
+ describe "with array-of-object input", ->
249
+ aosInput = [ {a:1, b:2}, {a:3, b:4} ]
250
+ pd = new $.pivotUtilities.PivotData aosInput, sumOverSumOpts
251
+
252
+ it "has the correct grand total value", ->
253
+ expect pd.getAggregator([],[]).value()
254
+ .toBe (1+3)/(2+4)
255
+
256
+ describe "with function input", ->
257
+ functionInput = (record) ->
258
+ record a:1, b:2
259
+ record a:3, b:4
260
+ pd = new $.pivotUtilities.PivotData functionInput, sumOverSumOpts
261
+
262
+ it "has the correct grand total value", ->
263
+ expect pd.getAggregator([],[]).value()
264
+ .toBe (1+3)/(2+4)
265
+
266
+ describe "with jQuery table element input", ->
267
+ tableInput = $ """
268
+ <table>
269
+ <thead>
270
+ <tr> <th>a</th><th>b</th> </tr>
271
+ </thead>
272
+ <tbody>
273
+ <tr> <td>1</td> <td>2</td> </tr>
274
+ <tr> <td>3</td> <td>4</td> </tr>
275
+ </tbody>
276
+ </table>
277
+ """
278
+
279
+ pd = new $.pivotUtilities.PivotData tableInput, sumOverSumOpts
280
+
281
+ it "has the correct grand total value", ->
282
+ expect pd.getAggregator([],[]).value()
283
+ .toBe (1+3)/(2+4)
284
+
285
+
286
+ describe "with rows/cols, no filters/sorters, count aggregator", ->
287
+ pd = new $.pivotUtilities.PivotData fixtureData,
288
+ rows: ["name", "colour"],
289
+ cols: ["trials", "successes"],
290
+ aggregator: $.pivotUtilities.aggregators["Count"](),
291
+ filter: -> true
292
+ sorters: ->
293
+
294
+ it "has correctly-ordered row keys", ->
295
+ expect pd.getRowKeys()
296
+ .toEqual [ [ 'Carol', 'yellow' ], [ 'Jane', 'red' ], [ 'John', 'blue' ], [ 'Nick', 'blue' ] ]
297
+
298
+ it "has correctly-ordered col keys", ->
299
+ expect pd.getColKeys()
300
+ .toEqual [ [ 95, 25 ], [ 102, 14 ], [ 103, 12 ], [ 112, 30 ] ]
301
+
302
+ it "can be iterated over", ->
303
+ numNotNull = 0
304
+ numNull = 0
305
+ for r in pd.getRowKeys()
306
+ for c in pd.getColKeys()
307
+ if pd.getAggregator(r, c).value()?
308
+ numNotNull++
309
+ else
310
+ numNull++
311
+ expect numNotNull
312
+ .toBe 4
313
+ expect numNull
314
+ .toBe 12
315
+
316
+ it "has a correct spot-checked aggregator", ->
317
+ agg = pd.getAggregator([ 'Carol', 'yellow' ],[ 102, 14 ])
318
+ val = agg.value()
319
+ expect(val).toBe 1
320
+ expect(agg.format(val)).toBe "1"
321
+
322
+ it "has a correct grand total aggregator", ->
323
+ agg = pd.getAggregator([],[])
324
+ val = agg.value()
325
+ expect(val).toBe 4
326
+ expect(agg.format(val)).toBe "4"
327
+
328
+ describe ".naturalSort()", ->
329
+ naturalSort = $.pivotUtilities.naturalSort
330
+
331
+ it "sorts numbers", ->
332
+ expect [2,1,3,4,0].sort naturalSort
333
+ .toEqual [0,1,2,3,4]
334
+
335
+ it "sorts strings", ->
336
+ expect ['b','a','c','d'].sort naturalSort
337
+ .toEqual ['a','b','c','d']
338
+
339
+ it "sorts numbers in strings", ->
340
+ expect ['1','12','2','10','11','112'].sort naturalSort
341
+ .toEqual ['1','2','10','11','12','112']
342
+
343
+ it "sorts 0-padded numbers", ->
344
+ expect ['02','01','10','11'].sort naturalSort
345
+ .toEqual ['01','02','10','11']
346
+
347
+ describe ".sortAs()", ->
348
+ sortAs = $.pivotUtilities.sortAs
349
+
350
+ it "sorts with unknown values sorted at the end", ->
351
+ expect [5,2,3,4,1].sort sortAs([4,3,2])
352
+ .toEqual [4,3,2,1,5]
353
+
354
+ describe ".numberFormat()", ->
355
+ numberFormat = $.pivotUtilities.numberFormat
356
+
357
+ it "formats numbers", ->
358
+ nf = numberFormat()
359
+ expect nf 1234567.89123456
360
+ .toEqual "1,234,567.89"
361
+
362
+ it "formats booleans", ->
363
+ nf = numberFormat()
364
+ expect nf true
365
+ .toEqual "1.00"
366
+
367
+ it "formats numbers in strings", ->
368
+ nf = numberFormat()
369
+ expect nf "1234567.89123456"
370
+ .toEqual "1,234,567.89"
371
+
372
+ it "doesn't formats strings", ->
373
+ nf = numberFormat()
374
+ expect nf "hi there"
375
+ .toEqual ""
376
+
377
+ it "doesn't formats objects", ->
378
+ nf = numberFormat()
379
+ expect nf {a:1}
380
+ .toEqual ""
381
+
382
+ it "formats percentages", ->
383
+ nf = numberFormat(scaler: 100, suffix: "%")
384
+ expect nf 0.12345
385
+ .toEqual "12.35%"
386
+
387
+ it "adds separators", ->
388
+ nf = numberFormat(thousandsSep: "a", decimalSep: "b")
389
+ expect nf 1234567.89123456
390
+ .toEqual "1a234a567b89"
391
+
392
+ it "adds prefixes and suffixes", ->
393
+ nf = numberFormat(prefix: "a", suffix: "b")
394
+ expect nf 1234567.89123456
395
+ .toEqual "a1,234,567.89b"
396
+
397
+ it "scales and rounds", ->
398
+ nf = numberFormat(digitsAfterDecimal: 3, scaler: 1000)
399
+ expect nf 1234567.89123456
400
+ .toEqual "1,234,567,891.235"
401
+
402
+ it "shows and hides zero", ->
403
+ nf = numberFormat(showZero: true)
404
+ expect nf 0
405
+ .toEqual "0.00"
406
+
407
+ nf = numberFormat(showZero: false)
408
+ expect nf 0
409
+ .toEqual ""
410
+
411
+ describe ".derivers", ->
412
+ describe ".dateFormat()", ->
413
+ df = $.pivotUtilities.derivers.dateFormat "x", "abc % %% %%% %a %y %m %n %d %w %x %H %M %S", true
414
+
415
+ it "formats date objects", ->
416
+ expect df {x: new Date("2015-01-02T23:43:11Z")}
417
+ .toBe 'abc % %% %%% %a 2015 01 Jan 02 Fri 5 23 43 11'
418
+
419
+ it "formats input parsed by Date.parse()", ->
420
+ expect df {x: "2015-01-02T23:43:11Z"}
421
+ .toBe 'abc % %% %%% %a 2015 01 Jan 02 Fri 5 23 43 11'
422
+
423
+ expect df {x: "bla"}
424
+ .toBe ''
425
+
426
+ describe ".bin()", ->
427
+ binner = $.pivotUtilities.derivers.bin "x", 10
428
+
429
+ it "bins numbers", ->
430
+ expect binner {x: 11}
431
+ .toBe 10
432
+
433
+ expect binner {x: 9}
434
+ .toBe 0
435
+
436
+ expect binner {x: 111}
437
+ .toBe 110
438
+
439
+ it "bins booleans", ->
440
+ expect binner {x: true}
441
+ .toBe 0
442
+
443
+ it "bins negative numbers", ->
444
+ expect binner {x: -12}
445
+ .toBe -10
446
+
447
+ it "doesn't bin strings", ->
448
+ expect binner {x: "a"}
449
+ .toBeNaN()
450
+
451
+ it "doesn't bin objects", ->
452
+ expect binner {x: {a:1}}
453
+ .toBeNaN()
454
+
455
+ # todo
456
+ # agg templates
457
+ # date.parse -> date() ?
458
+ # default options for PivotData, including filter