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.
- data/CHANGELOG.md +57 -3
- data/Gemfile +9 -7
- data/Gemfile.lock +37 -37
- data/Rakefile +18 -7
- data/bench/benchapp/Gemfile +1 -1
- data/bench/benchapp/config.ru +0 -3
- data/bench/benchapp/controllers/ruby/application.rb +17 -0
- data/bench/benchapp/controllers/ruby/application_controller.rb +17 -0
- data/bench/benchapp/controllers/ruby/mock_adapter_controller.rb +8 -0
- data/bench/benchapp/controllers/ruby/queue_mock_adapter_controller.rb +8 -0
- data/bench/benchapp/{sources → models/ruby}/mock_adapter.rb +1 -1
- data/bench/benchapp/{sources → models/ruby}/queue_mock_adapter.rb +0 -0
- data/bench/benchapp/spec/{sources → models/ruby}/mock_adapter_spec.rb +1 -1
- data/bench/benchapp/spec/{sources → models/ruby}/queue_mock_adapter_spec.rb +1 -1
- data/bench/benchapp/spec/spec_helper.rb +2 -2
- data/bench/blobapp/Gemfile +1 -1
- data/bench/blobapp/config.ru +0 -3
- data/bench/blobapp/controllers/ruby/application_controller.rb +17 -0
- data/bench/blobapp/controllers/ruby/blob_adapter_controller.rb +8 -0
- data/bench/blobapp/{sources → models/ruby}/blob_adapter.rb +9 -2
- data/bench/blobapp/spec/{sources → models/ruby}/blob_adapter_spec.rb +1 -1
- data/bench/blobapp/spec/spec_helper.rb +1 -1
- data/bench/lib/bench/cli.rb +1 -1
- data/bench/scripts/blob_cud_script.rb +1 -1
- data/bench/scripts/query_md_script.rb +1 -1
- data/bench/scripts/query_only_script.rb +1 -1
- data/bench/scripts/query_script.rb +1 -1
- data/bench/scripts/test_query_script.rb +7 -1
- data/bench/spec/mock_adapter_spec.rb +1 -1
- data/bench/spec/result_spec.rb +3 -3
- data/bin/rhoconnect +5 -3
- data/commands/dtach/dtach_install.rb +2 -2
- data/commands/execute.rb +8 -3
- data/commands/generators/app.rb +3 -3
- data/commands/generators/controller.rb +6 -0
- data/commands/generators/model.rb +6 -0
- data/commands/generators/source.rb +3 -3
- data/commands/generators/update.rb +1 -1
- data/commands/redis/redis_about.rb +2 -2
- data/commands/redis/redis_download.rb +1 -1
- data/commands/redis/redis_install.rb +4 -3
- data/commands/redis/redis_restart.rb +4 -4
- data/commands/redis/redis_start.rb +5 -4
- data/commands/redis/redis_startbg.rb +5 -4
- data/commands/redis/redis_status.rb +13 -0
- data/commands/redis/redis_stop.rb +3 -3
- data/commands/rhoconnect/config.rb +28 -16
- data/commands/rhoconnect/flushdb.rb +1 -2
- data/commands/rhoconnect/get_token.rb +15 -11
- data/commands/rhoconnect/restart.rb +13 -5
- data/commands/rhoconnect/set_admin_password.rb +8 -8
- data/commands/rhoconnect/start.rb +74 -16
- data/commands/rhoconnect/startbg.rb +1 -1
- data/commands/rhoconnect/startdebug.rb +1 -1
- data/commands/rhoconnect/stop.rb +13 -1
- data/commands/rhoconnect/web.rb +5 -5
- data/commands/rhoconnect_console/console.rb +7 -5
- data/commands/{rhoconnect → rhoconnect_spec}/spec.rb +0 -0
- data/commands/rhoconnect_war/war.rb +9 -9
- data/commands/utilities/blank_app.ru +56 -0
- data/commands/utilities/redis_runner.rb +54 -19
- data/doc/authentication.txt +80 -6
- data/doc/blob-sync.txt +104 -97
- data/doc/bulk-sync.txt +1 -1
- data/doc/client-java.txt +3 -3
- data/doc/client-objc.txt +2 -2
- data/doc/client.txt +4 -4
- data/doc/command-line.txt +105 -200
- data/doc/data-partitioning.txt +40 -0
- data/doc/deploying.txt +249 -77
- data/doc/extending-rhoconnect-server.txt +40 -57
- data/doc/heroku-addon.txt +2 -0
- data/doc/install.txt +45 -95
- data/doc/introduction.txt +1 -1
- data/doc/java-plugin.txt +365 -190
- data/doc/metadata.txt +1 -1
- data/doc/migration.txt +108 -142
- data/doc/preparing-production.txt +1 -1
- data/doc/push-backend-setup.txt +2 -0
- data/doc/push-client-setup-android.txt +78 -0
- data/doc/push-client-setup-bb.txt +81 -0
- data/doc/push-client-setup-ios.txt +70 -0
- data/doc/push-client-setup-rps.txt +200 -0
- data/doc/push-client-setup.txt +63 -66
- data/doc/push-server-setup.txt +67 -40
- data/doc/push-testing.txt +29 -0
- data/doc/push.txt +21 -6
- data/doc/rest-api.txt +128 -55
- data/doc/rhoconnect-redis-stack.txt +120 -0
- data/doc/settings.txt +4 -12
- data/doc/source-adapters-intro.txt +28 -0
- data/doc/source-adapters.txt +235 -272
- data/doc/stats-middleware.txt +9 -29
- data/doc/supported-platforms.txt +21 -30
- data/doc/testing.txt +40 -42
- data/doc/tutorial.txt +72 -57
- data/examples/simple/Gemfile +1 -1
- data/examples/simple/application.rb +4 -5
- data/examples/simple/my_server.rb +2 -2
- data/examples/simple/settings/settings.yml +1 -1
- data/generators/rhoconnect.rb +151 -50
- data/generators/templates/application/Gemfile +1 -1
- data/generators/templates/application/Rakefile +3 -3
- data/generators/templates/application/config.ru +1 -4
- data/generators/templates/application/controllers/application_controller.rb +17 -0
- data/generators/templates/application/controllers/js/application_controller.js +14 -0
- data/generators/templates/application/controllers/ruby/application_controller.rb +17 -0
- data/generators/templates/application/package.json +8 -0
- data/generators/templates/application/rcgemfile +2 -5
- data/generators/templates/application/settings/settings.yml +3 -3
- data/generators/templates/application/spec/application_controller_spec.rb +23 -0
- data/generators/templates/application/spec/js_spec.rb +25 -0
- data/generators/templates/application/spec/spec_helper.rb +21 -7
- data/generators/templates/source/controllers/js/controller.js +7 -0
- data/generators/templates/source/controllers/ruby/controller.rb +8 -0
- data/generators/templates/source/controllers/ruby/controller_spec.rb +27 -0
- data/generators/templates/source/models/js/model.js +46 -0
- data/generators/templates/source/{source_adapter.rb → models/ruby/model.rb} +15 -10
- data/generators/templates/source/{source_spec.rb → models/ruby/model_spec.rb} +1 -1
- data/install.sh +5 -5
- data/installer/unix-like/create_texts.rb +2 -2
- data/installer/unix-like/rho_connect_install_constants.rb +2 -2
- data/installer/unix-like/rho_connect_install_utilities.rb +1 -1
- data/installer/utils/constants.rb +4 -4
- data/js-adapters/ballroom.js +216 -0
- data/js-adapters/node.rb +52 -0
- data/js-adapters/node_channel.rb +181 -0
- data/js-adapters/request.js +27 -0
- data/js-adapters/response.js +57 -0
- data/js-adapters/rhoconnect_helpers.js +60 -0
- data/js-adapters/router.js +60 -0
- data/js-adapters/server.js +5 -0
- data/lib/rhoconnect/api/app/ans_login.rb +3 -3
- data/lib/rhoconnect/api/app/bulk_data.rb +10 -10
- data/lib/rhoconnect/api/app/fast_delete.rb +11 -10
- data/lib/rhoconnect/api/app/fast_insert.rb +11 -10
- data/lib/rhoconnect/api/app/fast_update.rb +11 -10
- data/lib/rhoconnect/api/app/login.rb +5 -5
- data/lib/rhoconnect/api/app/push_deletes.rb +12 -11
- data/lib/rhoconnect/api/app/push_objects.rb +12 -11
- data/lib/rhoconnect/api/app/query.rb +8 -7
- data/lib/rhoconnect/api/app/queue_updates.rb +98 -94
- data/lib/rhoconnect/api/app/search.rb +8 -7
- data/lib/rhoconnect/api/client/client_get_db_doc.rb +5 -5
- data/lib/rhoconnect/api/client/client_set_db_doc.rb +8 -8
- data/lib/rhoconnect/api/client/create.rb +7 -7
- data/lib/rhoconnect/api/client/get_client_params.rb +4 -4
- data/lib/rhoconnect/api/client/list_client_docs.rb +17 -17
- data/lib/rhoconnect/api/client/register.rb +12 -12
- data/lib/rhoconnect/api/client/reset.rb +5 -5
- data/lib/rhoconnect/api/readstate/set_refresh_time.rb +9 -9
- data/lib/rhoconnect/api/source/get_source_params.rb +4 -4
- data/lib/rhoconnect/api/source/list_sources.rb +16 -16
- data/lib/rhoconnect/api/source/update_source_params.rb +6 -6
- data/lib/rhoconnect/api/store/get_db_doc.rb +4 -4
- data/lib/rhoconnect/api/store/set_db_doc.rb +7 -7
- data/lib/rhoconnect/api/system/get_adapter.rb +4 -4
- data/lib/rhoconnect/api/system/get_license_info.rb +8 -8
- data/lib/rhoconnect/api/system/login.rb +15 -15
- data/lib/rhoconnect/api/system/reset.rb +11 -11
- data/lib/rhoconnect/api/system/save_adapter.rb +4 -4
- data/lib/rhoconnect/api/system/stats.rb +22 -22
- data/lib/rhoconnect/api/user/create_user.rb +7 -7
- data/lib/rhoconnect/api/user/delete_client.rb +6 -6
- data/lib/rhoconnect/api/user/delete_user.rb +11 -10
- data/lib/rhoconnect/api/user/list_clients.rb +4 -4
- data/lib/rhoconnect/api/user/list_source_docs.rb +10 -10
- data/lib/rhoconnect/api/user/list_users.rb +3 -3
- data/lib/rhoconnect/api/user/ping.rb +3 -3
- data/lib/rhoconnect/api/user/show_user.rb +3 -3
- data/lib/rhoconnect/api/user/update_user.rb +5 -5
- data/lib/rhoconnect/api/user/user_get_db_doc.rb +5 -5
- data/lib/rhoconnect/api/user/user_set_db_doc.rb +10 -10
- data/lib/rhoconnect/api_token.rb +5 -6
- data/lib/rhoconnect/app.rb +6 -46
- data/lib/rhoconnect/application/init.rb +5 -2
- data/lib/rhoconnect/async.rb +76 -39
- data/lib/rhoconnect/bulk_data/bulk_data.rb +6 -4
- data/lib/rhoconnect/client.rb +59 -9
- data/lib/rhoconnect/condition/admin_required.rb +27 -0
- data/lib/rhoconnect/condition/client_required.rb +50 -0
- data/lib/rhoconnect/condition/login_required.rb +22 -0
- data/lib/rhoconnect/condition/source_required.rb +49 -0
- data/lib/rhoconnect/condition/verbs.rb +17 -0
- data/lib/rhoconnect/condition/verify_success.rb +19 -0
- data/lib/rhoconnect/controller/app_base.rb +74 -0
- data/lib/rhoconnect/controller/base.rb +68 -0
- data/lib/rhoconnect/controller/clients_controller.rb +79 -0
- data/lib/rhoconnect/controller/dynamic_adapter_controller.rb +93 -0
- data/lib/rhoconnect/controller/js_base.rb +124 -0
- data/lib/rhoconnect/controller/read_state_controller.rb +22 -0
- data/lib/rhoconnect/controller/source_adapter_base.rb +14 -0
- data/lib/rhoconnect/controller/sources_controller.rb +44 -0
- data/lib/rhoconnect/controller/store_controller.rb +25 -0
- data/lib/rhoconnect/controller/system_controller.rb +67 -0
- data/lib/rhoconnect/controller/users_controller.rb +99 -0
- data/lib/rhoconnect/db_adapter.rb +1 -3
- data/lib/rhoconnect/document.rb +159 -50
- data/lib/rhoconnect/handler/authenticate/execute_methods.rb +77 -0
- data/lib/rhoconnect/handler/authenticate/runner.rb +49 -0
- data/lib/rhoconnect/handler/authenticate.rb +3 -0
- data/lib/rhoconnect/handler/bulk_data.rb +28 -0
- data/lib/rhoconnect/handler/changes/engine.rb +271 -0
- data/lib/rhoconnect/handler/changes/execute_methods.rb +88 -0
- data/lib/rhoconnect/handler/changes/pass_through_runner.rb +11 -0
- data/lib/rhoconnect/handler/changes/runner.rb +53 -0
- data/lib/rhoconnect/handler/changes.rb +31 -0
- data/lib/rhoconnect/handler/helpers/auth_method.rb +29 -0
- data/lib/rhoconnect/handler/helpers/binding.rb +18 -0
- data/lib/rhoconnect/handler/helpers/bulk_data.rb +53 -0
- data/lib/rhoconnect/handler/helpers/source_job.rb +14 -0
- data/lib/rhoconnect/handler/helpers.rb +4 -0
- data/lib/rhoconnect/handler/plugin_callbacks/execute_methods.rb +99 -0
- data/lib/rhoconnect/handler/plugin_callbacks/runner.rb +28 -0
- data/lib/rhoconnect/handler/plugin_callbacks.rb +67 -0
- data/lib/rhoconnect/handler/query/engine.rb +93 -0
- data/lib/rhoconnect/handler/query/execute_methods.rb +21 -0
- data/lib/rhoconnect/handler/query/pass_through_runner.rb +35 -0
- data/lib/rhoconnect/handler/query/runner.rb +270 -0
- data/lib/rhoconnect/handler/query.rb +19 -0
- data/lib/rhoconnect/handler/search/engine.rb +60 -0
- data/lib/rhoconnect/handler/search/execute_methods.rb +32 -0
- data/lib/rhoconnect/handler/search/pass_through_runner.rb +18 -0
- data/lib/rhoconnect/handler/search/runner.rb +104 -0
- data/lib/rhoconnect/handler/search.rb +26 -0
- data/lib/rhoconnect/handler/sync.rb +29 -0
- data/lib/rhoconnect/jobs/source_job.rb +13 -4
- data/lib/rhoconnect/js_adapter.rb +79 -0
- data/lib/rhoconnect/license.rb +10 -2
- data/lib/rhoconnect/middleware/current_user.rb +14 -1
- data/lib/rhoconnect/middleware/helpers.rb +10 -93
- data/lib/rhoconnect/middleware/x_domain_session_wrapper.rb +1 -1
- data/lib/rhoconnect/model/base.rb +229 -0
- data/lib/rhoconnect/model/dynamic_adapter_model.rb +90 -0
- data/lib/rhoconnect/model/js_base.rb +121 -0
- data/lib/rhoconnect/ping/android.rb +1 -1
- data/lib/rhoconnect/predefined_adapters/bench_adapter.rb +7 -4
- data/lib/rhoconnect/read_state.rb +3 -3
- data/lib/rhoconnect/server.rb +159 -190
- data/lib/rhoconnect/source.rb +100 -11
- data/lib/rhoconnect/stats/record.rb +10 -10
- data/lib/rhoconnect/store.rb +905 -591
- data/lib/rhoconnect/{model.rb → store_orm.rb} +53 -115
- data/lib/rhoconnect/tasks.rb +18 -4
- data/lib/rhoconnect/test_methods.rb +30 -17
- data/lib/rhoconnect/user.rb +35 -17
- data/lib/rhoconnect/utilities.rb +1 -1
- data/lib/rhoconnect/version.rb +2 -2
- data/lib/rhoconnect/web-console/server.rb +29 -14
- data/lib/rhoconnect/web-console/views/home.js +10 -10
- data/lib/rhoconnect/web-console/views/new_ping.js +1 -1
- data/lib/rhoconnect.rb +120 -51
- data/rhoconnect.gemspec +4 -3
- data/spec/api/api_helper.rb +1 -6
- data/spec/api/app/fast_delete_spec.rb +4 -4
- data/spec/api/app/fast_insert_spec.rb +4 -4
- data/spec/api/app/fast_update_spec.rb +8 -8
- data/spec/api/app/push_deletes_spec.rb +2 -2
- data/spec/api/app/push_objects_spec.rb +5 -5
- data/spec/api/client/client_get_db_doc_spec.rb +6 -4
- data/spec/api/client/client_set_db_doc_spec.rb +3 -2
- data/spec/api/client/get_client_params_spec.rb +14 -0
- data/spec/api/client/list_client_docs_spec.rb +30 -20
- data/spec/api/client/reset_spec.rb +36 -0
- data/spec/api/source/get_source_params_spec.rb +23 -17
- data/spec/api/system/get_license_info_spec.rb +0 -20
- data/spec/api/system/login_spec.rb +8 -0
- data/spec/api/system/reset_spec.rb +0 -1
- data/spec/api/system/stats_spec.rb +5 -5
- data/spec/api/user/create_user_spec.rb +14 -6
- data/spec/api/user/delete_user_spec.rb +20 -18
- data/spec/api/user/list_users_spec.rb +5 -6
- data/spec/api/user/update_user_spec.rb +5 -4
- data/spec/apps/rhotestapp/config.ru +16 -1
- data/spec/apps/rhotestapp/controllers/js/js_sample_controller.js +23 -0
- data/spec/apps/rhotestapp/controllers/js/sample2_controller.js +32 -0
- data/spec/apps/rhotestapp/controllers/ruby/application_controller.rb +21 -0
- data/spec/apps/rhotestapp/controllers/ruby/sample_adapter_controller.rb +8 -0
- data/spec/apps/rhotestapp/models/js/js_sample.js +55 -0
- data/spec/apps/rhotestapp/models/js/sample2.js +25 -0
- data/spec/apps/rhotestapp/{sources → models/ruby}/base_adapter.rb +0 -0
- data/spec/apps/rhotestapp/{sources → models/ruby}/fixed_schema_adapter.rb +0 -0
- data/spec/apps/rhotestapp/{sources → models/ruby}/other_adapter.rb +0 -0
- data/spec/apps/rhotestapp/{sources → models/ruby}/sample_adapter.rb +0 -0
- data/spec/apps/rhotestapp/{sources → models/ruby}/simple_adapter.rb +2 -2
- data/spec/apps/rhotestapp/{sources → models/ruby}/sub_adapter.rb +0 -0
- data/spec/apps/rhotestapp/settings/settings.yml +0 -1
- data/spec/bulk_data/bulk_data_spec.rb +20 -5
- data/spec/cli/cli_spec.rb +83 -0
- data/spec/client_spec.rb +20 -17
- data/spec/client_sync_spec.rb +244 -406
- data/spec/controllers/js_base_spec.rb +89 -0
- data/spec/doc/doc_spec.rb +18 -18
- data/spec/document_spec.rb +29 -13
- data/spec/dynamic_adapter_spec.rb +6 -6
- data/spec/generator/generator_spec.rb +7 -4
- data/spec/jobs/bulk_data_job_spec.rb +14 -10
- data/spec/jobs/source_job_spec.rb +8 -8
- data/spec/license_spec.rb +5 -2
- data/spec/models/js_model_spec.rb +39 -0
- data/spec/node_spec.rb +42 -0
- data/spec/perf/store_perf_spec.rb +67 -12
- data/spec/ping/android_spec.rb +1 -1
- data/spec/read_state_spec.rb +1 -1
- data/spec/rhoconnect_spec.rb +1 -1
- data/spec/server/cors_spec.rb +14 -18
- data/spec/server/server_spec.rb +265 -88
- data/spec/server/stats_spec.rb +1 -1
- data/spec/source_adapter_spec.rb +54 -27
- data/spec/source_spec.rb +8 -3
- data/spec/source_sync_spec.rb +538 -468
- data/spec/spec_helper.rb +35 -4
- data/spec/stats/record_spec.rb +10 -10
- data/spec/{model_spec.rb → store_orm_spec.rb} +56 -54
- data/spec/store_spec.rb +159 -179
- data/spec/support/shared_examples.rb +36 -27
- data/spec/sync_states_spec.rb +40 -33
- data/spec/test_methods_spec.rb +18 -14
- data/spec/user_spec.rb +17 -30
- metadata +156 -52
- data/bench/benchapp/application.rb +0 -39
- data/bench/blobapp/application.rb +0 -44
- data/commands/rhoconnect/clean_start.rb +0 -9
- data/commands/rhoconnect/create_user.rb +0 -18
- data/commands/rhoconnect/delete_device.rb +0 -9
- data/commands/rhoconnect/delete_user.rb +0 -8
- data/commands/rhoconnect/reset.rb +0 -16
- data/commands/rhoconnect/reset_refresh.rb +0 -11
- data/generators/templates/application/application.rb +0 -43
- data/lib/rhoconnect/client_sync.rb +0 -434
- data/lib/rhoconnect/dynamic_adapter.rb +0 -91
- data/lib/rhoconnect/middleware/admin_user.rb +0 -23
- data/lib/rhoconnect/middleware/current_request.rb +0 -16
- data/lib/rhoconnect/middleware/login_required.rb +0 -22
- data/lib/rhoconnect/source_adapter.rb +0 -132
- data/lib/rhoconnect/source_sync.rb +0 -464
- data/spec/apps/rhotestapp/application.rb +0 -23
data/doc/supported-platforms.txt
CHANGED
@@ -2,45 +2,39 @@ Supported Platforms
|
|
2
2
|
===
|
3
3
|
## Support Matrix
|
4
4
|
|
5
|
+
RhoConnect gem is available on the following platforms:
|
6
|
+
|
5
7
|
<table class="device-caps">
|
6
8
|
<tr>
|
7
9
|
<th>OS</th>
|
8
10
|
<th>Distribution</th>
|
9
|
-
<th>Ruby 1.8.7</th>
|
10
|
-
<th>Ruby Enterprise</th>
|
11
|
-
<th>Ruby 1.9.2</th>
|
12
11
|
<th>Ruby 1.9.3</th>
|
12
|
+
<th>Ruby 2.0.0</th>
|
13
13
|
<th>JRuby</th>
|
14
14
|
<th>Environment</th>
|
15
15
|
</tr>
|
16
16
|
<tr>
|
17
17
|
<td class='cap'>Linux</td>
|
18
|
-
<td> CentOS / RHEL 5 & 6,<br/>Ubuntu
|
19
|
-
<td> ruby-1.
|
20
|
-
<td>
|
21
|
-
<td>
|
22
|
-
<td> ruby-1.9.3-p286 </td>
|
23
|
-
<td> jruby-1.6.7 </td>
|
18
|
+
<td> CentOS / RHEL 5.x & 6.x,<br/>Ubuntu 12.04 </td>
|
19
|
+
<td> ruby-1.9.3-p392 </td>
|
20
|
+
<td class='tbd'> TBD </td>
|
21
|
+
<td class='tbd'> jruby-1.7.3 </td>
|
24
22
|
<td>Development &<br/>Production</td>
|
25
23
|
</tr>
|
26
24
|
<tr>
|
27
25
|
<td class='cap'>Mac OS </td>
|
28
|
-
<td> Mac OS X 10.
|
29
|
-
<td> ruby-1.
|
30
|
-
<td>
|
31
|
-
<td>
|
32
|
-
<td>
|
33
|
-
<td> jruby-1.6.7 </td>
|
34
|
-
<td>Development &<br/>Production</td>
|
26
|
+
<td> Mac OS X 10.7/10.8 </td>
|
27
|
+
<td> ruby-1.9.3-p392 </td>
|
28
|
+
<td class='tbd'> TBD </td>
|
29
|
+
<td class='tbd'> jruby-1.7.3 </td>
|
30
|
+
<td> Development </td>
|
35
31
|
</tr>
|
36
32
|
<tr>
|
37
33
|
<td class='cap'>Windows</td>
|
38
34
|
<td> Windows 7 </td>
|
39
|
-
<td> ruby-1.
|
40
|
-
<td class='tbd'> TBD </td>
|
41
|
-
<td class='tbd'> TBD </td>
|
42
|
-
<td> ruby-1.9.3-p286 </td>
|
35
|
+
<td> ruby-1.9.3-p392 </td>
|
43
36
|
<td class='tbd'> TBD </td>
|
37
|
+
<td class='tbd'> jruby-1.7.3 </td>
|
44
38
|
<td>Development</td>
|
45
39
|
</tr>
|
46
40
|
</table>
|
@@ -52,22 +46,19 @@ Other Ruby versions and releases might work with RhoConnect gem, but there are n
|
|
52
46
|
RhoConnect for Windows is supported only in development environments. The components you should have for this environment are:
|
53
47
|
|
54
48
|
* Ruby 1.9.3
|
55
|
-
* Redis 2.
|
49
|
+
* Redis 2.6.x
|
56
50
|
* Latest RhoConnect and Rhodes gems
|
57
51
|
* Eclipse 3.6 with latest RhoStudio plugin, or RhoStudio for Windows 32-bit
|
58
|
-
* Make 3.
|
52
|
+
* Make 3.81
|
59
53
|
* DevKit for Windows (or other Windows development environment)
|
60
54
|
|
61
|
-
RhoConnect for Linux
|
55
|
+
RhoConnect for Linux is supported for both development and production environments.
|
56
|
+
On Linux servers RhoConnect is available in the format of [Debian (deb) and Red Hat (rpm) packages](http://edgedocs.rhomobile.com/rhoconnect/deploying) for Ubuntu and CentOS respectively.
|
57
|
+
RhoConnect Mac OS X is supported in development environment.
|
58
|
+
The components you should have for this environment are:
|
62
59
|
|
63
60
|
* Ruby 1.9.3
|
64
61
|
* Nginx HTTP server (1.3.x)
|
65
|
-
* Redis data store (2.
|
62
|
+
* Redis data store (2.6.x)
|
66
63
|
* Thin application server
|
67
64
|
* RhoConnect gem with all required dependencies
|
68
|
-
|
69
|
-
|
70
|
-
## Known Issues
|
71
|
-
|
72
|
-
* If you deploy your RhoConnect application deploy on <b>Heroku</b>, then use new [Cedar](http://devcenter.heroku.com/articles/cedar) stack. The Bamboo stack is older than the widespread adoption of bundler,
|
73
|
-
so on Bamboo your application is not invoked in the context of your bundle and might not works properly.
|
data/doc/testing.txt
CHANGED
@@ -4,7 +4,7 @@ RhoConnect provides a [spec](http://rspec.info/) framework for [behavior driven
|
|
4
4
|
|
5
5
|
## Example Spec
|
6
6
|
|
7
|
-
Here is a simple example spec for the [rhostore product adapter](http://github.com/rhomobile/store-server/blob/master/sources/product.rb):
|
7
|
+
Here is a simple example model spec for the [rhostore product adapter](http://github.com/rhomobile/store-server/blob/master/sources/product.rb):
|
8
8
|
|
9
9
|
:::ruby
|
10
10
|
it "should process Product query" do
|
@@ -12,7 +12,7 @@ Here is a simple example spec for the [rhostore product adapter](http://github.c
|
|
12
12
|
query_errors.should == {}
|
13
13
|
end
|
14
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.
|
15
|
+
This simple spec runs the query method of our product adapter model and verifies the result is greater than one object and has no errors.
|
16
16
|
|
17
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
18
|
|
@@ -21,7 +21,7 @@ From your application's root folder:
|
|
21
21
|
|
22
22
|
:::term
|
23
23
|
$ rhoconnect spec
|
24
|
-
[05:51:48 PM 2012-04-19] Rhoconnect Server
|
24
|
+
[05:51:48 PM 2012-04-19] Rhoconnect Server v4.0.1 started...
|
25
25
|
Product
|
26
26
|
it should behave like SpecHelper
|
27
27
|
should process Product query (PENDING: No reason given)
|
@@ -41,17 +41,32 @@ From your application's root folder:
|
|
41
41
|
This will also automatically generate an rcov report under 'coverage' if you have rcov installed (currently only Mac/Linux support rcov).
|
42
42
|
|
43
43
|
## Test API
|
44
|
-
For the most up-to-date Test API, please see the [rdocs](http://rdoc.info/projects/rhomobile/rhoconnect).
|
45
44
|
|
46
|
-
|
47
|
-
|
45
|
+
The [RhoConnect Source Adapter Model Test API](/rhoconnectapi/test-api) provides the following methods to perform spec tests.
|
46
|
+
|
47
|
+
* [setup_test_for](/rhoconnectapi/test-api-ruby#setuptestfor) - Executes the adapter's query method and returns the master document.
|
48
|
+
* [test_query](/rhoconnectapi/test-api-ruby#testquery) - Executes the adapter's query method and returns the master document.
|
49
|
+
* [query_errors](/rhoconnectapi/test-api-ruby#queryerrors) - Returns any errors stored in redis for the previous source adapter query.
|
50
|
+
* [test_create](/rhoconnectapi/test-api-ruby#testcreate) - Executes the adapter's create method with a provided record and returns the object string from the create method.
|
51
|
+
* [create_errors](/rhoconnectapi/test-api-ruby#createerrors) - Returns the result of the adapter's create method..
|
52
|
+
* [test_update](/rhoconnectapi/test-api-ruby#testupdate) - Execute the source adapter's update method.
|
53
|
+
* [update_errors](/rhoconnectapi/test-api-ruby#updateerrors) - Returns any errors stored in redis from the previous source adapter update.
|
54
|
+
* [test_delete](/rhoconnectapi/test-api-ruby#testdelete) - Execute the source adapter's delete method.
|
55
|
+
* [delete_errors](/rhoconnectapi/test-api-ruby#deleteerrors) - Returns any errors stored in redis from the previous source adapter delete.
|
56
|
+
* [md](/rhoconnectapi/test-api-ruby#md) - Returns the master document (:md) for the source adapter stored in redis.
|
57
|
+
* [cd](/rhoconnectapi/test-api-ruby#cd) - Returns the client document (:cd) for the source adapter + client under test.
|
58
|
+
|
59
|
+
## Example of setup_test_for
|
60
|
+
|
61
|
+
This example initializes a source adapter model named Product under test for a user named testuser.
|
48
62
|
|
49
63
|
:::ruby
|
50
64
|
# 'testuser' will be used by rest of the specs
|
51
65
|
setup_test_for(Product,'testuser')
|
52
66
|
|
53
|
-
|
54
|
-
|
67
|
+
## Example of test_query
|
68
|
+
|
69
|
+
The `test_query` method executes the model's query method and returns the master document (:md) stored in redis.
|
55
70
|
|
56
71
|
For example, if your source adapter query method was:
|
57
72
|
|
@@ -82,8 +97,9 @@ For example, if your source adapter query method was:
|
|
82
97
|
}
|
83
98
|
}
|
84
99
|
|
85
|
-
|
86
|
-
|
100
|
+
## Example of query_errors
|
101
|
+
|
102
|
+
Returns any errors stored in redis for the previous model's query.
|
87
103
|
|
88
104
|
For example:
|
89
105
|
|
@@ -93,10 +109,10 @@ For example:
|
|
93
109
|
"message" => "error connecting to web service!"
|
94
110
|
}
|
95
111
|
}
|
96
|
-
|
97
112
|
|
98
|
-
|
99
|
-
|
113
|
+
## Example of test_create
|
114
|
+
|
115
|
+
The `test_create` method executes the model'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.
|
100
116
|
|
101
117
|
For example, in your spec:
|
102
118
|
:::ruby
|
@@ -125,23 +141,17 @@ For example, in your spec:
|
|
125
141
|
@s.pass_through = 'true'
|
126
142
|
new_product = test_create(@product)
|
127
143
|
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
144
|
|
133
|
-
|
134
|
-
Execute the source adapter's update method. Takes a record as hash of hashes (object_id => object)
|
145
|
+
## Example of test_update
|
135
146
|
|
136
|
-
|
147
|
+
This example executes the model's update method, calling the adapter's update method for object_id '4'.
|
137
148
|
|
138
149
|
:::ruby
|
139
150
|
test_update({'4' => {'price' => '$199.99'}})
|
140
151
|
update_errors.should == {}
|
141
152
|
test_query
|
142
153
|
md[product_id]['price'].should == '$199.99'
|
143
|
-
|
144
|
-
This will call the adapter's update method for object_id '4'.
|
154
|
+
|
145
155
|
|
146
156
|
**NOTE: To test the master document, you will need to run `test_query` as shown above.**
|
147
157
|
|
@@ -152,14 +162,10 @@ For example, in your spec:
|
|
152
162
|
record = {'4'=> { 'price' => '199.99' }}
|
153
163
|
@s.pass_through = 'true'
|
154
164
|
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
165
|
|
159
|
-
|
160
|
-
Execute the source adapter's delete method. Takes a record as hash of hashes (object_id => object).
|
166
|
+
## Example of test_delete
|
161
167
|
|
162
|
-
|
168
|
+
This example executes the source model's delete method, calling the adapter's delete method for product '4'.
|
163
169
|
|
164
170
|
:::ruby
|
165
171
|
@product = {
|
@@ -173,13 +179,10 @@ For example:
|
|
173
179
|
delete_errors.should == {}
|
174
180
|
md.should == {}
|
175
181
|
|
176
|
-
This will call the adapter's delete method for product '4'.
|
177
|
-
|
178
182
|
**NOTE: The master document (:md) will be updated and can be verified as shown above.**
|
179
183
|
|
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.
|
184
|
+
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. You could have the following code in your spec.
|
181
185
|
|
182
|
-
For example, in your spec:
|
183
186
|
:::ruby
|
184
187
|
@product = {
|
185
188
|
'name' => 'iPhone',
|
@@ -192,13 +195,9 @@ For example, in your spec:
|
|
192
195
|
@s.pass_through = 'true'
|
193
196
|
test_update(record).should == {'processed' => ["4"]}.to_json
|
194
197
|
|
195
|
-
|
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.
|
198
|
+
## Example of md
|
200
199
|
|
201
|
-
|
200
|
+
The md method returns the master document (:md) for the source adapter model stored in redis. This is equivalent to the @result hash of hashes structure.
|
202
201
|
|
203
202
|
:::ruby
|
204
203
|
md.should == {
|
@@ -212,11 +211,10 @@ For example:
|
|
212
211
|
}
|
213
212
|
}
|
214
213
|
|
215
|
-
|
216
|
-
|
214
|
+
## Example of cd
|
215
|
+
|
216
|
+
This example shows that the master document (:md) and client document (:cd) should be equal after the query is executed.
|
217
217
|
|
218
|
-
For example:
|
219
|
-
|
220
218
|
:::ruby
|
221
219
|
test_query.size.should > 0
|
222
220
|
md.should == cd
|
data/doc/tutorial.txt
CHANGED
@@ -52,11 +52,14 @@ Now you can run redis and your RhoConnect app:
|
|
52
52
|
|
53
53
|
If everything went well you should see:
|
54
54
|
|
55
|
-
[01:48:15 PM 2012-08-04] Rhoconnect Server
|
55
|
+
[01:48:15 PM 2012-08-04] Rhoconnect Server v4.0.1 started...
|
56
56
|
|
57
57
|
## Defining RhoConnect Source Adapters
|
58
58
|
|
59
|
-
Once RhoConnect is installed we're ready to build a RhoConnect source to integrate with our backend application.
|
59
|
+
Once RhoConnect is installed we're ready to build a RhoConnect source adapter to integrate with our backend application. Each Source Adapter consists of two pieces - Controller and Model.
|
60
|
+
Source Adapter Controller is a designated Sinatra application which is responsible for adding and routing the incoming requests to your Source Adapter. Controller instantiates the model and calls its methods when necessary.
|
61
|
+
Source Adapter Model is a placeholder for your Source Adapter business logic. This is where you implement the interaction with your backend service.
|
62
|
+
To define a RhoConnect model 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 model](/rhoconnect/source-adapters) documentation.
|
60
63
|
|
61
64
|
### Generating the Source Adapter from RhoStudio
|
62
65
|
|
@@ -76,8 +79,11 @@ After pressing the Finish button, you'll see the RhoConnect source adapter gener
|
|
76
79
|
|
77
80
|
You should now have files for the source adapter in your storeserver application. The files are organized as follows:
|
78
81
|
|
79
|
-
* product.rb
|
80
|
-
*
|
82
|
+
* `product.rb` - This is the source adapter's model file which contains the login, query, create, update, delete and logoff methods to call a backend service. You will add code to implement these methods.
|
83
|
+
* `product_controller.rb` - This is the source adapter's controller file which defines the RhoConnect application web end point and adds SYNC routes into your Source Adapter. You may add your custom routes here.
|
84
|
+
* `product_spec.rb` - This file contains the spec with tests which relate to our source adapter's model.
|
85
|
+
* `product_controller_spec.rb` - This file contains the spec with tests which relate to our source adapter's controller.
|
86
|
+
|
81
87
|
|
82
88
|
You can open these files for editing by clicking on them in the Project Explorer.
|
83
89
|
|
@@ -90,20 +96,38 @@ Then run the command to generate a source adapter for the product model. The pro
|
|
90
96
|
:::term
|
91
97
|
$ rhoconnect source product
|
92
98
|
|
93
|
-
which generates
|
99
|
+
which generates product controller, product model and the corresponding spec files:
|
94
100
|
|
95
101
|
Generating with source generator:
|
96
|
-
[ADDED]
|
97
|
-
[ADDED]
|
102
|
+
[ADDED] models/ruby/product.rb
|
103
|
+
[ADDED] controllers/ruby/product_controller.rb
|
104
|
+
[ADDED] spec/models/ruby/product_spec.rb
|
105
|
+
[ADDED] spec/controllers/ruby/product_controller_spec.rb
|
98
106
|
|
99
|
-
You can use the command line to navigate to
|
107
|
+
You can use the command line to navigate to files in your RhoConnect application folder.
|
100
108
|
|
101
|
-
### Understanding the
|
109
|
+
### Understanding the Controller File
|
102
110
|
|
103
|
-
The generated source adapter file (in this case,
|
111
|
+
The generated source adapter's controller file (in this case, product_controller.rb) is similar to the code listing below.
|
112
|
+
Its purpose is to define the RhoConnect application web end point and to register the corresponding routes.
|
113
|
+
Under the hood - it's an isolated Sinatra application designated to handle all incoming Product requests.
|
104
114
|
|
105
115
|
:::ruby
|
106
|
-
class
|
116
|
+
class ProductController < Rhoconnect::Controller::Base
|
117
|
+
register Rhoconnect::EndPoint
|
118
|
+
|
119
|
+
# add all SYNC routes
|
120
|
+
register Rhoconnect::Handler::Sync
|
121
|
+
|
122
|
+
# add your custom Product routes here
|
123
|
+
end
|
124
|
+
|
125
|
+
### Understanding the Model File
|
126
|
+
|
127
|
+
The generated source adapter's model file (in this case, product.rb) is similar to the code listing below. It has code to raise an exception for any required method.
|
128
|
+
|
129
|
+
:::ruby
|
130
|
+
class Product < Rhoconnect::Model::Base
|
107
131
|
def initialize(source)
|
108
132
|
super(source)
|
109
133
|
end
|
@@ -119,7 +143,7 @@ The generated source adapter file (in this case, product.rb) is similar to the c
|
|
119
143
|
# "1"=>{"name"=>"Acme", "industry"=>"Electronics"},
|
120
144
|
# "2"=>{"name"=>"Best", "industry"=>"Software"}
|
121
145
|
# }
|
122
|
-
raise
|
146
|
+
raise Rhoconnect::Model::Base::Exception.new("Please provide some code to read records from the backend data source")
|
123
147
|
end
|
124
148
|
|
125
149
|
def sync
|
@@ -165,9 +189,9 @@ The next step is for you to fill in the login, query, create, update, delete and
|
|
165
189
|
|
166
190
|
## A RhoConnect Query
|
167
191
|
|
168
|
-
If you're doing a readonly non-authenticated source adapter, you can just write 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.herokuapp.com) that exposes a REST interface. Note that RhoConnect can work with any protocol. This example shows JSON over HTTP with a REST interface, since that is common. The RhoConnect source adapter is 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.
|
192
|
+
If you're doing a readonly non-authenticated source adapter, you can just write one model 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.herokuapp.com>) that exposes a REST interface. Note that RhoConnect can work with any protocol. This example shows JSON over HTTP with a REST interface, since that is common. The RhoConnect source adapter model is 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.
|
169
193
|
|
170
|
-
For a more complete example of rewriting the source adapter methods (such as create, update, and delete), refer to the [source adapter example](/rhoconnect/source-adapters#sample-
|
194
|
+
For a more complete example of rewriting the source adapter model methods (such as create, update, and delete), refer to the [source adapter model example](/rhoconnect/source-adapters#sample-model) in the RhoConnect Developer Reference.
|
171
195
|
|
172
196
|
Our sample web service for returning all products in the catalog (http://rhostore.herokuapp.com/products.json) returns data like this:
|
173
197
|
|
@@ -199,17 +223,17 @@ Our sample web service for returning all products in the catalog (http://rhostor
|
|
199
223
|
}
|
200
224
|
]
|
201
225
|
|
202
|
-
The Ruby code for parsing that data,
|
226
|
+
The Ruby code for parsing that data, `models/ruby/product.rb`, is listed below. It 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 model class `sync` method can populate the Redis data store.
|
203
227
|
|
204
|
-
You can edit
|
228
|
+
You can edit models/ruby/product.rb within RhoStudio, or you can navigate to it within your RhoConnect application folder and edit it with a text editor.
|
205
229
|
|
206
|
-
We need to declare the standard libraries that we are using at the top of the
|
230
|
+
We need to declare the standard libraries that we are using at the top of the `models/ruby/product.rb` file:
|
207
231
|
|
208
232
|
:::ruby
|
209
233
|
require 'json'
|
210
234
|
require 'rest_client'
|
211
235
|
|
212
|
-
For convenience, we'll add an instance variable
|
236
|
+
For convenience, we'll add an instance variable `@base` which contains the base URL of the web service and sets the value in the constructor:
|
213
237
|
|
214
238
|
:::ruby
|
215
239
|
def initialize(source)
|
@@ -227,7 +251,7 @@ Then fill in the query method:
|
|
227
251
|
if parsed
|
228
252
|
parsed.each do |item|
|
229
253
|
key = item["product"]["id"].to_s
|
230
|
-
@result[key]=item["product"]
|
254
|
+
@result[key] = item["product"]
|
231
255
|
end
|
232
256
|
end
|
233
257
|
end
|
@@ -251,7 +275,15 @@ For example:
|
|
251
275
|
|
252
276
|
## Testing Sync from the Client
|
253
277
|
|
254
|
-
|
278
|
+
From RhoStudio, select your RhoConnect project in the Project Explorer, and select Run->Run Configurations… from the menu. The Run Configurations window appears.
|
279
|
+
|
280
|
+
<img src="http://rhodocs.s3.amazonaws.com/rhoconnect-tutorial/run-configurations-rc.png"/>
|
281
|
+
|
282
|
+
To create a new build configuration for your application, select RhoConnect Application. Then either right-click on RhoConnect Application or click the New button. A new configuration appears under RhoConnect Application. Click the Run button to run it.
|
283
|
+
|
284
|
+
<img src="http://rhodocs.s3.amazonaws.com/rhoconnect-tutorial/run-config-rhoconnect-new-rc.png"/>
|
285
|
+
|
286
|
+
If you are working from the command line, first make sure you are running redis. From the folder in which your app is located, run this command.
|
255
287
|
|
256
288
|
:::term
|
257
289
|
$ rhoconnect redis-start
|
@@ -261,9 +293,7 @@ Then start (or restart) your server:
|
|
261
293
|
:::term
|
262
294
|
$ rhoconnect start
|
263
295
|
|
264
|
-
|
265
|
-
|
266
|
-
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.
|
296
|
+
The code for the source adapter model 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 model's method is called.
|
267
297
|
|
268
298
|
Make sure your server URL is configured in the Rhodes app. If your server is running on YourIPAddress with the port 9292, the following line should be at the bottom of your corresponding Rhodes app, storemanager/rhoconfig.txt:
|
269
299
|
|
@@ -290,10 +320,10 @@ To sync with the RhoConnect server, the Rhodes client must log in. The Rhodes ge
|
|
290
320
|
1. From the home page in the Rhodes app, click on the login button in the upper right corner. Alternatively, you can click on the tool icon at the bottom of the screen to go to the Settings screen, and click the login button from there.
|
291
321
|
<img src="http://rhodocs.s3.amazonaws.com/rhoconnect-tutorial/storemanager-rhosimulator-home-arrows.png"/>
|
292
322
|
|
293
|
-
2. Login using any
|
323
|
+
2. Login using any username & password. The generated code allows any username, but you can modify that in `application_controller.rb`.
|
294
324
|
<img src="http://rhodocs.s3.amazonaws.com/rhoconnect-tutorial/rhosimulator-login.png"/>
|
295
325
|
|
296
|
-
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
|
326
|
+
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 Client ID will be generated.)
|
297
327
|
4. Sync is triggered automatically. Click on the home icon and then select "Products" and you should see the list of product records from the server.
|
298
328
|
|
299
329
|
This example shows a couple of iPhone products.
|
@@ -310,7 +340,7 @@ For your create method, the RhoConnect server will pass you a hash containing th
|
|
310
340
|
"brand" => "Acme"
|
311
341
|
}
|
312
342
|
|
313
|
-
The RhoConnect
|
343
|
+
The RhoConnect `models/ruby/product.rb` 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.herokuapp.com), which accepts an HTTP POST to perform a create action. The create method should 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.
|
314
344
|
|
315
345
|
:::ruby
|
316
346
|
def create(create_hash)
|
@@ -328,48 +358,33 @@ The RhoConnect sources/product.rb create method will be called once for every ob
|
|
328
358
|
JSON.parse(new_record)["product"]["id"].to_s
|
329
359
|
end
|
330
360
|
|
331
|
-
You will need to restart RhoConnect to reload the
|
361
|
+
You will need to restart RhoConnect to reload the model 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.
|
332
362
|
|
333
363
|
## Authentication
|
334
364
|
|
335
|
-
The generated RhoConnect application code includes
|
365
|
+
The generated RhoConnect application code includes an ApplicationController class which resides in the `controllers/ruby/application_controller.rb` which contains a route for authentication. The complete file looks like this:
|
336
366
|
|
337
367
|
:::ruby
|
338
|
-
class
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
super
|
348
|
-
end
|
349
|
-
|
350
|
-
# Calling super here returns rack tempfile path:
|
351
|
-
# i.e. /var/folders/J4/J4wGJ-r6H7S313GEZ-Xx5E+++TI
|
352
|
-
# Note: This tempfile is removed when server stops or crashes...
|
353
|
-
# See http://rack.rubyforge.org/doc/Multipart.html for more info
|
354
|
-
#
|
355
|
-
# Override this by creating a copy of the file somewhere
|
356
|
-
# and returning the path to that file (then don't call super!):
|
357
|
-
# i.e. /mnt/myimages/soccer.png
|
358
|
-
def store_blob(blob)
|
359
|
-
super #=> returns blob[:tempfile]
|
360
|
-
end
|
361
|
-
end
|
362
|
-
end
|
368
|
+
class ApplicationController < Rhoconnect::Controller::AppBase
|
369
|
+
register Rhoconnect::EndPoint
|
370
|
+
|
371
|
+
post "/login", :rc_handler => :authenticate do
|
372
|
+
login = params[:login]
|
373
|
+
password = params[:password]
|
374
|
+
true # do some interesting authentication here...
|
375
|
+
end
|
376
|
+
end
|
363
377
|
|
364
|
-
Application.initializer(ROOT_PATH)
|
365
378
|
|
366
|
-
If your back end web service requires authentication, add code to the
|
379
|
+
If your back end web service requires authentication, add code to the `/login` route and return true if authentication was successful or false to deny access to the application from this client. For example:
|
367
380
|
|
368
381
|
:::ruby
|
369
|
-
|
382
|
+
post '/login', :rc_handler => :authenticate do
|
383
|
+
login = params[:login]
|
384
|
+
password = params[:password]
|
370
385
|
# ... connect to backend using API and authenticate ...
|
371
386
|
if success
|
372
|
-
# save the data for later use
|
387
|
+
# save the data for later use
|
373
388
|
Store.put_value("username:#{username}:token",username)
|
374
389
|
end
|
375
390
|
return success
|
data/examples/simple/Gemfile
CHANGED
@@ -3,7 +3,7 @@ source 'http://rubygems.org'
|
|
3
3
|
# load rhoconnect from relative path
|
4
4
|
gem 'rhoconnect', :path => '../../'
|
5
5
|
|
6
|
-
gemfile_path = File.join(File.dirname(__FILE__), '..', '..', 'generators','templates', 'application', "
|
6
|
+
gemfile_path = File.join(File.dirname(__FILE__), '..', '..', 'generators','templates', 'application', "rcgemfile")
|
7
7
|
begin
|
8
8
|
eval(IO.read(gemfile_path))
|
9
9
|
rescue Exception => e
|
@@ -3,18 +3,18 @@ class Application < Rhoconnect::Base
|
|
3
3
|
def authenticate(username,password,session)
|
4
4
|
true # do some interesting authentication here...
|
5
5
|
end
|
6
|
-
|
6
|
+
|
7
7
|
# Add hooks for application startup here
|
8
8
|
# Don't forget to call super at the end!
|
9
9
|
def initializer(path)
|
10
10
|
super
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
# Calling super here returns rack tempfile path:
|
14
14
|
# i.e. /var/folders/J4/J4wGJ-r6H7S313GEZ-Xx5E+++TI
|
15
15
|
# Note: This tempfile is removed when server stops or crashes...
|
16
16
|
# See http://rack.rubyforge.org/doc/Multipart.html for more info
|
17
|
-
#
|
17
|
+
#
|
18
18
|
# Override this by creating a copy of the file somewhere
|
19
19
|
# and returning the path to that file (then don't call super!):
|
20
20
|
# i.e. /mnt/myimages/soccer.png
|
@@ -22,8 +22,7 @@ class Application < Rhoconnect::Base
|
|
22
22
|
super #=> returns blob[:tempfile]
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
26
|
-
puts "ans_authenticate - user: #{username} password: #{password}"
|
25
|
+
def rps_authenticate(username,password)
|
27
26
|
true
|
28
27
|
end
|
29
28
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
# FIXME: This is a temporary server to handle
|
1
|
+
# FIXME: This is a temporary server to handle rps token registration
|
2
2
|
class MyServer < Rhoconnect::Server
|
3
|
-
post '/
|
3
|
+
post '/rps/token' do
|
4
4
|
user = "tuser"
|
5
5
|
User.create(:login => user)
|
6
6
|
current_app.users << user
|