magic_carpet 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (225) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +202 -0
  3. data/README.md +232 -0
  4. data/Rakefile +15 -0
  5. data/app/assets/javascripts/magic_carpet/application.js +13 -0
  6. data/app/assets/javascripts/magic_carpet/magic_carpet.js +80 -0
  7. data/app/assets/stylesheets/magic_carpet/application.css +13 -0
  8. data/app/controllers/magic_carpet/application_controller.rb +4 -0
  9. data/app/controllers/magic_carpet/js_fixtures_controller.rb +110 -0
  10. data/app/helpers/magic_carpet/application_helper.rb +4 -0
  11. data/app/helpers/magic_carpet/js_fixtures_helper.rb +139 -0
  12. data/config/routes.rb +3 -0
  13. data/lib/magic_carpet/engine.rb +12 -0
  14. data/lib/magic_carpet/version.rb +3 -0
  15. data/lib/magic_carpet.rb +4 -0
  16. data/lib/tasks/magic_carpet_tasks.rake +4 -0
  17. data/spec/controllers/magic_carpet/js_fixtures_controller_spec.rb +275 -0
  18. data/spec/dummy/README.rdoc +28 -0
  19. data/spec/dummy/Rakefile +6 -0
  20. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  21. data/spec/dummy/app/assets/javascripts/jquery-2.1.0.js +9111 -0
  22. data/spec/dummy/app/assets/javascripts/users.js +2 -0
  23. data/spec/dummy/app/assets/javascripts/wishes.js +2 -0
  24. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  25. data/spec/dummy/app/assets/stylesheets/scaffold.css +56 -0
  26. data/spec/dummy/app/assets/stylesheets/users.css +4 -0
  27. data/spec/dummy/app/assets/stylesheets/wishes.css +4 -0
  28. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  29. data/spec/dummy/app/controllers/users_controller.rb +58 -0
  30. data/spec/dummy/app/controllers/wishes_controller.rb +70 -0
  31. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  32. data/spec/dummy/app/helpers/users_helper.rb +2 -0
  33. data/spec/dummy/app/helpers/wishes_helper.rb +2 -0
  34. data/spec/dummy/app/models/user.rb +3 -0
  35. data/spec/dummy/app/models/wish.rb +4 -0
  36. data/spec/dummy/app/views/layouts/application.html.erb +19 -0
  37. data/spec/dummy/app/views/layouts/other_layout.html.erb +15 -0
  38. data/spec/dummy/app/views/shared/_id_able.html.erb +5 -0
  39. data/spec/dummy/app/views/users/_form.html.erb +29 -0
  40. data/spec/dummy/app/views/users/edit.html.erb +6 -0
  41. data/spec/dummy/app/views/users/index.html.erb +31 -0
  42. data/spec/dummy/app/views/users/new.html.erb +5 -0
  43. data/spec/dummy/app/views/users/show.html.erb +19 -0
  44. data/spec/dummy/app/views/wishes/_form.html.erb +21 -0
  45. data/spec/dummy/app/views/wishes/_some_partial.html.erb +1 -0
  46. data/spec/dummy/app/views/wishes/_wish.html.erb +6 -0
  47. data/spec/dummy/app/views/wishes/_wish_list_item.html.erb +3 -0
  48. data/spec/dummy/app/views/wishes/edit.html.erb +6 -0
  49. data/spec/dummy/app/views/wishes/index.html.erb +22 -0
  50. data/spec/dummy/app/views/wishes/local_models.html.erb +3 -0
  51. data/spec/dummy/app/views/wishes/locals.html.erb +6 -0
  52. data/spec/dummy/app/views/wishes/new.html.erb +5 -0
  53. data/spec/dummy/app/views/wishes/numbers.html.erb +4 -0
  54. data/spec/dummy/app/views/wishes/plain.html.erb +1 -0
  55. data/spec/dummy/app/views/wishes/show.html.erb +9 -0
  56. data/spec/dummy/bin/bundle +3 -0
  57. data/spec/dummy/bin/rails +4 -0
  58. data/spec/dummy/bin/rake +4 -0
  59. data/spec/dummy/config/application.rb +28 -0
  60. data/spec/dummy/config/boot.rb +5 -0
  61. data/spec/dummy/config/database.yml +25 -0
  62. data/spec/dummy/config/environment.rb +5 -0
  63. data/spec/dummy/config/environments/development.rb +29 -0
  64. data/spec/dummy/config/environments/production.rb +80 -0
  65. data/spec/dummy/config/environments/test.rb +36 -0
  66. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  67. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  68. data/spec/dummy/config/initializers/inflections.rb +16 -0
  69. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  70. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  71. data/spec/dummy/config/initializers/session_store.rb +3 -0
  72. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  73. data/spec/dummy/config/locales/en.yml +23 -0
  74. data/spec/dummy/config/routes.rb +9 -0
  75. data/spec/dummy/config.ru +4 -0
  76. data/spec/dummy/db/development.sqlite3 +0 -0
  77. data/spec/dummy/db/migrate/20140201230228_create_wishes.rb +9 -0
  78. data/spec/dummy/db/migrate/20140201230247_create_users.rb +11 -0
  79. data/spec/dummy/db/migrate/20140208042514_associate_users_and_wishes.rb +5 -0
  80. data/spec/dummy/db/schema.rb +31 -0
  81. data/spec/dummy/db/test.sqlite3 +0 -0
  82. data/spec/dummy/log/development.log +21112 -0
  83. data/spec/dummy/log/test.log +33634 -0
  84. data/spec/dummy/public/404.html +58 -0
  85. data/spec/dummy/public/422.html +58 -0
  86. data/spec/dummy/public/500.html +57 -0
  87. data/spec/dummy/public/favicon.ico +0 -0
  88. data/spec/dummy/spec/javascripts/helpers/spec_helper.js +367 -0
  89. data/spec/dummy/spec/javascripts/magic_carpet_spec.js +314 -0
  90. data/spec/dummy/spec/javascripts/support/jasmine.yml +29 -0
  91. data/spec/dummy/tmp/cache/assets/development/sprockets/0743af5c3f490550c6a448f45e6889b4 +0 -0
  92. data/spec/dummy/tmp/cache/assets/development/sprockets/0800f54ee19cf3cee10b956fa9786799 +0 -0
  93. data/spec/dummy/tmp/cache/assets/development/sprockets/082245bc7cce1345893a81643f76284a +0 -0
  94. data/spec/dummy/tmp/cache/assets/development/sprockets/08b0d9573e11dc361c93563cec2a0106 +0 -0
  95. data/spec/dummy/tmp/cache/assets/development/sprockets/09f277e17472af932cda6f7dd86ff943 +0 -0
  96. data/spec/dummy/tmp/cache/assets/development/sprockets/0e3142f2ae2a0b8902383f65b86a5299 +0 -0
  97. data/spec/dummy/tmp/cache/assets/development/sprockets/0f87038bb320b83592e071bff83e4195 +0 -0
  98. data/spec/dummy/tmp/cache/assets/development/sprockets/10925724a66880466e7f3b4e158196cb +0 -0
  99. data/spec/dummy/tmp/cache/assets/development/sprockets/10fb651bf6e564ad505e391670c11a8d +0 -0
  100. data/spec/dummy/tmp/cache/assets/development/sprockets/12090b2e7e2e9ac2632e486d02ee346a +0 -0
  101. data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  102. data/spec/dummy/tmp/cache/assets/development/sprockets/142047722c23a8e9a96c6355d224b67e +0 -0
  103. data/spec/dummy/tmp/cache/assets/development/sprockets/1b4c56479f40fe3f7fc8daf684f4f71c +0 -0
  104. data/spec/dummy/tmp/cache/assets/development/sprockets/1c3579416ea74586464f5969c6949d5d +0 -0
  105. data/spec/dummy/tmp/cache/assets/development/sprockets/1e259f0863fa6da47ded59eef77ac351 +0 -0
  106. data/spec/dummy/tmp/cache/assets/development/sprockets/21d2c592e1570709ecd1208a030cfc66 +0 -0
  107. data/spec/dummy/tmp/cache/assets/development/sprockets/220ab8240fd9e0712b64dd9ff515f5df +0 -0
  108. data/spec/dummy/tmp/cache/assets/development/sprockets/277a51802284d997817fcaca55211243 +0 -0
  109. data/spec/dummy/tmp/cache/assets/development/sprockets/28c409c3bba590030a8074120aa781db +0 -0
  110. data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  111. data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  112. data/spec/dummy/tmp/cache/assets/development/sprockets/35906b4cd565b14db8ba786fc66c7eb3 +0 -0
  113. data/spec/dummy/tmp/cache/assets/development/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
  114. data/spec/dummy/tmp/cache/assets/development/sprockets/388a1d725ffd01cc06a34d720ea97775 +0 -0
  115. data/spec/dummy/tmp/cache/assets/development/sprockets/4050a4e5062ab95c9f32e9b6940821ea +0 -0
  116. data/spec/dummy/tmp/cache/assets/development/sprockets/442917e5b534e0e7ac0a3bac0c5299e7 +0 -0
  117. data/spec/dummy/tmp/cache/assets/development/sprockets/45ccf991e042a7cf7abe52d1125eeae3 +0 -0
  118. data/spec/dummy/tmp/cache/assets/development/sprockets/469198efe71fedae413489ff2fad66e4 +0 -0
  119. data/spec/dummy/tmp/cache/assets/development/sprockets/4817f65b5fc5c2042e04af7eb83a4c99 +0 -0
  120. data/spec/dummy/tmp/cache/assets/development/sprockets/497ff8927ce695e3febb3cdfd3e4a74e +0 -0
  121. data/spec/dummy/tmp/cache/assets/development/sprockets/510da110ae528e2d22533be39ff696c5 +0 -0
  122. data/spec/dummy/tmp/cache/assets/development/sprockets/51202fde1d49c04c5d5588ca203b7b1e +0 -0
  123. data/spec/dummy/tmp/cache/assets/development/sprockets/55ea602f40a0ad2185e22964a16b4d42 +0 -0
  124. data/spec/dummy/tmp/cache/assets/development/sprockets/596788b2d37e650dd4cf582b185f9d37 +0 -0
  125. data/spec/dummy/tmp/cache/assets/development/sprockets/5c09faba4e454de97f078861e82db15c +0 -0
  126. data/spec/dummy/tmp/cache/assets/development/sprockets/5f1a0d05e77ca8b9a1fc2a47e17a8174 +0 -0
  127. data/spec/dummy/tmp/cache/assets/development/sprockets/64de9e1fa2dd01768d6e85552dcdb18a +0 -0
  128. data/spec/dummy/tmp/cache/assets/development/sprockets/68c5fa1f98ca79274b1f6750d8611af5 +0 -0
  129. data/spec/dummy/tmp/cache/assets/development/sprockets/6bcea01ea8389e9a2ee296904803a01c +0 -0
  130. data/spec/dummy/tmp/cache/assets/development/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
  131. data/spec/dummy/tmp/cache/assets/development/sprockets/7406b6e2ecfc7b024db7822fb753c796 +0 -0
  132. data/spec/dummy/tmp/cache/assets/development/sprockets/744bda5bad4a3b9b9b244a4583fb6e29 +0 -0
  133. data/spec/dummy/tmp/cache/assets/development/sprockets/786804147f5da16b37ef8932e422797c +0 -0
  134. data/spec/dummy/tmp/cache/assets/development/sprockets/793dc2ede21315a9eabfe2b0a0ff13d4 +0 -0
  135. data/spec/dummy/tmp/cache/assets/development/sprockets/7b1c8fbfabc405ee6e5c8887095e6b43 +0 -0
  136. data/spec/dummy/tmp/cache/assets/development/sprockets/7c2edc3a2733a7bc22c572af66983a2e +0 -0
  137. data/spec/dummy/tmp/cache/assets/development/sprockets/7cd1032c2c1fa8a02016ac207cd9c76f +0 -0
  138. data/spec/dummy/tmp/cache/assets/development/sprockets/7d4bf0f7a6d67ade27f05b9bbdfaa13f +0 -0
  139. data/spec/dummy/tmp/cache/assets/development/sprockets/809136388a8f6d7a862b20361fad205c +0 -0
  140. data/spec/dummy/tmp/cache/assets/development/sprockets/80ba335c5610df2a1defeab247d03cc9 +0 -0
  141. data/spec/dummy/tmp/cache/assets/development/sprockets/817b43e6477d4059b9006261356b7147 +0 -0
  142. data/spec/dummy/tmp/cache/assets/development/sprockets/81b537f4760199f4030b928268605909 +0 -0
  143. data/spec/dummy/tmp/cache/assets/development/sprockets/83521bb0fd5da34426e16d8825eb314e +0 -0
  144. data/spec/dummy/tmp/cache/assets/development/sprockets/85b590662faa5956a7cb3a38390f16ca +0 -0
  145. data/spec/dummy/tmp/cache/assets/development/sprockets/8733ef9be8fb368ac9aa5b1ccbfce14c +0 -0
  146. data/spec/dummy/tmp/cache/assets/development/sprockets/87b209c0c9da28094a8d5581a21262c6 +0 -0
  147. data/spec/dummy/tmp/cache/assets/development/sprockets/8931ae3296ab13e8eed90f434208887f +0 -0
  148. data/spec/dummy/tmp/cache/assets/development/sprockets/8cb4c1afbd9a270155d8cdd697a8b20d +0 -0
  149. data/spec/dummy/tmp/cache/assets/development/sprockets/8d1f1fbd708160b30af96a108fef6c0d +0 -0
  150. data/spec/dummy/tmp/cache/assets/development/sprockets/91ef1ca0ef363be62f4a38fb3fbc2291 +0 -0
  151. data/spec/dummy/tmp/cache/assets/development/sprockets/9a25637a28779d7c49c40044188bd0e5 +0 -0
  152. data/spec/dummy/tmp/cache/assets/development/sprockets/a0d10779d647db6ab1328734733a0e4d +0 -0
  153. data/spec/dummy/tmp/cache/assets/development/sprockets/a0e04aab47dc3631152c26632687f898 +0 -0
  154. data/spec/dummy/tmp/cache/assets/development/sprockets/a74883b193a8e72f27cba5703a696a89 +0 -0
  155. data/spec/dummy/tmp/cache/assets/development/sprockets/a839288628913e4533ef8cba740de1eb +0 -0
  156. data/spec/dummy/tmp/cache/assets/development/sprockets/a95ead461bd72142ffb3040f8cd7cfa0 +0 -0
  157. data/spec/dummy/tmp/cache/assets/development/sprockets/ac47afc414ae67e366a330dc003edf1a +0 -0
  158. data/spec/dummy/tmp/cache/assets/development/sprockets/b1d1383958868d6f0e9e05c848682d70 +0 -0
  159. data/spec/dummy/tmp/cache/assets/development/sprockets/b4ff5ac95c02b56ca97786b337f8b845 +0 -0
  160. data/spec/dummy/tmp/cache/assets/development/sprockets/b718bc4e8c8146520d982e086897fe24 +0 -0
  161. data/spec/dummy/tmp/cache/assets/development/sprockets/b848029d2fa6db3db28ccbce818b399b +0 -0
  162. data/spec/dummy/tmp/cache/assets/development/sprockets/ba05f15307eb6d2c7e31e50768867139 +0 -0
  163. data/spec/dummy/tmp/cache/assets/development/sprockets/c1a8bdfcb2dca842a48acc85d3ff658a +0 -0
  164. data/spec/dummy/tmp/cache/assets/development/sprockets/c2eb6c5cabed0e6b333c035ac8400bbc +0 -0
  165. data/spec/dummy/tmp/cache/assets/development/sprockets/c3dbe303660d299b488648fc157fd32b +0 -0
  166. data/spec/dummy/tmp/cache/assets/development/sprockets/c45af704cb234484a8e1d0852f8fe0bc +0 -0
  167. data/spec/dummy/tmp/cache/assets/development/sprockets/c4868ba5188e0672b480e24d979224d0 +0 -0
  168. data/spec/dummy/tmp/cache/assets/development/sprockets/caa2f86bb055636b69e292f2ae993914 +0 -0
  169. data/spec/dummy/tmp/cache/assets/development/sprockets/ce4b669883cb8df0ccd1c6aca12e0434 +0 -0
  170. data/spec/dummy/tmp/cache/assets/development/sprockets/cebc6db0bbb8120f430da3970b173d2f +0 -0
  171. data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  172. data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  173. data/spec/dummy/tmp/cache/assets/development/sprockets/d8a7bed1e7150777f59a9e107c1acaa8 +0 -0
  174. data/spec/dummy/tmp/cache/assets/development/sprockets/db4f843f0e597f7ba079bec345a91d58 +0 -0
  175. data/spec/dummy/tmp/cache/assets/development/sprockets/dd5a838f402c1f78ff0f6e43b3ce6624 +0 -0
  176. data/spec/dummy/tmp/cache/assets/development/sprockets/dfd7187ca1d53815395570d20d933e13 +0 -0
  177. data/spec/dummy/tmp/cache/assets/development/sprockets/e4092eb95487a855cb730373c97b8756 +0 -0
  178. data/spec/dummy/tmp/cache/assets/development/sprockets/e41b3d9532b5ef87c246ef6eb88417ed +0 -0
  179. data/spec/dummy/tmp/cache/assets/development/sprockets/e8266bddb6510ce3a2bc5ae1469ab3f6 +0 -0
  180. data/spec/dummy/tmp/cache/assets/development/sprockets/e86f67e739e4d85d5b8b1830b327ee67 +0 -0
  181. data/spec/dummy/tmp/cache/assets/development/sprockets/efc1c13c84f6f8686ade375b47913c8d +0 -0
  182. data/spec/dummy/tmp/cache/assets/development/sprockets/f1e3cae1b4d4c1085b32f88d26fd1f89 +0 -0
  183. data/spec/dummy/tmp/cache/assets/development/sprockets/f21b1a83f2c41f61ba73c424b057ee19 +0 -0
  184. data/spec/dummy/tmp/cache/assets/development/sprockets/f25cc7f3223a9259336cb2dd38df220e +0 -0
  185. data/spec/dummy/tmp/cache/assets/development/sprockets/f56253b5f374fff1a33fbbc9881c9124 +0 -0
  186. data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  187. data/spec/dummy/tmp/cache/assets/test/sprockets/10fb651bf6e564ad505e391670c11a8d +0 -0
  188. data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  189. data/spec/dummy/tmp/cache/assets/test/sprockets/142047722c23a8e9a96c6355d224b67e +0 -0
  190. data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  191. data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  192. data/spec/dummy/tmp/cache/assets/test/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
  193. data/spec/dummy/tmp/cache/assets/test/sprockets/4050a4e5062ab95c9f32e9b6940821ea +0 -0
  194. data/spec/dummy/tmp/cache/assets/test/sprockets/51202fde1d49c04c5d5588ca203b7b1e +0 -0
  195. data/spec/dummy/tmp/cache/assets/test/sprockets/596788b2d37e650dd4cf582b185f9d37 +0 -0
  196. data/spec/dummy/tmp/cache/assets/test/sprockets/5f1a0d05e77ca8b9a1fc2a47e17a8174 +0 -0
  197. data/spec/dummy/tmp/cache/assets/test/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
  198. data/spec/dummy/tmp/cache/assets/test/sprockets/81b537f4760199f4030b928268605909 +0 -0
  199. data/spec/dummy/tmp/cache/assets/test/sprockets/87b209c0c9da28094a8d5581a21262c6 +0 -0
  200. data/spec/dummy/tmp/cache/assets/test/sprockets/8cb4c1afbd9a270155d8cdd697a8b20d +0 -0
  201. data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  202. data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  203. data/spec/dummy/tmp/cache/assets/test/sprockets/f56253b5f374fff1a33fbbc9881c9124 +0 -0
  204. data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  205. data/spec/dummy/tmp/jasmine/assets/application.js +9132 -0
  206. data/spec/dummy/tmp/jasmine/assets/boot.js +204 -0
  207. data/spec/dummy/tmp/jasmine/assets/helpers/spec_helper.js +462 -0
  208. data/spec/dummy/tmp/jasmine/assets/jasmine-console-reporter.js +125 -0
  209. data/spec/dummy/tmp/jasmine/assets/jasmine-console-shims.js +31 -0
  210. data/spec/dummy/tmp/jasmine/assets/jasmine-html.js +360 -0
  211. data/spec/dummy/tmp/jasmine/assets/jasmine-specs.js +0 -0
  212. data/spec/dummy/tmp/jasmine/assets/jasmine.css +55 -0
  213. data/spec/dummy/tmp/jasmine/assets/jasmine.js +2403 -0
  214. data/spec/dummy/tmp/jasmine/assets/jquery-2.1.0.js +9112 -0
  215. data/spec/dummy/tmp/jasmine/assets/json2.js +479 -0
  216. data/spec/dummy/tmp/jasmine/assets/magic_carpet/application.js +95 -0
  217. data/spec/dummy/tmp/jasmine/assets/magic_carpet/magic_carpet.js +81 -0
  218. data/spec/dummy/tmp/jasmine/assets/magic_carpet_spec.js +317 -0
  219. data/spec/dummy/tmp/jasmine/assets/users.js +3 -0
  220. data/spec/dummy/tmp/jasmine/assets/wishes.js +3 -0
  221. data/spec/dummy/tmp/jasmine/runner.html +28 -0
  222. data/spec/dummy/tmp/pids/server.pid +1 -0
  223. data/spec/helpers/magic_carpet/js_fixtures_helper_spec.rb +249 -0
  224. data/spec/spec_helper.rb +14 -0
  225. metadata +590 -0
@@ -0,0 +1,479 @@
1
+ /*
2
+ http://www.JSON.org/json2.js
3
+ 2009-08-17
4
+
5
+ Public Domain.
6
+
7
+ NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
8
+
9
+ See http://www.JSON.org/js.html
10
+
11
+ This file creates a global JSON object containing two methods: stringify
12
+ and parse.
13
+
14
+ JSON.stringify(value, replacer, space)
15
+ value any JavaScript value, usually an object or array.
16
+
17
+ replacer an optional parameter that determines how object
18
+ values are stringified for objects. It can be a
19
+ function or an array of strings.
20
+
21
+ space an optional parameter that specifies the indentation
22
+ of nested structures. If it is omitted, the text will
23
+ be packed without extra whitespace. If it is a number,
24
+ it will specify the number of spaces to indent at each
25
+ level. If it is a string (such as '\t' or ' '),
26
+ it contains the characters used to indent at each level.
27
+
28
+ This method produces a JSON text from a JavaScript value.
29
+
30
+ When an object value is found, if the object contains a toJSON
31
+ method, its toJSON method will be called and the result will be
32
+ stringified. A toJSON method does not serialize: it returns the
33
+ value represented by the name/value pair that should be serialized,
34
+ or undefined if nothing should be serialized. The toJSON method
35
+ will be passed the key associated with the value, and this will be
36
+ bound to the value
37
+
38
+ For example, this would serialize Dates as ISO strings.
39
+
40
+ Date.prototype.toJSON = function (key) {
41
+ function f(n) {
42
+ // Format integers to have at least two digits.
43
+ return n < 10 ? '0' + n : n;
44
+ }
45
+
46
+ return this.getUTCFullYear() + '-' +
47
+ f(this.getUTCMonth() + 1) + '-' +
48
+ f(this.getUTCDate()) + 'T' +
49
+ f(this.getUTCHours()) + ':' +
50
+ f(this.getUTCMinutes()) + ':' +
51
+ f(this.getUTCSeconds()) + 'Z';
52
+ };
53
+
54
+ You can provide an optional replacer method. It will be passed the
55
+ key and value of each member, with this bound to the containing
56
+ object. The value that is returned from your method will be
57
+ serialized. If your method returns undefined, then the member will
58
+ be excluded from the serialization.
59
+
60
+ If the replacer parameter is an array of strings, then it will be
61
+ used to select the members to be serialized. It filters the results
62
+ such that only members with keys listed in the replacer array are
63
+ stringified.
64
+
65
+ Values that do not have JSON representations, such as undefined or
66
+ functions, will not be serialized. Such values in objects will be
67
+ dropped; in arrays they will be replaced with null. You can use
68
+ a replacer function to replace those with JSON values.
69
+ JSON.stringify(undefined) returns undefined.
70
+
71
+ The optional space parameter produces a stringification of the
72
+ value that is filled with line breaks and indentation to make it
73
+ easier to read.
74
+
75
+ If the space parameter is a non-empty string, then that string will
76
+ be used for indentation. If the space parameter is a number, then
77
+ the indentation will be that many spaces.
78
+
79
+ Example:
80
+
81
+ text = JSON.stringify(['e', {pluribus: 'unum'}]);
82
+ // text is '["e",{"pluribus":"unum"}]'
83
+
84
+
85
+ text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
86
+ // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
87
+
88
+ text = JSON.stringify([new Date()], function (key, value) {
89
+ return this[key] instanceof Date ?
90
+ 'Date(' + this[key] + ')' : value;
91
+ });
92
+ // text is '["Date(---current time---)"]'
93
+
94
+
95
+ JSON.parse(text, reviver)
96
+ This method parses a JSON text to produce an object or array.
97
+ It can throw a SyntaxError exception.
98
+
99
+ The optional reviver parameter is a function that can filter and
100
+ transform the results. It receives each of the keys and values,
101
+ and its return value is used instead of the original value.
102
+ If it returns what it received, then the structure is not modified.
103
+ If it returns undefined then the member is deleted.
104
+
105
+ Example:
106
+
107
+ // Parse the text. Values that look like ISO date strings will
108
+ // be converted to Date objects.
109
+
110
+ myData = JSON.parse(text, function (key, value) {
111
+ var a;
112
+ if (typeof value === 'string') {
113
+ a =
114
+ /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
115
+ if (a) {
116
+ return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
117
+ +a[5], +a[6]));
118
+ }
119
+ }
120
+ return value;
121
+ });
122
+
123
+ myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
124
+ var d;
125
+ if (typeof value === 'string' &&
126
+ value.slice(0, 5) === 'Date(' &&
127
+ value.slice(-1) === ')') {
128
+ d = new Date(value.slice(5, -1));
129
+ if (d) {
130
+ return d;
131
+ }
132
+ }
133
+ return value;
134
+ });
135
+
136
+
137
+ This is a reference implementation. You are free to copy, modify, or
138
+ redistribute.
139
+
140
+ This code should be minified before deployment.
141
+ See http://javascript.crockford.com/jsmin.html
142
+
143
+ USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
144
+ NOT CONTROL.
145
+ */
146
+
147
+ /*jslint evil: true */
148
+
149
+ /*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
150
+ call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
151
+ getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
152
+ lastIndex, length, parse, prototype, push, replace, slice, stringify,
153
+ test, toJSON, toString, valueOf
154
+ */
155
+
156
+
157
+ "use strict";
158
+
159
+ // Create a JSON object only if one does not already exist. We create the
160
+ // methods in a closure to avoid creating global variables.
161
+
162
+ if (!this.JSON) {
163
+ this.JSON = {};
164
+ }
165
+
166
+ (function () {
167
+
168
+ function f(n) {
169
+ // Format integers to have at least two digits.
170
+ return n < 10 ? '0' + n : n;
171
+ }
172
+
173
+ if (typeof Date.prototype.toJSON !== 'function') {
174
+
175
+ Date.prototype.toJSON = function (key) {
176
+
177
+ return isFinite(this.valueOf()) ?
178
+ this.getUTCFullYear() + '-' +
179
+ f(this.getUTCMonth() + 1) + '-' +
180
+ f(this.getUTCDate()) + 'T' +
181
+ f(this.getUTCHours()) + ':' +
182
+ f(this.getUTCMinutes()) + ':' +
183
+ f(this.getUTCSeconds()) + 'Z' : null;
184
+ };
185
+
186
+ String.prototype.toJSON =
187
+ Number.prototype.toJSON =
188
+ Boolean.prototype.toJSON = function (key) {
189
+ return this.valueOf();
190
+ };
191
+ }
192
+
193
+ var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
194
+ escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
195
+ gap,
196
+ indent,
197
+ meta = { // table of character substitutions
198
+ '\b': '\\b',
199
+ '\t': '\\t',
200
+ '\n': '\\n',
201
+ '\f': '\\f',
202
+ '\r': '\\r',
203
+ '"' : '\\"',
204
+ '\\': '\\\\'
205
+ },
206
+ rep;
207
+
208
+
209
+ function quote(string) {
210
+
211
+ // If the string contains no control characters, no quote characters, and no
212
+ // backslash characters, then we can safely slap some quotes around it.
213
+ // Otherwise we must also replace the offending characters with safe escape
214
+ // sequences.
215
+
216
+ escapable.lastIndex = 0;
217
+ return escapable.test(string) ?
218
+ '"' + string.replace(escapable, function (a) {
219
+ var c = meta[a];
220
+ return typeof c === 'string' ? c :
221
+ '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
222
+ }) + '"' :
223
+ '"' + string + '"';
224
+ }
225
+
226
+
227
+ function str(key, holder) {
228
+ // Produce a string from holder[key].
229
+
230
+ var i, // The loop counter.
231
+ k, // The member key.
232
+ v, // The member value.
233
+ length,
234
+ mind = gap,
235
+ partial,
236
+ value = holder[key];
237
+
238
+ // If the value has a toJSON method, call it to obtain a replacement value.
239
+
240
+ if (value && typeof value === 'object' &&
241
+ typeof value.toJSON === 'function') {
242
+ value = value.toJSON(key);
243
+ }
244
+
245
+ // If we were called with a replacer function, then call the replacer to
246
+ // obtain a replacement value.
247
+
248
+ if (typeof rep === 'function') {
249
+ value = rep.call(holder, key, value);
250
+ }
251
+
252
+ // What happens next depends on the value's type.
253
+
254
+ switch (typeof value) {
255
+ case 'string':
256
+ return quote(value);
257
+
258
+ case 'number':
259
+
260
+ // JSON numbers must be finite. Encode non-finite numbers as null.
261
+
262
+ return isFinite(value) ? String(value) : 'null';
263
+
264
+ case 'boolean':
265
+ case 'null':
266
+
267
+ // If the value is a boolean or null, convert it to a string. Note:
268
+ // typeof null does not produce 'null'. The case is included here in
269
+ // the remote chance that this gets fixed someday.
270
+
271
+ return String(value);
272
+
273
+ // If the type is 'object', we might be dealing with an object or an array or
274
+ // null.
275
+
276
+ case 'object':
277
+
278
+ // Due to a specification blunder in ECMAScript, typeof null is 'object',
279
+ // so watch out for that case.
280
+
281
+ if (!value) {
282
+ return 'null';
283
+ }
284
+
285
+ // Make an array to hold the partial results of stringifying this object value.
286
+
287
+ gap += indent;
288
+ partial = [];
289
+
290
+ // Is the value an array?
291
+
292
+ if (Object.prototype.toString.apply(value) === '[object Array]') {
293
+
294
+ // The value is an array. Stringify every element. Use null as a placeholder
295
+ // for non-JSON values.
296
+
297
+ length = value.length;
298
+ for (i = 0; i < length; i += 1) {
299
+ partial[i] = str(i, value) || 'null';
300
+ }
301
+
302
+ // Join all of the elements together, separated with commas, and wrap them in
303
+ // brackets.
304
+
305
+ v = partial.length === 0 ? '[]' :
306
+ gap ? '[\n' + gap +
307
+ partial.join(',\n' + gap) + '\n' +
308
+ mind + ']' :
309
+ '[' + partial.join(',') + ']';
310
+ gap = mind;
311
+ return v;
312
+ }
313
+
314
+ // If the replacer is an array, use it to select the members to be stringified.
315
+
316
+ if (rep && typeof rep === 'object') {
317
+ length = rep.length;
318
+ for (i = 0; i < length; i += 1) {
319
+ k = rep[i];
320
+ if (typeof k === 'string') {
321
+ v = str(k, value);
322
+ if (v) {
323
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
324
+ }
325
+ }
326
+ }
327
+ } else {
328
+
329
+ // Otherwise, iterate through all of the keys in the object.
330
+
331
+ for (k in value) {
332
+ if (Object.hasOwnProperty.call(value, k)) {
333
+ v = str(k, value);
334
+ if (v) {
335
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
336
+ }
337
+ }
338
+ }
339
+ }
340
+
341
+ // Join all of the member texts together, separated with commas,
342
+ // and wrap them in braces.
343
+
344
+ v = partial.length === 0 ? '{}' :
345
+ gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
346
+ mind + '}' : '{' + partial.join(',') + '}';
347
+ gap = mind;
348
+ return v;
349
+ }
350
+ }
351
+
352
+ // If the JSON object does not yet have a stringify method, give it one.
353
+
354
+ if (typeof JSON.stringify !== 'function') {
355
+ JSON.stringify = function (value, replacer, space) {
356
+ // The stringify method takes a value and an optional replacer, and an optional
357
+ // space parameter, and returns a JSON text. The replacer can be a function
358
+ // that can replace values, or an array of strings that will select the keys.
359
+ // A default replacer method can be provided. Use of the space parameter can
360
+ // produce text that is more easily readable.
361
+
362
+ var i;
363
+ gap = '';
364
+ indent = '';
365
+
366
+ // If the space parameter is a number, make an indent string containing that
367
+ // many spaces.
368
+
369
+ if (typeof space === 'number') {
370
+ for (i = 0; i < space; i += 1) {
371
+ indent += ' ';
372
+ }
373
+
374
+ // If the space parameter is a string, it will be used as the indent string.
375
+
376
+ } else if (typeof space === 'string') {
377
+ indent = space;
378
+ }
379
+
380
+ // If there is a replacer, it must be a function or an array.
381
+ // Otherwise, throw an error.
382
+
383
+ rep = replacer;
384
+ if (replacer && typeof replacer !== 'function' &&
385
+ (typeof replacer !== 'object' ||
386
+ typeof replacer.length !== 'number')) {
387
+ throw new Error('JSON.stringify');
388
+ }
389
+
390
+ // Make a fake root object containing our value under the key of ''.
391
+ // Return the result of stringifying the value.
392
+
393
+ return str('', {'': value});
394
+ };
395
+ }
396
+
397
+
398
+ // If the JSON object does not yet have a parse method, give it one.
399
+
400
+ if (typeof JSON.parse !== 'function') {
401
+ JSON.parse = function (text, reviver) {
402
+
403
+ // The parse method takes a text and an optional reviver function, and returns
404
+ // a JavaScript value if the text is a valid JSON text.
405
+
406
+ var j;
407
+
408
+ function walk(holder, key) {
409
+
410
+ // The walk method is used to recursively walk the resulting structure so
411
+ // that modifications can be made.
412
+
413
+ var k, v, value = holder[key];
414
+ if (value && typeof value === 'object') {
415
+ for (k in value) {
416
+ if (Object.hasOwnProperty.call(value, k)) {
417
+ v = walk(value, k);
418
+ if (v !== undefined) {
419
+ value[k] = v;
420
+ } else {
421
+ delete value[k];
422
+ }
423
+ }
424
+ }
425
+ }
426
+ return reviver.call(holder, key, value);
427
+ }
428
+
429
+
430
+ // Parsing happens in four stages. In the first stage, we replace certain
431
+ // Unicode characters with escape sequences. JavaScript handles many characters
432
+ // incorrectly, either silently deleting them, or treating them as line endings.
433
+
434
+ cx.lastIndex = 0;
435
+ if (cx.test(text)) {
436
+ text = text.replace(cx, function (a) {
437
+ return '\\u' +
438
+ ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
439
+ });
440
+ }
441
+
442
+ // In the second stage, we run the text against regular expressions that look
443
+ // for non-JSON patterns. We are especially concerned with '()' and 'new'
444
+ // because they can cause invocation, and '=' because it can cause mutation.
445
+ // But just to be safe, we want to reject all unexpected forms.
446
+
447
+ // We split the second stage into 4 regexp operations in order to work around
448
+ // crippling inefficiencies in IE's and Safari's regexp engines. First we
449
+ // replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
450
+ // replace all simple value tokens with ']' characters. Third, we delete all
451
+ // open brackets that follow a colon or comma or that begin the text. Finally,
452
+ // we look to see that the remaining characters are only whitespace or ']' or
453
+ // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
454
+
455
+ if (/^[\],:{}\s]*$/.
456
+ test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
457
+ replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
458
+ replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
459
+
460
+ // In the third stage we use the eval function to compile the text into a
461
+ // JavaScript structure. The '{' operator is subject to a syntactic ambiguity
462
+ // in JavaScript: it can begin a block or an object literal. We wrap the text
463
+ // in parens to eliminate the ambiguity.
464
+
465
+ j = eval('(' + text + ')');
466
+
467
+ // In the optional fourth stage, we recursively walk the new structure, passing
468
+ // each name/value pair to a reviver function for possible transformation.
469
+
470
+ return typeof reviver === 'function' ?
471
+ walk({'': j}, '') : j;
472
+ }
473
+
474
+ // If the text is not JSON parseable, then a SyntaxError is thrown.
475
+
476
+ throw new SyntaxError('JSON.parse');
477
+ };
478
+ }
479
+ }());
@@ -0,0 +1,95 @@
1
+ (MagicCarpet = {
2
+ async: false,
3
+ asyncComplete: true,
4
+ cache: {},
5
+
6
+ initialize: function() {
7
+ this.bindAll();
8
+ this.cacheElements();
9
+ this.appendSandbox();
10
+ },
11
+
12
+ bindAll: function() {
13
+ for(var prop in this) {
14
+ if (typeof this[prop] === "function" && this.hasOwnProperty(prop))
15
+ this.bind(this, prop);
16
+ }
17
+ },
18
+
19
+ bind: function(context, methodName) {
20
+ var func = context[methodName];
21
+ context[methodName] = function() {
22
+ return func.apply(context, arguments);
23
+ };
24
+ },
25
+
26
+ cacheElements: function() {
27
+ this.sandbox = this.createSandbox();
28
+ },
29
+
30
+ createSandbox: function() {
31
+ var div = document.createElement("div");
32
+ div.setAttribute("id", "magic-carpet");
33
+ return div;
34
+ },
35
+
36
+ appendSandbox: function() {
37
+ document.body.appendChild(this.sandbox);
38
+ },
39
+
40
+ emptySandbox: function() {
41
+ this.sandbox.innerHTML = "";
42
+ },
43
+
44
+ request: function(data) {
45
+ var cachedMarkup = this.cache[$.param(data)];
46
+ if (cachedMarkup) {
47
+ this.sandbox.innerHTML = cachedMarkup;
48
+ } else {
49
+ this.fetch(data);
50
+ }
51
+ },
52
+
53
+ fetch: function(data) {
54
+ this.lastRequest = data;
55
+ this.asyncComplete = false;
56
+ $.ajax({
57
+ url: "/magic_carpet",
58
+ method: "get",
59
+ async: this.async,
60
+ data: data
61
+ })
62
+ .done(this.handleSuccess)
63
+ .fail(this.handleFailure)
64
+ .always(this.afterRequest);
65
+ },
66
+
67
+ handleSuccess: function(markup) {
68
+ var cacheKey = $.param(this.lastRequest);
69
+ this.cache[cacheKey] = markup;
70
+ this.request(this.lastRequest);
71
+ },
72
+
73
+ handleFailure: function(response) {
74
+ debugger;
75
+ throw new Error(response.responseJSON.error);
76
+ },
77
+
78
+ afterRequest: function() {
79
+ this.asyncComplete = true;
80
+ }
81
+ }).initialize();
82
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
83
+ // listed below.
84
+ //
85
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
86
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
87
+ //
88
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
89
+ // compiled file.
90
+ //
91
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
92
+ // about supported directives.
93
+ //
94
+
95
+ ;
@@ -0,0 +1,81 @@
1
+ (MagicCarpet = {
2
+ async: false,
3
+ asyncComplete: true,
4
+ cache: {},
5
+
6
+ initialize: function() {
7
+ this.bindAll();
8
+ this.cacheElements();
9
+ this.appendSandbox();
10
+ },
11
+
12
+ bindAll: function() {
13
+ for(var prop in this) {
14
+ if (typeof this[prop] === "function" && this.hasOwnProperty(prop))
15
+ this.bind(this, prop);
16
+ }
17
+ },
18
+
19
+ bind: function(context, methodName) {
20
+ var func = context[methodName];
21
+ context[methodName] = function() {
22
+ return func.apply(context, arguments);
23
+ };
24
+ },
25
+
26
+ cacheElements: function() {
27
+ this.sandbox = this.createSandbox();
28
+ },
29
+
30
+ createSandbox: function() {
31
+ var div = document.createElement("div");
32
+ div.setAttribute("id", "magic-carpet");
33
+ return div;
34
+ },
35
+
36
+ appendSandbox: function() {
37
+ document.body.appendChild(this.sandbox);
38
+ },
39
+
40
+ emptySandbox: function() {
41
+ this.sandbox.innerHTML = "";
42
+ },
43
+
44
+ request: function(data) {
45
+ var cachedMarkup = this.cache[$.param(data)];
46
+ if (cachedMarkup) {
47
+ this.sandbox.innerHTML = cachedMarkup;
48
+ } else {
49
+ this.fetch(data);
50
+ }
51
+ },
52
+
53
+ fetch: function(data) {
54
+ this.lastRequest = data;
55
+ this.asyncComplete = false;
56
+ $.ajax({
57
+ url: "/magic_carpet",
58
+ method: "get",
59
+ async: this.async,
60
+ data: data
61
+ })
62
+ .done(this.handleSuccess)
63
+ .fail(this.handleFailure)
64
+ .always(this.afterRequest);
65
+ },
66
+
67
+ handleSuccess: function(markup) {
68
+ var cacheKey = $.param(this.lastRequest);
69
+ this.cache[cacheKey] = markup;
70
+ this.request(this.lastRequest);
71
+ },
72
+
73
+ handleFailure: function(response) {
74
+ debugger;
75
+ throw new Error(response.responseJSON.error);
76
+ },
77
+
78
+ afterRequest: function() {
79
+ this.asyncComplete = true;
80
+ }
81
+ }).initialize();