rhoconnect 3.4.5 → 4.0.0.beta.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (337) hide show
  1. data/CHANGELOG.md +57 -3
  2. data/Gemfile +9 -7
  3. data/Gemfile.lock +37 -37
  4. data/Rakefile +18 -7
  5. data/bench/benchapp/Gemfile +1 -1
  6. data/bench/benchapp/config.ru +0 -3
  7. data/bench/benchapp/controllers/ruby/application.rb +17 -0
  8. data/bench/benchapp/controllers/ruby/application_controller.rb +17 -0
  9. data/bench/benchapp/controllers/ruby/mock_adapter_controller.rb +8 -0
  10. data/bench/benchapp/controllers/ruby/queue_mock_adapter_controller.rb +8 -0
  11. data/bench/benchapp/{sources → models/ruby}/mock_adapter.rb +1 -1
  12. data/bench/benchapp/{sources → models/ruby}/queue_mock_adapter.rb +0 -0
  13. data/bench/benchapp/spec/{sources → models/ruby}/mock_adapter_spec.rb +1 -1
  14. data/bench/benchapp/spec/{sources → models/ruby}/queue_mock_adapter_spec.rb +1 -1
  15. data/bench/benchapp/spec/spec_helper.rb +2 -2
  16. data/bench/blobapp/Gemfile +1 -1
  17. data/bench/blobapp/config.ru +0 -3
  18. data/bench/blobapp/controllers/ruby/application_controller.rb +17 -0
  19. data/bench/blobapp/controllers/ruby/blob_adapter_controller.rb +8 -0
  20. data/bench/blobapp/{sources → models/ruby}/blob_adapter.rb +9 -2
  21. data/bench/blobapp/spec/{sources → models/ruby}/blob_adapter_spec.rb +1 -1
  22. data/bench/blobapp/spec/spec_helper.rb +1 -1
  23. data/bench/lib/bench/cli.rb +1 -1
  24. data/bench/scripts/blob_cud_script.rb +1 -1
  25. data/bench/scripts/query_md_script.rb +1 -1
  26. data/bench/scripts/query_only_script.rb +1 -1
  27. data/bench/scripts/query_script.rb +1 -1
  28. data/bench/scripts/test_query_script.rb +7 -1
  29. data/bench/spec/mock_adapter_spec.rb +1 -1
  30. data/bench/spec/result_spec.rb +3 -3
  31. data/bin/rhoconnect +5 -3
  32. data/commands/dtach/dtach_install.rb +2 -2
  33. data/commands/execute.rb +8 -3
  34. data/commands/generators/app.rb +3 -3
  35. data/commands/generators/controller.rb +6 -0
  36. data/commands/generators/model.rb +6 -0
  37. data/commands/generators/source.rb +3 -3
  38. data/commands/generators/update.rb +1 -1
  39. data/commands/redis/redis_about.rb +2 -2
  40. data/commands/redis/redis_download.rb +1 -1
  41. data/commands/redis/redis_install.rb +4 -3
  42. data/commands/redis/redis_restart.rb +4 -4
  43. data/commands/redis/redis_start.rb +5 -4
  44. data/commands/redis/redis_startbg.rb +5 -4
  45. data/commands/redis/redis_status.rb +13 -0
  46. data/commands/redis/redis_stop.rb +3 -3
  47. data/commands/rhoconnect/config.rb +28 -16
  48. data/commands/rhoconnect/flushdb.rb +1 -2
  49. data/commands/rhoconnect/get_token.rb +15 -11
  50. data/commands/rhoconnect/restart.rb +13 -5
  51. data/commands/rhoconnect/set_admin_password.rb +8 -8
  52. data/commands/rhoconnect/start.rb +74 -16
  53. data/commands/rhoconnect/startbg.rb +1 -1
  54. data/commands/rhoconnect/startdebug.rb +1 -1
  55. data/commands/rhoconnect/stop.rb +13 -1
  56. data/commands/rhoconnect/web.rb +5 -5
  57. data/commands/rhoconnect_console/console.rb +7 -5
  58. data/commands/{rhoconnect → rhoconnect_spec}/spec.rb +0 -0
  59. data/commands/rhoconnect_war/war.rb +9 -9
  60. data/commands/utilities/blank_app.ru +56 -0
  61. data/commands/utilities/redis_runner.rb +54 -19
  62. data/doc/authentication.txt +80 -6
  63. data/doc/blob-sync.txt +104 -97
  64. data/doc/bulk-sync.txt +1 -1
  65. data/doc/client-java.txt +3 -3
  66. data/doc/client-objc.txt +2 -2
  67. data/doc/client.txt +4 -4
  68. data/doc/command-line.txt +105 -200
  69. data/doc/data-partitioning.txt +40 -0
  70. data/doc/deploying.txt +249 -77
  71. data/doc/extending-rhoconnect-server.txt +40 -57
  72. data/doc/heroku-addon.txt +2 -0
  73. data/doc/install.txt +45 -95
  74. data/doc/introduction.txt +1 -1
  75. data/doc/java-plugin.txt +365 -190
  76. data/doc/metadata.txt +1 -1
  77. data/doc/migration.txt +108 -142
  78. data/doc/preparing-production.txt +1 -1
  79. data/doc/push-backend-setup.txt +2 -0
  80. data/doc/push-client-setup-android.txt +78 -0
  81. data/doc/push-client-setup-bb.txt +81 -0
  82. data/doc/push-client-setup-ios.txt +70 -0
  83. data/doc/push-client-setup-rps.txt +200 -0
  84. data/doc/push-client-setup.txt +63 -66
  85. data/doc/push-server-setup.txt +67 -40
  86. data/doc/push-testing.txt +29 -0
  87. data/doc/push.txt +21 -6
  88. data/doc/rest-api.txt +128 -55
  89. data/doc/rhoconnect-redis-stack.txt +120 -0
  90. data/doc/settings.txt +4 -12
  91. data/doc/source-adapters-intro.txt +28 -0
  92. data/doc/source-adapters.txt +235 -272
  93. data/doc/stats-middleware.txt +9 -29
  94. data/doc/supported-platforms.txt +21 -30
  95. data/doc/testing.txt +40 -42
  96. data/doc/tutorial.txt +72 -57
  97. data/examples/simple/Gemfile +1 -1
  98. data/examples/simple/application.rb +4 -5
  99. data/examples/simple/my_server.rb +2 -2
  100. data/examples/simple/settings/settings.yml +1 -1
  101. data/generators/rhoconnect.rb +151 -50
  102. data/generators/templates/application/Gemfile +1 -1
  103. data/generators/templates/application/Rakefile +3 -3
  104. data/generators/templates/application/config.ru +1 -4
  105. data/generators/templates/application/controllers/application_controller.rb +17 -0
  106. data/generators/templates/application/controllers/js/application_controller.js +14 -0
  107. data/generators/templates/application/controllers/ruby/application_controller.rb +17 -0
  108. data/generators/templates/application/package.json +8 -0
  109. data/generators/templates/application/rcgemfile +2 -5
  110. data/generators/templates/application/settings/settings.yml +3 -3
  111. data/generators/templates/application/spec/application_controller_spec.rb +23 -0
  112. data/generators/templates/application/spec/js_spec.rb +25 -0
  113. data/generators/templates/application/spec/spec_helper.rb +21 -7
  114. data/generators/templates/source/controllers/js/controller.js +7 -0
  115. data/generators/templates/source/controllers/ruby/controller.rb +8 -0
  116. data/generators/templates/source/controllers/ruby/controller_spec.rb +27 -0
  117. data/generators/templates/source/models/js/model.js +46 -0
  118. data/generators/templates/source/{source_adapter.rb → models/ruby/model.rb} +15 -10
  119. data/generators/templates/source/{source_spec.rb → models/ruby/model_spec.rb} +1 -1
  120. data/install.sh +5 -5
  121. data/installer/unix-like/create_texts.rb +2 -2
  122. data/installer/unix-like/rho_connect_install_constants.rb +2 -2
  123. data/installer/unix-like/rho_connect_install_utilities.rb +1 -1
  124. data/installer/utils/constants.rb +4 -4
  125. data/js-adapters/ballroom.js +216 -0
  126. data/js-adapters/node.rb +52 -0
  127. data/js-adapters/node_channel.rb +181 -0
  128. data/js-adapters/request.js +27 -0
  129. data/js-adapters/response.js +57 -0
  130. data/js-adapters/rhoconnect_helpers.js +60 -0
  131. data/js-adapters/router.js +60 -0
  132. data/js-adapters/server.js +5 -0
  133. data/lib/rhoconnect/api/app/ans_login.rb +3 -3
  134. data/lib/rhoconnect/api/app/bulk_data.rb +10 -10
  135. data/lib/rhoconnect/api/app/fast_delete.rb +11 -10
  136. data/lib/rhoconnect/api/app/fast_insert.rb +11 -10
  137. data/lib/rhoconnect/api/app/fast_update.rb +11 -10
  138. data/lib/rhoconnect/api/app/login.rb +5 -5
  139. data/lib/rhoconnect/api/app/push_deletes.rb +12 -11
  140. data/lib/rhoconnect/api/app/push_objects.rb +12 -11
  141. data/lib/rhoconnect/api/app/query.rb +8 -7
  142. data/lib/rhoconnect/api/app/queue_updates.rb +98 -94
  143. data/lib/rhoconnect/api/app/search.rb +8 -7
  144. data/lib/rhoconnect/api/client/client_get_db_doc.rb +5 -5
  145. data/lib/rhoconnect/api/client/client_set_db_doc.rb +8 -8
  146. data/lib/rhoconnect/api/client/create.rb +7 -7
  147. data/lib/rhoconnect/api/client/get_client_params.rb +4 -4
  148. data/lib/rhoconnect/api/client/list_client_docs.rb +17 -17
  149. data/lib/rhoconnect/api/client/register.rb +12 -12
  150. data/lib/rhoconnect/api/client/reset.rb +5 -5
  151. data/lib/rhoconnect/api/readstate/set_refresh_time.rb +9 -9
  152. data/lib/rhoconnect/api/source/get_source_params.rb +4 -4
  153. data/lib/rhoconnect/api/source/list_sources.rb +16 -16
  154. data/lib/rhoconnect/api/source/update_source_params.rb +6 -6
  155. data/lib/rhoconnect/api/store/get_db_doc.rb +4 -4
  156. data/lib/rhoconnect/api/store/set_db_doc.rb +7 -7
  157. data/lib/rhoconnect/api/system/get_adapter.rb +4 -4
  158. data/lib/rhoconnect/api/system/get_license_info.rb +8 -8
  159. data/lib/rhoconnect/api/system/login.rb +15 -15
  160. data/lib/rhoconnect/api/system/reset.rb +11 -11
  161. data/lib/rhoconnect/api/system/save_adapter.rb +4 -4
  162. data/lib/rhoconnect/api/system/stats.rb +22 -22
  163. data/lib/rhoconnect/api/user/create_user.rb +7 -7
  164. data/lib/rhoconnect/api/user/delete_client.rb +6 -6
  165. data/lib/rhoconnect/api/user/delete_user.rb +11 -10
  166. data/lib/rhoconnect/api/user/list_clients.rb +4 -4
  167. data/lib/rhoconnect/api/user/list_source_docs.rb +10 -10
  168. data/lib/rhoconnect/api/user/list_users.rb +3 -3
  169. data/lib/rhoconnect/api/user/ping.rb +3 -3
  170. data/lib/rhoconnect/api/user/show_user.rb +3 -3
  171. data/lib/rhoconnect/api/user/update_user.rb +5 -5
  172. data/lib/rhoconnect/api/user/user_get_db_doc.rb +5 -5
  173. data/lib/rhoconnect/api/user/user_set_db_doc.rb +10 -10
  174. data/lib/rhoconnect/api_token.rb +5 -6
  175. data/lib/rhoconnect/app.rb +6 -46
  176. data/lib/rhoconnect/application/init.rb +5 -2
  177. data/lib/rhoconnect/async.rb +76 -39
  178. data/lib/rhoconnect/bulk_data/bulk_data.rb +6 -4
  179. data/lib/rhoconnect/client.rb +59 -9
  180. data/lib/rhoconnect/condition/admin_required.rb +27 -0
  181. data/lib/rhoconnect/condition/client_required.rb +50 -0
  182. data/lib/rhoconnect/condition/login_required.rb +22 -0
  183. data/lib/rhoconnect/condition/source_required.rb +49 -0
  184. data/lib/rhoconnect/condition/verbs.rb +17 -0
  185. data/lib/rhoconnect/condition/verify_success.rb +19 -0
  186. data/lib/rhoconnect/controller/app_base.rb +74 -0
  187. data/lib/rhoconnect/controller/base.rb +68 -0
  188. data/lib/rhoconnect/controller/clients_controller.rb +79 -0
  189. data/lib/rhoconnect/controller/dynamic_adapter_controller.rb +93 -0
  190. data/lib/rhoconnect/controller/js_base.rb +124 -0
  191. data/lib/rhoconnect/controller/read_state_controller.rb +22 -0
  192. data/lib/rhoconnect/controller/source_adapter_base.rb +14 -0
  193. data/lib/rhoconnect/controller/sources_controller.rb +44 -0
  194. data/lib/rhoconnect/controller/store_controller.rb +25 -0
  195. data/lib/rhoconnect/controller/system_controller.rb +67 -0
  196. data/lib/rhoconnect/controller/users_controller.rb +99 -0
  197. data/lib/rhoconnect/db_adapter.rb +1 -3
  198. data/lib/rhoconnect/document.rb +159 -50
  199. data/lib/rhoconnect/handler/authenticate/execute_methods.rb +77 -0
  200. data/lib/rhoconnect/handler/authenticate/runner.rb +49 -0
  201. data/lib/rhoconnect/handler/authenticate.rb +3 -0
  202. data/lib/rhoconnect/handler/bulk_data.rb +28 -0
  203. data/lib/rhoconnect/handler/changes/engine.rb +271 -0
  204. data/lib/rhoconnect/handler/changes/execute_methods.rb +88 -0
  205. data/lib/rhoconnect/handler/changes/pass_through_runner.rb +11 -0
  206. data/lib/rhoconnect/handler/changes/runner.rb +53 -0
  207. data/lib/rhoconnect/handler/changes.rb +31 -0
  208. data/lib/rhoconnect/handler/helpers/auth_method.rb +29 -0
  209. data/lib/rhoconnect/handler/helpers/binding.rb +18 -0
  210. data/lib/rhoconnect/handler/helpers/bulk_data.rb +53 -0
  211. data/lib/rhoconnect/handler/helpers/source_job.rb +14 -0
  212. data/lib/rhoconnect/handler/helpers.rb +4 -0
  213. data/lib/rhoconnect/handler/plugin_callbacks/execute_methods.rb +99 -0
  214. data/lib/rhoconnect/handler/plugin_callbacks/runner.rb +28 -0
  215. data/lib/rhoconnect/handler/plugin_callbacks.rb +67 -0
  216. data/lib/rhoconnect/handler/query/engine.rb +93 -0
  217. data/lib/rhoconnect/handler/query/execute_methods.rb +21 -0
  218. data/lib/rhoconnect/handler/query/pass_through_runner.rb +35 -0
  219. data/lib/rhoconnect/handler/query/runner.rb +270 -0
  220. data/lib/rhoconnect/handler/query.rb +19 -0
  221. data/lib/rhoconnect/handler/search/engine.rb +60 -0
  222. data/lib/rhoconnect/handler/search/execute_methods.rb +32 -0
  223. data/lib/rhoconnect/handler/search/pass_through_runner.rb +18 -0
  224. data/lib/rhoconnect/handler/search/runner.rb +104 -0
  225. data/lib/rhoconnect/handler/search.rb +26 -0
  226. data/lib/rhoconnect/handler/sync.rb +29 -0
  227. data/lib/rhoconnect/jobs/source_job.rb +13 -4
  228. data/lib/rhoconnect/js_adapter.rb +79 -0
  229. data/lib/rhoconnect/license.rb +10 -2
  230. data/lib/rhoconnect/middleware/current_user.rb +14 -1
  231. data/lib/rhoconnect/middleware/helpers.rb +10 -93
  232. data/lib/rhoconnect/middleware/x_domain_session_wrapper.rb +1 -1
  233. data/lib/rhoconnect/model/base.rb +229 -0
  234. data/lib/rhoconnect/model/dynamic_adapter_model.rb +90 -0
  235. data/lib/rhoconnect/model/js_base.rb +121 -0
  236. data/lib/rhoconnect/ping/android.rb +1 -1
  237. data/lib/rhoconnect/predefined_adapters/bench_adapter.rb +7 -4
  238. data/lib/rhoconnect/read_state.rb +3 -3
  239. data/lib/rhoconnect/server.rb +159 -190
  240. data/lib/rhoconnect/source.rb +100 -11
  241. data/lib/rhoconnect/stats/record.rb +10 -10
  242. data/lib/rhoconnect/store.rb +905 -591
  243. data/lib/rhoconnect/{model.rb → store_orm.rb} +53 -115
  244. data/lib/rhoconnect/tasks.rb +18 -4
  245. data/lib/rhoconnect/test_methods.rb +30 -17
  246. data/lib/rhoconnect/user.rb +35 -17
  247. data/lib/rhoconnect/utilities.rb +1 -1
  248. data/lib/rhoconnect/version.rb +2 -2
  249. data/lib/rhoconnect/web-console/server.rb +29 -14
  250. data/lib/rhoconnect/web-console/views/home.js +10 -10
  251. data/lib/rhoconnect/web-console/views/new_ping.js +1 -1
  252. data/lib/rhoconnect.rb +120 -51
  253. data/rhoconnect.gemspec +4 -3
  254. data/spec/api/api_helper.rb +1 -6
  255. data/spec/api/app/fast_delete_spec.rb +4 -4
  256. data/spec/api/app/fast_insert_spec.rb +4 -4
  257. data/spec/api/app/fast_update_spec.rb +8 -8
  258. data/spec/api/app/push_deletes_spec.rb +2 -2
  259. data/spec/api/app/push_objects_spec.rb +5 -5
  260. data/spec/api/client/client_get_db_doc_spec.rb +6 -4
  261. data/spec/api/client/client_set_db_doc_spec.rb +3 -2
  262. data/spec/api/client/get_client_params_spec.rb +14 -0
  263. data/spec/api/client/list_client_docs_spec.rb +30 -20
  264. data/spec/api/client/reset_spec.rb +36 -0
  265. data/spec/api/source/get_source_params_spec.rb +23 -17
  266. data/spec/api/system/get_license_info_spec.rb +0 -20
  267. data/spec/api/system/login_spec.rb +8 -0
  268. data/spec/api/system/reset_spec.rb +0 -1
  269. data/spec/api/system/stats_spec.rb +5 -5
  270. data/spec/api/user/create_user_spec.rb +14 -6
  271. data/spec/api/user/delete_user_spec.rb +20 -18
  272. data/spec/api/user/list_users_spec.rb +5 -6
  273. data/spec/api/user/update_user_spec.rb +5 -4
  274. data/spec/apps/rhotestapp/config.ru +16 -1
  275. data/spec/apps/rhotestapp/controllers/js/js_sample_controller.js +23 -0
  276. data/spec/apps/rhotestapp/controllers/js/sample2_controller.js +32 -0
  277. data/spec/apps/rhotestapp/controllers/ruby/application_controller.rb +21 -0
  278. data/spec/apps/rhotestapp/controllers/ruby/sample_adapter_controller.rb +8 -0
  279. data/spec/apps/rhotestapp/models/js/js_sample.js +55 -0
  280. data/spec/apps/rhotestapp/models/js/sample2.js +25 -0
  281. data/spec/apps/rhotestapp/{sources → models/ruby}/base_adapter.rb +0 -0
  282. data/spec/apps/rhotestapp/{sources → models/ruby}/fixed_schema_adapter.rb +0 -0
  283. data/spec/apps/rhotestapp/{sources → models/ruby}/other_adapter.rb +0 -0
  284. data/spec/apps/rhotestapp/{sources → models/ruby}/sample_adapter.rb +0 -0
  285. data/spec/apps/rhotestapp/{sources → models/ruby}/simple_adapter.rb +2 -2
  286. data/spec/apps/rhotestapp/{sources → models/ruby}/sub_adapter.rb +0 -0
  287. data/spec/apps/rhotestapp/settings/settings.yml +0 -1
  288. data/spec/bulk_data/bulk_data_spec.rb +20 -5
  289. data/spec/cli/cli_spec.rb +83 -0
  290. data/spec/client_spec.rb +20 -17
  291. data/spec/client_sync_spec.rb +244 -406
  292. data/spec/controllers/js_base_spec.rb +89 -0
  293. data/spec/doc/doc_spec.rb +18 -18
  294. data/spec/document_spec.rb +29 -13
  295. data/spec/dynamic_adapter_spec.rb +6 -6
  296. data/spec/generator/generator_spec.rb +7 -4
  297. data/spec/jobs/bulk_data_job_spec.rb +14 -10
  298. data/spec/jobs/source_job_spec.rb +8 -8
  299. data/spec/license_spec.rb +5 -2
  300. data/spec/models/js_model_spec.rb +39 -0
  301. data/spec/node_spec.rb +42 -0
  302. data/spec/perf/store_perf_spec.rb +67 -12
  303. data/spec/ping/android_spec.rb +1 -1
  304. data/spec/read_state_spec.rb +1 -1
  305. data/spec/rhoconnect_spec.rb +1 -1
  306. data/spec/server/cors_spec.rb +14 -18
  307. data/spec/server/server_spec.rb +265 -88
  308. data/spec/server/stats_spec.rb +1 -1
  309. data/spec/source_adapter_spec.rb +54 -27
  310. data/spec/source_spec.rb +8 -3
  311. data/spec/source_sync_spec.rb +538 -468
  312. data/spec/spec_helper.rb +35 -4
  313. data/spec/stats/record_spec.rb +10 -10
  314. data/spec/{model_spec.rb → store_orm_spec.rb} +56 -54
  315. data/spec/store_spec.rb +159 -179
  316. data/spec/support/shared_examples.rb +36 -27
  317. data/spec/sync_states_spec.rb +40 -33
  318. data/spec/test_methods_spec.rb +18 -14
  319. data/spec/user_spec.rb +17 -30
  320. metadata +156 -52
  321. data/bench/benchapp/application.rb +0 -39
  322. data/bench/blobapp/application.rb +0 -44
  323. data/commands/rhoconnect/clean_start.rb +0 -9
  324. data/commands/rhoconnect/create_user.rb +0 -18
  325. data/commands/rhoconnect/delete_device.rb +0 -9
  326. data/commands/rhoconnect/delete_user.rb +0 -8
  327. data/commands/rhoconnect/reset.rb +0 -16
  328. data/commands/rhoconnect/reset_refresh.rb +0 -11
  329. data/generators/templates/application/application.rb +0 -43
  330. data/lib/rhoconnect/client_sync.rb +0 -434
  331. data/lib/rhoconnect/dynamic_adapter.rb +0 -91
  332. data/lib/rhoconnect/middleware/admin_user.rb +0 -23
  333. data/lib/rhoconnect/middleware/current_request.rb +0 -16
  334. data/lib/rhoconnect/middleware/login_required.rb +0 -22
  335. data/lib/rhoconnect/source_adapter.rb +0 -132
  336. data/lib/rhoconnect/source_sync.rb +0 -464
  337. data/spec/apps/rhotestapp/application.rb +0 -23
@@ -1,13 +1,9 @@
1
- RhoConnect Source Adapters
1
+ RhoConnect Source Adapters (Ruby)
2
2
  ===
3
3
 
4
- Connecting to a backend service with RhoConnect requires that you write a small amount of code for the query, create, update and delete operations of your particular enterprise backend. One way to do this is through a RhoConnect source adapter, which is a collection of Ruby code for these operations.
5
-
6
- You can generate a RhoConnect source adapter with RhoStudio or with the `rhoconnect` utility command line tool.
7
-
8
4
  ## Generating the Source Adapter from RhoStudio
9
5
 
10
- To generate a RhoConnect source adapter and create the associated Controller templates, open your Rhoconnect project in RhoStudio. Then right-click on the project in the Project Explorer and select New->Rhoconnect Source Adapter.
6
+ To generate a RhoConnect source adapter and create the associated Controller/Model templates, open your RhoConnect project in RhoStudio. Then right-click on the project in the Project Explorer and select New->RhoConnect Source Adapter.
11
7
 
12
8
  <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-tutorial/menu-new-rhoconnect_source-adapter.png"/>
13
9
 
@@ -23,347 +19,314 @@ After pressing the Finish button, you'll see the RhoConnect source adapter gener
23
19
 
24
20
  ## Generating the Source Adapter from the Command Line
25
21
 
26
- To generate a source for your RhoConnect application, you can run the `rhoconnect source` command within your application directory.
27
-
28
- :::term
29
- Usage: rhoconnect source name [options] [args]
30
-
31
- Generates a new source adapter.
32
-
33
- Required:
34
- name - the source name(i.e. product)
22
+ To generate a source adapter for your RhoConnect application, you can run the `rhoconnect source` command within your application directory.
35
23
 
24
+ :::term
25
+ $ rhoconnect source
26
+ Usage: rhoconnect source name [options] [args]
36
27
 
37
- Options specific for this generator:
28
+ Generates a new source adapter.
38
29
 
39
- General options:
40
- -p, --pretend Run, but do not make any changes.
41
- -f, --force Overwrite files that already exist.
42
- -s, --skip Skip files that already exist.
43
- -d, --delete Delete files that have previously been generated with this generator.
44
- --no-color Don't colorize the output
45
- -h, --help Show this message
46
- --debug Do not catch errors
30
+ Required:
31
+ name - the source adapter name(i.e. product)
47
32
 
48
- For the storeserver application example, within the sourceserver directory, run:
49
33
 
50
- :::term
51
- $ rhoconnect source product
52
- Generating with source generator:
53
- [ADDED] sources/product.rb
54
- [ADDED] spec/sources/product_spec.rb
34
+ Options specific for this generator:
55
35
 
56
- ## Understanding the Generated Source Adapter Files
36
+ General options:
37
+ -p, --pretend Run, but do not make any changes.
38
+ -f, --force Overwrite files that already exist.
39
+ -s, --skip Skip files that already exist.
40
+ -d, --delete Delete files that have previously been generated with this generator.
41
+ --no-color Don't colorize the output
42
+ -h, --help Show this message
43
+ --debug Do not catch errors
57
44
 
58
- Generating a source adapter named "product" will generate a new ruby class called `sources/product.rb`:
45
+ For the storeserver application example, within the storeserver directory, run:
59
46
 
60
- :::ruby
61
- class Product < SourceAdapter
62
- def initialize(source)
63
- super(source)
64
- end
47
+ :::term
48
+ $ rhoconnect source product
49
+ Generating with source generator:
50
+ [ADDED] models/ruby/product.rb
51
+ [ADDED] controllers/ruby/product_controller.rb
52
+ [ADDED] spec/models/ruby/product_spec.rb
53
+ [ADDED] spec/controllers/ruby/product_controller_spec.rb
65
54
 
66
- def login
67
- # TODO: Login to your data source here if necessary
68
- end
55
+ ## Understanding the Generated Controller File
69
56
 
70
- def query
71
- # TODO: Query your backend data source and assign the records
72
- # to a nested hash structure called @result. For example:
73
- # @result = {
74
- # "1"=>{"name"=>"Acme", "industry"=>"Electronics"},
75
- # "2"=>{"name"=>"Best", "industry"=>"Software"}
76
- # }
77
- raise SourceAdapterException.new("Please provide some code to read records from the backend data source")
78
- end
57
+ The generated source adapter's controller file (in this case, product_controller.rb) is similar to the code listing below.
58
+ Its purpose is to define the RhoConnect application HTTP end point and to register the corresponding SYNC routes.
59
+ Under the hood - it's an isolated Sinatra application designated to handle all incoming Product requests:
79
60
 
80
- def sync
81
- super
82
- end
61
+ :::ruby
62
+ class ProductController < Rhoconnect::Controller::Base
63
+ register Rhoconnect::EndPoint
83
64
 
84
- def create(create_hash)
85
- # TODO: Create a new record in your backend data source
86
- # If your rhodes rhom object contains image/binary data
87
- # (has the image_uri attribute), then a blob will be provided
88
- raise "Please provide some code to create a single record in the backend data source using the create_hash"
89
- end
65
+ # add all SYNC routes
66
+ register Rhoconnect::Handler::Sync
90
67
 
91
- def update(update_hash)
92
- # TODO: Update an existing record in your backend data source
93
- raise "Please provide some code to update a single record in the backend data source using the update_hash"
94
- end
68
+ # add your custom Product routes here
69
+ end
95
70
 
96
- def delete(delete_hash)
97
- # TODO: write some code here if applicable
98
- # be sure to have a hash key and value for "object"
99
- # for now, we'll say that its OK to not have a delete operation
100
- # raise "Please provide some code to delete a single object in the backend application using the object_id"
101
- end
71
+ ## Understanding the Generated Model File
72
+
73
+ The generated source adapter's model file (in this case, product.rb) is similar to the code listing below:
74
+
75
+ :::ruby
76
+ class Product < Rhoconnect::Model::Base
77
+ def initialize(source)
78
+ super(source)
79
+ end
80
+
81
+ def login
82
+ # TODO: Login to your data source here if necessary
83
+ end
84
+
85
+ def query
86
+ # TODO: Query your backend data source and assign the records
87
+ # to a nested hash structure called @result. For example:
88
+ # @result = {
89
+ # "1"=>{"name"=>"Acme", "industry"=>"Electronics"},
90
+ # "2"=>{"name"=>"Best", "industry"=>"Software"}
91
+ # }
92
+ raise Rhoconnect::Model::Exception.new("Please provide some code to read records from the backend data source")
93
+ end
94
+
95
+ def create(create_hash)
96
+ # TODO: Create a new record in your backend data source
97
+ # If your rhodes rhom object contains image/binary data
98
+ # (has the image_uri attribute), then a blob will be provided
99
+ raise "Please provide some code to create a single record in the backend data source using the create_hash"
100
+ end
101
+
102
+ def update(update_hash)
103
+ # TODO: Update an existing record in your backend data source
104
+ raise "Please provide some code to update a single record in the backend data source using the update_hash"
105
+ end
106
+
107
+ def delete(delete_hash)
108
+ # TODO: write some code here if applicable
109
+ # be sure to have a hash key and value for "object"
110
+ # for now, we'll say that its OK to not have a delete operation
111
+ # raise "Please provide some code to delete a single object in the backend application using the object_id"
112
+ end
113
+
114
+ def logoff
115
+ # TODO: Logout from the data source if necessary
116
+ end
117
+ end
102
118
 
103
- def logoff
104
- # TODO: Logout from the data source if necessary
105
- end
106
- end
119
+ During generation of the model, the `settings/settings.yml` file will be updated with some default options for the corresponding source:
107
120
 
108
- It also adds a corresponding [rspec](http://rspec.info/) file `spec/sources/product_spec.rb` and updates `settings/settings.yml` with the product adapter to the sources section with some default options:
121
+ :::yaml
122
+ :sources:
123
+ Product:
124
+ :poll_interval: 300
109
125
 
110
- :::yaml
111
- :sources:
112
- Product:
113
- :poll_interval: 300
114
126
 
115
127
  ## Source Adapter API
116
- The source adapter interface is described below, your source adapter can use any of these methods to interact with your backend service.
117
-
118
- ### `login`
119
- Login to your backend service (optional).
120
-
121
- :::ruby
122
- def login
123
- MyWebService.login(current_user.login)
124
- end
125
-
126
- ### `logoff`
127
- Logoff from your backend service (optional).
128
-
129
- :::ruby
130
- def logoff
131
- MyWebService.logoff(current_user.login)
132
- end
133
-
134
- ### `query(params = nil)`
135
- Query your backend service and build a hash of hashes (required).
136
-
137
- **NOTE: This method must assign `@result` to a hash of hashes. If @result is `nil` or `{}`, the master document will be erased from redis.**
138
-
139
- :::ruby
140
- def query
141
- parsed = JSON.parse(RestClient.get("#{@base}.json").body)
142
-
143
- @result = {}
144
- parsed.each do |item|
145
- @result[item["product"]["id"].to_s] = item["product"]
146
- end if parsed
147
- end
148
-
149
- ### `search(params)`
150
- Search your backend based on params and build a hash of hashes (optional). Similar to query, however the master document accumulates the data in `@result` instead of replacing when it runs.
151
-
152
- :::ruby
153
- def search(params)
154
- parsed = JSON.parse(RestClient.get("#{@base}.json").body)
155
-
156
- @result = {}
157
- parsed.each do |item|
158
- if item["product"]["name"].downcase == params['name'].downcase
159
- @result[item["product"]["id"].to_s] = item["product"]
160
- end
161
- end if parsed
162
- end
163
-
164
- Next, you will need to add search to your Rhodes application. For details, see the [Rhodes search section](/rhodes/synchronization#filtering-datasets-with-search).
165
128
 
166
- ### `create(create_hash)`
167
- Create a new record in the backend (optional).
129
+ ### Source Adapter Controller API (Ruby)
168
130
 
169
- **NOTE: RhoConnect can establish a 'link' between the local record id provided by the client and the new record id provided by the backend service. To enable this link, return the new record id as a string.**
131
+ You can use the following methods and techniques inside of your source adapter controller.
170
132
 
171
- :::ruby
172
- def create(create_hash)
173
- res = MyWebService.create(create_hash)
133
+ * [@model](/rhoconnectapi/source-adapter-controller-api-ruby#@model) - Access to the source adapter's model instance.
134
+ * [params,request,response](/rhoconnectapi/source-adapter-controller-api-ruby#sinatra-context) - Allows to use any standard Sinatra context objects.
135
+ * [Sinatra framework](/rhoconnectapi/source-adapter-controller-api-ruby#sinatra-features) - Allows to use any standard Sinatra features.
174
136
 
175
- # return new product id so we establish a client link
176
- res.new_id
177
- end
137
+ ### Source Adapter Model API (Ruby)
178
138
 
179
- ### `update(update_hash)`
180
- Update an existing record in the backend (optional).
139
+ You can write the following methods for your source adapter model. These methods will be called by the controller at run-time and allow your source adapter model to interact with your backend service.
181
140
 
182
- :::ruby
183
- def update(update_hash)
184
- end
185
-
186
- ### `delete(delete_hash)`
187
- Delete an existing record in the backend (optional).
188
-
189
- :::ruby
190
- def delete(delete_hash)
191
- MyWebService.delete(delete_hash['id'])
192
- end
193
-
194
- ### `current_user`
195
- Returns the current user which called the adapter. For example, you could filter results for a specific user in your query method:
196
-
197
- :::ruby
198
- def query
199
- @result = MyWebService.get_records_for_user(current_user.login)
200
- end
201
-
202
- ### `stash_result`
203
- Saves the current state of `@result` to redis and assigns it to `nil`. Typically this is used when your adapter has to paginate through backend service data.
204
-
205
- :::ruby
206
- def query
207
- @result = {}
208
- ('a'..'z').each_with_index do |letter,i|
209
- @result ||= {}
210
- @result.merge!( DictionaryService.get_records_for(letter) )
211
- stash_result if i % 2 == 0
212
- end
213
- end
141
+ * [login](/rhoconnectapi/source-adapter-model-api-ruby#login) - Login to your backend service (optional).
142
+ * [logoff](/rhoconnectapi/source-adapter-model-api-ruby#logoff) - Logoff from your backend service (optional).
143
+ * [query](/rhoconnectapi/source-adapter-model-api-ruby#query) - Query your backend service and build a hash of hashes (required).
144
+ * [search](/rhoconnectapi/source-adapter-model-api-ruby#search) - Search your backend based on params and build a hash of hashes (optional).
145
+ * [create](/rhoconnectapi/source-adapter-model-api-ruby#create) - Create a new record in the backend (optional).
146
+ * [update](/rhoconnectapi/source-adapter-model-api-ruby#update) - Update an existing record in the backend.
147
+ * [delete](/rhoconnectapi/source-adapter-model-api-ruby#delete) - Delete an existing record in the backend.
148
+ * [current_user](/rhoconnectapi/source-adapter-model-api-ruby#currentuser) - Returns the current user which called the adapter's model.
149
+ * [stash_result](/rhoconnectapi/source-adapter-model-api-ruby#stashresult) - Saves the current state of `@result` to redis and assigns it to `nil`.
150
+ * [store_blob](/rhoconnectapi/source-adapter-model-api-ruby#store_blob) - Save the incoming blob data into permanent storage for the future processing.
151
+ * [get_data](/rhoconnectapi/source-adapter-model-api-ruby#get_data) - Get the model document data from Store.
214
152
 
215
153
  ## Data Partitioning
154
+
216
155
  Data is stored in RhoConnect using [redis sets](http://redis.io/commands#set). The `@result` hash from the `query` method is stored in redis and referred to as the Master Document or MD.
217
156
 
218
- The MD is referenced in RhoConnect by a corresponding partition. Source adapters can partition data in two ways: user and app. As you might have guessed, user partitioning stores a copy of the source adapter MD for each user (one copy shared across all devices for a user).
157
+ The MD is referenced in RhoConnect by a corresponding partition. Source adapters can partition data in two ways: user and app. As you might have guessed, user partitioning stores a copy of the source adapter MD for each user (one copy shared across all devices for a given user).
219
158
 
220
- Likewise, app partitioning stores one copy of the source adapter MD for the entire application (all users and devices share the same data). App partitioning can be particularly useful if you have source adapters which retrieve large amounts of data that is fixed from user to user, for example a global product catalog. Using app partitioning wherever possible ***greatly reduces*** the amount of data in redis.
159
+ Likewise, app partitioning stores one copy of the source adapter MD for the entire application (all users and devices share the same data). App partitioning can be particularly useful if you have source adapter models which retrieve large amounts of data that is fixed from user to user, for example a global product catalog. Using app partitioning wherever possible ***greatly reduces*** the amount of data in redis.
221
160
 
222
161
  ### User Partition
223
- User partitioning is the default scheme for source adapters, however you can explicitly define it in `settings/settings.yml` with:
162
+ User partitioning is the default mode for source adapters, however you can explicitly define it in `settings/settings.yml` with:
224
163
 
225
- :::yaml
226
- :sources:
227
- Product:
228
- :poll_interval: 300
229
- :partition_type: user
164
+ :::yaml
165
+ :sources:
166
+ Product:
167
+ :poll_interval: 300
168
+ :partition_type: user
230
169
 
231
170
  ### App Partition
232
171
  Enable app partitioning the same way:
233
172
 
234
- :::yaml
235
- :sources:
236
- Product:
237
- :poll_interval: 300
238
- :partition_type: app
173
+ :::yaml
174
+ :sources:
175
+ Product:
176
+ :poll_interval: 300
177
+ :partition_type: app
239
178
 
240
179
  Now you have a single copy of the `Product` source adapter dataset for all users.
241
180
 
242
181
  ## Pass Through
243
- RhoConnect provides a simple way to keep data out of redis. If you have sensitive data that you do not want saved in redis, add the pass_through option in settings/settings.yml for each source:
182
+ RhoConnect provides a simple way to keep data out of redis. If you have sensitive data that you do not want saved in redis, add the `pass_through` option in settings/settings.yml for each source:
244
183
 
245
- :::yaml
246
- :sources:
247
- Product:
248
- :pass_through: true
184
+ :::yaml
185
+ :sources:
186
+ Product:
187
+ :pass_through: true
249
188
 
250
189
  **NOTE: When running query or search the entire data set will be returned from your backend service. **
251
190
 
252
191
  ## Redis Interface
253
192
  RhoConnect provides a simple redis interface for saving/retrieving arbitrary data. This is useful if you want to save data in your application to be used later (i.e. in an async job or a subsequent source adapter execution).
254
193
 
255
- :::ruby
256
- Store.put_value('hello','world')
194
+ :::ruby
195
+ Store.put_value('hello','world')
257
196
 
258
- Store.get_value('hello') #=> 'world'
197
+ Store.get_value('hello') #=> 'world'
259
198
 
260
- # You can store nested hashes too!
261
- Store.put_data(
262
- 'mydata',
263
- {
264
- '1' => { 'hello' => 'world' }
265
- }
266
- )
199
+ # You can store nested hashes too!
200
+ Store.put_data(
201
+ 'mydata',
202
+ {
203
+ '1' => { 'hello' => 'world' }
204
+ }
205
+ )
267
206
 
268
- Store.get_data('mydata') #=> { '1' => { 'hello' => 'world' } }
207
+ Store.get_data('mydata') #=> { '1' => { 'hello' => 'world' } }
269
208
 
270
209
  ## Handling Exceptions
271
- If your source adapter raises an instance of `SourceAdapterException`, the resulting message will be sent to the client's sync callback(in `@params['error_message']`). See the rhodes [sync exception handling docs](/rhodes/synchronization#handling-exceptions) for more details.
210
+ If your source adapter model raises an instance of `Rhoconnect::Model::Exception`, the resulting message will be sent to the client's sync callback(in `@params['error_message']`). See the rhodes [sync exception handling docs](/rhodes/synchronization#handling-exceptions) for more details.
272
211
 
273
- You can use `SourceAdapterException` as a convenient way to notify your application of various error conditions.
212
+ You can use `Rhoconnect::Model::Exception` as a convenient way to notify your application of various error conditions.
274
213
 
275
214
  For example, your delete method might check the web service HTTP response code was 200 to make sure the record was deleted:
276
215
 
277
- :::ruby
278
- def delete(delete_hash)
279
- rest_result = RestClient.delete("#{@base}/#{delete_hash['id']}")
280
- if rest_result.code != 200
281
- raise SourceAdapterException.new("Error deleting record.")
282
- end
283
- end
216
+ :::ruby
217
+ def delete(delete_hash)
218
+ rest_result = RestClient.delete("#{@base}/#{delete_hash['id']}")
219
+ if rest_result.code != 200
220
+ raise Rhoconnect::Model::Exception.new("Error deleting record.")
221
+ end
222
+ end
284
223
 
285
224
  **NOTE: When your adapter method raises an exception, no data is removed from the adapter's master document.**
286
225
 
287
226
  The following exceptions are provided for convenience:
288
227
 
289
- ### `SourceAdapterLoginException`
290
- Useful to raise in your adapter's login method if it failed.
228
+ ### `Rhoconnect::Model::LoginException`
229
+ Useful to raise in your model's login method if it failed.
291
230
 
292
- ### `SourceAdapterLogoffException`
293
- Similar to login, raise this if your adapter's logoff failed.
231
+ ### `Rhoconnect::Model::LogoffException`
232
+ Similar to login, raise this if your model's logoff failed.
294
233
 
295
- ### `SourceAdapterServerTimeoutException`
234
+ ### `Rhoconnect::Model::ServerTimeoutException`
296
235
  Raise if your backend service connection times out.
297
236
 
298
- ### `SourceAdapterServerErrorException`
237
+ ### `Rhoconnect::Model::ServerErrorException`
299
238
  Raise this if your backend service returns a non-successful response.
300
239
 
301
240
 
302
241
  ## Handling Conflicts
303
242
 
304
- Handling conflicts in RhoConnect follows the same pattern as handling exceptions. Once your adapter method has detected a conflict, you can raise a `SourceAdapterObjectConflictError` which will be sent to your application's sync callback.
243
+ Handling conflicts in RhoConnect follows the same pattern as handling exceptions. Once your model method has detected a conflict, you can raise a `Rhoconnect::Model::ObjectConflictError` which will be sent to your application's sync callback.
305
244
 
306
- ### `SourceAdapterObjectConflictError`
307
- Raise this if your adapter has detected a conflict.
245
+ ### `Rhoconnect::Model::ObjectConflictError`
246
+ Raise this if your model has detected a conflict.
308
247
 
309
- :::ruby
310
- def update(update_hash)
248
+ :::ruby
249
+ def update(update_hash)
311
250
  obj_id = update_hash['id']
312
251
  update_hash.delete('id')
313
252
  rest_result = RestClient.put("#{@base}/#{obj_id}",:product => update_hash)
314
- if rest_result.code != 200
315
- raise SourceAdapterObjectConflictError.new("Conflict detected updating the object.")
316
- end
253
+ if rest_result.code != 200
254
+ raise Rhoconnect::Model::ObjectConflictError.new("Conflict detected updating the object.")
255
+ end
256
+ end
257
+
258
+ ## Sample Model
259
+ Here's a complete example of how the completed [product model might look](https://github.com/rhomobile/store-server/blob/master/sources/product.rb):
260
+
261
+ :::ruby
262
+ require 'json'
263
+ require 'rest_client'
264
+
265
+ class Product < Rhoconnect::Model::Base
266
+
267
+ def initialize(source)
268
+ @base = 'http://rhostore.herokuapp.com/products'
269
+ super(source)
270
+ end
271
+
272
+ def query(params=nil)
273
+ rest_result = RestClient.get("#{@base}.json").body
274
+
275
+ if rest_result.code != 200
276
+ raise Rhoconnect::Model::Exception.new("Error connecting!")
277
+ end
278
+ parsed = JSON.parse(rest_result)
279
+
280
+ @result={}
281
+ parsed.each do |item|
282
+ @result[item["product"]["id"].to_s] = item["product"]
283
+ end if parsed
284
+ end
285
+
286
+ def create(create_hash)
287
+ res = RestClient.post(@base,:product => create_hash)
288
+
289
+ # After create we are redirected to the new record.
290
+ # We need to get the id of that record and return
291
+ # it as part of create so rhoconnect can establish a link
292
+ # from its temporary object on the client to this newly
293
+ # created object on the server
294
+ JSON.parse(
295
+ RestClient.get("#{res.headers[:location]}.json").body
296
+ )["product"]["id"]
297
+ end
298
+
299
+ def update(update_hash)
300
+ obj_id = update_hash['id']
301
+ update_hash.delete('id')
302
+ RestClient.put("#{@base}/#{obj_id}",:product => update_hash)
303
+ end
304
+
305
+ def delete(delete_hash)
306
+ RestClient.delete("#{@base}/#{delete_hash['id']}")
307
+ end
317
308
  end
318
309
 
319
- ## Sample Adapter
320
- Here's a complete example of how the completed [product adapter might look](https://github.com/rhomobile/store-server/blob/master/sources/product.rb):
321
-
322
- :::ruby
323
- require 'json'
324
- require 'rest_client'
325
-
326
- class Product < SourceAdapter
327
-
328
- def initialize(source)
329
- @base = 'http://rhostore.herokuapp.com/products'
330
- super(source)
331
- end
332
-
333
- def query(params=nil)
334
- rest_result = RestClient.get("#{@base}.json").body
335
-
336
- if rest_result.code != 200
337
- raise SourceAdapterException.new("Error connecting!")
338
- end
339
- parsed = JSON.parse(rest_result)
340
-
341
- @result={}
342
- parsed.each do |item|
343
- @result[item["product"]["id"].to_s] = item["product"]
344
- end if parsed
345
- end
346
-
347
- def create(create_hash)
348
- res = RestClient.post(@base,:product => create_hash)
349
-
350
- # After create we are redirected to the new record.
351
- # We need to get the id of that record and return
352
- # it as part of create so rhoconnect can establish a link
353
- # from its temporary object on the client to this newly
354
- # created object on the server
355
- JSON.parse(
356
- RestClient.get("#{res.headers[:location]}.json").body
357
- )["product"]["id"]
358
- end
359
-
360
- def update(update_hash)
361
- obj_id = update_hash['id']
362
- update_hash.delete('id')
363
- RestClient.put("#{@base}/#{obj_id}",:product => update_hash)
364
- end
365
-
366
- def delete(delete_hash)
367
- RestClient.delete("#{@base}/#{delete_hash['id']}")
368
- end
369
- end
310
+ ## Compatibility with older versions of RhoConnect
311
+
312
+ The RhoConnect Source Adapter Controller/Model concept has been introduced in RhoConnect 4. In previous versions, a Source Adapter consisted only of one class - which is now has been moved to Source Adapter model. "Controller" part of the Source Adapter has been hidden inside of the RhoConnect library code. This posed a significant obstacle in a way how the developer could utilize the code and the common techniques. To overcome this obstacle, RhoConnect 4 provides you with direct access to the Controller allowing you to customize route behavior and utilize all of the powerful sinatra plugins/extensions that are available.
313
+
314
+ At the same time, applications that were written using the pre-4.0 versions of RhoConnect will still continue to function without modifications for at least one version cycle. This is accomplished by providing the "default" implementation of the controller for the pre-4.0 Source Adapters. All the Model APIs that are described throughout the documentation are still applicable to the pre-4.0 Source Adapters. In this sense - the RhoConnect 4 Source Adapter Model class and pre-4.0 Source Adapter are interchangeable.
315
+
316
+ However, we strongly recommend migrating your pre-4.0 application using this [guide](migration). RhoConnect 4 will print a warning at startup if it detects a pre-4.0 code structure.
317
+
318
+ RhoConnect has detected that you're using deprecated Application class.
319
+
320
+ Application class support will be removed in RhoConnect 4.1.
321
+ Please, migrate your Application class into ApplicationController.
322
+
323
+ For more details, see RhoConnect Migration guidelines at
324
+ docs.rhomobile.com
325
+
326
+ RhoConnect has detected that you're using deprecated SourceAdapter classes.
327
+
328
+ SourceAdapter class support will be removed in RhoConnect 4.1.
329
+ Please, migrate your SourceAdapter classes into RhoConnect Models.
330
+
331
+ For more details, see RhoConnect Migration guidelines at
332
+ docs.rhomobile.com
@@ -11,37 +11,17 @@ To enable stats in your RhoConnect application, simply turn on the stats middlew
11
11
  A complete config.ru might look like:
12
12
 
13
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
14
+ require 'rhoconnect/application/init'
15
+
16
+ # secret is generated along with the app
17
+ Rhoconnect::Server.set :secret, 'my_secret'
36
18
 
37
- # Load our rhoconnect application
38
- require './application'
19
+ # !!! Add your custom initializers and overrides here !!!
20
+ Rhoconnect::Server.enable :stats
39
21
 
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
22
+ # run RhoConnect Application
23
+ run Rhoconnect.app
24
+
45
25
 
46
26
  Now just restart your rhoconnect application:
47
27