rhoconnect 3.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (361) hide show
  1. data/CHANGELOG +208 -0
  2. data/CREDITS +38 -0
  3. data/Gemfile +18 -0
  4. data/Gemfile.lock +97 -0
  5. data/LICENSE +75 -0
  6. data/README.md +10 -0
  7. data/Rakefile +82 -0
  8. data/bench/bench +7 -0
  9. data/bench/bench_runner.rb +112 -0
  10. data/bench/benchapp/Gemfile +21 -0
  11. data/bench/benchapp/Gemfile.lock +76 -0
  12. data/bench/benchapp/Rakefile +22 -0
  13. data/bench/benchapp/application.rb +39 -0
  14. data/bench/benchapp/config.ru +36 -0
  15. data/bench/benchapp/settings/license.key +1 -0
  16. data/bench/benchapp/settings/settings.yml +20 -0
  17. data/bench/benchapp/sources/mock_adapter.rb +55 -0
  18. data/bench/benchapp/sources/queue_mock_adapter.rb +2 -0
  19. data/bench/benchapp/spec/sources/mock_adapter_spec.rb +25 -0
  20. data/bench/benchapp/spec/sources/queue_mock_adapter_spec.rb +25 -0
  21. data/bench/benchapp/spec/spec_helper.rb +42 -0
  22. data/bench/blobapp/Gemfile +31 -0
  23. data/bench/blobapp/Gemfile.lock +103 -0
  24. data/bench/blobapp/Rakefile +25 -0
  25. data/bench/blobapp/application.rb +44 -0
  26. data/bench/blobapp/config.ru +36 -0
  27. data/bench/blobapp/settings/license.key +1 -0
  28. data/bench/blobapp/settings/settings.yml +16 -0
  29. data/bench/blobapp/sources/blob_adapter.rb +71 -0
  30. data/bench/blobapp/spec/sources/blob_adapter_spec.rb +25 -0
  31. data/bench/blobapp/spec/spec_helper.rb +42 -0
  32. data/bench/lib/bench/cli.rb +16 -0
  33. data/bench/lib/bench/logging.rb +13 -0
  34. data/bench/lib/bench/mock_client.rb +41 -0
  35. data/bench/lib/bench/result.rb +50 -0
  36. data/bench/lib/bench/runner.rb +107 -0
  37. data/bench/lib/bench/session.rb +67 -0
  38. data/bench/lib/bench/statistics.rb +56 -0
  39. data/bench/lib/bench/test_data.rb +98 -0
  40. data/bench/lib/bench/timer.rb +10 -0
  41. data/bench/lib/bench/utils.rb +49 -0
  42. data/bench/lib/bench.rb +129 -0
  43. data/bench/lib/testdata/100-data.txt +148 -0
  44. data/bench/lib/testdata/5-data.txt +9 -0
  45. data/bench/lib/testdata/images/icon.ico +0 -0
  46. data/bench/lib/testdata/images/icon.png +0 -0
  47. data/bench/lib/testdata/images/loading-Landscape.png +0 -0
  48. data/bench/lib/testdata/images/loading-LandscapeLeft.png +0 -0
  49. data/bench/lib/testdata/images/loading-LandscapeRight.png +0 -0
  50. data/bench/lib/testdata/images/loading-Portrait.png +0 -0
  51. data/bench/lib/testdata/images/loading-PortraitUpsideDown.png +0 -0
  52. data/bench/lib/testdata/images/loading.png +0 -0
  53. data/bench/lib/testdata/images/loading@2x.png +0 -0
  54. data/bench/run_bench.sh +42 -0
  55. data/bench/run_blob_script.sh +3 -0
  56. data/bench/run_cud_script.sh +3 -0
  57. data/bench/run_query_md_script.sh +3 -0
  58. data/bench/run_query_only_script.sh +3 -0
  59. data/bench/run_query_script.sh +3 -0
  60. data/bench/scripts/blob_cud_script.rb +98 -0
  61. data/bench/scripts/cud_script.rb +92 -0
  62. data/bench/scripts/helpers.rb +101 -0
  63. data/bench/scripts/query_md_script.rb +45 -0
  64. data/bench/scripts/query_only_script.rb +51 -0
  65. data/bench/scripts/query_script.rb +45 -0
  66. data/bench/spec/bench_spec_helper.rb +33 -0
  67. data/bench/spec/logging_spec.rb +15 -0
  68. data/bench/spec/mock_adapter_spec.rb +61 -0
  69. data/bench/spec/mock_client_spec.rb +65 -0
  70. data/bench/spec/result_spec.rb +61 -0
  71. data/bench/spec/utils_spec.rb +36 -0
  72. data/bin/rhoconnect +34 -0
  73. data/bin/rhoconnect-setup +84 -0
  74. data/doc/async-jobs.txt +69 -0
  75. data/doc/authentication.txt +76 -0
  76. data/doc/benchmarks.txt +168 -0
  77. data/doc/blob-sync.txt +130 -0
  78. data/doc/bulk-sync.txt +102 -0
  79. data/doc/client.txt +432 -0
  80. data/doc/command-line.txt +210 -0
  81. data/doc/contributing.txt +60 -0
  82. data/doc/deploying.txt +82 -0
  83. data/doc/install.txt +28 -0
  84. data/doc/introduction.txt +20 -0
  85. data/doc/licensing.txt +18 -0
  86. data/doc/metadata.txt +458 -0
  87. data/doc/migration.txt +182 -0
  88. data/doc/public/css/print.css +29 -0
  89. data/doc/public/css/screen.css +257 -0
  90. data/doc/public/css/style.css +20 -0
  91. data/doc/push.txt +135 -0
  92. data/doc/release.txt +41 -0
  93. data/doc/rest-api.txt +367 -0
  94. data/doc/source-adapters.txt +325 -0
  95. data/doc/stats-middleware.txt +69 -0
  96. data/doc/testing.txt +222 -0
  97. data/doc/tutorial.txt +315 -0
  98. data/doc/web-console.txt +35 -0
  99. data/examples/simple/Rakefile +14 -0
  100. data/examples/simple/application.rb +27 -0
  101. data/examples/simple/config.ru +49 -0
  102. data/examples/simple/settings/license.key +1 -0
  103. data/examples/simple/settings/settings.yml +23 -0
  104. data/examples/simple/sources/sample_adapter.rb +5 -0
  105. data/examples/simple/sources/simple_adapter.rb +5 -0
  106. data/generators/rhoconnect.rb +119 -0
  107. data/generators/templates/application/Gemfile +21 -0
  108. data/generators/templates/application/Rakefile +22 -0
  109. data/generators/templates/application/application.rb +39 -0
  110. data/generators/templates/application/config.ru +36 -0
  111. data/generators/templates/application/settings/license.key +1 -0
  112. data/generators/templates/application/settings/settings.yml +14 -0
  113. data/generators/templates/application/spec/spec_helper.rb +42 -0
  114. data/generators/templates/source/source_adapter.rb +47 -0
  115. data/generators/templates/source/source_spec.rb +25 -0
  116. data/install.sh +408 -0
  117. data/installer/unix-like/rho_connect_install_checkers.rb +140 -0
  118. data/installer/unix-like/rho_connect_install_constants.rb +51 -0
  119. data/installer/unix-like/rho_connect_install_debian.rb +63 -0
  120. data/installer/unix-like/rho_connect_install_dnd.rb +58 -0
  121. data/installer/unix-like/rho_connect_install_get_params.rb +30 -0
  122. data/installer/unix-like/rho_connect_install_installers.rb +142 -0
  123. data/installer/unix-like/rho_connect_install_utilities.rb +85 -0
  124. data/installer/unix-like/rho_connect_install_yum.rb +63 -0
  125. data/installer/unix-like/rhoinstaller.rb +89 -0
  126. data/installer/utils/create_texts.rb +366 -0
  127. data/installer/utils/install_test.rb +140 -0
  128. data/installer/windows/EnvVarUpdate.nsh +328 -0
  129. data/installer/windows/ServiceLib.nsh +369 -0
  130. data/installer/windows/configUi.ini +44 -0
  131. data/installer/windows/icon.ico +0 -0
  132. data/installer/windows/rhosync.nsi +418 -0
  133. data/installer/windows/uninstall.bat +7 -0
  134. data/lib/rhoconnect/api/admin/get_api_token.rb +14 -0
  135. data/lib/rhoconnect/api/admin/get_license_info.rb +8 -0
  136. data/lib/rhoconnect/api/admin/login.rb +6 -0
  137. data/lib/rhoconnect/api/admin/reset.rb +10 -0
  138. data/lib/rhoconnect/api/admin/stats.rb +21 -0
  139. data/lib/rhoconnect/api/application/bulk_data.rb +7 -0
  140. data/lib/rhoconnect/api/application/clientcreate.rb +8 -0
  141. data/lib/rhoconnect/api/application/clientlogin.rb +6 -0
  142. data/lib/rhoconnect/api/application/clientregister.rb +6 -0
  143. data/lib/rhoconnect/api/application/clientreset.rb +6 -0
  144. data/lib/rhoconnect/api/application/query.rb +7 -0
  145. data/lib/rhoconnect/api/application/queue_updates.rb +6 -0
  146. data/lib/rhoconnect/api/application/search.rb +6 -0
  147. data/lib/rhoconnect/api/client/create_client.rb +3 -0
  148. data/lib/rhoconnect/api/client/delete_client.rb +5 -0
  149. data/lib/rhoconnect/api/client/get_client_params.rb +3 -0
  150. data/lib/rhoconnect/api/client/list_client_docs.rb +12 -0
  151. data/lib/rhoconnect/api/client/list_clients.rb +3 -0
  152. data/lib/rhoconnect/api/client/ping.rb +7 -0
  153. data/lib/rhoconnect/api/source/get_adapter.rb +3 -0
  154. data/lib/rhoconnect/api/source/get_db_doc.rb +7 -0
  155. data/lib/rhoconnect/api/source/get_source_params.rb +3 -0
  156. data/lib/rhoconnect/api/source/list_source_docs.rb +10 -0
  157. data/lib/rhoconnect/api/source/list_sources.rb +15 -0
  158. data/lib/rhoconnect/api/source/push_deletes.rb +8 -0
  159. data/lib/rhoconnect/api/source/push_objects.rb +8 -0
  160. data/lib/rhoconnect/api/source/save_adapter.rb +3 -0
  161. data/lib/rhoconnect/api/source/set_db_doc.rb +8 -0
  162. data/lib/rhoconnect/api/source/set_refresh_time.rb +8 -0
  163. data/lib/rhoconnect/api/source/upload_file.rb +4 -0
  164. data/lib/rhoconnect/api/user/create_user.rb +7 -0
  165. data/lib/rhoconnect/api/user/delete_user.rb +9 -0
  166. data/lib/rhoconnect/api/user/list_users.rb +3 -0
  167. data/lib/rhoconnect/api/user/update_user.rb +4 -0
  168. data/lib/rhoconnect/api_token.rb +19 -0
  169. data/lib/rhoconnect/app.rb +76 -0
  170. data/lib/rhoconnect/bulk_data/bulk_data.rb +88 -0
  171. data/lib/rhoconnect/bulk_data/syncdb.index.schema +4 -0
  172. data/lib/rhoconnect/bulk_data/syncdb.schema +41 -0
  173. data/lib/rhoconnect/bulk_data.rb +2 -0
  174. data/lib/rhoconnect/client.rb +96 -0
  175. data/lib/rhoconnect/client_sync.rb +412 -0
  176. data/lib/rhoconnect/console/app/helpers/auth_helper.rb +22 -0
  177. data/lib/rhoconnect/console/app/helpers/extensions.rb +19 -0
  178. data/lib/rhoconnect/console/app/helpers/helpers.rb +57 -0
  179. data/lib/rhoconnect/console/app/public/ThickBox.css +649 -0
  180. data/lib/rhoconnect/console/app/public/home.css +438 -0
  181. data/lib/rhoconnect/console/app/public/images/foot_logo_rhoconnect.png +0 -0
  182. data/lib/rhoconnect/console/app/public/images/header_halo.jpg +0 -0
  183. data/lib/rhoconnect/console/app/public/images/land_separator.gif +0 -0
  184. data/lib/rhoconnect/console/app/public/images/landing_header.jpg +0 -0
  185. data/lib/rhoconnect/console/app/public/images/logo_rhoconnect.png +0 -0
  186. data/lib/rhoconnect/console/app/public/images/rhomobile_rhohub_logo.png +0 -0
  187. data/lib/rhoconnect/console/app/public/images/tabs_separator.png +0 -0
  188. data/lib/rhoconnect/console/app/public/jqplot/excanvas.min.js +35 -0
  189. data/lib/rhoconnect/console/app/public/jqplot/jqplot.barRenderer.min.js +34 -0
  190. data/lib/rhoconnect/console/app/public/jqplot/jqplot.canvasAxisLabelRenderer.js +187 -0
  191. data/lib/rhoconnect/console/app/public/jqplot/jqplot.canvasAxisTickRenderer.js +226 -0
  192. data/lib/rhoconnect/console/app/public/jqplot/jqplot.canvasTextRenderer.js +408 -0
  193. data/lib/rhoconnect/console/app/public/jqplot/jqplot.categoryAxisRenderer.min.js +34 -0
  194. data/lib/rhoconnect/console/app/public/jqplot/jqplot.cursor.js +952 -0
  195. data/lib/rhoconnect/console/app/public/jqplot/jqplot.dateAxisRenderer.js +313 -0
  196. data/lib/rhoconnect/console/app/public/jqplot/jqplot.dateAxisRenderer.min.js +34 -0
  197. data/lib/rhoconnect/console/app/public/jqplot/jqplot.pointLabels.min.js +34 -0
  198. data/lib/rhoconnect/console/app/public/jqplot/jquery-1.4.2.min.js +154 -0
  199. data/lib/rhoconnect/console/app/public/jqplot/jquery.jqplot.min.css +1 -0
  200. data/lib/rhoconnect/console/app/public/jqplot/jquery.jqplot.min.js +34 -0
  201. data/lib/rhoconnect/console/app/public/main.css +7 -0
  202. data/lib/rhoconnect/console/app/public/reset.css +76 -0
  203. data/lib/rhoconnect/console/app/public/style.css +2201 -0
  204. data/lib/rhoconnect/console/app/public/text.txt +0 -0
  205. data/lib/rhoconnect/console/app/routes/adapter.rb +28 -0
  206. data/lib/rhoconnect/console/app/routes/auth.rb +29 -0
  207. data/lib/rhoconnect/console/app/routes/client.rb +31 -0
  208. data/lib/rhoconnect/console/app/routes/docs.rb +145 -0
  209. data/lib/rhoconnect/console/app/routes/heroku.rb +19 -0
  210. data/lib/rhoconnect/console/app/routes/home.rb +63 -0
  211. data/lib/rhoconnect/console/app/routes/timing.rb +242 -0
  212. data/lib/rhoconnect/console/app/routes/user.rb +117 -0
  213. data/lib/rhoconnect/console/app/views/adapter.erb +16 -0
  214. data/lib/rhoconnect/console/app/views/client.erb +30 -0
  215. data/lib/rhoconnect/console/app/views/content.erb +14 -0
  216. data/lib/rhoconnect/console/app/views/doc.erb +8 -0
  217. data/lib/rhoconnect/console/app/views/docdata.erb +28 -0
  218. data/lib/rhoconnect/console/app/views/docs.erb +30 -0
  219. data/lib/rhoconnect/console/app/views/edituser.erb +13 -0
  220. data/lib/rhoconnect/console/app/views/headermenu.erb +40 -0
  221. data/lib/rhoconnect/console/app/views/home.erb +24 -0
  222. data/lib/rhoconnect/console/app/views/index.erb +58 -0
  223. data/lib/rhoconnect/console/app/views/jqplot.erb +52 -0
  224. data/lib/rhoconnect/console/app/views/layout.erb +165 -0
  225. data/lib/rhoconnect/console/app/views/login.erb +26 -0
  226. data/lib/rhoconnect/console/app/views/newuser.erb +17 -0
  227. data/lib/rhoconnect/console/app/views/ping.erb +28 -0
  228. data/lib/rhoconnect/console/app/views/result.erb +11 -0
  229. data/lib/rhoconnect/console/app/views/rightboxlinks.erb +15 -0
  230. data/lib/rhoconnect/console/app/views/select_doc.erb +17 -0
  231. data/lib/rhoconnect/console/app/views/upload_doc.erb +23 -0
  232. data/lib/rhoconnect/console/app/views/user.erb +29 -0
  233. data/lib/rhoconnect/console/app/views/users.erb +12 -0
  234. data/lib/rhoconnect/console/rhoconnect_api.rb +245 -0
  235. data/lib/rhoconnect/console/server.rb +32 -0
  236. data/lib/rhoconnect/console.rb +3 -0
  237. data/lib/rhoconnect/cors.rb +229 -0
  238. data/lib/rhoconnect/credential.rb +9 -0
  239. data/lib/rhoconnect/db_adapter.rb +46 -0
  240. data/lib/rhoconnect/document.rb +49 -0
  241. data/lib/rhoconnect/dynamic_adapter.rb +91 -0
  242. data/lib/rhoconnect/generator.rb +1 -0
  243. data/lib/rhoconnect/jobs/bulk_data_job.rb +203 -0
  244. data/lib/rhoconnect/jobs/ping_job.rb +46 -0
  245. data/lib/rhoconnect/jobs/source_job.rb +16 -0
  246. data/lib/rhoconnect/license.rb +86 -0
  247. data/lib/rhoconnect/lock_ops.rb +11 -0
  248. data/lib/rhoconnect/model.rb +414 -0
  249. data/lib/rhoconnect/ping/android.rb +56 -0
  250. data/lib/rhoconnect/ping/apple.rb +52 -0
  251. data/lib/rhoconnect/ping/blackberry.rb +56 -0
  252. data/lib/rhoconnect/ping.rb +3 -0
  253. data/lib/rhoconnect/read_state.rb +31 -0
  254. data/lib/rhoconnect/rho_indifferent_access.rb +88 -0
  255. data/lib/rhoconnect/server/views/index.erb +13 -0
  256. data/lib/rhoconnect/server.rb +286 -0
  257. data/lib/rhoconnect/source.rb +289 -0
  258. data/lib/rhoconnect/source_adapter.rb +123 -0
  259. data/lib/rhoconnect/source_sync.rb +302 -0
  260. data/lib/rhoconnect/stats/middleware.rb +20 -0
  261. data/lib/rhoconnect/stats/record.rb +108 -0
  262. data/lib/rhoconnect/store.rb +232 -0
  263. data/lib/rhoconnect/tasks.rb +350 -0
  264. data/lib/rhoconnect/test_methods.rb +220 -0
  265. data/lib/rhoconnect/user.rb +95 -0
  266. data/lib/rhoconnect/version.rb +3 -0
  267. data/lib/rhoconnect/x_domain_session_wrapper.rb +53 -0
  268. data/lib/rhoconnect.rb +285 -0
  269. data/rhoconnect.gemspec +67 -0
  270. data/spec/api/admin/api_token_spec.rb +14 -0
  271. data/spec/api/admin/get_api_token_spec.rb +36 -0
  272. data/spec/api/admin/get_license_info_spec.rb +38 -0
  273. data/spec/api/admin/reset_spec.rb +22 -0
  274. data/spec/api/admin/stats_spec.rb +66 -0
  275. data/spec/api/api_helper.rb +21 -0
  276. data/spec/api/application/rhoconnect_api_spec.rb +548 -0
  277. data/spec/api/client/create_client_spec.rb +13 -0
  278. data/spec/api/client/delete_client_spec.rb +13 -0
  279. data/spec/api/client/get_client_params_spec.rb +18 -0
  280. data/spec/api/client/list_client_docs_spec.rb +32 -0
  281. data/spec/api/client/list_clients_spec.rb +22 -0
  282. data/spec/api/client/ping_spec.rb +23 -0
  283. data/spec/api/rhosync_api_spec.rb.orig +606 -0
  284. data/spec/api/source/adapter_spec.rb +29 -0
  285. data/spec/api/source/get_db_doc_spec.rb +21 -0
  286. data/spec/api/source/get_source_params_spec.rb +32 -0
  287. data/spec/api/source/list_source_docs_spec.rb +25 -0
  288. data/spec/api/source/list_sources_spec.rb +26 -0
  289. data/spec/api/source/push_deletes_spec.rb +18 -0
  290. data/spec/api/source/push_objects_spec.rb +27 -0
  291. data/spec/api/source/set_db_doc_spec.rb +19 -0
  292. data/spec/api/source/set_refresh_time_spec.rb +43 -0
  293. data/spec/api/source/upload_file_spec.rb +26 -0
  294. data/spec/api/user/create_user_spec.rb +16 -0
  295. data/spec/api/user/delete_user_spec.rb +36 -0
  296. data/spec/api/user/list_users_spec.rb +30 -0
  297. data/spec/api/user/update_user_spec.rb +31 -0
  298. data/spec/api_token_spec.rb +14 -0
  299. data/spec/app_spec.rb +18 -0
  300. data/spec/apps/emptyapp/application.rb +27 -0
  301. data/spec/apps/emptyapp/settings/license.key +1 -0
  302. data/spec/apps/emptyapp/settings/settings.yml +14 -0
  303. data/spec/apps/rhotestapp/Rakefile +1 -0
  304. data/spec/apps/rhotestapp/application.rb +19 -0
  305. data/spec/apps/rhotestapp/config.ru +1 -0
  306. data/spec/apps/rhotestapp/settings/apple_fake_cert.pem +1 -0
  307. data/spec/apps/rhotestapp/settings/license.key +1 -0
  308. data/spec/apps/rhotestapp/settings/settings.yml +36 -0
  309. data/spec/apps/rhotestapp/sources/base_adapter.rb +9 -0
  310. data/spec/apps/rhotestapp/sources/fixed_schema_adapter.rb +28 -0
  311. data/spec/apps/rhotestapp/sources/sample_adapter.rb +71 -0
  312. data/spec/apps/rhotestapp/sources/simple_adapter.rb +41 -0
  313. data/spec/apps/rhotestapp/sources/sub_adapter.rb +7 -0
  314. data/spec/apps/rhotestapp/vendor/mygem-0.1.0/lib/mygem/mygem.rb +8 -0
  315. data/spec/apps/rhotestapp/vendor/mygem-0.1.0/lib/mygem.rb +1 -0
  316. data/spec/bulk_data/bulk_data_spec.rb +97 -0
  317. data/spec/client_spec.rb +124 -0
  318. data/spec/client_sync_spec.rb +774 -0
  319. data/spec/doc/base.html +72 -0
  320. data/spec/doc/doc_spec.rb +376 -0
  321. data/spec/doc/footer.html +4 -0
  322. data/spec/doc/header.html +30 -0
  323. data/spec/document_spec.rb +31 -0
  324. data/spec/dynamic_adapter_spec.rb +43 -0
  325. data/spec/factories/factories.rb +17 -0
  326. data/spec/generator/generator_spec.rb +58 -0
  327. data/spec/generator/generator_spec_helper.rb +9 -0
  328. data/spec/jobs/bulk_data_job_spec.rb +125 -0
  329. data/spec/jobs/ping_job_spec.rb +102 -0
  330. data/spec/jobs/source_job_spec.rb +29 -0
  331. data/spec/license_spec.rb +66 -0
  332. data/spec/model_spec.rb +273 -0
  333. data/spec/perf/bulk_data_perf_spec.rb +32 -0
  334. data/spec/perf/perf_spec_helper.rb +50 -0
  335. data/spec/perf/store_perf_spec.rb +27 -0
  336. data/spec/ping/android_spec.rb +91 -0
  337. data/spec/ping/apple_spec.rb +70 -0
  338. data/spec/ping/blackberry_spec.rb +62 -0
  339. data/spec/read_state_spec.rb +35 -0
  340. data/spec/rhosync_spec.rb +75 -0
  341. data/spec/server/cors_spec.rb +287 -0
  342. data/spec/server/server_spec.rb +470 -0
  343. data/spec/server/x_domain_session_wrapper_spec.rb +150 -0
  344. data/spec/source_adapter_spec.rb +125 -0
  345. data/spec/source_spec.rb +114 -0
  346. data/spec/source_sync_spec.rb +328 -0
  347. data/spec/spec.opts +4 -0
  348. data/spec/spec_helper.rb +231 -0
  349. data/spec/stats/middleware_spec.rb +53 -0
  350. data/spec/stats/record_spec.rb +92 -0
  351. data/spec/store_spec.rb +251 -0
  352. data/spec/support/shared_examples.rb +168 -0
  353. data/spec/sync_states_spec.rb +72 -0
  354. data/spec/test_methods_spec.rb +134 -0
  355. data/spec/testdata/1000-data.txt +1414 -0
  356. data/spec/testdata/compressed/compress-data.txt +1 -0
  357. data/spec/testdata/upload1.txt +1 -0
  358. data/spec/testdata/upload2.txt +1 -0
  359. data/spec/user_spec.rb +139 -0
  360. data/tasks/redis.rake +206 -0
  361. metadata +706 -0
data/install.sh ADDED
@@ -0,0 +1,408 @@
1
+ #!/bin/bash
2
+
3
+ # DO FIRST
4
+
5
+ # make sure only run as root
6
+ if [ "$(id -u)" != "0" ]; then
7
+ echo "This script must be run as root"
8
+ exit 1
9
+ fi
10
+
11
+ timeInitial=`date +%H%M%S`
12
+ installTime=$timeInitial
13
+
14
+ # CONSTANTS
15
+
16
+ DEPS=(gcc tar make wget)
17
+ # This array is a list of all software that needs to be installed for
18
+ # the process to be successful
19
+ INSTALL_ARRAY=(ruby rubygems redis sqlite passenger rhoconnect)
20
+
21
+ # FUNCTIONS
22
+
23
+ echoLog ()
24
+ {
25
+ timeStamp="[`date`]: "
26
+ echo -e $1
27
+ #end echoLog
28
+ }
29
+
30
+ showHelp ()
31
+ {
32
+ echoLog "
33
+ Usage: install.sh [options]\n
34
+ --no-redis Skip the installation of the redis server.\n
35
+ --offline Check that all necessary files are installed in /opt/rhoconnect if no prefix is specified.\n
36
+ -p, --prefix PREFIX Specify PREFIX as the installation directory. Default is /opt/rhoconnect.\n
37
+ -r, --ruby-version VERSION Specify version of ruby to install. Default is Ruby Enterprise.\n
38
+ -s, --silent Perform installation with minimal output.\n
39
+ --skip-ruby Use system ruby instead of ruby installed through this installer.\n
40
+ -w, --web-server SERVER Specify that you are using web server SERVER. Default is Apache2.\n
41
+ -h, --help Display this screen.\n
42
+ "
43
+ # End script after printing help message
44
+ exit
45
+ } #end showHelp
46
+
47
+ checkDeps ()
48
+ {
49
+ missingDeps=""
50
+ for ((i=0; i<${#DEPS[@]}; i++))
51
+ do
52
+ dep=`which ${DEPS[$i]}`
53
+ if [[ $dep == "" ]]; then
54
+ missingDeps="${missingDeps}${DEPS[$i]}\n"
55
+ fi
56
+ done
57
+
58
+ if [[ $missingDeps != "" ]]; then
59
+ echoLog "Dependencies Missing:" | tee -a $log
60
+ echoLog "${missingDeps}" | tee -a $log
61
+ echoLog "These must be installed before setup can continue..." | tee -a $log
62
+ exit
63
+ fi
64
+ } #end checkDeps
65
+
66
+ updatePkgMgr ()
67
+ {
68
+ pmutd="pkgMgrUTD"
69
+ if ! [ -e $pmutd ]; then
70
+ if [[ `which apt-get` != "" ]]; then
71
+ pkgMgr="apt-get -y"
72
+ dist='debian'
73
+ $pkgMgr update
74
+ $pkgMgr --version >> $pmutd
75
+ elif [[ `which yum` != "" ]]; then
76
+ pkgMgr="yum -y"
77
+ dist='yum'
78
+ $pkgMgr update
79
+ $pkgMgr version >> $pmutd
80
+ else
81
+ echoLog "No supported package manager." | tee -a $log
82
+ echoLog "Please install apt-get or yum to continue..." | tee -a $log
83
+ exit
84
+ fi
85
+ fi
86
+ } #end updatePkgMgr
87
+
88
+ parseOpts ()
89
+ {
90
+ for i; do
91
+ i="${i,,}"
92
+ opts="${opts}${i} "
93
+ # looking for getVal flag to grab next value.
94
+ case $getVal in
95
+ "p" )
96
+ prefix=$getVal
97
+ ;;
98
+ "w" )
99
+ webServer=$getVal
100
+ ;;
101
+ "r" )
102
+ rubyVersion=$getVal
103
+ ;;
104
+ * )
105
+ ;;
106
+ esac
107
+
108
+ # Check options passed in and assign flags where applicable
109
+ case ${i} in
110
+ --web-server | -w )
111
+ getVal="w"
112
+ ;;
113
+ --prefix | -p )
114
+ getVal="p"
115
+ ;;
116
+ --ruby-version )
117
+ getVal="r"
118
+ ;;
119
+ --offline )
120
+ ;;
121
+ --silent | -s )
122
+ ;;
123
+ --no-redis )
124
+ redis=false
125
+ ;;
126
+ --skip-ruby )
127
+ ;;
128
+ --help | -h )
129
+ showHelp
130
+ ;;
131
+ * )
132
+ echoLog "${i} is not a valid option" | tee -a $log
133
+ exit
134
+ ;;
135
+ esac
136
+ done
137
+ } #end parseOpts
138
+
139
+ cleanPrefix ()
140
+ {
141
+ # put a / on the end if not there already
142
+ if [[ $prefix != *\/ ]]; then
143
+ prefix=$prefix"/"
144
+ fi
145
+
146
+ # make sure there are no double /'s in the prefix path
147
+ prefix=${prefix/\/\/+/"/"}
148
+
149
+ # make sure path is absolute for ruby EE installation
150
+ if [[ $prefix == *\.* ]]; then
151
+ prefix=${prefix/\./`pwd`}
152
+ fi
153
+
154
+ # make sure prefix exists, create if not
155
+ if ! [ -d $prefix ]; then
156
+ mkdir -p $prefix
157
+ fi
158
+ } #end cleanPrefix
159
+
160
+ setPrefixDependantPaths ()
161
+ {
162
+ # if rubyBinDir not specified
163
+ if [$rubyBinDir == ""]; then
164
+ rubyBinDir="${prefix}ruby/bin"
165
+ fi
166
+
167
+ # If logs directory does not exist, create it
168
+ if ! [[ -d "${prefix}logs/" ]]; then
169
+ mkdir "${prefix}logs/"
170
+ fi
171
+
172
+ # Make path to log file absolute and create directory if not already existent
173
+ log="${prefix}logs/${log}"
174
+ installchecklist=$prefix"installchecklist"
175
+ touch $log
176
+ touch $installchecklist
177
+
178
+ # Add the log file path to the info file
179
+ echoLog $log >> info.dat
180
+ cat info.dat
181
+
182
+ # Move pmutd into installation directory
183
+ if ! [ -e $prefix$pmutd ]; then
184
+ mv $pmutd $prefix$pmutd
185
+ pmutd=$prefix$pmutd
186
+ fi
187
+
188
+ # Move info.dat into installation directory if not already there
189
+ if ! [ -e "${prefix}info.dat" ]; then
190
+ mv info.dat "${prefix}info.dat"
191
+ fi
192
+ } #end setPrefixDependantPaths
193
+
194
+ setDefaults ()
195
+ {
196
+ # if $prefix not specified set to /opt/rhoconnect
197
+ if [$prefix == ""]; then
198
+ prefix="/opt/rhoconnect/"
199
+ fi
200
+
201
+ # if $webServer not specified set to apache2
202
+ if [$webServer == ""]; then
203
+ webServer="apache2"
204
+ fi
205
+ } #end setDefaults
206
+
207
+ logAndPrint ()
208
+ {
209
+ $1 > tempout 2>&1
210
+ exitStatus=$?
211
+ cat tempout | tee -a $log
212
+ } #end logAndPrint
213
+
214
+ setRubyVars ()
215
+ {
216
+ if [[ $rubyVersion == "" || $rubyVersion =~ ruby'ee'|'enterprise' ]]; then
217
+ rubyVersion="rubyee"
218
+ rubyDir="ruby-enterprise-1.8.7-2011.03"
219
+ rubyTar="${rubyDir}.tar.gz"
220
+ rubyURL="http://rubyenterpriseedition.googlecode.com/files/${rubyTar}"
221
+ elif [$rubyVersion == "ruby187"]; then
222
+ rubyDir="ruby-1.8.7"
223
+ rubyTar="${rubyDir}.tar.gz"
224
+ rubyURL="ftp://ftp.ruby-lang.org/pub/ruby/1.8/${rubyTar}"
225
+ elif [$rubyVersion == "ruby192"]; then
226
+ rubyDir="ruby-1.9.2-p180"
227
+ rubyTar="${rubyDir}.tar.gz"
228
+ rubyURL="http://ftp.ruby-lang.org/pub/ruby/1.9/${rubyTar}"
229
+ else
230
+ echoLog "${rubyVersion} is not a valid ruby version" | tee -a $log
231
+ exit
232
+ fi
233
+ } #end setRubyVars
234
+
235
+ installRuby ()
236
+ {
237
+ if [[ ! -d "${prefix}${rubyDir}" ]]; then
238
+ echoLog "Loading ruby tarball ..." | tee -a $log
239
+ echoLog "wget -P ${prefix} ${rubyURL}" | tee -a $log
240
+ wget -P ${prefix} ${rubyURL}
241
+ echoLog "tar -xzf ${prefix}${rubyTar} -C ${prefix}" | tee -a $log
242
+ tar -xzf ${prefix}${rubyTar} -C ${prefix}
243
+ fi
244
+ echoLog "Installing ruby. This may take some time..." | tee -a $log
245
+
246
+ case $rubyVersion in
247
+ rubyee)
248
+ logAndPrint "${prefix}${rubyDir}/installer --dont-install-useful-gems --no-dev-docs --auto ${prefix}"
249
+ ;;
250
+ ruby187)
251
+ logAndPrint "${prefix}${rubyDir}/configure --prefix=\"${prefix}\""
252
+ logAndPrint "make && make install"
253
+ ;;
254
+ ruby192)
255
+ logAndPrint "${prefix}${rubyDir}/configure --prefix=\"${prefix}\""
256
+ logAndPrint "make && make install"
257
+ ;;
258
+ *)
259
+ logAndPrint "echoLog \"${rubyVersion} is not a supported ruby version\""
260
+ exit
261
+ ;;
262
+ esac
263
+
264
+ if [[ $exitStatus != 0 ]]; then
265
+ echoLog "Some dependencies not installed..." | tee -a $log
266
+ echoLog "Please install them and then re-run the installation script." | tee -a $log
267
+ exit
268
+ else
269
+ echoLog "ruby" >> ${prefix}installchecklist
270
+ fi
271
+
272
+ rm tempout
273
+ } #end installRuby
274
+
275
+ getTime ()
276
+ {
277
+ timeDiff=$(( $1 - $timeInitial ))
278
+ timeSec=$(( $timeDiff % 100 ))
279
+ timeDiff=$(( $timeDiff / 100 ))
280
+
281
+ if [ $timeSec -gt 1 ]; then
282
+ timeSec=$timeSec" seconds"
283
+ else
284
+ timeSec=$timeSec" second"
285
+ fi
286
+
287
+ if [ $timeDiff -gt 0 ]; then
288
+ timeMin=$(( $timeDiff % 100 ))
289
+ timeDiff=$(( $timeDiff / 100 ))
290
+ if [ $timeMin -gt 1 ]; then
291
+ timeMin=$timeMin" minutes and "
292
+ else
293
+ timeMin=$timeMin" minute and "
294
+ fi
295
+ fi
296
+
297
+ if [ $timeDiff -gt 0 ]; then
298
+ timeHour=$(( $timeDiff % 100 ))
299
+ timeDiff=$(( $timeDiff / 100 ))
300
+ if [ $timeHour -gt 1 ]; then
301
+ timeHour=$timeHour" hours, "
302
+ else
303
+ timeHour=$timeHour" hour, "
304
+ fi
305
+ fi
306
+
307
+ echoLog "\nInstallation completed in ${timeHour}${timeMin}${timeSec}."
308
+ } #end getTime
309
+
310
+ checkInstalledSoftware ()
311
+ {
312
+ installedSoftware=""
313
+ while read line
314
+ do
315
+ for (( i=0; i < ${#INSTALL_ARRAY[@]}; i++ ))
316
+ do
317
+ if [ $line == ${INSTALL_ARRAY[$i]} ]; then
318
+ installedSoftware=$(( $installedSoftware + 1 ))
319
+ fi
320
+ done
321
+ done < $installchecklist
322
+
323
+ if ! [[ $installedSoftware -ge ${#INSTALL_ARRAY[@]} ]]; then
324
+ echoLog "Not all software installed"
325
+ else
326
+ echoLog "All software installed"
327
+ fi
328
+
329
+ rm $installchecklist
330
+ } #end checkInstalledSoftware
331
+
332
+ # SCRIPT
333
+ # define log file name
334
+ DATEFILE=`date +%Y%m%d%H%M%S`
335
+ log=rhoconnect_$(date +$DATEFILE).log
336
+ installchecklist="installchecklist"
337
+
338
+ # Make sure basic system dependencies are installed
339
+ checkDeps
340
+
341
+ # update the system's package manager
342
+ updatePkgMgr
343
+
344
+ # define option variables
345
+ opts=""
346
+ prefix=""
347
+ getVal=""
348
+ webServer=""
349
+ rubyVersion=""
350
+ rubyBinDir=""
351
+
352
+ # parse command-line options
353
+ parseOpts
354
+
355
+ # Set default Values
356
+ setDefaults
357
+
358
+ # Reformat ruby version to fit this scripts format
359
+ # Tolower rubyVersion
360
+ rubyVersion=$(echoLog $rubyVersion | tr '[:upper:]' '[:lower:]')
361
+ # Remove all white space
362
+ rubyVersion=${rubyVersion//[[:space:]]}
363
+ # Remove periods and hyphens such as those present in version numbers
364
+ rubyVersion=${rubyVersion//[-.]/}
365
+
366
+ # Set ruby insatallation variables
367
+ setRubyVars
368
+
369
+ # Clean up the formatting of prefix
370
+ cleanPrefix
371
+
372
+ # Once the prefix path is cleaned up...
373
+ setPrefixDependantPaths
374
+
375
+ # Install ruby if not already installed
376
+ if ! [ -e "${prefix}bin/ruby" ]; then
377
+ installRuby
378
+ else
379
+ echoLog "Ruby already installed" | tee -a $log
380
+ echoLog "ruby" >> ${prefix}installchecklist
381
+ fi
382
+
383
+ # Construct the string with which to call the ruby installation script.
384
+ callruby="sudo ${prefix}bin/ruby ./installer/unix-like/rhoinstaller.rb ${opts}"
385
+ # Call the ruby script
386
+ $callruby
387
+
388
+ checkInstalledSoftware
389
+
390
+ if [[ $installedSoftware -eq ${#INSTALL_ARRAY[@]} ]]; then
391
+ rm "${prefix}info.dat"
392
+ rm $pmutd
393
+ if [ -e $prefix$rubyTar ]; then
394
+ mv $prefix$rubyTar $prefix"downloads/"$rubyTar
395
+ fi
396
+ if [ -e $prefix$rubyDir ]; then
397
+ mv $prefix$rubyDir $prefix"downloads/"$rubyDir
398
+ fi
399
+ if [ ! -e $prefix"post-install" ]; then
400
+ mkdir $prefix"post-install"
401
+ fi
402
+
403
+ opts=$opts" -d $dist"
404
+
405
+ sudo ${prefix}bin/ruby installer/utils/create_texts.rb ${opts}
406
+ timeFinal=`date +%H%M%S`
407
+ getTime $timeFinal
408
+ fi
@@ -0,0 +1,140 @@
1
+ require 'rho_connect_install_constants'
2
+
3
+ module Checkers
4
+ extend self
5
+
6
+ # check_all_installed
7
+ # This method runs all tests that check whether or not the software is
8
+ # installed correctly.
9
+ def check_all_installed(options)
10
+ @options=options
11
+ not_installed = ""
12
+ Constants::CHECKS.each do |check|
13
+ installed = self.send(check)
14
+ if installed && !installed.empty?
15
+ not_installed << installed
16
+ end #if
17
+ end #do
18
+ if not_installed && !not_installed.empty?
19
+ log_print "The following packages are not installed properly"
20
+ log_print not_installed
21
+ else
22
+ log_print "Everything is fully installed"
23
+ end #if
24
+ end #check_all_installed
25
+
26
+ # check_all_packages
27
+ # This method calls check_package for each package in the list defined in the
28
+ # Constants file
29
+ def check_all_packages
30
+ packages_not_installed = []
31
+ Constants::PACKAGES.each do |pkg|
32
+ string = "Looking for package #{pkg}..."
33
+ installed = check_package(pkg)
34
+ installed ? string << green("Found") : string << red("Not Found")
35
+ log_print string
36
+ if !installed
37
+ #if not installed append package name to packages_not_installed list
38
+ packages_not_installed << pkg
39
+ end #if
40
+ end #do
41
+
42
+ packages_not_installed
43
+ end #check_all_packages
44
+
45
+ # check_package
46
+ # This method uses a system call to check that an individual package is
47
+ # installed
48
+ def check_package(pkg)
49
+ string = "Looking for #{pkg}..."
50
+ installed = `#{ @options[:pkg_chkr] } | grep #{ pkg }`
51
+ if installed !~ /.*#{ pkg }.*/
52
+ installed = false
53
+ else
54
+ installed = true
55
+ end #if
56
+
57
+ installed
58
+ end #check_package
59
+
60
+ # check_all_gems
61
+ # This method calls check_gem for each gem in the list of gems defined in the
62
+ # Constants file
63
+ def check_all_gems(gem_path)
64
+ gems_not_installed = []
65
+ Constants::GEMS.each do |gem|
66
+ string = "Looking for Gem \"#{gem}\"..."
67
+ installed = check_gem gem, gem_path
68
+ installed ? string << green("Found") : string << red("Not Found")
69
+ log_print string
70
+ if !installed
71
+ #if not installed append gem name to gems_not_installed list
72
+ gems_not_installed << gem
73
+ end #if
74
+ end # do
75
+
76
+ gems_not_installed
77
+ end #check_all_gems
78
+
79
+ # check_gem
80
+ # This method uses a system call to chack that a gem is installed
81
+ def check_gem(gem, gem_path)
82
+ result = `#{gem_path} query --local | grep #{ gem }`
83
+ puts "Result:" + result
84
+ if result == ""
85
+ installed = false
86
+ else
87
+ installed = true
88
+ end #if
89
+
90
+ installed
91
+ end #check_gem
92
+
93
+ # check_web_server_running
94
+ # This method checks the response from the WEB_SERVER_URL defined in the
95
+ # Constants file to make sure the web server is up and running
96
+ def check_web_server_running
97
+ string = "Testing Web Server..."
98
+ url = Constants::WEB_SERVER_URL
99
+
100
+ # check if http:// was in the url if not add it in there
101
+ url.insert(0, "http://") unless(url.match(/^http\:\/\//))
102
+
103
+ # Get the HTTP_RESPONSE from the site we are checking
104
+ begin
105
+ res = Net::HTTP.get_response(URI.parse(url.to_s))
106
+ # Check the response code
107
+ if !res.code =~ /2|3\d{2}/
108
+ running = false
109
+ string << " " + red("Not Running!")
110
+ else
111
+ running = ''
112
+ string << " " + green("Running")
113
+ end #if
114
+ log_print string
115
+ rescue
116
+ @log.error {"#{@options[:web_server]} web server not unresponsive!"}
117
+ running = false
118
+ end
119
+
120
+ running
121
+ end #check_web_server_running
122
+
123
+ # colorize
124
+ # Inserts color code into text strings for colorized output
125
+ def colorize(text, color_code)
126
+ "#{color_code}#{text}\033[0m"
127
+ end
128
+
129
+ # red
130
+ # Changes text to a red color
131
+ def red(text)
132
+ colorize text, "\033[1;31m"
133
+ end
134
+
135
+ # green
136
+ # Changes text to a green color
137
+ def green(text)
138
+ colorize text, "\033[1;32m"
139
+ end
140
+ end #Checkers
@@ -0,0 +1,51 @@
1
+ module Constants
2
+
3
+ PACKAGES = ["zlib1g-dev",
4
+ "libcurl4-openssl-dev",
5
+ "apache2-mpm-prefork",
6
+ "apache2-prefork-dev",
7
+ "libapr1-dev",
8
+ "libaprutil1-dev",
9
+ "dtach"]
10
+
11
+ RUBYGEMS = "rubygems-1.8.5"
12
+ REDIS = "redis-2.2.12"
13
+ SQLITE3 = "sqlite-autoconf-3070701"
14
+
15
+ SOFTWARE = [RUBYGEMS,
16
+ REDIS,
17
+ SQLITE3]
18
+
19
+ RUBYGEMS_URL = "http://rubyforge.org/frs/download.php/74954/" +
20
+ "#{ RUBYGEMS }.tgz"
21
+ REDIS_URL = "http://redis.googlecode.com/files/#{ REDIS }.tar.gz"
22
+ SQLITE3_URL = "http://www.sqlite.org/sqlite-autoconf-3070701.tar.gz"
23
+
24
+
25
+ URLS = [RUBYGEMS_URL,
26
+ REDIS_URL,
27
+ SQLITE3_URL]
28
+
29
+ GEMS = ["bundler",
30
+ "passenger",
31
+ "sqlite3"]
32
+
33
+ SUPPORTED_PKG_MGRS = ["apt-get", "yum"]
34
+
35
+ SUPPORTED_WEB_SERVERS = ["apache2", "nginx"]
36
+
37
+ WEB_SERVER_URL = "http://localhost/"
38
+
39
+ CHECKS = ["check_all_packages",
40
+ "check_all_gems",
41
+ "check_web_server_running"]
42
+
43
+ DEFAULT_INSTALL_DIR = "/opt/rhoconnect/"
44
+
45
+ DEFAULTS = {"Packages" => PACKAGES,
46
+ "Software" => SOFTWARE,
47
+ "Gems" => GEMS,
48
+ "Supported Package Managers" => SUPPORTED_PKG_MGRS,
49
+ "Supported Web Servers" => SUPPORTED_WEB_SERVERS,
50
+ "Default Install Directory" => DEFAULT_INSTALL_DIR}
51
+ end #Constants
@@ -0,0 +1,63 @@
1
+ require 'rho_connect_install_utilities'
2
+ require 'rho_connect_install_constants'
3
+
4
+ include Utilities
5
+
6
+ class Debian
7
+ attr_accessor :options
8
+
9
+ def initialize(options)
10
+ @@flavor = "Debian"
11
+ @options = options
12
+ @options[:pkg_mgr] = 'apt-get -y'
13
+ @options[:pkg_chkr] = 'dpkg -l'
14
+ end #initialize
15
+
16
+ # check_for_installed_software_only
17
+ # This method runs checks against the software that must be installed.
18
+ def check_for_installed_software_only
19
+ check_all_installed @options
20
+ end #check_for_installed_software_only
21
+
22
+ # execute_installation
23
+ # This method orchestrates the actual installation process
24
+ def execute_installation
25
+ #start logging
26
+ set_log_file @options[:log]
27
+
28
+ #gather necessary files
29
+ download_and_decompress @options[:prefix]
30
+
31
+ #install ruby gems
32
+ install_rubygems
33
+ install_redis if @options[:redis]
34
+ install_sqlite
35
+
36
+ #start installing
37
+ install_all_gems
38
+ configure_passenger @options
39
+
40
+ #install rhoconnect
41
+ install_rhoconnect
42
+
43
+ #remove downloaded tarballs
44
+ cleanup options[:prefix], @options
45
+ end #execute_installation
46
+
47
+ # to_s
48
+ # This method overrides the default to_s method
49
+ def to_s
50
+ string = "Debian Installation Parameters:\n"
51
+ string << "\tPackage Manager\n"
52
+ string << "\t\tapt-get\n"
53
+ Constants::DEFAULTS.each do |key, val|
54
+ string << "\t" + key + "\n"
55
+ val.each do |field|
56
+ string << "\t\t" + field + "\n"
57
+ end #do
58
+ end #do
59
+
60
+ string
61
+ end #to_s
62
+
63
+ end #Debian