rhoconnect 3.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (361) hide show
  1. data/CHANGELOG +208 -0
  2. data/CREDITS +38 -0
  3. data/Gemfile +18 -0
  4. data/Gemfile.lock +97 -0
  5. data/LICENSE +75 -0
  6. data/README.md +10 -0
  7. data/Rakefile +82 -0
  8. data/bench/bench +7 -0
  9. data/bench/bench_runner.rb +112 -0
  10. data/bench/benchapp/Gemfile +21 -0
  11. data/bench/benchapp/Gemfile.lock +76 -0
  12. data/bench/benchapp/Rakefile +22 -0
  13. data/bench/benchapp/application.rb +39 -0
  14. data/bench/benchapp/config.ru +36 -0
  15. data/bench/benchapp/settings/license.key +1 -0
  16. data/bench/benchapp/settings/settings.yml +20 -0
  17. data/bench/benchapp/sources/mock_adapter.rb +55 -0
  18. data/bench/benchapp/sources/queue_mock_adapter.rb +2 -0
  19. data/bench/benchapp/spec/sources/mock_adapter_spec.rb +25 -0
  20. data/bench/benchapp/spec/sources/queue_mock_adapter_spec.rb +25 -0
  21. data/bench/benchapp/spec/spec_helper.rb +42 -0
  22. data/bench/blobapp/Gemfile +31 -0
  23. data/bench/blobapp/Gemfile.lock +103 -0
  24. data/bench/blobapp/Rakefile +25 -0
  25. data/bench/blobapp/application.rb +44 -0
  26. data/bench/blobapp/config.ru +36 -0
  27. data/bench/blobapp/settings/license.key +1 -0
  28. data/bench/blobapp/settings/settings.yml +16 -0
  29. data/bench/blobapp/sources/blob_adapter.rb +71 -0
  30. data/bench/blobapp/spec/sources/blob_adapter_spec.rb +25 -0
  31. data/bench/blobapp/spec/spec_helper.rb +42 -0
  32. data/bench/lib/bench/cli.rb +16 -0
  33. data/bench/lib/bench/logging.rb +13 -0
  34. data/bench/lib/bench/mock_client.rb +41 -0
  35. data/bench/lib/bench/result.rb +50 -0
  36. data/bench/lib/bench/runner.rb +107 -0
  37. data/bench/lib/bench/session.rb +67 -0
  38. data/bench/lib/bench/statistics.rb +56 -0
  39. data/bench/lib/bench/test_data.rb +98 -0
  40. data/bench/lib/bench/timer.rb +10 -0
  41. data/bench/lib/bench/utils.rb +49 -0
  42. data/bench/lib/bench.rb +129 -0
  43. data/bench/lib/testdata/100-data.txt +148 -0
  44. data/bench/lib/testdata/5-data.txt +9 -0
  45. data/bench/lib/testdata/images/icon.ico +0 -0
  46. data/bench/lib/testdata/images/icon.png +0 -0
  47. data/bench/lib/testdata/images/loading-Landscape.png +0 -0
  48. data/bench/lib/testdata/images/loading-LandscapeLeft.png +0 -0
  49. data/bench/lib/testdata/images/loading-LandscapeRight.png +0 -0
  50. data/bench/lib/testdata/images/loading-Portrait.png +0 -0
  51. data/bench/lib/testdata/images/loading-PortraitUpsideDown.png +0 -0
  52. data/bench/lib/testdata/images/loading.png +0 -0
  53. data/bench/lib/testdata/images/loading@2x.png +0 -0
  54. data/bench/run_bench.sh +42 -0
  55. data/bench/run_blob_script.sh +3 -0
  56. data/bench/run_cud_script.sh +3 -0
  57. data/bench/run_query_md_script.sh +3 -0
  58. data/bench/run_query_only_script.sh +3 -0
  59. data/bench/run_query_script.sh +3 -0
  60. data/bench/scripts/blob_cud_script.rb +98 -0
  61. data/bench/scripts/cud_script.rb +92 -0
  62. data/bench/scripts/helpers.rb +101 -0
  63. data/bench/scripts/query_md_script.rb +45 -0
  64. data/bench/scripts/query_only_script.rb +51 -0
  65. data/bench/scripts/query_script.rb +45 -0
  66. data/bench/spec/bench_spec_helper.rb +33 -0
  67. data/bench/spec/logging_spec.rb +15 -0
  68. data/bench/spec/mock_adapter_spec.rb +61 -0
  69. data/bench/spec/mock_client_spec.rb +65 -0
  70. data/bench/spec/result_spec.rb +61 -0
  71. data/bench/spec/utils_spec.rb +36 -0
  72. data/bin/rhoconnect +34 -0
  73. data/bin/rhoconnect-setup +84 -0
  74. data/doc/async-jobs.txt +69 -0
  75. data/doc/authentication.txt +76 -0
  76. data/doc/benchmarks.txt +168 -0
  77. data/doc/blob-sync.txt +130 -0
  78. data/doc/bulk-sync.txt +102 -0
  79. data/doc/client.txt +432 -0
  80. data/doc/command-line.txt +210 -0
  81. data/doc/contributing.txt +60 -0
  82. data/doc/deploying.txt +82 -0
  83. data/doc/install.txt +28 -0
  84. data/doc/introduction.txt +20 -0
  85. data/doc/licensing.txt +18 -0
  86. data/doc/metadata.txt +458 -0
  87. data/doc/migration.txt +182 -0
  88. data/doc/public/css/print.css +29 -0
  89. data/doc/public/css/screen.css +257 -0
  90. data/doc/public/css/style.css +20 -0
  91. data/doc/push.txt +135 -0
  92. data/doc/release.txt +41 -0
  93. data/doc/rest-api.txt +367 -0
  94. data/doc/source-adapters.txt +325 -0
  95. data/doc/stats-middleware.txt +69 -0
  96. data/doc/testing.txt +222 -0
  97. data/doc/tutorial.txt +315 -0
  98. data/doc/web-console.txt +35 -0
  99. data/examples/simple/Rakefile +14 -0
  100. data/examples/simple/application.rb +27 -0
  101. data/examples/simple/config.ru +49 -0
  102. data/examples/simple/settings/license.key +1 -0
  103. data/examples/simple/settings/settings.yml +23 -0
  104. data/examples/simple/sources/sample_adapter.rb +5 -0
  105. data/examples/simple/sources/simple_adapter.rb +5 -0
  106. data/generators/rhoconnect.rb +119 -0
  107. data/generators/templates/application/Gemfile +21 -0
  108. data/generators/templates/application/Rakefile +22 -0
  109. data/generators/templates/application/application.rb +39 -0
  110. data/generators/templates/application/config.ru +36 -0
  111. data/generators/templates/application/settings/license.key +1 -0
  112. data/generators/templates/application/settings/settings.yml +14 -0
  113. data/generators/templates/application/spec/spec_helper.rb +42 -0
  114. data/generators/templates/source/source_adapter.rb +47 -0
  115. data/generators/templates/source/source_spec.rb +25 -0
  116. data/install.sh +408 -0
  117. data/installer/unix-like/rho_connect_install_checkers.rb +140 -0
  118. data/installer/unix-like/rho_connect_install_constants.rb +51 -0
  119. data/installer/unix-like/rho_connect_install_debian.rb +63 -0
  120. data/installer/unix-like/rho_connect_install_dnd.rb +58 -0
  121. data/installer/unix-like/rho_connect_install_get_params.rb +30 -0
  122. data/installer/unix-like/rho_connect_install_installers.rb +142 -0
  123. data/installer/unix-like/rho_connect_install_utilities.rb +85 -0
  124. data/installer/unix-like/rho_connect_install_yum.rb +63 -0
  125. data/installer/unix-like/rhoinstaller.rb +89 -0
  126. data/installer/utils/create_texts.rb +366 -0
  127. data/installer/utils/install_test.rb +140 -0
  128. data/installer/windows/EnvVarUpdate.nsh +328 -0
  129. data/installer/windows/ServiceLib.nsh +369 -0
  130. data/installer/windows/configUi.ini +44 -0
  131. data/installer/windows/icon.ico +0 -0
  132. data/installer/windows/rhosync.nsi +418 -0
  133. data/installer/windows/uninstall.bat +7 -0
  134. data/lib/rhoconnect/api/admin/get_api_token.rb +14 -0
  135. data/lib/rhoconnect/api/admin/get_license_info.rb +8 -0
  136. data/lib/rhoconnect/api/admin/login.rb +6 -0
  137. data/lib/rhoconnect/api/admin/reset.rb +10 -0
  138. data/lib/rhoconnect/api/admin/stats.rb +21 -0
  139. data/lib/rhoconnect/api/application/bulk_data.rb +7 -0
  140. data/lib/rhoconnect/api/application/clientcreate.rb +8 -0
  141. data/lib/rhoconnect/api/application/clientlogin.rb +6 -0
  142. data/lib/rhoconnect/api/application/clientregister.rb +6 -0
  143. data/lib/rhoconnect/api/application/clientreset.rb +6 -0
  144. data/lib/rhoconnect/api/application/query.rb +7 -0
  145. data/lib/rhoconnect/api/application/queue_updates.rb +6 -0
  146. data/lib/rhoconnect/api/application/search.rb +6 -0
  147. data/lib/rhoconnect/api/client/create_client.rb +3 -0
  148. data/lib/rhoconnect/api/client/delete_client.rb +5 -0
  149. data/lib/rhoconnect/api/client/get_client_params.rb +3 -0
  150. data/lib/rhoconnect/api/client/list_client_docs.rb +12 -0
  151. data/lib/rhoconnect/api/client/list_clients.rb +3 -0
  152. data/lib/rhoconnect/api/client/ping.rb +7 -0
  153. data/lib/rhoconnect/api/source/get_adapter.rb +3 -0
  154. data/lib/rhoconnect/api/source/get_db_doc.rb +7 -0
  155. data/lib/rhoconnect/api/source/get_source_params.rb +3 -0
  156. data/lib/rhoconnect/api/source/list_source_docs.rb +10 -0
  157. data/lib/rhoconnect/api/source/list_sources.rb +15 -0
  158. data/lib/rhoconnect/api/source/push_deletes.rb +8 -0
  159. data/lib/rhoconnect/api/source/push_objects.rb +8 -0
  160. data/lib/rhoconnect/api/source/save_adapter.rb +3 -0
  161. data/lib/rhoconnect/api/source/set_db_doc.rb +8 -0
  162. data/lib/rhoconnect/api/source/set_refresh_time.rb +8 -0
  163. data/lib/rhoconnect/api/source/upload_file.rb +4 -0
  164. data/lib/rhoconnect/api/user/create_user.rb +7 -0
  165. data/lib/rhoconnect/api/user/delete_user.rb +9 -0
  166. data/lib/rhoconnect/api/user/list_users.rb +3 -0
  167. data/lib/rhoconnect/api/user/update_user.rb +4 -0
  168. data/lib/rhoconnect/api_token.rb +19 -0
  169. data/lib/rhoconnect/app.rb +76 -0
  170. data/lib/rhoconnect/bulk_data/bulk_data.rb +88 -0
  171. data/lib/rhoconnect/bulk_data/syncdb.index.schema +4 -0
  172. data/lib/rhoconnect/bulk_data/syncdb.schema +41 -0
  173. data/lib/rhoconnect/bulk_data.rb +2 -0
  174. data/lib/rhoconnect/client.rb +96 -0
  175. data/lib/rhoconnect/client_sync.rb +412 -0
  176. data/lib/rhoconnect/console/app/helpers/auth_helper.rb +22 -0
  177. data/lib/rhoconnect/console/app/helpers/extensions.rb +19 -0
  178. data/lib/rhoconnect/console/app/helpers/helpers.rb +57 -0
  179. data/lib/rhoconnect/console/app/public/ThickBox.css +649 -0
  180. data/lib/rhoconnect/console/app/public/home.css +438 -0
  181. data/lib/rhoconnect/console/app/public/images/foot_logo_rhoconnect.png +0 -0
  182. data/lib/rhoconnect/console/app/public/images/header_halo.jpg +0 -0
  183. data/lib/rhoconnect/console/app/public/images/land_separator.gif +0 -0
  184. data/lib/rhoconnect/console/app/public/images/landing_header.jpg +0 -0
  185. data/lib/rhoconnect/console/app/public/images/logo_rhoconnect.png +0 -0
  186. data/lib/rhoconnect/console/app/public/images/rhomobile_rhohub_logo.png +0 -0
  187. data/lib/rhoconnect/console/app/public/images/tabs_separator.png +0 -0
  188. data/lib/rhoconnect/console/app/public/jqplot/excanvas.min.js +35 -0
  189. data/lib/rhoconnect/console/app/public/jqplot/jqplot.barRenderer.min.js +34 -0
  190. data/lib/rhoconnect/console/app/public/jqplot/jqplot.canvasAxisLabelRenderer.js +187 -0
  191. data/lib/rhoconnect/console/app/public/jqplot/jqplot.canvasAxisTickRenderer.js +226 -0
  192. data/lib/rhoconnect/console/app/public/jqplot/jqplot.canvasTextRenderer.js +408 -0
  193. data/lib/rhoconnect/console/app/public/jqplot/jqplot.categoryAxisRenderer.min.js +34 -0
  194. data/lib/rhoconnect/console/app/public/jqplot/jqplot.cursor.js +952 -0
  195. data/lib/rhoconnect/console/app/public/jqplot/jqplot.dateAxisRenderer.js +313 -0
  196. data/lib/rhoconnect/console/app/public/jqplot/jqplot.dateAxisRenderer.min.js +34 -0
  197. data/lib/rhoconnect/console/app/public/jqplot/jqplot.pointLabels.min.js +34 -0
  198. data/lib/rhoconnect/console/app/public/jqplot/jquery-1.4.2.min.js +154 -0
  199. data/lib/rhoconnect/console/app/public/jqplot/jquery.jqplot.min.css +1 -0
  200. data/lib/rhoconnect/console/app/public/jqplot/jquery.jqplot.min.js +34 -0
  201. data/lib/rhoconnect/console/app/public/main.css +7 -0
  202. data/lib/rhoconnect/console/app/public/reset.css +76 -0
  203. data/lib/rhoconnect/console/app/public/style.css +2201 -0
  204. data/lib/rhoconnect/console/app/public/text.txt +0 -0
  205. data/lib/rhoconnect/console/app/routes/adapter.rb +28 -0
  206. data/lib/rhoconnect/console/app/routes/auth.rb +29 -0
  207. data/lib/rhoconnect/console/app/routes/client.rb +31 -0
  208. data/lib/rhoconnect/console/app/routes/docs.rb +145 -0
  209. data/lib/rhoconnect/console/app/routes/heroku.rb +19 -0
  210. data/lib/rhoconnect/console/app/routes/home.rb +63 -0
  211. data/lib/rhoconnect/console/app/routes/timing.rb +242 -0
  212. data/lib/rhoconnect/console/app/routes/user.rb +117 -0
  213. data/lib/rhoconnect/console/app/views/adapter.erb +16 -0
  214. data/lib/rhoconnect/console/app/views/client.erb +30 -0
  215. data/lib/rhoconnect/console/app/views/content.erb +14 -0
  216. data/lib/rhoconnect/console/app/views/doc.erb +8 -0
  217. data/lib/rhoconnect/console/app/views/docdata.erb +28 -0
  218. data/lib/rhoconnect/console/app/views/docs.erb +30 -0
  219. data/lib/rhoconnect/console/app/views/edituser.erb +13 -0
  220. data/lib/rhoconnect/console/app/views/headermenu.erb +40 -0
  221. data/lib/rhoconnect/console/app/views/home.erb +24 -0
  222. data/lib/rhoconnect/console/app/views/index.erb +58 -0
  223. data/lib/rhoconnect/console/app/views/jqplot.erb +52 -0
  224. data/lib/rhoconnect/console/app/views/layout.erb +165 -0
  225. data/lib/rhoconnect/console/app/views/login.erb +26 -0
  226. data/lib/rhoconnect/console/app/views/newuser.erb +17 -0
  227. data/lib/rhoconnect/console/app/views/ping.erb +28 -0
  228. data/lib/rhoconnect/console/app/views/result.erb +11 -0
  229. data/lib/rhoconnect/console/app/views/rightboxlinks.erb +15 -0
  230. data/lib/rhoconnect/console/app/views/select_doc.erb +17 -0
  231. data/lib/rhoconnect/console/app/views/upload_doc.erb +23 -0
  232. data/lib/rhoconnect/console/app/views/user.erb +29 -0
  233. data/lib/rhoconnect/console/app/views/users.erb +12 -0
  234. data/lib/rhoconnect/console/rhoconnect_api.rb +245 -0
  235. data/lib/rhoconnect/console/server.rb +32 -0
  236. data/lib/rhoconnect/console.rb +3 -0
  237. data/lib/rhoconnect/cors.rb +229 -0
  238. data/lib/rhoconnect/credential.rb +9 -0
  239. data/lib/rhoconnect/db_adapter.rb +46 -0
  240. data/lib/rhoconnect/document.rb +49 -0
  241. data/lib/rhoconnect/dynamic_adapter.rb +91 -0
  242. data/lib/rhoconnect/generator.rb +1 -0
  243. data/lib/rhoconnect/jobs/bulk_data_job.rb +203 -0
  244. data/lib/rhoconnect/jobs/ping_job.rb +46 -0
  245. data/lib/rhoconnect/jobs/source_job.rb +16 -0
  246. data/lib/rhoconnect/license.rb +86 -0
  247. data/lib/rhoconnect/lock_ops.rb +11 -0
  248. data/lib/rhoconnect/model.rb +414 -0
  249. data/lib/rhoconnect/ping/android.rb +56 -0
  250. data/lib/rhoconnect/ping/apple.rb +52 -0
  251. data/lib/rhoconnect/ping/blackberry.rb +56 -0
  252. data/lib/rhoconnect/ping.rb +3 -0
  253. data/lib/rhoconnect/read_state.rb +31 -0
  254. data/lib/rhoconnect/rho_indifferent_access.rb +88 -0
  255. data/lib/rhoconnect/server/views/index.erb +13 -0
  256. data/lib/rhoconnect/server.rb +286 -0
  257. data/lib/rhoconnect/source.rb +289 -0
  258. data/lib/rhoconnect/source_adapter.rb +123 -0
  259. data/lib/rhoconnect/source_sync.rb +302 -0
  260. data/lib/rhoconnect/stats/middleware.rb +20 -0
  261. data/lib/rhoconnect/stats/record.rb +108 -0
  262. data/lib/rhoconnect/store.rb +232 -0
  263. data/lib/rhoconnect/tasks.rb +350 -0
  264. data/lib/rhoconnect/test_methods.rb +220 -0
  265. data/lib/rhoconnect/user.rb +95 -0
  266. data/lib/rhoconnect/version.rb +3 -0
  267. data/lib/rhoconnect/x_domain_session_wrapper.rb +53 -0
  268. data/lib/rhoconnect.rb +285 -0
  269. data/rhoconnect.gemspec +67 -0
  270. data/spec/api/admin/api_token_spec.rb +14 -0
  271. data/spec/api/admin/get_api_token_spec.rb +36 -0
  272. data/spec/api/admin/get_license_info_spec.rb +38 -0
  273. data/spec/api/admin/reset_spec.rb +22 -0
  274. data/spec/api/admin/stats_spec.rb +66 -0
  275. data/spec/api/api_helper.rb +21 -0
  276. data/spec/api/application/rhoconnect_api_spec.rb +548 -0
  277. data/spec/api/client/create_client_spec.rb +13 -0
  278. data/spec/api/client/delete_client_spec.rb +13 -0
  279. data/spec/api/client/get_client_params_spec.rb +18 -0
  280. data/spec/api/client/list_client_docs_spec.rb +32 -0
  281. data/spec/api/client/list_clients_spec.rb +22 -0
  282. data/spec/api/client/ping_spec.rb +23 -0
  283. data/spec/api/rhosync_api_spec.rb.orig +606 -0
  284. data/spec/api/source/adapter_spec.rb +29 -0
  285. data/spec/api/source/get_db_doc_spec.rb +21 -0
  286. data/spec/api/source/get_source_params_spec.rb +32 -0
  287. data/spec/api/source/list_source_docs_spec.rb +25 -0
  288. data/spec/api/source/list_sources_spec.rb +26 -0
  289. data/spec/api/source/push_deletes_spec.rb +18 -0
  290. data/spec/api/source/push_objects_spec.rb +27 -0
  291. data/spec/api/source/set_db_doc_spec.rb +19 -0
  292. data/spec/api/source/set_refresh_time_spec.rb +43 -0
  293. data/spec/api/source/upload_file_spec.rb +26 -0
  294. data/spec/api/user/create_user_spec.rb +16 -0
  295. data/spec/api/user/delete_user_spec.rb +36 -0
  296. data/spec/api/user/list_users_spec.rb +30 -0
  297. data/spec/api/user/update_user_spec.rb +31 -0
  298. data/spec/api_token_spec.rb +14 -0
  299. data/spec/app_spec.rb +18 -0
  300. data/spec/apps/emptyapp/application.rb +27 -0
  301. data/spec/apps/emptyapp/settings/license.key +1 -0
  302. data/spec/apps/emptyapp/settings/settings.yml +14 -0
  303. data/spec/apps/rhotestapp/Rakefile +1 -0
  304. data/spec/apps/rhotestapp/application.rb +19 -0
  305. data/spec/apps/rhotestapp/config.ru +1 -0
  306. data/spec/apps/rhotestapp/settings/apple_fake_cert.pem +1 -0
  307. data/spec/apps/rhotestapp/settings/license.key +1 -0
  308. data/spec/apps/rhotestapp/settings/settings.yml +36 -0
  309. data/spec/apps/rhotestapp/sources/base_adapter.rb +9 -0
  310. data/spec/apps/rhotestapp/sources/fixed_schema_adapter.rb +28 -0
  311. data/spec/apps/rhotestapp/sources/sample_adapter.rb +71 -0
  312. data/spec/apps/rhotestapp/sources/simple_adapter.rb +41 -0
  313. data/spec/apps/rhotestapp/sources/sub_adapter.rb +7 -0
  314. data/spec/apps/rhotestapp/vendor/mygem-0.1.0/lib/mygem/mygem.rb +8 -0
  315. data/spec/apps/rhotestapp/vendor/mygem-0.1.0/lib/mygem.rb +1 -0
  316. data/spec/bulk_data/bulk_data_spec.rb +97 -0
  317. data/spec/client_spec.rb +124 -0
  318. data/spec/client_sync_spec.rb +774 -0
  319. data/spec/doc/base.html +72 -0
  320. data/spec/doc/doc_spec.rb +376 -0
  321. data/spec/doc/footer.html +4 -0
  322. data/spec/doc/header.html +30 -0
  323. data/spec/document_spec.rb +31 -0
  324. data/spec/dynamic_adapter_spec.rb +43 -0
  325. data/spec/factories/factories.rb +17 -0
  326. data/spec/generator/generator_spec.rb +58 -0
  327. data/spec/generator/generator_spec_helper.rb +9 -0
  328. data/spec/jobs/bulk_data_job_spec.rb +125 -0
  329. data/spec/jobs/ping_job_spec.rb +102 -0
  330. data/spec/jobs/source_job_spec.rb +29 -0
  331. data/spec/license_spec.rb +66 -0
  332. data/spec/model_spec.rb +273 -0
  333. data/spec/perf/bulk_data_perf_spec.rb +32 -0
  334. data/spec/perf/perf_spec_helper.rb +50 -0
  335. data/spec/perf/store_perf_spec.rb +27 -0
  336. data/spec/ping/android_spec.rb +91 -0
  337. data/spec/ping/apple_spec.rb +70 -0
  338. data/spec/ping/blackberry_spec.rb +62 -0
  339. data/spec/read_state_spec.rb +35 -0
  340. data/spec/rhosync_spec.rb +75 -0
  341. data/spec/server/cors_spec.rb +287 -0
  342. data/spec/server/server_spec.rb +470 -0
  343. data/spec/server/x_domain_session_wrapper_spec.rb +150 -0
  344. data/spec/source_adapter_spec.rb +125 -0
  345. data/spec/source_spec.rb +114 -0
  346. data/spec/source_sync_spec.rb +328 -0
  347. data/spec/spec.opts +4 -0
  348. data/spec/spec_helper.rb +231 -0
  349. data/spec/stats/middleware_spec.rb +53 -0
  350. data/spec/stats/record_spec.rb +92 -0
  351. data/spec/store_spec.rb +251 -0
  352. data/spec/support/shared_examples.rb +168 -0
  353. data/spec/sync_states_spec.rb +72 -0
  354. data/spec/test_methods_spec.rb +134 -0
  355. data/spec/testdata/1000-data.txt +1414 -0
  356. data/spec/testdata/compressed/compress-data.txt +1 -0
  357. data/spec/testdata/upload1.txt +1 -0
  358. data/spec/testdata/upload2.txt +1 -0
  359. data/spec/user_spec.rb +139 -0
  360. data/tasks/redis.rake +206 -0
  361. metadata +706 -0
@@ -0,0 +1,69 @@
1
+ Collecting Runtime Stats
2
+ ===
3
+ RhoConnect provides a simple stats [rack middleware](http://railscasts.com/episodes/151-rack-middleware) for collecting runtime information on your application. These stats are accessible from the [REST API](/rhoconnect/rest-api) and some default graphs are available from the [web console](/rhoconnect/web-console).
4
+
5
+ ## Enabling Stats
6
+ To enable stats in your RhoConnect application, simply turn on the stats middleware by editing config.ru:
7
+
8
+ :::ruby
9
+ Rhoconnect::Server.enable :stats
10
+
11
+ A complete config.ru might look like:
12
+
13
+ :::ruby
14
+ # Try to load vendor-ed rhoconnect, otherwise load the gem
15
+ begin
16
+ require 'vendor/rhoconnect/lib/rhoconnect/server'
17
+ require 'vendor/rhoconnect/lib/rhoconnect/console/server'
18
+ rescue LoadError
19
+ require 'rhoconnect/server'
20
+ require 'rhoconnect/console/server'
21
+ end
22
+
23
+ # By default, turn on the resque web console
24
+ require 'resque/server'
25
+
26
+ ROOT_PATH = File.expand_path(File.dirname(__FILE__))
27
+
28
+ # Rhoconnect server flags
29
+ Rhoconnect::Server.disable :run
30
+ Rhoconnect::Server.disable :clean_trace
31
+ Rhoconnect::Server.enable :raise_errors
32
+ Rhoconnect::Server.set :secret, '<changeme>'
33
+ Rhoconnect::Server.set :root, ROOT_PATH
34
+ Rhoconnect::Server.enable :stats
35
+ Rhoconnect::Server.use Rack::Static, :urls => ["/data"], :root => Rhoconnect::Server.root
36
+
37
+ # Load our rhoconnect application
38
+ require './application'
39
+
40
+ # Setup the url map
41
+ run Rack::URLMap.new \
42
+ "/" => Rhoconnect::Server.new,
43
+ "/resque" => Resque::Server.new, # If you don't want resque frontend, disable it here
44
+ "/console" => RhoconnectConsole::Server.new # If you don't want rhoconnect frontend, disable it here
45
+
46
+ Now just restart your rhoconnect application:
47
+
48
+ :::term
49
+ $ rake rhoconnect:restart
50
+
51
+ And navigate to the 'Statistics' tab in your RhoConnect console:
52
+
53
+ :::term
54
+ $ rake rhoconnect:web
55
+
56
+ ## Stats Console
57
+ You should see graphs, organized by categories on the right:
58
+
59
+ <img src="https://img.skitch.com/20110112-x2h6tg8wr75snxfp11ia89w51j.png"/>
60
+
61
+ RhoConnect statistics are organized into the following categories:
62
+
63
+ * User Count - # of users stored in redis
64
+
65
+ * Device Count - # of devices currently registered with RhoConnect
66
+
67
+ * HTTP Timing - # average HTTP request time by URL
68
+
69
+ * Source Timing - # average source adapter execution time by method
data/doc/testing.txt ADDED
@@ -0,0 +1,222 @@
1
+ Testing Your RhoConnect Application
2
+ ===
3
+ RhoConnect provides a [spec](http://rspec.info/) framework for [behavior driven development](http://en.wikipedia.org/wiki/Behavior_Driven_Development) of your application. When your application and source adapters are generated, you will see spec files generated in the top-level 'spec' folder of your application.
4
+
5
+ ## Example Spec
6
+
7
+ Here is a simple example spec for the [rhostore product adapter](http://github.com/rhomobile/store-server/blob/master/sources/product.rb):
8
+
9
+ :::ruby
10
+ it "should process Product query" do
11
+ test_query.size.should > 0
12
+ query_errors.should == {}
13
+ end
14
+
15
+ This simple spec runs the query method of our product adapter and verifies the result is greater than one object and has no errors.
16
+
17
+ The full code listing for this product_spec is available [on github](http://github.com/rhomobile/store-server/blob/master/spec/sources/product_spec.rb).
18
+
19
+ ## Running Specs
20
+ From your application's root folder:
21
+
22
+ :::term
23
+ $ rake rhoconnect:spec
24
+ [05:51:48 PM 2011-04-19] Rhoconnect Server v3.0.0 started...
25
+ Product
26
+ it should behave like SpecHelper
27
+ should process Product query (PENDING: No reason given)
28
+ should process Product create (PENDING: No reason given)
29
+ should process Product update (PENDING: No reason given)
30
+ should process Product delete (PENDING: No reason given)
31
+ Pending:
32
+ Product it should behave like SpecHelper should process Product query
33
+ Product it should behave like SpecHelper should process Product create
34
+ Product it should behave like SpecHelper should process Product update
35
+ Product it should behave like SpecHelper should process Product delete
36
+
37
+ Finished in 0.05877 seconds
38
+ 4 examples, 0 failures, 4 pending
39
+
40
+
41
+ This will also automatically generate an rcov report under 'coverage' if you have rcov installed (currently only Mac/Linux support rcov).
42
+
43
+ ## Test API
44
+ For the most up-to-date Test API, please see the [rdocs](http://rdoc.info/projects/rhomobile/rhoconnect).
45
+
46
+ ### `setup_test_for(adapter,user_id)`
47
+ Initializes the source adapter under test for a given user, typically in a before(:each) block
48
+
49
+ :::ruby
50
+ # 'testuser' will be used by rest of the specs
51
+ setup_test_for(Product,'testuser')
52
+
53
+ ### `test_query`
54
+ Executes the adapter's query method and returns the master document (:md) stored in redis.
55
+
56
+ For example, if your source adapter query method was:
57
+
58
+ :::ruby
59
+ def query(params=nil)
60
+ @result = {
61
+ "1" => {
62
+ "name"=>"Acme",
63
+ "industry"=>"Electronics"},
64
+ "2" => {
65
+ "name"=>"Best",
66
+ "industry"=>"Software"
67
+ }
68
+ }
69
+ end
70
+
71
+ `test_query` would return:
72
+
73
+ :::ruby
74
+ {
75
+ "1" => {
76
+ "name" => "Acme",
77
+ "industry"=>"Electronics"
78
+ },
79
+ "2" => {
80
+ "name" => "Best",
81
+ "industry" => "Software"
82
+ }
83
+ }
84
+
85
+ ### `query_errors`
86
+ Returns any errors stored in redis for the previous source adapter query.
87
+
88
+ For example:
89
+
90
+ :::ruby
91
+ {
92
+ "query-error" => {
93
+ "message" => "error connecting to web service!"
94
+ }
95
+ }
96
+
97
+
98
+ ### `test_create(record)`
99
+ Execute's the adapter's create method with a provided record and returns the object string from the create method. If the create method returns a string, then a link will be saved for the device next time it synchronizes. This link can be tested here.
100
+
101
+ For example, in your spec:
102
+ :::ruby
103
+ @product = {
104
+ 'name' => 'iPhone',
105
+ 'brand' => 'Apple',
106
+ 'price' => '$299.99',
107
+ 'quantity' => '5',
108
+ 'sku' => '1234'
109
+ }
110
+ new_product_id = test_create(@product)
111
+ create_errors.should == {}
112
+ md[new_product_id].should == @product
113
+
114
+ If you have set [pass through](http://docs.rhomobile.com/rhoconnect/source-adapters#pass-through) to true, the create method will not return a string but instead a json hash of the object ids created. When testing the id will always be set to 'temp_id'.
115
+
116
+ For example, in your spec:
117
+ :::ruby
118
+ @product = {
119
+ 'name' => 'iPhone',
120
+ 'brand' => 'Apple',
121
+ 'price' => '$299.99',
122
+ 'quantity' => '5',
123
+ 'sku' => '1234'
124
+ }
125
+ @s.pass_through = 'true'
126
+ new_product = test_create(@product)
127
+ new_product.should == {'processed' => ["temp-id"]}.to_json
128
+
129
+ ### `create_errors`
130
+ This will return the result of the adapter's create method. The master document (:md) should also contain the new record.
131
+ Returns any errors stored in redis from the previous source adapter create (same structure as query errors).
132
+
133
+ ### `test_update(record)`
134
+ Execute the source adapter's update method. Takes a record as hash of hashes (object_id => object)
135
+
136
+ For example:
137
+
138
+ :::ruby
139
+ test_update({'4' => {'price' => '$199.99'}})
140
+ update_errors.should == {}
141
+ test_query
142
+ md[product_id]['price'].should == '$199.99'
143
+
144
+ This will call the adapter's update method for object_id '4'.
145
+
146
+ **NOTE: To test the master document, you will need to run `test_query` as shown above.**
147
+
148
+ If you have set [pass through](http://docs.rhomobile.com/rhoconnect/source-adapters#pass-through) to true, the update method will return a json hash of the object id updated.
149
+
150
+ For example, in your spec:
151
+ :::ruby
152
+ record = {'4'=> { 'price' => '199.99' }}
153
+ @s.pass_through = 'true'
154
+ test_update(record).should == {'processed' => ["4"]}.to_json
155
+
156
+ ### `update_errors`
157
+ Returns any errors stored in redis from the previous source adapter update (same structure as query errors).
158
+
159
+ ### `test_delete(record)`
160
+ Execute the source adapter's delete method. Takes a record as hash of hashes (object_id => object).
161
+
162
+ For example:
163
+
164
+ :::ruby
165
+ @product = {
166
+ 'name' => 'iPhone',
167
+ 'brand' => 'Apple',
168
+ 'price' => '$299.99',
169
+ 'quantity' => '5',
170
+ 'sku' => '1234'
171
+ }
172
+ test_delete('4' => @product)
173
+ delete_errors.should == {}
174
+ md.should == {}
175
+
176
+ This will call the adapter's delete method for product '4'.
177
+
178
+ **NOTE: The master document (:md) will be updated and can be verified as shown above.**
179
+
180
+ If you have set [pass through](http://docs.rhomobile.com/rhoconnect/source-adapters#pass-through) to true, the delete method will return a json hash of the object id deleted.
181
+
182
+ For example, in your spec:
183
+ :::ruby
184
+ @product = {
185
+ 'name' => 'iPhone',
186
+ 'brand' => 'Apple',
187
+ 'price' => '$299.99',
188
+ 'quantity' => '5',
189
+ 'sku' => '1234'
190
+ }
191
+ record = {'4'=> { 'price' => '199.99' }}
192
+ @s.pass_through = 'true'
193
+ test_update(record).should == {'processed' => ["4"]}.to_json
194
+
195
+ ### `delete_errors`
196
+ Returns any errors stored in redis from the previous source adapter delete (same structure as query errors).
197
+
198
+ ### `md`
199
+ Returns the master document (:md) for the source adapter stored in redis. This is equivalent to the @result hash of hashes structure.
200
+
201
+ For example:
202
+
203
+ :::ruby
204
+ md.should == {
205
+ "1" => {
206
+ "name"=>"Acme",
207
+ "industry"=>"Electronics"
208
+ },
209
+ "2" => {
210
+ "name"=>"Best",
211
+ "industry"=>"Software"
212
+ }
213
+ }
214
+
215
+ ### `cd`
216
+ Returns the client document (:cd) for the source adapter + client under test. The master document (:md) and client document (:cd) should be equal after the query is executed.
217
+
218
+ For example:
219
+
220
+ :::ruby
221
+ test_query.size.should > 0
222
+ md.should == cd
data/doc/tutorial.txt ADDED
@@ -0,0 +1,315 @@
1
+ RhoConnect Tutorial
2
+ ===
3
+
4
+ Adding Synchronized Data to Your App with RhoConnect
5
+ ---
6
+
7
+ RhoConnect is a synchronization framework consisting of a client component on the device and a server component that runs on any server capable of running Ruby. RhoConnect requires that you write a small amount of Ruby code for the query, create, update and delete operations of your particular enterprise backend. The collection of the Ruby code for these operations we refer to as a "source" or "source adapter". Full documentation of all capabilities of RhoConnect is in the [RhoConnect Developer Reference](/rhoconnect/introduction).
8
+
9
+ Install the RhoConnect Dependencies
10
+ ---
11
+
12
+ * Install RhoConnect as described [here](/rhoconnect/install).
13
+
14
+ * If you have a RhoConnect license that has been sent to you you can replace the settings/license.yml file as described [here](/rhoconnect/licensing).
15
+
16
+ Now you are ready to write your RhoConnect app. You can generate an app with the RhoConnect app command.
17
+
18
+ :::term
19
+ $ rhoconnect app storemanager-server
20
+ $ cd storemanager-server/
21
+
22
+ **If you are running this for the first time on Mac or Linux**, you will need to install [dtach](http://dtach.sourceforge.net/):
23
+
24
+ :::term
25
+ $ sudo rake dtach:install
26
+
27
+ ### Verify Installation
28
+
29
+ Now you can run redis and your RhoConnect app:
30
+
31
+ :::term
32
+ $ rake redis:start
33
+ $ rake rhoconnect:start
34
+
35
+ If everything went well you should see:
36
+
37
+ [07:01:15 PM 2010-05-04] Rhoconnect Server v3.0.0 started...
38
+
39
+ **NOTE: You will be prompted to edit the session secret in your config.ru to something other than "\<changeme\>"**
40
+
41
+ Defining RhoConnect Source Adapters
42
+ ---
43
+
44
+ Once RhoConnect is installed we're ready to build a RhoConnect source to integrate with our backend application. To define a RhoConnect source you just need to identify a handful of operations to interact with your backend data source: login, query, sync, create, update, delete and logoff. For more information please see the [RhoConnect source adapter](/rhoconnect/source-adapters) documentation.
45
+
46
+ From the storemanager-sever directory, generate a source adapter for the product model:
47
+
48
+ :::term
49
+ $ rhoconnect source product
50
+
51
+ which generates two files, the product adapter and the product spec:
52
+
53
+ Generating with source generator:
54
+ [ADDED] sources/product.rb
55
+ [ADDED] spec/sources/product_spec.rb
56
+
57
+ You'll see a file similar to the following one below. The generated source adapter has code to raise an exception for any required method. Note that you don't need to use the source generator. You can just create a Ruby file and place it into your lib directory. The class name of the source adapter must match that of the client model.
58
+
59
+ :::ruby
60
+ class Product < SourceAdapter
61
+ def initialize(source)
62
+ super(source)
63
+ end
64
+
65
+ def login
66
+ # TODO: Login to your data source here if necessary
67
+ end
68
+
69
+ def query
70
+ # TODO: Query your backend data source and assign the records
71
+ # to a nested hash structure called @result. For example:
72
+ # @result = {
73
+ # "1"=>{"name"=>"Acme", "industry"=>"Electronics"},
74
+ # "2"=>{"name"=>"Best", "industry"=>"Software"}
75
+ # }
76
+ raise SourceAdapterException.new("Please provide some code to read records from the backend data source")
77
+ end
78
+
79
+ def sync
80
+ # Manipulate @result before it is saved, or save it
81
+ # yourself using the Rhoconnect::Store interface.
82
+ # By default, super is called below which simply saves @result
83
+ super
84
+ end
85
+
86
+ def create(create_hash)
87
+ # TODO: Create a new record in your backend data source
88
+ # If your rhodes rhom object contains image/binary data
89
+ # (has the image_uri attribute), then a blob will be provided
90
+ raise "Please provide some code to create a single record in the backend data source using the create_hash"
91
+ end
92
+
93
+ def update(update_hash)
94
+ # TODO: Update an existing record in your backend data source
95
+ raise "Please provide some code to update a single record in the backend data source using the update_hash"
96
+ end
97
+
98
+ def delete(delete_hash)
99
+ # TODO: write some code here if applicable
100
+ # be sure to have a hash key and value for "object"
101
+ # for now, we'll say that its OK to not have a delete operation
102
+ # raise "Please provide some code to delete a single object in the backend application using the object_id"
103
+ end
104
+
105
+ def logoff
106
+ # TODO: Logout from the data source if necessary
107
+ end
108
+ end
109
+
110
+ The generator will also edit settings/settings.yml and add the product adapter to the sources section with some default options:
111
+
112
+ :::ruby
113
+ #Sources
114
+ :sources:
115
+ Product:
116
+ :poll_interval: 300
117
+
118
+ The next step is for you to fill in the login, query, create, update, delete and logoff methods with your own code to call a backend service.
119
+
120
+ The description below shows what such code might look like.
121
+
122
+ A RhoConnect Query
123
+ ---
124
+ If you're doing a readonly non-authenticated source adapter, you can get away with just writing one method, query, to retrieve records as we describe here. The following is a sample query method to interact with a simple product catalog (available at http://rhostore.heroku.com) that exposes a REST interface. Note that RhoConnect can work with any protocol. This example simply shows JSON over HTTP with a REST interface since that is common. The RhoConnect source adapter is pure Ruby code and there are ruby libraries (aka gems) that will make it easy to connect to and parse whatever you need -- the query code would just be slightly different.
125
+
126
+ Our sample web service for returning all products in the catalog (http://rhostore.heroku.com/products.json) returns data like this:
127
+
128
+ :::json
129
+ [
130
+ {
131
+ "product": {
132
+ "name": "iPhone",
133
+ "brand": "Apple",
134
+ "updated_at": "2010-05-11T02:04:57Z",
135
+ "price": "$299.99",
136
+ "quantity": "5",
137
+ "id": 649,
138
+ "sku": "1234",
139
+ "created_at": "2010-05-11T02:04:57Z"
140
+ }
141
+ },
142
+ {
143
+ "product": {
144
+ "name": "Accord",
145
+ "brand": "Honda",
146
+ "updated_at": "2010-05-13T22:24:48Z",
147
+ "price": "$6000",
148
+ "quantity": "",
149
+ "id": 648,
150
+ "sku": "123",
151
+ "created_at": "2010-05-11T02:04:53Z"
152
+ }
153
+ }
154
+ ]
155
+
156
+ The Ruby code for parsing that data listed below uses the standard Ruby JSON library and the RestClient library for easy access to the REST web service. This example uses the id of the product record as the hash key. Note that the key for this hash must be a string and the value can be any set of name-value pairs which are represented as a Ruby hash. The instance variable @result must be set by the query method to this "hash of hashes", indexed by a unique identifier, so that the base SourceAdapter class sync method can populate Redis data store.
157
+
158
+ We need to declare the standard libraries that we are using at the top of the file:
159
+
160
+ :::ruby
161
+ require 'json'
162
+ require 'rest_client'
163
+
164
+ For convenience, we'll add an instance variable @base which contains the base URL of the web service and set the value in the constructor:
165
+
166
+ :::ruby
167
+ def initialize(source,credential)
168
+ @base = 'http://rhostore.heroku.com/products'
169
+ super(source,credential)
170
+ end
171
+
172
+ Then fill in the query method:
173
+
174
+ :::ruby
175
+ def query
176
+ parsed=JSON.parse(RestClient.get("#{@base}.json").body)
177
+
178
+ @result={}
179
+ if parsed
180
+ parsed.each do |item|
181
+ key = item["product"]["id"].to_s
182
+ @result[key]=item["product"]
183
+ end
184
+ end
185
+ end
186
+
187
+ **NOTE: The code above could be much more concise, but it is written to be easily readable by programmers who are unfamiliar with the Ruby language. If you are new to Ruby, you can read [Ruby from other languages](http://www.ruby-lang.org/en/documentation/ruby-from-other-languages/) for a good introduction.
188
+ Each hash key in the inner hash represents an attribute of an individual object. All datatypes must be strings (so the hash values need to all be strings not integers).**
189
+
190
+ For example:
191
+
192
+ :::ruby
193
+ @result = {
194
+ "1" => {
195
+ "name" => "inner tube",
196
+ "brand" => "Michelin"
197
+ },
198
+ "2" => {
199
+ "name" => "tire",
200
+ "brand" => "Michelin"
201
+ }
202
+ }
203
+
204
+ Testing Sync from the Client
205
+ ---
206
+ Make sure you are running redis and start (or restart) your server:
207
+
208
+ :::term
209
+ $ rake rhoconnect:start
210
+
211
+ The code for the source adapter loads when the server starts. If you have a syntax error in your Ruby code, it will be reported and the server will not start; however, if you have a runtime error, that will not be reported until the source adapter is called.
212
+
213
+ Make sure your server URL is configured in the app. If your server is running on localhost with the default port, the following line should be at the bottom of rhoconfig.txt:
214
+
215
+ syncserver = 'http://localhost:9292/application'
216
+
217
+ Enable sync in your storemanager/app/Product/product.rb model:
218
+
219
+ :::ruby
220
+ class Product
221
+ include Rhom::PropertyBag
222
+
223
+ enable :sync
224
+ end
225
+
226
+ To get a feel for what is happening, it is helpful to watch the server log (the output of rake rhoconnect:start) in one window, and tail the client log in another window. For example, on the iPhone, display the end of the client log with:
227
+
228
+ :::term
229
+ $ tail -f rholog-User.txt
230
+
231
+ To sync with the server, the client must log in. The generated app includes some screens for login and other common functions, which you will typically modify to suit the design of your application. The generated UI is useful since it allows you to focus on the core functionality of your application before implementing the important, but mundane, details of user authentication and settings.
232
+
233
+ 1. Click on the gears icon at the bottom of the screen to go to the Settings screen
234
+ 2. Login using any name & password. The generated code allows any login, but you can modify that in application.rb.
235
+ 3. If login is successful, you will see a Client ID in the settings screen. The ClientID is generated the first time you log in and is stored in the client database. It serves as a unique identifier which is required for rhoconnect. (Note: this value will persist across logins, but if you reset the client database or the user re-installs the app, a new ClientID will be generated.)
236
+ 4. Sync is triggered automatically. Click on the home icon and then select "Products" and you should see the records from the server.
237
+
238
+ Creating Objects with RhoConnect
239
+ ---
240
+ For your create method you can assume that the RhoConnect server will pass you a hash containing the new record called "create_hash". For example it might be:
241
+
242
+ :::ruby
243
+ {
244
+ "name" => "Hovercraft",
245
+ "brand" => "Acme"
246
+ }
247
+
248
+ The create method will be called once for every object that has been created on the client since the last sync. Your code for create (or edit or delete) needs to use this populated array to do its work. Below is an example of a create method against the [rhostore](http://rhostore.heroku.com), which accepts an HTTP POST to perform a create action. The create method must return a unique id string for the object for it to be later modifiable by the client. If no id is returned, then you should treat the client object as read only, because it will not be able to be synchronized.
249
+
250
+ :::ruby
251
+ def create(create_hash)
252
+ result = RestClient.post(@base, :product => create_hash)
253
+
254
+ # after create we are redirected to the new record.
255
+ # The URL of the new record is given in the location header
256
+ location = "#{result.headers[:location]}.json"
257
+
258
+ # We need to get the id of that record and return it as part of create
259
+ # so rhoconnect can establish a link from its temporary object on the
260
+ # client to this newly created object on the server
261
+
262
+ new_record = RestClient.get(location).body
263
+ JSON.parse(new_record)["product"]["id"].to_s
264
+ end
265
+
266
+ You will need to restart RhoConnect to reload the source adapter after modifying code. Note that the object will be created on the client right away, but it will be sent to the server on the next sync.
267
+
268
+ Authentication
269
+ ---
270
+ The generated application code includes a file at the root of the directory called "application.rb" which contains a hook for authentication. The complete file looks like this:
271
+
272
+ :::ruby
273
+ class Application < Rhoconnect::Base
274
+ class << self
275
+ def authenticate(username,password,session)
276
+ true # do some interesting authentication here...
277
+ end
278
+
279
+ # Add hooks for application startup here
280
+ # Don't forget to call super at the end!
281
+ def initializer(path)
282
+ super
283
+ end
284
+
285
+ # Calling super here returns rack tempfile path:
286
+ # i.e. /var/folders/J4/J4wGJ-r6H7S313GEZ-Xx5E+++TI
287
+ # Note: This tempfile is removed when server stops or crashes...
288
+ # See http://rack.rubyforge.org/doc/Multipart.html for more info
289
+ #
290
+ # Override this by creating a copy of the file somewhere
291
+ # and returning the path to that file (then don't call super!):
292
+ # i.e. /mnt/myimages/soccer.png
293
+ def store_blob(blob)
294
+ super #=> returns blob[:tempfile]
295
+ end
296
+ end
297
+ end
298
+
299
+ Application.initializer(ROOT_PATH)
300
+
301
+ If your back end web service requires authentication, simply add code to the authenticate method and return true if authentication was successful or false to deny access to the application from this client. For example:
302
+
303
+ :::ruby
304
+ def authenticate(username, password, session)
305
+ # ... connect to backend using API and authenticate ...
306
+ if success
307
+ # save the data for later use in the source adapter
308
+ Store.put_value("username:#{username}:token",username)
309
+ end
310
+ return success
311
+ end
312
+
313
+ Using RhoConnect from Objective C
314
+ ---
315
+ You don't have to use Rhodes to use RhoConnect. For this scenario, we offer an [Objective C client for RhoConnect](/rhoconnect/client).
@@ -0,0 +1,35 @@
1
+ Web Console
2
+ ===
3
+
4
+ Your RhoConnect application exposes a web interface which runs on http://localhost:9292/console/ (port 80 on Windows) by default. You can open the console by running the following in your application directory:
5
+
6
+ :::term
7
+ $ rake rhoconnect:web
8
+
9
+ To login to the console:
10
+
11
+ 1. Click on the "Console" link
12
+ 2. Make sure the server field matches the host and port your rhoconnect app is running
13
+ 3. Default username is 'rhoadmin' and the password is empty
14
+ 4. Now you will be presented with a page showing your current license, for example:
15
+
16
+
17
+ Licensed to Rhomobile on Fri Apr 23 17:20:13 -0700 2010,
18
+ available 9 of 10 devices
19
+
20
+ It will also show a link to "Application Users" where you can view users of the system as well as devices they have registered.
21
+
22
+ If you want to disable this web interface, you can do so by editing the rackup file, config.ru:
23
+
24
+ :::ruby
25
+ # Setup the url map
26
+ run Rack::URLMap.new \
27
+ "/" => Rhoconnect::Server.new,
28
+ "/resque" => Resque::Server.new, # If you don't want resque frontend, disable it here
29
+ #"/console" => RhoconnectConsole::Server.new # If you don't want rhoconnect frontend, disable it here
30
+
31
+ **NOTE: This web console is intended to be used for basic tests and views into the running RhoConnect application. It uses the [RhoConnect REST API](/rhoconnect/rest-api) for everything it does, so it is very easy to extend this console or programmatically control your RhoConnect application directly using the [RhoConnect API](/rhoconnect/rest-api). **
32
+
33
+ Here is a screenshot of the web console:
34
+
35
+ <img src="https://img.skitch.com/20110110-f81w9mr8ujegyep543bjsrkigj.jpg"/>
@@ -0,0 +1,14 @@
1
+ $:.unshift File.join(File.dirname(__FILE__),'..','..','lib')
2
+ require 'rhoconnect/tasks'
3
+
4
+ ROOT_PATH = File.expand_path(File.dirname(__FILE__))
5
+
6
+ begin
7
+ require 'resque/tasks'
8
+ task "resque:setup" do
9
+ require 'application'
10
+ end
11
+ rescue LoadError
12
+ puts "Resque not available. Install it with: "
13
+ puts "gem install resque\n\n"
14
+ end
@@ -0,0 +1,27 @@
1
+ class Application < Rhoconnect::Base
2
+ class << self
3
+ def authenticate(username,password,session)
4
+ true # do some interesting authentication here...
5
+ end
6
+
7
+ # Add hooks for application startup here
8
+ # Don't forget to call super at the end!
9
+ def initializer(path)
10
+ super
11
+ end
12
+
13
+ # Calling super here returns rack tempfile path:
14
+ # i.e. /var/folders/J4/J4wGJ-r6H7S313GEZ-Xx5E+++TI
15
+ # Note: This tempfile is removed when server stops or crashes...
16
+ # See http://rack.rubyforge.org/doc/Multipart.html for more info
17
+ #
18
+ # Override this by creating a copy of the file somewhere
19
+ # and returning the path to that file (then don't call super!):
20
+ # i.e. /mnt/myimages/soccer.png
21
+ def store_blob(obj,field_name,blob)
22
+ super #=> returns blob[:tempfile]
23
+ end
24
+ end
25
+ end
26
+
27
+ Application.initializer(ROOT_PATH)