middleman-core-x86-mingw32 3.0.1.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (401) hide show
  1. data/.cane +2 -0
  2. data/.cane-exclusions.yml +5 -0
  3. data/.gemtest +0 -0
  4. data/Rakefile +7 -0
  5. data/bin/middleman +25 -0
  6. data/features/3rd_party_cli.feature +15 -0
  7. data/features/auto_layout.feature +36 -0
  8. data/features/automatic_directory_matcher.feature +32 -0
  9. data/features/builder.feature +50 -0
  10. data/features/chained_templates.feature +19 -0
  11. data/features/clean_build.feature +28 -0
  12. data/features/cli_extension.feature +14 -0
  13. data/features/cli_init.feature +89 -0
  14. data/features/current_page_request_path_backwards.feature +6 -0
  15. data/features/custom_layout_engines.feature +8 -0
  16. data/features/custom_layouts.feature +64 -0
  17. data/features/data.feature +22 -0
  18. data/features/dynamic_pages.feature +133 -0
  19. data/features/extensionless_text_files.feature +24 -0
  20. data/features/feature_params.feature +6 -0
  21. data/features/front-matter.feature +72 -0
  22. data/features/frontmatter_page_settings.feature +43 -0
  23. data/features/helpers_external.feature +12 -0
  24. data/features/ignore.feature +121 -0
  25. data/features/implied_extensions.feature +69 -0
  26. data/features/instance_vars.feature +9 -0
  27. data/features/mount_rack.feature +8 -0
  28. data/features/preview_changes.feature +29 -0
  29. data/features/request_params.feature +6 -0
  30. data/features/sitemap_traversal.feature +73 -0
  31. data/features/static_server.feature +6 -0
  32. data/features/step_definitions/page_layout_steps.rb +15 -0
  33. data/features/strip_url.feature +40 -0
  34. data/features/support/env.rb +6 -0
  35. data/features/unicode_filenames.feature +36 -0
  36. data/features/wildcard_page_helper.feature +10 -0
  37. data/fixtures/automatic-directory-matcher-app/config.rb +1 -0
  38. data/fixtures/automatic-directory-matcher-app/source/root-plain.html +1 -0
  39. data/fixtures/automatic-directory-matcher-app/source/root.html.erb +1 -0
  40. data/fixtures/automatic-directory-matcher-app/source/sub--sub--sub-plain.html +1 -0
  41. data/fixtures/automatic-directory-matcher-app/source/sub--sub--sub.html.erb +1 -0
  42. data/fixtures/automatic-directory-matcher-app/source/sub--sub-plain.html +1 -0
  43. data/fixtures/automatic-directory-matcher-app/source/sub--sub.html.erb +1 -0
  44. data/fixtures/basic-data-app/config.rb +4 -0
  45. data/fixtures/basic-data-app/data/test.yml +4 -0
  46. data/fixtures/basic-data-app/data/test2.json +4 -0
  47. data/fixtures/basic-data-app/source/data.html.erb +1 -0
  48. data/fixtures/basic-data-app/source/data3.html.erb +1 -0
  49. data/fixtures/build-with-errors-app/config.rb +1 -0
  50. data/fixtures/build-with-errors-app/source/index.html.erb +1 -0
  51. data/fixtures/chained-app/config.rb +0 -0
  52. data/fixtures/chained-app/data/article.yml +2 -0
  53. data/fixtures/chained-app/source/index.html.str.erb +8 -0
  54. data/fixtures/clean-app/config-complications.rb +11 -0
  55. data/fixtures/clean-app/config-empty.rb +0 -0
  56. data/fixtures/clean-app/config.rb +11 -0
  57. data/fixtures/clean-app/source/index.html.erb +1 -0
  58. data/fixtures/clean-app/source/layout.erb +9 -0
  59. data/fixtures/clean-app/source/layouts/custom.erb +8 -0
  60. data/fixtures/clean-app/source/real/index.html.erb +5 -0
  61. data/fixtures/clean-app/source/real.html +1 -0
  62. data/fixtures/clean-app/source/should_be_ignored.html +1 -0
  63. data/fixtures/clean-app/source/should_be_ignored2.html +1 -0
  64. data/fixtures/clean-app/source/should_be_ignored3.html +1 -0
  65. data/fixtures/clean-app/source/static.html +1 -0
  66. data/fixtures/clean-nested-app/config.rb +3 -0
  67. data/fixtures/clean-nested-app/source/about.html +1 -0
  68. data/fixtures/csspie/config.rb +0 -0
  69. data/fixtures/csspie/source/stylesheets/PIE.htc +96 -0
  70. data/fixtures/current-page-app/config.rb +3 -0
  71. data/fixtures/current-page-app/source/request-path.html.erb +1 -0
  72. data/fixtures/custom-layout-app/config.rb +1 -0
  73. data/fixtures/custom-layout-app/source/index.html.erb +1 -0
  74. data/fixtures/custom-layout-app/source/layout.str +9 -0
  75. data/fixtures/custom-layout-app2/config.rb +0 -0
  76. data/fixtures/custom-layout-app2/source/custom-layout-dir/index.html.erb +1 -0
  77. data/fixtures/custom-layout-app2/source/custom-layout.html.erb +1 -0
  78. data/fixtures/custom-layout-app2/source/layouts/custom.erb +8 -0
  79. data/fixtures/data-app/config.rb +3 -0
  80. data/fixtures/data-app/data/pages.yml +6 -0
  81. data/fixtures/data-app/source/index.html.erb +1 -0
  82. data/fixtures/data-app/source/layout.erb +5 -0
  83. data/fixtures/different-engine-layout/config.rb +0 -0
  84. data/fixtures/different-engine-layout/source/index.html.str +1 -0
  85. data/fixtures/different-engine-layout/source/layout.erb +9 -0
  86. data/fixtures/dynamic-pages-app/config.rb +52 -0
  87. data/fixtures/dynamic-pages-app/source/real/index.html.erb +9 -0
  88. data/fixtures/dynamic-pages-app/source/real.html +1 -0
  89. data/fixtures/dynamic-pages-app/source/should_be_ignored.html +1 -0
  90. data/fixtures/dynamic-pages-app/source/should_be_ignored2.html +1 -0
  91. data/fixtures/dynamic-pages-app/source/should_be_ignored3.html +1 -0
  92. data/fixtures/dynamic-pages-app/source/should_be_ignored4.html +1 -0
  93. data/fixtures/dynamic-pages-app/source/should_be_ignored5.html +1 -0
  94. data/fixtures/dynamic-pages-app/source/should_be_ignored6.html +1 -0
  95. data/fixtures/dynamic-pages-app/source/should_be_ignored7.html +1 -0
  96. data/fixtures/dynamic-pages-app/source/should_be_ignored8.html +1 -0
  97. data/fixtures/empty-app/not-config.rb +0 -0
  98. data/fixtures/engine-matching-layout/config.rb +0 -0
  99. data/fixtures/engine-matching-layout/source/index.html.erb +1 -0
  100. data/fixtures/engine-matching-layout/source/layout.erb +9 -0
  101. data/fixtures/extensionless-text-files-app/config.rb +0 -0
  102. data/fixtures/extensionless-text-files-app/source/CNAME +1 -0
  103. data/fixtures/extensionless-text-files-app/source/LICENSE +1 -0
  104. data/fixtures/extensionless-text-files-app/source/README +1 -0
  105. data/fixtures/extensionless-text-files-app/source/index.html +1 -0
  106. data/fixtures/external-helpers/config.rb +4 -0
  107. data/fixtures/external-helpers/helpers/derp.rb +3 -0
  108. data/fixtures/external-helpers/helpers/four_helpers.rb +3 -0
  109. data/fixtures/external-helpers/helpers/one_helper.rb +3 -0
  110. data/fixtures/external-helpers/helpers/yet_another_thingy.rb +3 -0
  111. data/fixtures/external-helpers/lib/hello_helper.rb +5 -0
  112. data/fixtures/external-helpers/source/automatic.html.erb +1 -0
  113. data/fixtures/external-helpers/source/index.html.erb +1 -0
  114. data/fixtures/feature-params-app/config.rb +12 -0
  115. data/fixtures/feature-params-app/source/index.html.erb +3 -0
  116. data/fixtures/frontmatter-app/config.rb +0 -0
  117. data/fixtures/frontmatter-app/source/front-matter-2.php.erb +7 -0
  118. data/fixtures/frontmatter-app/source/front-matter-auto.erb +6 -0
  119. data/fixtures/frontmatter-app/source/front-matter-change.html.erb +5 -0
  120. data/fixtures/frontmatter-app/source/front-matter-encoding.html.erb +7 -0
  121. data/fixtures/frontmatter-app/source/front-matter-line-2.html.erb +7 -0
  122. data/fixtures/frontmatter-app/source/json-front-matter-2.php.erb +7 -0
  123. data/fixtures/frontmatter-app/source/json-front-matter-auto.erb +6 -0
  124. data/fixtures/frontmatter-app/source/json-front-matter-encoding.html.erb +7 -0
  125. data/fixtures/frontmatter-app/source/json-front-matter-line-2.html.erb +7 -0
  126. data/fixtures/frontmatter-app/source/json-front-matter.html.erb +6 -0
  127. data/fixtures/frontmatter-settings-app/config.rb +4 -0
  128. data/fixtures/frontmatter-settings-app/source/alternate_layout.html.erb +5 -0
  129. data/fixtures/frontmatter-settings-app/source/ignored.html.erb +5 -0
  130. data/fixtures/frontmatter-settings-app/source/layouts/alternate.erb +3 -0
  131. data/fixtures/frontmatter-settings-app/source/layouts/override.erb +2 -0
  132. data/fixtures/frontmatter-settings-app/source/override_layout.html.erb +4 -0
  133. data/fixtures/frontmatter-settings-app/source/page_mentioned.html.erb +4 -0
  134. data/fixtures/generator-test/config.rb +80 -0
  135. data/fixtures/generator-test/source/index.html.erb +10 -0
  136. data/fixtures/glob-app/config.rb +1 -0
  137. data/fixtures/glob-app/source/index.html.erb +4 -0
  138. data/fixtures/glob-app/source/stylesheets/site.css.str +3 -0
  139. data/fixtures/ignore-app/source/about.html.erb +1 -0
  140. data/fixtures/ignore-app/source/images/icon/messages.png +0 -0
  141. data/fixtures/ignore-app/source/images/pic.png +0 -0
  142. data/fixtures/ignore-app/source/images/portrait.jpg +0 -0
  143. data/fixtures/ignore-app/source/index.html.erb +0 -0
  144. data/fixtures/ignore-app/source/plain.html +1 -0
  145. data/fixtures/ignore-app/source/reports/another.html +0 -0
  146. data/fixtures/ignore-app/source/reports/index.html +0 -0
  147. data/fixtures/implied-extensions-app/config.rb +0 -0
  148. data/fixtures/implied-extensions-app/source/index.erb +1 -0
  149. data/fixtures/indexable-app/config.rb +0 -0
  150. data/fixtures/indexable-app/source/.htaccess +1 -0
  151. data/fixtures/indexable-app/source/a_folder/needs_index.html +1 -0
  152. data/fixtures/indexable-app/source/leave_me_alone.html +1 -0
  153. data/fixtures/indexable-app/source/needs_index.html +1 -0
  154. data/fixtures/indexable-app/source/regular/index.html +1 -0
  155. data/fixtures/indexable-app/source/wildcard_leave_me_alone.html +1 -0
  156. data/fixtures/instance-vars-app/config.rb +7 -0
  157. data/fixtures/instance-vars-app/source/content.html.erb +2 -0
  158. data/fixtures/instance-vars-app/source/layout.erb +1 -0
  159. data/fixtures/large-build-app/config.rb +3 -0
  160. data/fixtures/large-build-app/source/.htaccess +1 -0
  161. data/fixtures/large-build-app/source/_partial.erb +1 -0
  162. data/fixtures/large-build-app/source/feed.xml.builder +4 -0
  163. data/fixtures/large-build-app/source/images/Child folder/regular_file(example).txt +1 -0
  164. data/fixtures/large-build-app/source/images/Read me (example).txt +1 -0
  165. data/fixtures/large-build-app/source/images/blank.gif +0 -0
  166. data/fixtures/large-build-app/source/index.html.erb +1 -0
  167. data/fixtures/large-build-app/source/layout.erb +9 -0
  168. data/fixtures/large-build-app/source/layouts/content_for.erb +4 -0
  169. data/fixtures/large-build-app/source/layouts/custom.erb +8 -0
  170. data/fixtures/large-build-app/source/other_layout.erb +1 -0
  171. data/fixtures/large-build-app/source/services/index.html.erb +1 -0
  172. data/fixtures/large-build-app/source/spaces in file.html.erb +1 -0
  173. data/fixtures/large-build-app/source/static.html +1 -0
  174. data/fixtures/large-build-app/source/stylesheets/static.css +2 -0
  175. data/fixtures/manual-layout/config.rb +1 -0
  176. data/fixtures/manual-layout/source/index.html.erb +1 -0
  177. data/fixtures/manual-layout/source/layouts/custom.erb +9 -0
  178. data/fixtures/manual-layout-missing/config.rb +1 -0
  179. data/fixtures/manual-layout-missing/source/index.html.erb +1 -0
  180. data/fixtures/manual-layout-override/config.rb +3 -0
  181. data/fixtures/manual-layout-override/source/index.html.erb +1 -0
  182. data/fixtures/manual-layout-override/source/layouts/another.erb +9 -0
  183. data/fixtures/manual-layout-override/source/layouts/custom.erb +9 -0
  184. data/fixtures/multiple-layouts/config.rb +0 -0
  185. data/fixtures/multiple-layouts/source/index.html.erb +1 -0
  186. data/fixtures/multiple-layouts/source/layout.erb +9 -0
  187. data/fixtures/multiple-layouts/source/layout.str +9 -0
  188. data/fixtures/no-layout/config.rb +0 -0
  189. data/fixtures/no-layout/source/index.html.erb +1 -0
  190. data/fixtures/page-helper-layout-block-app/config.rb +6 -0
  191. data/fixtures/page-helper-layout-block-app/source/index.html.erb +1 -0
  192. data/fixtures/page-helper-layout-block-app/source/layouts/alt.erb +3 -0
  193. data/fixtures/page-helper-layout-block-app/source/layouts/layout.erb +3 -0
  194. data/fixtures/page-helper-layout-block-app/source/path/child.html.erb +1 -0
  195. data/fixtures/page-helper-layout-block-app/source/path/index.html.erb +1 -0
  196. data/fixtures/plain-app/index.html +1 -0
  197. data/fixtures/preview-app/config.rb +0 -0
  198. data/fixtures/preview-app/source/content.html.erb +1 -0
  199. data/fixtures/preview-app/source/layout.erb +1 -0
  200. data/fixtures/request-app/config.rb +0 -0
  201. data/fixtures/request-app/source/index.html.erb +3 -0
  202. data/fixtures/sinatra-app/config.rb +11 -0
  203. data/fixtures/sinatra-app/source/index.html.erb +5 -0
  204. data/fixtures/strip-url-app/config.rb +0 -0
  205. data/fixtures/strip-url-app/source/index.html.erb +1 -0
  206. data/fixtures/strip-url-app/source/other.html.erb +1 -0
  207. data/fixtures/strip-url-app/source/subdir/index.html.erb +1 -0
  208. data/fixtures/traversal-app/config.rb +5 -0
  209. data/fixtures/traversal-app/source/directory-indexed/sibling.html.erb +3 -0
  210. data/fixtures/traversal-app/source/directory-indexed/sibling2.html.erb +3 -0
  211. data/fixtures/traversal-app/source/directory-indexed/sub2/index.html.erb +0 -0
  212. data/fixtures/traversal-app/source/directory-indexed/sub3/deep.html.erb +0 -0
  213. data/fixtures/traversal-app/source/directory-indexed.html.erb +0 -0
  214. data/fixtures/traversal-app/source/index.html.erb +0 -0
  215. data/fixtures/traversal-app/source/layout.erb +21 -0
  216. data/fixtures/traversal-app/source/proxied.html.erb +0 -0
  217. data/fixtures/traversal-app/source/root.html.erb +0 -0
  218. data/fixtures/traversal-app/source/sub/index.html.erb +0 -0
  219. data/fixtures/traversal-app/source/sub/sibling.html.erb +0 -0
  220. data/fixtures/traversal-app/source/sub/sibling2.html.erb +0 -0
  221. data/fixtures/traversal-app/source/sub/sub2/index.html.erb +0 -0
  222. data/fixtures/traversal-app/source/sub/sub3/deep.html.erb +0 -0
  223. data/fixtures/wildcard-app/config.rb +1 -0
  224. data/fixtures/wildcard-app/source/admin/index.html.erb +1 -0
  225. data/fixtures/wildcard-app/source/admin/page.html.erb +1 -0
  226. data/fixtures/wildcard-app/source/index.html.erb +1 -0
  227. data/fixtures/wildcard-app/source/layouts/admin.erb +2 -0
  228. data/fixtures/wildcard-app/source/layouts/layout.erb +2 -0
  229. data/lib/middleman/rack.rb +4 -0
  230. data/lib/middleman-core/application.rb +245 -0
  231. data/lib/middleman-core/cli/build.rb +286 -0
  232. data/lib/middleman-core/cli/bundler.rb +40 -0
  233. data/lib/middleman-core/cli/extension.rb +49 -0
  234. data/lib/middleman-core/cli/init.rb +58 -0
  235. data/lib/middleman-core/cli/server.rb +73 -0
  236. data/lib/middleman-core/cli.rb +89 -0
  237. data/lib/middleman-core/core_extensions/builder.rb +17 -0
  238. data/lib/middleman-core/core_extensions/data.rb +180 -0
  239. data/lib/middleman-core/core_extensions/extensions.rb +161 -0
  240. data/lib/middleman-core/core_extensions/external_helpers.rb +39 -0
  241. data/lib/middleman-core/core_extensions/file_watcher.rb +167 -0
  242. data/lib/middleman-core/core_extensions/front_matter.rb +213 -0
  243. data/lib/middleman-core/core_extensions/rendering.rb +439 -0
  244. data/lib/middleman-core/core_extensions/request.rb +338 -0
  245. data/lib/middleman-core/core_extensions/routing.rb +94 -0
  246. data/lib/middleman-core/core_extensions/ruby_encoding.rb +24 -0
  247. data/lib/middleman-core/core_extensions/show_exceptions.rb +31 -0
  248. data/lib/middleman-core/core_extensions.rb +33 -0
  249. data/lib/middleman-core/extensions.rb +103 -0
  250. data/lib/middleman-core/load_paths.rb +56 -0
  251. data/lib/middleman-core/logger.rb +29 -0
  252. data/lib/middleman-core/preview_server.rb +186 -0
  253. data/lib/middleman-core/profiling.rb +58 -0
  254. data/lib/middleman-core/renderers/coffee_script.rb +45 -0
  255. data/lib/middleman-core/renderers/erb.rb +36 -0
  256. data/lib/middleman-core/renderers/haml.rb +30 -0
  257. data/lib/middleman-core/renderers/less.rb +49 -0
  258. data/lib/middleman-core/renderers/liquid.rb +35 -0
  259. data/lib/middleman-core/renderers/markdown.rb +56 -0
  260. data/lib/middleman-core/renderers/redcarpet.rb +58 -0
  261. data/lib/middleman-core/renderers/sass.rb +101 -0
  262. data/lib/middleman-core/renderers/slim.rb +38 -0
  263. data/lib/middleman-core/sitemap/extensions/ignores.rb +91 -0
  264. data/lib/middleman-core/sitemap/extensions/on_disk.rb +84 -0
  265. data/lib/middleman-core/sitemap/extensions/proxies.rb +114 -0
  266. data/lib/middleman-core/sitemap/extensions/traversal.rb +84 -0
  267. data/lib/middleman-core/sitemap/resource.rb +149 -0
  268. data/lib/middleman-core/sitemap/store.rb +219 -0
  269. data/lib/middleman-core/sitemap.rb +78 -0
  270. data/lib/middleman-core/step_definitions/builder_steps.rb +56 -0
  271. data/lib/middleman-core/step_definitions/middleman_steps.rb +17 -0
  272. data/lib/middleman-core/step_definitions/server_steps.rb +91 -0
  273. data/lib/middleman-core/step_definitions.rb +12 -0
  274. data/lib/middleman-core/templates/default/source/images/background.png +0 -0
  275. data/lib/middleman-core/templates/default/source/images/middleman.png +0 -0
  276. data/lib/middleman-core/templates/default/source/index.html.erb +10 -0
  277. data/lib/middleman-core/templates/default/source/javascripts/all.js +1 -0
  278. data/lib/middleman-core/templates/default/source/layouts/layout.erb +19 -0
  279. data/lib/middleman-core/templates/default/source/stylesheets/all.css +55 -0
  280. data/lib/middleman-core/templates/default/source/stylesheets/normalize.css +431 -0
  281. data/lib/middleman-core/templates/default.rb +38 -0
  282. data/lib/middleman-core/templates/extension/Gemfile +17 -0
  283. data/lib/middleman-core/templates/extension/Rakefile +14 -0
  284. data/lib/middleman-core/templates/extension/features/support/env.rb +4 -0
  285. data/lib/middleman-core/templates/extension/gemspec +24 -0
  286. data/lib/middleman-core/templates/extension/gitignore +2 -0
  287. data/lib/middleman-core/templates/extension/lib/lib.rb +49 -0
  288. data/lib/middleman-core/templates/extension/lib/middleman_extension.rb +1 -0
  289. data/lib/middleman-core/templates/html5/source/404.html +43 -0
  290. data/lib/middleman-core/templates/html5/source/README.md +55 -0
  291. data/lib/middleman-core/templates/html5/source/apple-touch-icon-114x114-precomposed.png +0 -0
  292. data/lib/middleman-core/templates/html5/source/apple-touch-icon-57x57-precomposed.png +0 -0
  293. data/lib/middleman-core/templates/html5/source/apple-touch-icon-72x72-precomposed.png +0 -0
  294. data/lib/middleman-core/templates/html5/source/apple-touch-icon-precomposed.png +0 -0
  295. data/lib/middleman-core/templates/html5/source/apple-touch-icon.png +0 -0
  296. data/lib/middleman-core/templates/html5/source/crossdomain.xml +25 -0
  297. data/lib/middleman-core/templates/html5/source/css/style.css +293 -0
  298. data/lib/middleman-core/templates/html5/source/favicon.ico +0 -0
  299. data/lib/middleman-core/templates/html5/source/humans.txt +43 -0
  300. data/lib/middleman-core/templates/html5/source/img/.gitignore +0 -0
  301. data/lib/middleman-core/templates/html5/source/index.html +67 -0
  302. data/lib/middleman-core/templates/html5/source/js/libs/jquery-1.7.1.js +9266 -0
  303. data/lib/middleman-core/templates/html5/source/js/libs/jquery-1.7.1.min.js +4 -0
  304. data/lib/middleman-core/templates/html5/source/js/libs/modernizr-2.5.3.min.js +4 -0
  305. data/lib/middleman-core/templates/html5/source/js/plugins.js +11 -0
  306. data/lib/middleman-core/templates/html5/source/js/script.js +8 -0
  307. data/lib/middleman-core/templates/html5/source/robots.txt +4 -0
  308. data/lib/middleman-core/templates/html5.rb +30 -0
  309. data/lib/middleman-core/templates/local.rb +28 -0
  310. data/lib/middleman-core/templates/mobile/source/404.html +37 -0
  311. data/lib/middleman-core/templates/mobile/source/README.markdown +21 -0
  312. data/lib/middleman-core/templates/mobile/source/crossdomain.xml +25 -0
  313. data/lib/middleman-core/templates/mobile/source/css/style.css +315 -0
  314. data/lib/middleman-core/templates/mobile/source/humans.txt +43 -0
  315. data/lib/middleman-core/templates/mobile/source/img/h/apple-touch-icon.png +0 -0
  316. data/lib/middleman-core/templates/mobile/source/img/h/splash.png +0 -0
  317. data/lib/middleman-core/templates/mobile/source/img/l/apple-touch-icon-precomposed.png +0 -0
  318. data/lib/middleman-core/templates/mobile/source/img/l/apple-touch-icon.png +0 -0
  319. data/lib/middleman-core/templates/mobile/source/img/l/splash.png +0 -0
  320. data/lib/middleman-core/templates/mobile/source/img/m/apple-touch-icon.png +0 -0
  321. data/lib/middleman-core/templates/mobile/source/index.html +92 -0
  322. data/lib/middleman-core/templates/mobile/source/js/libs/modernizr-custom.js +14 -0
  323. data/lib/middleman-core/templates/mobile/source/js/libs/respond.min.js +7 -0
  324. data/lib/middleman-core/templates/mobile/source/js/mylibs/helper.js +171 -0
  325. data/lib/middleman-core/templates/mobile/source/js/plugins.js +20 -0
  326. data/lib/middleman-core/templates/mobile/source/js/script.js +0 -0
  327. data/lib/middleman-core/templates/mobile/source/robots.txt +4 -0
  328. data/lib/middleman-core/templates/mobile/source/sitemap.xml +9 -0
  329. data/lib/middleman-core/templates/mobile/source/test/index.html +31 -0
  330. data/lib/middleman-core/templates/mobile/source/test/qunit/qunit.css +148 -0
  331. data/lib/middleman-core/templates/mobile/source/test/qunit/qunit.js +1265 -0
  332. data/lib/middleman-core/templates/mobile/source/test/tests.js +21 -0
  333. data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/Readme.PDF +0 -0
  334. data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx1.snippet +31 -0
  335. data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx2.snippet +2 -0
  336. data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/aspx/ga.aspx +195 -0
  337. data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/aspx/sample.aspx +44 -0
  338. data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/jsp/ga.jsp +225 -0
  339. data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp1.snippet +35 -0
  340. data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp2.snippet +2 -0
  341. data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/jsp/sample.jsp +51 -0
  342. data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/php/ga.php +176 -0
  343. data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/php/php1.snippet +30 -0
  344. data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/php/php2.snippet +4 -0
  345. data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/php/sample.php +44 -0
  346. data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/pl/ga.pl +195 -0
  347. data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/pl/perl1.snippet +27 -0
  348. data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/pl/perl2.snippet +1 -0
  349. data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/pl/sample.pl +38 -0
  350. data/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/COPYING +202 -0
  351. data/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/bookmark_bubble.js +559 -0
  352. data/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/example/example.html +43 -0
  353. data/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/example/example.js +57 -0
  354. data/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/images/arrow.png +0 -0
  355. data/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/images/close.png +0 -0
  356. data/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/images/generate_base64_images +33 -0
  357. data/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/images/icon_calendar.png +0 -0
  358. data/lib/middleman-core/templates/mobile/source/tools/wspl/README +27 -0
  359. data/lib/middleman-core/templates/mobile/source/tools/wspl/databasefactory.js +45 -0
  360. data/lib/middleman-core/templates/mobile/source/tools/wspl/dbworker.js +324 -0
  361. data/lib/middleman-core/templates/mobile/source/tools/wspl/dbworker_test.html +393 -0
  362. data/lib/middleman-core/templates/mobile/source/tools/wspl/dbworkerstarter.js +32 -0
  363. data/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapper_gears.js +595 -0
  364. data/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapper_gears_test.html +404 -0
  365. data/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapper_html5.js +203 -0
  366. data/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapper_html5_test.html +468 -0
  367. data/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapperapi.js +202 -0
  368. data/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapperapi_test.html +51 -0
  369. data/lib/middleman-core/templates/mobile/source/tools/wspl/gears_resultset.js +71 -0
  370. data/lib/middleman-core/templates/mobile/source/tools/wspl/gears_resultset_test.html +86 -0
  371. data/lib/middleman-core/templates/mobile/source/tools/wspl/gears_transaction.js +196 -0
  372. data/lib/middleman-core/templates/mobile/source/tools/wspl/gears_transaction_test.html +221 -0
  373. data/lib/middleman-core/templates/mobile/source/tools/wspl/gearsutils.js +94 -0
  374. data/lib/middleman-core/templates/mobile/source/tools/wspl/gearsutils_test.html +84 -0
  375. data/lib/middleman-core/templates/mobile/source/tools/wspl/global_functions.js +72 -0
  376. data/lib/middleman-core/templates/mobile/source/tools/wspl/simplenotes/index.html +347 -0
  377. data/lib/middleman-core/templates/mobile/source/tools/wspl/simplenotes/simplenotes.js +503 -0
  378. data/lib/middleman-core/templates/mobile/source/tools/wspl/simplenotes/styles.css +66 -0
  379. data/lib/middleman-core/templates/mobile/source/tools/wspl/simplenotes/template.js +75 -0
  380. data/lib/middleman-core/templates/mobile.rb +25 -0
  381. data/lib/middleman-core/templates/shared/Gemfile.tt +3 -0
  382. data/lib/middleman-core/templates/shared/config.ru +4 -0
  383. data/lib/middleman-core/templates/shared/config.tt +92 -0
  384. data/lib/middleman-core/templates/shared/gitignore +14 -0
  385. data/lib/middleman-core/templates.rb +85 -0
  386. data/lib/middleman-core/util.rb +174 -0
  387. data/lib/middleman-core/vendor/hooks-0.2.0/CHANGES.textile +9 -0
  388. data/lib/middleman-core/vendor/hooks-0.2.0/Gemfile +3 -0
  389. data/lib/middleman-core/vendor/hooks-0.2.0/README.rdoc +107 -0
  390. data/lib/middleman-core/vendor/hooks-0.2.0/Rakefile +12 -0
  391. data/lib/middleman-core/vendor/hooks-0.2.0/hooks.gemspec +22 -0
  392. data/lib/middleman-core/vendor/hooks-0.2.0/lib/hooks/inheritable_attribute.rb +33 -0
  393. data/lib/middleman-core/vendor/hooks-0.2.0/lib/hooks.rb +109 -0
  394. data/lib/middleman-core/vendor/hooks-0.2.0/test/hooks_test.rb +141 -0
  395. data/lib/middleman-core/vendor/hooks-0.2.0/test/inheritable_attribute_test.rb +55 -0
  396. data/lib/middleman-core/vendor/hooks-0.2.0/test/test_helper.rb +10 -0
  397. data/lib/middleman-core/version.rb +5 -0
  398. data/lib/middleman-core.rb +16 -0
  399. data/middleman-core-x86-mingw32.gemspec +38 -0
  400. data/middleman-core.gemspec +39 -0
  401. metadata +806 -0
@@ -0,0 +1,468 @@
1
+ <!DOCTYPE html>
2
+ <!--
3
+ Copyright 2009 Google Inc.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ -->
17
+
18
+ <html>
19
+ <head>
20
+ <title>Database wrapper tests</title>
21
+ <script type="text/javascript" src="../jsunit/app/jsUnitCore.js"></script>
22
+ <script type="text/javascript" src="jsmock.js"></script>
23
+ <script type="text/javascript" src="global_functions.js"></script>
24
+ <script type="text/javascript" src="dbwrapperapi.js"></script>
25
+ <script type="text/javascript" src="dbwrapper_html5.js"></script>
26
+ </head>
27
+ <body>
28
+ <script type='text/javascript'>
29
+
30
+ var mockControl;
31
+ var html5Tx;
32
+ var callbackMock;
33
+ var html5Window;
34
+ var html5Db;
35
+ var populateMock;
36
+
37
+ function setUp() {
38
+ mockControl = new MockControl();
39
+ html5Tx = mockControl.createMock({executeSql: function(){}});
40
+ callbackMock = mockControl.createMock({onSuccess: function(){},
41
+ onFailure: function(){}});
42
+ html5Window = mockControl.createMock({openDatabase: function(){}});
43
+ html5Db = mockControl.createMock({transaction: function(){}});
44
+ populateMock = mockControl.createMock({populate: function(){}});
45
+
46
+ dbTx = mockControl.createMock({execute: function(){}, executeAll:
47
+ function(){}});
48
+ dbRows = mockControl.createMock({item: function(){}});
49
+ }
50
+
51
+ function testConstructTransaction() {
52
+ var trans = new google.wspl.html5.Transaction('foo');
53
+ assertEquals('transaction instance not set correctly', 'foo', trans.tx_);
54
+ }
55
+
56
+ function testTransactionExecuteAll() {
57
+ var trans = new google.wspl.html5.Transaction(html5Tx);
58
+
59
+ try {
60
+ trans.executeAll([], callbackMock);
61
+ fail('Should never get here');
62
+ } catch(e) {
63
+ assertEquals(
64
+ 'did not exception fault on empty statement list',
65
+ 'Error: Possibly silly attempt to execute empty statement list.',
66
+ e.toString());
67
+ }
68
+ mockControl.verify();
69
+ }
70
+
71
+ /*
72
+ The sequence of digits at the end of the test names indicate as boolean
73
+ variables the success or failure of each statement.
74
+ */
75
+ function testTransactionExecuteAll_1() {
76
+ var stat1 = new google.wspl.Statement('stat1');
77
+
78
+ var trans = new google.wspl.html5.Transaction(html5Tx);
79
+
80
+ var successCallback = null;
81
+ var failureCallback = null;
82
+ html5Tx.expects().executeSql('stat1', TypeOf.isA(Array),
83
+ TypeOf.isA(Function), TypeOf.isA(Function)).andStub(function() {
84
+ successCallback = arguments[2];
85
+ });
86
+
87
+ callbackMock.expects().onSuccess(trans,
88
+ TypeOf.isA(google.wspl.html5.ResultSet)).andStub(function() {
89
+ assertEquals('result not returned', 'resultset', arguments[1].result_)});
90
+
91
+ trans.executeAll([stat1], callbackMock);
92
+ successCallback(html5Tx, 'resultset');
93
+ mockControl.verify();
94
+ }
95
+
96
+ function testTransactionExecuteAll_11() {
97
+ var stat1 = new google.wspl.Statement('stat1');
98
+ var stat2 = new google.wspl.Statement('stat2', [1]);
99
+
100
+ var trans = new google.wspl.html5.Transaction(html5Tx);
101
+
102
+ var successCallback1 = null;
103
+ var successCallback2 = null;
104
+ var failureCallback = null;
105
+
106
+ html5Tx.expects().executeSql('stat1', TypeOf.isA(Array),
107
+ TypeOf.isA(Function), TypeOf.isA(Function)).andStub(function() {
108
+ successCallback1 = arguments[2];
109
+ });
110
+
111
+ html5Tx.expects().executeSql('stat2', TypeOf.isA(Array),
112
+ TypeOf.isA(Function), TypeOf.isA(Function)).andStub(function() {
113
+ successCallback2 = arguments[2];
114
+ var params = arguments[1];
115
+ assertEquals('incorrect params to sql', 1, params[0]);
116
+ });
117
+
118
+ callbackMock.expects().onSuccess(trans,
119
+ TypeOf.isA(google.wspl.html5.ResultSet)).andStub(function() {
120
+ assertEquals('result not returned', 'resultset1', arguments[1].result_)});
121
+
122
+ callbackMock.expects().onSuccess(trans,
123
+ TypeOf.isA(google.wspl.html5.ResultSet)).andStub(function() {
124
+ assertEquals('result not returned', 'resultset2', arguments[1].result_)});
125
+
126
+ trans.executeAll([stat1, stat2], callbackMock);
127
+ successCallback1(html5Tx, 'resultset1');
128
+ successCallback2(html5Tx, 'resultset2');
129
+ mockControl.verify();
130
+ }
131
+
132
+ function testTransactionExecuteAll_111() {
133
+ var stat1 = new google.wspl.Statement('stat1');
134
+ var stat2 = new google.wspl.Statement('stat2', [1]);
135
+ var stat3 = new google.wspl.Statement('stat3', [2, 3]);
136
+
137
+ var trans = new google.wspl.html5.Transaction(html5Tx);
138
+
139
+ var successCallback1 = null;
140
+ var successCallback2 = null;
141
+ var successCallback3 = null;
142
+ var failureCallback = null;
143
+
144
+ html5Tx.expects().executeSql('stat1', TypeOf.isA(Array),
145
+ TypeOf.isA(Function), TypeOf.isA(Function)).andStub(function() {
146
+ successCallback1 = arguments[2];
147
+ });
148
+
149
+ html5Tx.expects().executeSql('stat2', TypeOf.isA(Array),
150
+ TypeOf.isA(Function), TypeOf.isA(Function)).andStub(function() {
151
+ successCallback2 = arguments[2];
152
+ var params = arguments[1];
153
+ assertEquals('incorrect params to sql', 1, params[0]);
154
+ });
155
+
156
+ html5Tx.expects().executeSql('stat3', TypeOf.isA(Array),
157
+ TypeOf.isA(Function), TypeOf.isA(Function)).andStub(function() {
158
+ successCallback3 = arguments[2];
159
+ var params = arguments[1];
160
+ assertEquals('incorrect params to sql', 2, params[0]);
161
+ assertEquals('incorrect params to sql', 3, params[1]);
162
+ });
163
+
164
+ callbackMock.expects().onSuccess(trans,
165
+ TypeOf.isA(google.wspl.html5.ResultSet)).andStub(function() {
166
+ assertEquals('result not returned', 'resultset1', arguments[1].result_)});
167
+
168
+ callbackMock.expects().onSuccess(trans,
169
+ TypeOf.isA(google.wspl.html5.ResultSet)).andStub(function() {
170
+ assertEquals('result not returned', 'resultset2', arguments[1].result_)});
171
+
172
+ callbackMock.expects().onSuccess(trans,
173
+ TypeOf.isA(google.wspl.html5.ResultSet)).andStub(function() {
174
+ assertEquals('result not returned', 'resultset3', arguments[1].result_)});
175
+
176
+ trans.executeAll([stat1, stat2, stat3], callbackMock);
177
+ successCallback1(html5Tx, 'resultset1');
178
+ successCallback2(html5Tx, 'resultset2');
179
+ successCallback3(html5Tx, 'resultset3');
180
+ mockControl.verify();
181
+ }
182
+
183
+ function testTransactionExecuteAll_noCallback_111() {
184
+ var stat1 = new google.wspl.Statement('stat1');
185
+ var stat2 = new google.wspl.Statement('stat2', [1]);
186
+ var stat3 = new google.wspl.Statement('stat3', [2, 3]);
187
+
188
+ var trans = new google.wspl.html5.Transaction(html5Tx);
189
+
190
+ var successCallback1 = null;
191
+ var successCallback2 = null;
192
+ var successCallback3 = null;
193
+ var failureCallback = null;
194
+
195
+ html5Tx.expects().executeSql('stat1', TypeOf.isA(Array),
196
+ TypeOf.isA(Function), TypeOf.isA(Function)).andStub(function() {
197
+ successCallback1 = arguments[2];
198
+ });
199
+
200
+ html5Tx.expects().executeSql('stat2', TypeOf.isA(Array),
201
+ TypeOf.isA(Function), TypeOf.isA(Function)).andStub(
202
+ function() { successCallback2 = arguments[2];
203
+ var params = arguments[1];
204
+ assertEquals('incorrect params to sql', 1, params[0]);
205
+ });
206
+
207
+ html5Tx.expects().executeSql('stat3', TypeOf.isA(Array),
208
+ TypeOf.isA(Function), TypeOf.isA(Function)).andStub(
209
+ function() { successCallback3 = arguments[2];
210
+ var params = arguments[1];
211
+ assertEquals('incorrect params to sql', 2, params[0]);
212
+ assertEquals('incorrect params to sql', 3, params[1]);
213
+ });
214
+
215
+ trans.executeAll([stat1, stat2, stat3]);
216
+ successCallback1(html5Tx, 'resultset1');
217
+ successCallback2(html5Tx, 'resultset2');
218
+ successCallback3(html5Tx, 'resultset3');
219
+ mockControl.verify();
220
+ }
221
+
222
+ function testTransactionExecuteAll_110() {
223
+ var stat1 = new google.wspl.Statement('stat1');
224
+ var stat2 = new google.wspl.Statement('stat2', [1]);
225
+ var stat3 = new google.wspl.Statement('stat3', [2, 3]);
226
+
227
+ var trans = new google.wspl.html5.Transaction(html5Tx);
228
+
229
+ var successCallback1 = null;
230
+ var successCallback2 = null;
231
+ var successCallback3 = null;
232
+ var failureCallback3 = null;
233
+
234
+ html5Tx.expects().executeSql('stat1', TypeOf.isA(Array),
235
+ TypeOf.isA(Function), TypeOf.isA(Function)).andStub(function() {
236
+ successCallback1 = arguments[2];
237
+ });
238
+
239
+ html5Tx.expects().executeSql('stat2', TypeOf.isA(Array),
240
+ TypeOf.isA(Function), TypeOf.isA(Function)).andStub(function() {
241
+ successCallback2 = arguments[2];
242
+ var params = arguments[1];
243
+ assertEquals('incorrect params to sql', 1, params[0]);
244
+ });
245
+
246
+ html5Tx.expects().executeSql('stat3', TypeOf.isA(Array),
247
+ TypeOf.isA(Function), TypeOf.isA(Function)).andStub(function() {
248
+ successCallback3 = arguments[2];
249
+ failureCallback3 = arguments[3];
250
+ var params = arguments[1];
251
+ assertEquals('incorrect params to sql', 2, params[0]);
252
+ assertEquals('incorrect params to sql', 3, params[1]);
253
+ });
254
+
255
+ callbackMock.expects().onSuccess(trans,
256
+ TypeOf.isA(google.wspl.html5.ResultSet)).andStub(function() {
257
+ assertEquals('result not returned', 'resultset1', arguments[1].result_)});
258
+
259
+ callbackMock.expects().onSuccess(trans,
260
+ TypeOf.isA(google.wspl.html5.ResultSet)).andStub(function() {
261
+ assertEquals('result not returned', 'resultset2', arguments[1].result_)});
262
+
263
+ callbackMock.expects().onFailure('error3');
264
+
265
+ trans.executeAll([stat1, stat2, stat3], callbackMock);
266
+ successCallback1(html5Tx, 'resultset1');
267
+ successCallback2(html5Tx, 'resultset2');
268
+ assertTrue('failure case callback not terminating transaction',
269
+ failureCallback3(html5Tx, 'error3'));
270
+ mockControl.verify();
271
+ }
272
+
273
+ function testTransactionExecute_nocallback() {
274
+ var stat1 = new google.wspl.Statement('stat1');
275
+
276
+ var trans = new google.wspl.html5.Transaction(html5Tx);
277
+
278
+ var successCallback = null;
279
+ var failureCallback = null;
280
+ html5Tx.expects().executeSql('stat1', TypeOf.isA(Array),
281
+ TypeOf.isA(Function), TypeOf.isA(Function)).andStub(function() {
282
+ successCallback = arguments[2];
283
+ });
284
+
285
+ trans.execute(stat1);
286
+ successCallback(html5Tx, 'resultset');
287
+ mockControl.verify();
288
+ }
289
+
290
+ function buildDatabase() {
291
+ html5Window.expects().openDatabase('name', '', 'name',
292
+ google.wspl.LARGEST_SUPPORTED_DATABASE).
293
+ andReturn(html5Db);
294
+ return new google.wspl.html5.Database('name', html5Window);
295
+ }
296
+
297
+ function testConstructDatabase() {
298
+ var db = buildDatabase();
299
+ mockControl.verify();
300
+ assertEquals('did not set db_ correctly', db.db_, html5Db);
301
+ }
302
+
303
+ function testConstructDatabase_null() {
304
+ html5Window.expects().openDatabase('name', '', 'name',
305
+ google.wspl.LARGEST_SUPPORTED_DATABASE).
306
+ andReturn(null);
307
+ try {
308
+ var db = google.wspl.html5.Database('name', html5Window);
309
+ fail('Should never get here');
310
+ } catch (e) {
311
+ if (e.isJsUnitException) {
312
+ throw e;
313
+ }
314
+ }
315
+ mockControl.verify();
316
+ }
317
+
318
+ function testConstructDatabase_undefined() {
319
+ html5Window.expects().openDatabase('name', '', 'name',
320
+ google.wspl.LARGEST_SUPPORTED_DATABASE).
321
+ andReturn(undefined);
322
+ try {
323
+ var db = google.wspl.html5.Database('name', html5Window);
324
+ fail('Should never get here');
325
+ } catch (e) {
326
+ if (e.isJsUnitException) {
327
+ throw e;
328
+ }
329
+ }
330
+ mockControl.verify();
331
+ }
332
+
333
+ function createTransactionCore() {
334
+ var db = buildDatabase();
335
+ var fun1 = null;
336
+ var failure = null;
337
+ var success = null;
338
+ html5Db.expects().transaction(TypeOf.isA(Function), TypeOf.isA(Function),
339
+ TypeOf.isA(Function)).andStub(function() {
340
+ fun1 = arguments[0];
341
+ failure = arguments[1];
342
+ success = arguments[2];
343
+ });
344
+
345
+ var tx = null;
346
+ var populateMock = function(txa) {
347
+ tx = txa;
348
+ };
349
+
350
+ db.createTransaction(populateMock, callbackMock);
351
+ fun1('transactionTest');
352
+
353
+ assertEquals('transaction not saved', 'transactionTest', tx.tx_);
354
+ assertEquals('did not set db_ correctly', db.db_, html5Db);
355
+
356
+ return {failure: failure, success: success};
357
+ }
358
+
359
+ function testCreateTransaction_success() {
360
+ cbs = createTransactionCore();
361
+ callbackMock.expects().onSuccess();
362
+ cbs.success('success');
363
+ mockControl.verify();
364
+ }
365
+
366
+ function testCreateTransaction_failure() {
367
+ cbs = createTransactionCore();
368
+ callbackMock.expects().onFailure('error');
369
+ cbs.failure('error');
370
+ mockControl.verify();
371
+ }
372
+
373
+ function testCreateTransaction_onlyPopulate() {
374
+ cbs = createTransactionCore();
375
+ mockControl.verify();
376
+ }
377
+
378
+ function testDatabaseExecute_nocallback() {
379
+ var db = buildDatabase();
380
+
381
+ dbTx.expects().execute('statementText', null);
382
+ db.execute('statementText');
383
+ }
384
+
385
+ function testDatabaseExecute_nocallback() {
386
+ var db = buildDatabase();
387
+
388
+ dbTx.expects().execute('statementText', null);
389
+ db.execute('statementText');
390
+ }
391
+
392
+ function testDatabaseExecuteAll() {
393
+ var db = buildDatabase();
394
+ dbTx.expects().executeAll(TypeOf.isA(Array));
395
+ }
396
+
397
+ function testResultSetNext() {
398
+ var res = {rows: {length: 4}};
399
+ var result = new google.wspl.html5.ResultSet(res);
400
+
401
+ for (var i = 0; i < 4; i++) {
402
+ assertTrue('expected valid row', result.isValidRow());
403
+ result.next();
404
+ }
405
+ assertFalse('expected invalid row', result.isValidRow());
406
+ }
407
+
408
+ function testResultSetIsValidRow() {
409
+ var res = {rows: {length: 0}};
410
+ var result = new google.wspl.html5.ResultSet(res);
411
+
412
+ assertFalse('expected invalid row', result.isValidRow());
413
+ res.rows.length = 1;
414
+ assertTrue('expected valid row', result.isValidRow());
415
+ result.next();
416
+ assertFalse('expected invalid row', result.isValidRow());
417
+ }
418
+
419
+ function testResultSetGetRow() {
420
+ var res = {rows: {
421
+ length: 3,
422
+ item: function(index) {
423
+ assertEquals('expected index of 1', 1, index);
424
+ return {h0: 'value0', h1: 'value1', h2: 'value2'};
425
+ }
426
+ }};
427
+
428
+ var result = new google.wspl.html5.ResultSet(res);
429
+ result.next();
430
+ var row = result.getRow();
431
+ assertEquals('first field is not valid', 'value0', row.h0);
432
+ assertEquals('first field is not valid', 'value1', row.h1);
433
+ assertEquals('first field is not valid', 'value2', row.h2);
434
+ }
435
+
436
+ function testHasInflightTransactions() {
437
+ var fakeTime = 1000;
438
+ var db = buildDatabase();
439
+ var dummyPopulate = function() {};
440
+ db.getCurrentTime = function() {return fakeTime;};
441
+
442
+ // Create a transaction, make sure it's kept track of.
443
+ var transId = db.sequenceNum_;
444
+ db.createTransaction(dummyPopulate);
445
+ assertEquals('There should be an inflight request.',
446
+ fakeTime, db.inflightTransactions_[transId]);
447
+
448
+ // Haven't advanced time, so hasInflightTransactions should return false.
449
+ assertFalse('Expected hasInflightTransactions=false.',
450
+ db.hasInflightTransactions(100));
451
+
452
+ // Advance time, now hasInflightTransactions should return true.
453
+ fakeTime += 10000;
454
+ var faqs = db.hasInflightTransactions(100);
455
+ assertTrue('Expected hasInflightTransactions=true.',
456
+ db.hasInflightTransactions(100));
457
+
458
+ // Now now have the transaction completed, hasInflightTransactions
459
+ // should return false.
460
+ delete db.inflightTransactions_[transId];
461
+ assertFalse('Expected hasInflightTransactions=false.',
462
+ db.hasInflightTransactions(100));
463
+
464
+ };
465
+
466
+ </script>
467
+ </body>
468
+ </html>
@@ -0,0 +1,202 @@
1
+ /*
2
+ Copyright 2009 Google Inc.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ /**
18
+ * @fileoverview Generic Database API.
19
+ *
20
+ * A small set of classes to define how we interact with databases that can
21
+ * easily be implemented on top of HTML5 and Gears. The classes in this file
22
+ * should be extended to provide the missing method implementations and more
23
+ * sophisticated constructors where applicable.
24
+ *
25
+ */
26
+
27
+ /**
28
+ * Constructs a Statement object. A Statement is an SQL statement paired
29
+ * with the parameters needed to execute it.
30
+ *
31
+ * @constructor
32
+ * @param {!string} sql The SQL statement.
33
+ * @param {Array.<Object>?} opt_params The parameters for the SQL statement.
34
+ */
35
+ google.wspl.Statement = function(sql, opt_params) {
36
+
37
+ /**
38
+ * The SQL statement with '?' in place of parameters.
39
+ * @type {string}
40
+ */
41
+ this.sql = sql;
42
+
43
+ /**
44
+ * The parameters to use with the SQL statement.
45
+ * @type {!Array}
46
+ */
47
+ this.params = opt_params || [];
48
+ };
49
+
50
+ /**
51
+ * Returns a new statement object from the given statement with the parameters
52
+ * set as specified.
53
+ * @param {Array.<Object>} params The array of values for ? placeholders.
54
+ * @return {!google.wspl.Statement} The created Statement.
55
+ */
56
+ google.wspl.Statement.prototype.createStatement = function(params) {
57
+ return new google.wspl.Statement(this.sql, params);
58
+ };
59
+
60
+ /**
61
+ * Constructs a Transaction object. Transaction objects
62
+ * group together a series of statements into a single atomic
63
+ * action on the database.
64
+ *
65
+ * @constructor
66
+ */
67
+ google.wspl.Transaction = function() {
68
+ };
69
+
70
+ /**
71
+ * Takes a statement and an optional callback object and
72
+ * runs the statement on the database. The callback can be used to
73
+ * add more statements to the same transaction, or execute can be
74
+ * called repeatedly and the transactions will later execute in the
75
+ * order provided.
76
+ *
77
+ * @param {google.wspl.Statement} statement The statement to execute.
78
+ * @param {Object} opt_callback An object containing onSuccess and onFailure
79
+ * handlers.
80
+ */
81
+ google.wspl.Transaction.prototype.execute = function(statement,
82
+ opt_callback) {
83
+ this.executeAll([statement], opt_callback);
84
+ };
85
+
86
+ /**
87
+ * Runs an array of statements in a single database transaction.
88
+ * Invokes the onSuccess callback once for each successfully executed
89
+ * statement and once for the first failed statement. The callback can be
90
+ * used to add more statements to the same transaction, or executeAll can
91
+ * be called repeatedly and each block of statements given will execute
92
+ * in the same order as the sequence of calls to executeAll.
93
+ *
94
+ * @param {Array.<google.wspl.Statement>} statements The statements to
95
+ * execute.
96
+ * @param {Object?} opt_callback An object containing onSuccess and onFailure
97
+ * handlers.
98
+ */
99
+ google.wspl.Transaction.prototype.executeAll = function(statements,
100
+ opt_callback) {
101
+ throw Error('executeAll not implemented');
102
+ };
103
+
104
+ /**
105
+ * Constructs a Database object. Database objects are handles that allow
106
+ * access to a database (and create the corresponding database if it doesn't
107
+ * already exist). To open the database, pass the name of the needed
108
+ * database to the constructor, and then execute transactions on it using
109
+ * the execute method.
110
+ *
111
+ * @constructor
112
+ */
113
+ google.wspl.Database = function() {
114
+ };
115
+
116
+ /**
117
+ * Creates a transaction object that can execute a series of SQL statements
118
+ * atomically.
119
+ *
120
+ * @param {Function} populate A callback to run execute calls on the
121
+ * transaction.
122
+ * @param {Object?} opt_callback An optional success/failure callback that is
123
+ * called when the entire transaction is finished executing.
124
+ */
125
+ google.wspl.Database.prototype.createTransaction = function(populate,
126
+ opt_callback) {
127
+ throw Error('createTransaction not implemented');
128
+ };
129
+
130
+ /**
131
+ * Executes an array of statements on the database, invoking the optional
132
+ * callback after statement execution and the optional transactionCallback upon
133
+ * completion of the transaction.
134
+ *
135
+ * @param {google.wspl.Statement} statement the statement to execute
136
+ * @param {Object?} opt_callback object that defines onSuccess and onFailure
137
+ * @param {Object?} opt_transactionCallback object that defines onSuccess and
138
+ * onFailure
139
+ */
140
+ google.wspl.Database.prototype.execute = function(statement,
141
+ opt_callback,
142
+ opt_transactionCallback) {
143
+ this.createTransaction(function(tx) {
144
+ tx.execute(statement, opt_callback);
145
+ }, opt_transactionCallback);
146
+ };
147
+
148
+ /**
149
+ * Executes an array of statements on the database, invoking the optional
150
+ * callback for each statement in the transaction. In the case of a statement
151
+ * failure, only the first failed statement will be reported and the transaction
152
+ * will be rolled back. This method invokes the optional transactionCallback
153
+ * upon completion of the transaction.
154
+ *
155
+ * @param {Array.<google.wspl.Statement>} statements the statements to execute
156
+ * @param {Object?} opt_callback object that defines onSuccess and onFailure
157
+ * @param {Object?} opt_transactionCallback object that defines onSuccess and
158
+ * onFailure
159
+ */
160
+ google.wspl.Database.prototype.executeAll = function(statements,
161
+ opt_callback,
162
+ opt_transactionCallback) {
163
+ this.createTransaction(function(tx) {
164
+ tx.executeAll(statements, opt_callback);
165
+ }, opt_transactionCallback);
166
+ };
167
+
168
+ /**
169
+ * An immutable set of results that is returned from a single successful query
170
+ * on the database.
171
+ *
172
+ * @constructor
173
+ */
174
+ google.wspl.ResultSet = function() {
175
+ };
176
+
177
+ /**
178
+ * Returns true if next() will advance to a valid row in the result set.
179
+ *
180
+ * @return {boolean} if next() will advance to a valid row in the result set
181
+ */
182
+ google.wspl.ResultSet.prototype.isValidRow = function() {
183
+ throw Error('isValidRow not implemented');
184
+ };
185
+
186
+ /**
187
+ * Advances to the next row in the results.
188
+ */
189
+ google.wspl.ResultSet.prototype.next = function() {
190
+ throw Error('next not implemented');
191
+ };
192
+
193
+ /**
194
+ * Returns the current row as an object with a property for each field returned
195
+ * by the database. The property will have the name of the column and the value
196
+ * of the cell.
197
+ *
198
+ * @return {Object} The current row
199
+ */
200
+ google.wspl.ResultSet.prototype.getRow = function() {
201
+ throw Error('getRow not implemented');
202
+ };