rhoconnect 3.1.2 → 3.2.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (248) hide show
  1. data/CHANGELOG.md +14 -2
  2. data/CREDITS +151 -10
  3. data/Gemfile +16 -5
  4. data/Gemfile.lock +58 -23
  5. data/Rakefile +70 -50
  6. data/bench/bench_runner.rb +2 -2
  7. data/bench/benchapp/Gemfile +6 -0
  8. data/bench/benchapp/Gemfile.lock +5 -0
  9. data/bench/benchapp/config.ru +2 -0
  10. data/bench/lib/bench/cli.rb +2 -0
  11. data/bench/lib/bench/distr_runner.rb +3 -2
  12. data/bench/lib/bench/runner.rb +1 -1
  13. data/bench/lib/bench.rb +10 -1
  14. data/bench/run_bench.sh +1 -1
  15. data/bench/scripts/test_query_script.rb +2 -1
  16. data/bench/spec/bench_spec_helper.rb +1 -0
  17. data/bin/rhoconnect +9 -27
  18. data/bin/rhoconnect-benchmark +10 -1
  19. data/commands/commands/dtach_commands/dtach_about.rb +6 -0
  20. data/commands/commands/dtach_commands/dtach_install.rb +30 -0
  21. data/commands/commands/redis_commands/redis_about.rb +6 -0
  22. data/commands/commands/redis_commands/redis_attach.rb +6 -0
  23. data/commands/commands/redis_commands/redis_download.rb +33 -0
  24. data/commands/commands/redis_commands/redis_install.rb +26 -0
  25. data/commands/commands/redis_commands/redis_make.rb +9 -0
  26. data/commands/commands/redis_commands/redis_restart.rb +7 -0
  27. data/commands/commands/redis_commands/redis_runner.rb +67 -0
  28. data/commands/commands/redis_commands/redis_start.rb +6 -0
  29. data/commands/commands/redis_commands/redis_startbg.rb +6 -0
  30. data/commands/commands/redis_commands/redis_stop.rb +6 -0
  31. data/commands/commands/rhoconnect/attach.rb +7 -0
  32. data/commands/commands/rhoconnect/clean_start.rb +9 -0
  33. data/commands/commands/rhoconnect/config.rb +15 -0
  34. data/commands/commands/rhoconnect/console.rb +15 -0
  35. data/commands/commands/rhoconnect/console_helper.rb +3 -0
  36. data/commands/commands/rhoconnect/create_user.rb +18 -0
  37. data/commands/commands/rhoconnect/delete_device.rb +9 -0
  38. data/commands/commands/rhoconnect/delete_user.rb +8 -0
  39. data/commands/commands/rhoconnect/flushdb.rb +14 -0
  40. data/commands/commands/rhoconnect/get_token.rb +25 -0
  41. data/commands/commands/rhoconnect/reset.rb +16 -0
  42. data/commands/commands/rhoconnect/reset_refresh.rb +11 -0
  43. data/commands/commands/rhoconnect/restart.rb +7 -0
  44. data/commands/commands/rhoconnect/secret.rb +11 -0
  45. data/commands/commands/rhoconnect/set_admin_password.rb +26 -0
  46. data/commands/commands/rhoconnect/spec.rb +15 -0
  47. data/commands/commands/rhoconnect/start.rb +18 -0
  48. data/commands/commands/rhoconnect/startbg.rb +34 -0
  49. data/commands/commands/rhoconnect/startdebug.rb +35 -0
  50. data/commands/commands/rhoconnect/stop.rb +11 -0
  51. data/commands/commands/rhoconnect/war.rb +32 -0
  52. data/commands/commands/rhoconnect/web.rb +7 -0
  53. data/commands/execute.rb +35 -0
  54. data/commands/generators/app.rb +6 -0
  55. data/commands/generators/source.rb +6 -0
  56. data/commands/utilities/dtach_installed.rb +10 -0
  57. data/doc/benchmarks-running.txt +5 -0
  58. data/doc/command-line.txt +216 -27
  59. data/doc/heroku-addon.txt +1 -1
  60. data/doc/preparing-production.txt +20 -1
  61. data/doc/public/cli.txt +191 -0
  62. data/doc/push-backend-setup.txt +148 -0
  63. data/doc/push-client-setup.txt +61 -0
  64. data/doc/push-server-setup.txt +91 -0
  65. data/doc/push.txt +8 -137
  66. data/doc/rest-api.txt +96 -0
  67. data/doc/settings.txt +1 -1
  68. data/doc/supported-platforms.txt +2 -1
  69. data/doc/tutorial.txt +6 -4
  70. data/examples/simple/Gemfile +39 -0
  71. data/examples/simple/Rakefile +7 -12
  72. data/examples/simple/config.ru +16 -31
  73. data/examples/simple/settings/settings.yml +5 -4
  74. data/examples/simple/sources/product.rb +51 -0
  75. data/generators/templates/application/Gemfile +7 -0
  76. data/generators/templates/application/Rakefile +5 -18
  77. data/generators/templates/application/config.ru +11 -19
  78. data/install.sh +24 -49
  79. data/installer/unix-like/create_texts.rb +71 -123
  80. data/installer/unix-like/post_install.sh +3 -0
  81. data/installer/unix-like/post_uninstall.sh +2 -0
  82. data/installer/unix-like/pre_install.sh +5 -3
  83. data/installer/unix-like/pre_uninstall.sh +14 -6
  84. data/installer/unix-like/rho_connect_install_checkers.rb +1 -1
  85. data/installer/unix-like/rho_connect_install_constants.rb +6 -10
  86. data/installer/unix-like/rho_connect_install_debian.rb +2 -2
  87. data/installer/unix-like/rho_connect_install_dnd.rb +2 -5
  88. data/installer/unix-like/rho_connect_install_installers.rb +15 -23
  89. data/installer/unix-like/rho_connect_install_yum.rb +2 -2
  90. data/installer/utils/constants.rb +4 -4
  91. data/installer/utils/create_sha1.rb +1 -1
  92. data/installer/utils/nix_install_test.rb +32 -31
  93. data/installer/utils/nix_installation.rake +1 -1
  94. data/installer/utils/package_upload/repos.rake +34 -30
  95. data/installer/utils/package_upload/s3_upload.rb +3 -3
  96. data/lib/rhoconnect/api/source/fast_delete.rb +10 -0
  97. data/lib/rhoconnect/api/source/fast_insert.rb +10 -0
  98. data/lib/rhoconnect/api/source/fast_update.rb +10 -0
  99. data/lib/rhoconnect/api/source/get_source_params.rb +1 -1
  100. data/lib/rhoconnect/api/source/list_sources.rb +2 -2
  101. data/lib/rhoconnect/api/source/save_adapter.rb +1 -1
  102. data/lib/rhoconnect/api/source/update_source_params.rb +6 -0
  103. data/lib/rhoconnect/async.rb +82 -0
  104. data/lib/rhoconnect/bulk_data/bulk_data.rb +5 -1
  105. data/lib/rhoconnect/client_sync.rb +18 -3
  106. data/lib/rhoconnect/console/rhoconnect_api.rb +2 -2
  107. data/lib/rhoconnect/console/server.rb +5 -32
  108. data/lib/rhoconnect/console.rb +2 -2
  109. data/lib/rhoconnect/graph_helper.rb +225 -0
  110. data/lib/rhoconnect/jobs/bulk_data_job.rb +24 -2
  111. data/lib/rhoconnect/server.rb +31 -11
  112. data/lib/rhoconnect/source.rb +10 -5
  113. data/lib/rhoconnect/source_sync.rb +32 -2
  114. data/lib/rhoconnect/tasks.rb +19 -108
  115. data/lib/rhoconnect/test_methods.rb +20 -0
  116. data/lib/rhoconnect/utilities.rb +118 -0
  117. data/lib/rhoconnect/version.rb +1 -1
  118. data/lib/rhoconnect/web-console/controllers/admins.js +245 -0
  119. data/lib/rhoconnect/web-console/models/adapter.js +53 -0
  120. data/lib/rhoconnect/web-console/models/client.js +105 -0
  121. data/lib/rhoconnect/web-console/models/doc.js +113 -0
  122. data/lib/rhoconnect/web-console/models/session.js +40 -0
  123. data/lib/rhoconnect/web-console/models/source.js +115 -0
  124. data/lib/rhoconnect/web-console/models/stats.js +84 -0
  125. data/lib/rhoconnect/web-console/models/user.js +111 -0
  126. data/lib/rhoconnect/web-console/public/backbone.js +1432 -0
  127. data/lib/rhoconnect/web-console/public/bootstrap.css +3990 -0
  128. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/excanvas.min.js +0 -0
  129. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.barRenderer.min.js +0 -0
  130. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.canvasAxisLabelRenderer.js +0 -0
  131. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.canvasAxisTickRenderer.js +0 -0
  132. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.canvasTextRenderer.js +0 -0
  133. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.categoryAxisRenderer.min.js +0 -0
  134. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.cursor.js +0 -0
  135. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.dateAxisRenderer.js +0 -0
  136. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.dateAxisRenderer.min.js +0 -0
  137. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.pointLabels.min.js +0 -0
  138. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jquery-1.4.2.min.js +0 -0
  139. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jquery.jqplot.min.css +0 -0
  140. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jquery.jqplot.min.js +0 -0
  141. data/lib/rhoconnect/web-console/public/jquery-1.7.1.min.js +154 -0
  142. data/lib/rhoconnect/web-console/public/rhoconnect-web.js +15 -0
  143. data/lib/rhoconnect/web-console/public/underscore.js +999 -0
  144. data/lib/rhoconnect/web-console/server.rb +55 -0
  145. data/lib/rhoconnect/web-console/templates/index.erb +90 -0
  146. data/lib/rhoconnect/web-console/templates/jqplot.erb +60 -0
  147. data/lib/rhoconnect/web-console/views/api_token.js +16 -0
  148. data/lib/rhoconnect/web-console/views/doc.js +63 -0
  149. data/lib/rhoconnect/web-console/views/edit_user.js +43 -0
  150. data/lib/rhoconnect/web-console/views/home.js +56 -0
  151. data/lib/rhoconnect/web-console/views/index.js +63 -0
  152. data/lib/rhoconnect/web-console/views/new_ping.js +58 -0
  153. data/lib/rhoconnect/web-console/views/new_user.js +29 -0
  154. data/lib/rhoconnect/web-console/views/server_doc.js +103 -0
  155. data/lib/rhoconnect/web-console/views/set_adapter.js +38 -0
  156. data/lib/rhoconnect/web-console/views/settings.js +53 -0
  157. data/lib/rhoconnect/web-console/views/show_device.js +56 -0
  158. data/lib/rhoconnect/web-console/views/show_user.js +38 -0
  159. data/lib/rhoconnect/web-console/views/source_docs.js +30 -0
  160. data/lib/rhoconnect/web-console/views/stats.js +69 -0
  161. data/lib/rhoconnect/web-console/views/users.js +20 -0
  162. data/lib/rhoconnect.rb +2 -1
  163. data/rhoconnect.gemspec +3 -1
  164. data/spec/api/application/rhoconnect_api_spec.rb +3 -5
  165. data/spec/api/source/fast_delete_spec.rb +27 -0
  166. data/spec/api/source/fast_insert_spec.rb +28 -0
  167. data/spec/api/source/fast_update_spec.rb +51 -0
  168. data/spec/api/source/get_source_params_spec.rb +1 -0
  169. data/spec/api/source/update_source_params_spec.rb +24 -0
  170. data/spec/async_spec.rb +19 -0
  171. data/spec/client_sync_spec.rb +19 -2
  172. data/spec/javascripts/PlayerSpec.js +58 -0
  173. data/spec/javascripts/admins_routes_spec.js +117 -0
  174. data/spec/javascripts/admins_spec.js +27 -0
  175. data/spec/javascripts/doc_view_spec.js +37 -0
  176. data/spec/javascripts/edit_user_view_spec.js +44 -0
  177. data/spec/javascripts/helpers/SpecHelper.js +9 -0
  178. data/spec/javascripts/helpers/jasmine-jquery.js +305 -0
  179. data/spec/javascripts/helpers/jasmine-sinon.js +43 -0
  180. data/spec/javascripts/helpers/sinon-1.3.2.js +3551 -0
  181. data/spec/javascripts/home_view_spec.js +39 -0
  182. data/spec/javascripts/index_view_spec.js +42 -0
  183. data/spec/javascripts/new_ping_view_spec.js +48 -0
  184. data/spec/javascripts/new_user_view_spec.js +42 -0
  185. data/spec/javascripts/server_doc_view_spec.js +39 -0
  186. data/spec/javascripts/set_adapter_view_spec.js +32 -0
  187. data/spec/javascripts/show_device_view_spec.js +41 -0
  188. data/spec/javascripts/show_user_view_spec.js +46 -0
  189. data/spec/javascripts/source_docs_view_spec.js +36 -0
  190. data/spec/javascripts/support/jasmine.yml +79 -0
  191. data/spec/javascripts/support/jasmine_config.rb +23 -0
  192. data/spec/javascripts/support/jasmine_runner.rb +32 -0
  193. data/spec/javascripts/users_view_spec.js +35 -0
  194. data/spec/jobs/bulk_data_job_spec.rb +10 -2
  195. data/spec/perf/bulk_data_perf_spec.rb +1 -0
  196. data/spec/server/server_spec.rb +3 -1
  197. data/spec/source_sync_spec.rb +14 -1
  198. data/spec/spec_helper.rb +51 -0
  199. data/spec/store_spec.rb +6 -0
  200. data/spec/test_methods_spec.rb +11 -0
  201. data/tasks/redis.rake +3 -1
  202. metadata +172 -64
  203. data/doc/contributing.txt +0 -60
  204. data/lib/rhoconnect/console/app/helpers/auth_helper.rb +0 -22
  205. data/lib/rhoconnect/console/app/helpers/extensions.rb +0 -19
  206. data/lib/rhoconnect/console/app/helpers/helpers.rb +0 -57
  207. data/lib/rhoconnect/console/app/public/ThickBox.css +0 -649
  208. data/lib/rhoconnect/console/app/public/home.css +0 -431
  209. data/lib/rhoconnect/console/app/public/images/foot_logo_rhoconnect.png +0 -0
  210. data/lib/rhoconnect/console/app/public/images/header_halo.jpg +0 -0
  211. data/lib/rhoconnect/console/app/public/images/land_separator.gif +0 -0
  212. data/lib/rhoconnect/console/app/public/images/landing_header.jpg +0 -0
  213. data/lib/rhoconnect/console/app/public/images/logo_rhoconnect.png +0 -0
  214. data/lib/rhoconnect/console/app/public/images/tabs_separator.png +0 -0
  215. data/lib/rhoconnect/console/app/public/main.css +0 -7
  216. data/lib/rhoconnect/console/app/public/reset.css +0 -76
  217. data/lib/rhoconnect/console/app/public/style.css +0 -2201
  218. data/lib/rhoconnect/console/app/public/text.txt +0 -0
  219. data/lib/rhoconnect/console/app/routes/adapter.rb +0 -28
  220. data/lib/rhoconnect/console/app/routes/auth.rb +0 -29
  221. data/lib/rhoconnect/console/app/routes/client.rb +0 -31
  222. data/lib/rhoconnect/console/app/routes/docs.rb +0 -145
  223. data/lib/rhoconnect/console/app/routes/heroku.rb +0 -19
  224. data/lib/rhoconnect/console/app/routes/home.rb +0 -63
  225. data/lib/rhoconnect/console/app/routes/timing.rb +0 -242
  226. data/lib/rhoconnect/console/app/routes/user.rb +0 -122
  227. data/lib/rhoconnect/console/app/views/adapter.erb +0 -16
  228. data/lib/rhoconnect/console/app/views/client.erb +0 -30
  229. data/lib/rhoconnect/console/app/views/content.erb +0 -14
  230. data/lib/rhoconnect/console/app/views/doc.erb +0 -8
  231. data/lib/rhoconnect/console/app/views/docdata.erb +0 -28
  232. data/lib/rhoconnect/console/app/views/docs.erb +0 -30
  233. data/lib/rhoconnect/console/app/views/edituser.erb +0 -13
  234. data/lib/rhoconnect/console/app/views/headermenu.erb +0 -40
  235. data/lib/rhoconnect/console/app/views/home.erb +0 -24
  236. data/lib/rhoconnect/console/app/views/index.erb +0 -58
  237. data/lib/rhoconnect/console/app/views/jqplot.erb +0 -52
  238. data/lib/rhoconnect/console/app/views/layout.erb +0 -153
  239. data/lib/rhoconnect/console/app/views/login.erb +0 -26
  240. data/lib/rhoconnect/console/app/views/newuser.erb +0 -17
  241. data/lib/rhoconnect/console/app/views/ping.erb +0 -40
  242. data/lib/rhoconnect/console/app/views/result.erb +0 -11
  243. data/lib/rhoconnect/console/app/views/rightboxlinks.erb +0 -15
  244. data/lib/rhoconnect/console/app/views/select_doc.erb +0 -17
  245. data/lib/rhoconnect/console/app/views/upload_doc.erb +0 -23
  246. data/lib/rhoconnect/console/app/views/user.erb +0 -29
  247. data/lib/rhoconnect/console/app/views/users.erb +0 -19
  248. data/lib/rhoconnect/server/views/index.erb +0 -13
data/doc/rest-api.txt CHANGED
@@ -142,6 +142,86 @@ documents, `push_deletes` method can be optimized by invoking only the necessary
142
142
  the number of transactions with Redis. To force the optimization, user can use the `:rebuild_md => false` flag
143
143
  in the `push_deletes` parameters hash.
144
144
 
145
+ ### `fast_insert`
146
+ Push new objects to RhoConnect. Changes are inserted into the Redis set without any checking for previous existence.
147
+ This way, the insert is very fast, but user must ensure that the object didn't exist before. No safeguards are implemented.
148
+ Use this method only when you can ensure the integrity of the data.
149
+
150
+ **NOTE: you may use [ping](/rhoconnect/push) to notify client after the insert and trigger sync.**
151
+
152
+ :::ruby
153
+ # list of objects in the canonical hash of hashes structure
154
+ data = {
155
+ '5' => {
156
+ 'name' => 'iPhone'
157
+ }
158
+ }
159
+ RestClient.post(
160
+ "#{server}/api/fast_insert",
161
+ {
162
+ :api_token => token,
163
+ :user_id => user_id,
164
+ :source_id => source_name,
165
+ :data => data
166
+ }.to_json,
167
+ :content_type => :json
168
+ )
169
+
170
+ ### `fast_update`
171
+ Push object updates to RhoConnect. This method doesn't involve pulling the existing data out of Redis. Instead it required user to provide the previous state of the data. This way, this method allows for very fast updates (since it just removes the previous data from set and adds new ones). However, no data integrity checks are performed. Therefore, this method must be used only if user can ensure the integrity of the data (i.e. previous state must exist, otherwise it won't be properly deleted). Also, this method can be used to perform fast appends and deletes for any of the object's attributes (However, you shoudn't use this method to remove all of the attributes, `fast_delete` should be used instead.)
172
+
173
+ **NOTE: you may use [ping](/rhoconnect/push) to notify client after the update and trigger sync.**
174
+
175
+ :::ruby
176
+ # list of objects in the canonical hash of hashes structure
177
+ # delete_data contains previous state of the object (to be deleted)
178
+ delete_data = {
179
+ '5' => {
180
+ 'name' => 'iPhone'
181
+ }
182
+ }
183
+ # data contains new state of the object
184
+ # to be inserted
185
+ data = {
186
+ '5' => {
187
+ 'name' => 'HTC'
188
+ }
189
+ }
190
+ RestClient.post(
191
+ "#{server}/api/fast_update",
192
+ {
193
+ :api_token => token,
194
+ :user_id => user_id,
195
+ :source_id => source_name,
196
+ :delete_data => delete_data,
197
+ :data => data
198
+ }.to_json,
199
+ :content_type => :json
200
+ )
201
+
202
+ ### `fast_delete`
203
+ Push object deletes to RhoConnect. This method doesn't involve pulling the existing data out of Redis and removing all of its attributes. Instead it required user to provide all of the object's data in the hash to be removed. This way, this method allows for very fast deletes (since it just removes the object's data from set). However, no data integrity checks are performed. Therefore, this method must be used only if user can ensure the integrity of the data (i.e. supply all of the object's data to be removed, otherwise some object's data will remain in Redis).
204
+
205
+ **NOTE: you may use [ping](/rhoconnect/push) to notify client after the delete and trigger sync.**
206
+
207
+ :::ruby
208
+ # list of objects in the canonical hash of hashes structure
209
+ # data contains all of the object's data (to be deleted)
210
+ data = {
211
+ '5' => {
212
+ 'name' => 'iPhone'
213
+ }
214
+ }
215
+ RestClient.post(
216
+ "#{server}/api/fast_delete",
217
+ {
218
+ :api_token => token,
219
+ :user_id => user_id,
220
+ :source_id => source_name,
221
+ :data => data
222
+ }.to_json,
223
+ :content_type => :json
224
+ )
145
225
 
146
226
  ### `list_users`
147
227
  List users registered with this RhoConnect application.
@@ -284,6 +364,22 @@ Return attributes associated with a given source:
284
364
  :content_type => :json
285
365
  ).body
286
366
 
367
+ ### `update_source_params`
368
+ Updates attributes associated with a given source:
369
+
370
+ * `poll_interval` - query poll interval; defines how often RhoConnect will call source adapter to query for new data, set to -1 to disable polling, 0 to always poll
371
+
372
+ :::ruby
373
+ attributes = RestClient.post("#{server}/api/update_source_params",
374
+ {
375
+ :api_token => token,
376
+ :source_name => source_name,
377
+ :user_name => user,
378
+ :data => {:poll_interval => 25}
379
+ }.to_json,
380
+ :content_type => :json
381
+ ).body
382
+
287
383
  ### `set_refresh_time`
288
384
  Sets source poll interval to "current time plus x seconds".
289
385
 
data/doc/settings.txt CHANGED
@@ -21,7 +21,7 @@ In addition, the following settings can be specified:
21
21
  This setting is used as a default if source doesn't specify
22
22
  its own value. Also, it is applied to dynamic adapters
23
23
  as a default sync poll interval.
24
- :bulk_data_poll_interval: <secs> - poll interval setting for bulk data sync
24
+ :bulk_sync_poll_interval: <secs> - poll interval setting for bulk data sync
25
25
 
26
26
  :c2dm_username: <google's email>
27
27
  :c2dm_passwd: <passwd>
@@ -71,4 +71,5 @@ RhoConnect for Linux and Mac OS X is supported for both development and producti
71
71
  * Windows platform: only pre-release (~> 1.0.0.beta) of <b>eventmachine</b> is working on Windows
72
72
  * Examples for <b>RSpec</b> (~> 2.8.0) fail for Ruby 1.8.7, gemset locked to ver. >= 2.6.0. <b>Issue is fixed in v. 3.1.2.</b>
73
73
  * Rack is locked to version 1.3.6 due to issues with RhoConnect applications deployed on Heroku (502 server error if rhoconnect bundled with rake 1.4.1). <b>Fixed in v. 3.1.2.</b>
74
-
74
+ * 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,
75
+ so on Bamboo your application is not invoked in the context of your bundle and might not works properly.
data/doc/tutorial.txt CHANGED
@@ -251,10 +251,10 @@ For example:
251
251
 
252
252
  ## Testing Sync from the Client
253
253
 
254
- Make sure you are running redis.
254
+ Make sure you are running redis. From the folder in which you app is located, run this command.
255
255
 
256
256
  :::term
257
- rake redis:start
257
+ $ rake redis:start
258
258
 
259
259
  Then start (or restart) your server:
260
260
 
@@ -265,9 +265,11 @@ Then start (or restart) your server:
265
265
 
266
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.
267
267
 
268
- Make sure your server URL is configured in the Rhodes app. If your server is running on localhost with the default port, the following line should be at the bottom of your corresponding Rhodes app, storemanager/rhoconfig.txt:
268
+ 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
+
270
+ syncserver = 'http://YourIPAddress:9292/application'
269
271
 
270
- syncserver = 'http://localhost:9292/application'
272
+ **NOTE: If you are using Android, syncserver cannot be set to localhost.**
271
273
 
272
274
  Enable sync in your corresponding Rhodes app, storemanager/app/Product/product.rb model:
273
275
 
@@ -0,0 +1,39 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # load rhoconnect from relative path
4
+ gem 'rhoconnect', :path => '../../'
5
+
6
+ # Helps with some of the limitations of green threads, not needed in ruby 1.9.x
7
+ gem 'SystemTimer', '~> 1.2.3', :platforms => :ruby_18
8
+ gem 'win32-process', :platforms => [:mswin, :mingw]
9
+
10
+ # for Async, Eventful execution
11
+ platforms :ruby_19 do
12
+ gem 'rack-fiber_pool'
13
+ gem 'async-rack'
14
+ end
15
+
16
+ platforms :jruby do
17
+ gem 'jdbc-sqlite3', ">= 3.7.2"
18
+ gem 'dbi', ">= 0.4.5"
19
+ gem 'dbd-jdbc', ">= 0.1.4"
20
+ gem 'jruby-openssl', ">= 0.7.4"
21
+ gem 'trinidad'
22
+ gem 'warbler'
23
+ end
24
+
25
+ gem 'sqlite3', ">= 1.3.3", :platforms => [:ruby, :mswin, :mingw]
26
+
27
+ group :development do
28
+ # FIXME: At this moment (01/10/2012) only pre release of 'eventmachine' is working on Windows
29
+ gem 'eventmachine', '~> 1.0.0.beta', :platforms => [:mswin, :mingw]
30
+ # By default to run application thin web server is used
31
+ gem 'thin', :platforms => [:ruby, :mswin, :mingw]
32
+ gem 'rhomobile-debug', ">= 1.0.2"
33
+ end
34
+
35
+ group :test do
36
+ gem 'rack-test', '>= 0.5.3', :require => "rack/test"
37
+ gem 'rspec', '~> 2.6.0'
38
+ gem 'rhomobile-debug', ">= 1.0.2"
39
+ end
@@ -1,14 +1,9 @@
1
- $:.unshift File.join(File.dirname(__FILE__),'..','..','lib')
1
+ require 'rubygems'
2
+ require 'bundler/setup'
2
3
  require 'rhoconnect/tasks'
4
+ require 'rhoconnect'
5
+ require 'resque/tasks'
3
6
 
4
- ROOT_PATH = File.expand_path(File.dirname(__FILE__))
5
-
6
- begin
7
- require 'resque/tasks'
8
- task "resque:setup" do
9
- require 'application'
10
- end
11
- rescue LoadError
12
- puts "Resque not available. Install it with: "
13
- puts "gem install resque\n\n"
14
- end
7
+ task 'resque:setup' do
8
+ require './application'
9
+ end
@@ -1,49 +1,34 @@
1
1
  #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'bundler'
4
+ Bundler.require
2
5
 
3
- path = File.join(File.dirname(__FILE__),'..','..','lib')
4
- $:.unshift path
6
+ ROOT_PATH = File.expand_path(File.dirname(__FILE__))
5
7
 
6
- # Try to load vendor-ed rhoconnect, otherwise load the gem
7
- begin
8
- require 'vendor/rhoconnect/lib/rhoconnect/server'
9
- require 'vendor/rhoconnect/lib/rhoconnect/console/server'
10
- rescue LoadError
11
- require 'rhoconnect/server'
12
- require 'rhoconnect/console/server'
8
+ if ENV['DEBUG'] == 'yes'
9
+ ENV['APP_TYPE'] = 'rhosync'
10
+ ENV['ROOT_PATH'] = ROOT_PATH
11
+ require 'debugger'
13
12
  end
14
13
 
15
- require 'x_domain_session_wrapper'
16
- use XDomainSessionWrapper
17
-
18
- # By default, turn on the resque web console
14
+ require 'rhoconnect/server'
15
+ require 'rhoconnect/console/server'
19
16
  require 'resque/server'
20
17
 
21
- ROOT_PATH = File.expand_path(File.dirname(__FILE__))
22
-
23
18
  # Rhoconnect server flags
24
19
  Rhoconnect::Server.disable :run
20
+ Rhoconnect::Server.enable :stats
25
21
  Rhoconnect::Server.disable :clean_trace
26
22
  Rhoconnect::Server.enable :raise_errors
23
+ Rhoconnect::Server.set :secret, '3ddaa72a36466bae3fc5e54c09324db50cfc30588d8dee1a2700e61195bdbbb5eeb65da2a184d274ce644b20b0e986046c2447730c85555ce18a4eb2fce7ebf5'
27
24
  Rhoconnect::Server.set :root, ROOT_PATH
28
- #Rhoconnect::Server.enable :stats
29
- Rhoconnect::Server.set :secret, '3ddaa72a36466bae3fc5e54c09324db50cfc30588d8dee1a2700e61195bdbbb5eeb65da2a184d274ce644b20b0e986046c2447730c85555ce18a4eb2fce7ebf5'
30
- Rhoconnect::Server.use Rack::Static, :urls => ["/data"], :root => Rhoconnect::Server.root
31
-
32
- # configure Cross-Domain Resource Sharing
33
- require 'cors'
34
- use Rack::Cors do |cfg|
35
- cfg.allow do |allow|
36
- allow.origins /.*/
37
- allow.resource '/application', :headers => :any, :methods => [:get, :post, :put, :delete], :credentials => true
38
- allow.resource '/application/*', :headers => :any, :methods => [:get, :post, :put, :delete], :credentials => true
39
- end
40
- end
41
-
25
+ Rhoconnect::Server.use Rack::Static, :urls => ['/data'], :root => Rhoconnect::Server.root
26
+
42
27
  # Load our rhoconnect application
43
28
  require './application'
44
29
 
45
30
  # Setup the url map
46
31
  run Rack::URLMap.new \
47
- "/" => Rhoconnect::Server.new,
48
- "/resque" => Resque::Server.new, # If you don't want resque frontend, disable it here
32
+ '/' => Rhoconnect::Server.new,
33
+ '/resque' => Resque::Server.new, # If you don't want resque frontend, disable it here
49
34
  "/console" => RhoconnectConsole::Server.new # If you don't want rhoconnect frontend, disable it here
@@ -4,20 +4,21 @@
4
4
  SampleAdapter:
5
5
  :partition_type: app
6
6
  :poll_interval: 500
7
+ Product:
8
+ :partition_type: user
9
+ :poll_interval: 500
7
10
 
8
11
  :development:
9
12
  :licensefile: settings/license.key
10
13
  :redis: localhost:6379
11
14
  :syncserver: http://localhost:9292/api/application/
12
- :api_token: sometokenforme
13
- :test:
15
+ :test:
14
16
  :licensefile: settings/license.key
15
17
  :redis: localhost:6379
16
18
  :syncserver: http://localhost:9292/api/application/
17
- :api_token: sometokenforme
18
19
  :production:
19
20
  :licensefile: settings/license.key
20
21
  :redis: localhost:6379
21
22
  :syncserver: http://localhost:9292/api/application/
22
- :api_token: sometokenforme
23
+
23
24
 
@@ -0,0 +1,51 @@
1
+ require 'json'
2
+ require 'rest_client'
3
+
4
+ class Product < SourceAdapter
5
+ def initialize(source)
6
+ @base = 'http://rhostore.heroku.com/products'
7
+ super(source)
8
+ end
9
+
10
+ def query
11
+ parsed=JSON.parse(RestClient.get("#{@base}.json").body)
12
+
13
+ @result={}
14
+ if parsed
15
+ parsed.each do |item|
16
+ key = item["product"]["id"].to_s
17
+ @result[key]=item["product"]
18
+ end
19
+ end
20
+ end
21
+
22
+ def sync
23
+ # Manipulate @result before it is saved, or save it
24
+ # yourself using the Rhoconnect::Store interface.
25
+ # By default, super is called below which simply saves @result
26
+ super
27
+ end
28
+
29
+ def create(create_hash)
30
+ # TODO: Create a new record in your backend data source
31
+ # If your rhodes rhom object contains image/binary data
32
+ # (has the image_uri attribute), then a blob will be provided
33
+ raise "Please provide some code to create a single record in the backend data source using the create_hash"
34
+ end
35
+
36
+ def update(update_hash)
37
+ # TODO: Update an existing record in your backend data source
38
+ raise "Please provide some code to update a single record in the backend data source using the update_hash"
39
+ end
40
+
41
+ def delete(delete_hash)
42
+ # TODO: write some code here if applicable
43
+ # be sure to have a hash key and value for "object"
44
+ # for now, we'll say that its OK to not have a delete operation
45
+ # raise "Please provide some code to delete a single object in the backend application using the object_id"
46
+ end
47
+
48
+ def logoff
49
+ # TODO: Logout from the data source if necessary
50
+ end
51
+ end
@@ -6,6 +6,13 @@ gem 'rhoconnect', '<%=gem_version%>'
6
6
  gem 'SystemTimer', '~> 1.2.3', :platforms => :ruby_18
7
7
  gem 'win32-process', :platforms => [:mswin, :mingw]
8
8
 
9
+ # for Async, Eventful execution
10
+ platforms :ruby_19 do
11
+ gem 'thin'
12
+ gem 'rack-fiber_pool'
13
+ gem 'async-rack'
14
+ end
15
+
9
16
  platforms :jruby do
10
17
  gem 'jdbc-sqlite3', ">= 3.7.2"
11
18
  gem 'dbi', ">= 0.4.5"
@@ -1,22 +1,9 @@
1
1
  require 'rubygems'
2
2
  require 'bundler/setup'
3
+ require 'rhoconnect/tasks'
4
+ require 'rhoconnect'
5
+ require 'resque/tasks'
3
6
 
4
- begin
5
- require 'vendor/rhoconnect/lib/rhoconnect/tasks'
6
- require 'vendor/rhoconnect/lib/rhoconnect'
7
- rescue LoadError
8
- require 'rhoconnect/tasks'
9
- require 'rhoconnect'
7
+ task 'resque:setup' do
8
+ require './application'
10
9
  end
11
-
12
- ROOT_PATH = File.expand_path(File.dirname(__FILE__))
13
-
14
- begin
15
- require 'resque/tasks'
16
- task "resque:setup" do
17
- require 'application'
18
- end
19
- rescue LoadError
20
- puts "Resque not available. Install it with: "
21
- puts "gem install resque\n\n"
22
- end
@@ -6,37 +6,29 @@ Bundler.require
6
6
  ROOT_PATH = File.expand_path(File.dirname(__FILE__))
7
7
 
8
8
  if ENV['DEBUG'] == 'yes'
9
- ENV['APP_TYPE'] = 'rhosync'
10
- ENV['ROOT_PATH'] = ROOT_PATH
11
- require 'debugger'
9
+ ENV['APP_TYPE'] = 'rhosync'
10
+ ENV['ROOT_PATH'] = ROOT_PATH
11
+ require 'debugger'
12
12
  end
13
13
 
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
14
+ require 'rhoconnect/server'
15
+ require 'rhoconnect/web-console/server'
24
16
  require 'resque/server'
25
17
 
26
-
27
18
  # Rhoconnect server flags
19
+ #Rhoconnect::Server.enable :stats
28
20
  Rhoconnect::Server.disable :run
29
21
  Rhoconnect::Server.disable :clean_trace
30
22
  Rhoconnect::Server.enable :raise_errors
31
23
  Rhoconnect::Server.set :secret, '<%= @secret %>'
32
24
  Rhoconnect::Server.set :root, ROOT_PATH
33
- Rhoconnect::Server.use Rack::Static, :urls => ["/data"], :root => Rhoconnect::Server.root
25
+ Rhoconnect::Server.use Rack::Static, :urls => ['/data'], :root => Rhoconnect::Server.root
34
26
 
35
27
  # Load our rhoconnect application
36
- require "#{ROOT_PATH}/application"
28
+ require './application'
37
29
 
38
30
  # Setup the url map
39
31
  run Rack::URLMap.new \
40
- "/" => Rhoconnect::Server.new,
41
- "/resque" => Resque::Server.new, # If you don't want resque frontend, disable it here
42
- "/console" => RhoconnectConsole::Server.new # If you don't want rhoconnect frontend, disable it here
32
+ '/' => Rhoconnect::Server.new,
33
+ '/resque' => Resque::Server.new, # If you don't want resque frontend, disable it here
34
+ '/console' => RhoconnectConsole::Server.new # If you don't want rhoconnect frontend, disable it here
data/install.sh CHANGED
@@ -200,10 +200,11 @@ logAndPrint ()
200
200
  setRubyVars ()
201
201
  {
202
202
  if [[ $rubyVersion == "" || $rubyVersion =~ ruby'ee'|'enterprise' ]]; then
203
- rubyVersion="rubyee"
204
- rubyDir="ruby-enterprise-1.8.7-2012.02"
203
+ rubyVersion="ruby-1.9.3-p125"
204
+ rubyDir="ruby-1.9.3-p125"
205
205
  rubyTar="${rubyDir}.tar.gz"
206
- rubyURL="http://rubyenterpriseedition.googlecode.com/files/${rubyTar}"
206
+ # http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
207
+ rubyURL="http://ftp.ruby-lang.org/pub/ruby/1.9/${rubyTar}"
207
208
  elif [$rubyVersion == "ruby187"]; then
208
209
  rubyDir="ruby-1.8.7"
209
210
  rubyTar="${rubyDir}.tar.gz"
@@ -223,15 +224,26 @@ installRuby ()
223
224
  if [[ ! -d "${prefix}${rubyDir}" ]]; then
224
225
  echo "Downloading ${rubyURL} ..." | tee -a $log
225
226
  echo "wget -P ${prefix} ${rubyURL}" >> $log
226
- wget -P ${prefix} ${rubyURL} > $log 2>&1
227
+ wget -P ${prefix} ${rubyURL} -o /dev/null
227
228
  echo "tar -xzf ${prefix}/${rubyTar} -C ${prefix}" >> $log
228
- tar -xzf ${prefix}/${rubyTar} -C ${prefix} > $log 2>&1
229
+ tar -xzf ${prefix}/${rubyTar} -C ${prefix} > /dev/null 2>&1
229
230
  fi
230
231
  echo "Installing ruby. This may take some time..." | tee -a $log
231
232
 
232
233
  case $rubyVersion in
233
- rubyee)
234
- logAndPrint "${prefix}/${rubyDir}/installer --dont-install-useful-gems --no-dev-docs --auto ${prefix}"
234
+ # rubyee)
235
+ # logAndPrint "${prefix}/${rubyDir}/installer --dont-install-useful-gems --no-dev-docs --auto ${prefix}"
236
+ # ;;
237
+ ruby-1.9.3-p125)
238
+ (
239
+ echo "cd ${prefix}/${rubyDir}" | tee -a $log
240
+ cd ${prefix}/${rubyDir}
241
+ echo "./configure --prefix=${prefix} --enable-shared --disable-install-doc" | tee -a $log
242
+ ./configure --prefix=${prefix} --enable-shared --disable-install-doc >> $log 2>&1
243
+ echo "make && make install" | tee -a $log
244
+ make >> $log 2>&1
245
+ make install >> $log 2>&1
246
+ )
235
247
  ;;
236
248
  ruby187)
237
249
  logAndPrint "${prefix}/${rubyDir}/configure --prefix=\"${prefix}\""
@@ -247,50 +259,15 @@ installRuby ()
247
259
  ;;
248
260
  esac
249
261
 
250
- if [[ $exitStatus != 0 ]]; then
262
+ if [[ $? != 0 ]]; then
251
263
  echo "Some dependencies not installed..." | tee -a $log
252
264
  echo "Please install them and then re-run the installation script." | tee -a $log
253
265
  echo "For troubleshooting see file $log ..." | tee -a $log
254
266
  exit
255
267
  fi
256
268
 
257
- echo "Ruby $rubyDir is successfully installed." | tee -a $log
258
- } #end installRuby
259
-
260
- getTime ()
261
- {
262
- timeDiff=$(( $1 - $timeInitial ))
263
- timeSec=$(( $timeDiff % 100 ))
264
- timeDiff=$(( $timeDiff / 100 ))
265
-
266
- if [ $timeSec -gt 1 ]; then
267
- timeSec=$timeSec" seconds"
268
- else
269
- timeSec=$timeSec" second"
270
- fi
271
-
272
- if [ $timeDiff -gt 0 ]; then
273
- timeMin=$(( $timeDiff % 100 ))
274
- timeDiff=$(( $timeDiff / 100 ))
275
- if [ $timeMin -gt 1 ]; then
276
- timeMin=$timeMin" minutes and "
277
- else
278
- timeMin=$timeMin" minute and "
279
- fi
280
- fi
281
-
282
- if [ $timeDiff -gt 0 ]; then
283
- timeHour=$(( $timeDiff % 100 ))
284
- timeDiff=$(( $timeDiff / 100 ))
285
- if [ $timeHour -gt 1 ]; then
286
- timeHour=$timeHour" hours, "
287
- else
288
- timeHour=$timeHour" hour, "
289
- fi
290
- fi
291
-
292
- echo "\nInstallation completed in ${timeHour}${timeMin}${timeSec}."
293
- } #end getTime
269
+ echo -e "$rubyDir is successfully installed.\n" | tee -a $log
270
+ }
294
271
 
295
272
  # SCRIPT
296
273
 
@@ -369,11 +346,9 @@ if [[ $installedSoftware -eq ${#INSTALL_ARRAY[@]} ]]; then
369
346
  fi
370
347
 
371
348
  if (( $rho_status )) ; then
372
- echo "Installation failed. For troubleshooting see file $log ..." | tee -a $log
349
+ echo "Installation failed. For troubleshooting see file $log ..." | tee -a $log
373
350
  else
374
- opts=" -d $dist"
351
+ opts=" -d $dist -l $log"
375
352
  ${prefix}/bin/ruby ${INSTALL_DIR}/unix-like/create_texts.rb ${opts}
376
353
  fi
377
- # timeFinal=`date +%H%M%S`
378
- # getTime $timeFinal
379
354
  fi