barkest_core 1.5.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (308) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/Gemfile +22 -0
  4. data/Gemfile.lock +254 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.md +364 -0
  7. data/Rakefile +37 -0
  8. data/app/assets/fonts/barkest_core/ArchivoNarrow-Bold.ttf +0 -0
  9. data/app/assets/fonts/barkest_core/ArchivoNarrow-BoldItalic.ttf +0 -0
  10. data/app/assets/fonts/barkest_core/ArchivoNarrow-Italic.ttf +0 -0
  11. data/app/assets/fonts/barkest_core/ArchivoNarrow-Regular.ttf +0 -0
  12. data/app/assets/images/barkest_core/.keep +0 -0
  13. data/app/assets/images/barkest_core/barcode-B.svg +181 -0
  14. data/app/assets/javascripts/barkest_core/.keep +0 -0
  15. data/app/assets/javascripts/barkest_core/application.js +22 -0
  16. data/app/assets/javascripts/barkest_core/bootstrap-datepicker.js +1800 -0
  17. data/app/assets/javascripts/barkest_core/field_init.js +7 -0
  18. data/app/assets/javascripts/barkest_core/jquery.doubleScroll.js +112 -0
  19. data/app/assets/javascripts/barkest_core/masked_edit.js +25 -0
  20. data/app/assets/javascripts/barkest_core/system_status.js.erb +201 -0
  21. data/app/assets/stylesheets/barkest_core/.keep +0 -0
  22. data/app/assets/stylesheets/barkest_core/application.css +17 -0
  23. data/app/assets/stylesheets/barkest_core/custom.css.scss +264 -0
  24. data/app/assets/stylesheets/barkest_core/datepicker3.css +790 -0
  25. data/app/controllers/.keep +0 -0
  26. data/app/controllers/access_groups_controller.rb +74 -0
  27. data/app/controllers/account_activations_controller.rb +29 -0
  28. data/app/controllers/application_controller.rb +5 -0
  29. data/app/controllers/barkest_core/application_controller_base.rb +113 -0
  30. data/app/controllers/barkest_core/engine_controller_base.rb +15 -0
  31. data/app/controllers/barkest_core/testsub_controller.rb +21 -0
  32. data/app/controllers/contact_controller.rb +32 -0
  33. data/app/controllers/log_view_controller.rb +31 -0
  34. data/app/controllers/password_resets_controller.rb +126 -0
  35. data/app/controllers/sessions_controller.rb +64 -0
  36. data/app/controllers/status_controller.rb +150 -0
  37. data/app/controllers/system_config_controller.rb +238 -0
  38. data/app/controllers/system_update_controller.rb +164 -0
  39. data/app/controllers/test_access_controller.rb +44 -0
  40. data/app/controllers/test_report_controller.rb +75 -0
  41. data/app/controllers/users_controller.rb +218 -0
  42. data/app/helpers/.keep +0 -0
  43. data/app/helpers/barkest_core/application_helper.rb +134 -0
  44. data/app/helpers/barkest_core/form_helper.rb +469 -0
  45. data/app/helpers/barkest_core/html_helper.rb +70 -0
  46. data/app/helpers/barkest_core/misc_helper.rb +68 -0
  47. data/app/helpers/barkest_core/pdf_helper.rb +180 -0
  48. data/app/helpers/barkest_core/recaptcha_helper.rb +115 -0
  49. data/app/helpers/barkest_core/sessions_helper.rb +94 -0
  50. data/app/helpers/barkest_core/status_helper.rb +118 -0
  51. data/app/helpers/barkest_core/users_helper.rb +32 -0
  52. data/app/mailers/.keep +0 -0
  53. data/app/mailers/application_mailer.rb +5 -0
  54. data/app/mailers/barkest_core/application_mailer_base.rb +30 -0
  55. data/app/mailers/barkest_core/contact_form.rb +20 -0
  56. data/app/mailers/barkest_core/user_mailer.rb +44 -0
  57. data/app/models/.keep +0 -0
  58. data/app/models/access_group.rb +121 -0
  59. data/app/models/access_group_group_member.rb +13 -0
  60. data/app/models/access_group_user_member.rb +11 -0
  61. data/app/models/barkest_core/auth_config.rb +95 -0
  62. data/app/models/barkest_core/authorize_failure.rb +7 -0
  63. data/app/models/barkest_core/contact_message.rb +37 -0
  64. data/app/models/barkest_core/database_config.rb +223 -0
  65. data/app/models/barkest_core/db_table.rb +21 -0
  66. data/app/models/barkest_core/email_config.rb +132 -0
  67. data/app/models/barkest_core/global_status.rb +267 -0
  68. data/app/models/barkest_core/log_entry.rb +101 -0
  69. data/app/models/barkest_core/log_view_options.rb +51 -0
  70. data/app/models/barkest_core/ms_sql_db_definition.rb +441 -0
  71. data/app/models/barkest_core/ms_sql_definition.rb +221 -0
  72. data/app/models/barkest_core/ms_sql_function.rb +423 -0
  73. data/app/models/barkest_core/not_logged_in.rb +7 -0
  74. data/app/models/barkest_core/pdf_table_builder.rb +407 -0
  75. data/app/models/barkest_core/self_update_config.rb +37 -0
  76. data/app/models/barkest_core/user_alert.rb +29 -0
  77. data/app/models/barkest_core/user_alert_generators.rb +58 -0
  78. data/app/models/barkest_core/user_manager.rb +404 -0
  79. data/app/models/barkest_core/work_path.rb +74 -0
  80. data/app/models/disable_user.rb +18 -0
  81. data/app/models/ldap_access_group.rb +15 -0
  82. data/app/models/system_config.rb +99 -0
  83. data/app/models/user.rb +405 -0
  84. data/app/models/user_login_history.rb +11 -0
  85. data/app/views/.keep +0 -0
  86. data/app/views/access_groups/_form.html.erb +19 -0
  87. data/app/views/access_groups/edit.html.erb +2 -0
  88. data/app/views/access_groups/index.html.erb +32 -0
  89. data/app/views/access_groups/new.html.erb +2 -0
  90. data/app/views/access_groups/show.html.erb +4 -0
  91. data/app/views/barkest_core/contact_form/contact.html.erb +16 -0
  92. data/app/views/barkest_core/contact_form/contact.text.erb +13 -0
  93. data/app/views/barkest_core/testsub/_links.html.erb +5 -0
  94. data/app/views/barkest_core/testsub/page1.html.erb +3 -0
  95. data/app/views/barkest_core/testsub/page2.html.erb +2 -0
  96. data/app/views/barkest_core/testsub/page3.html.erb +2 -0
  97. data/app/views/barkest_core/user_mailer/account_activation.html.erb +7 -0
  98. data/app/views/barkest_core/user_mailer/account_activation.text.erb +6 -0
  99. data/app/views/barkest_core/user_mailer/invalid_password_reset.html.erb +3 -0
  100. data/app/views/barkest_core/user_mailer/invalid_password_reset.text.erb +5 -0
  101. data/app/views/barkest_core/user_mailer/password_reset.html.erb +8 -0
  102. data/app/views/barkest_core/user_mailer/password_reset.text.erb +7 -0
  103. data/app/views/contact/index.html.erb +24 -0
  104. data/app/views/layouts/_footer_copyright.html.erb +1 -0
  105. data/app/views/layouts/_menu_admin.html.erb +5 -0
  106. data/app/views/layouts/_menu_anon.html.erb +0 -0
  107. data/app/views/layouts/_menu_auth.html.erb +3 -0
  108. data/app/views/layouts/_menu_footer.html.erb +1 -0
  109. data/app/views/layouts/_nav_logo.html.erb +1 -0
  110. data/app/views/layouts/application.html.erb +2 -0
  111. data/app/views/layouts/barkest_core/_application.html.erb +24 -0
  112. data/app/views/layouts/barkest_core/_footer.html.erb +18 -0
  113. data/app/views/layouts/barkest_core/_header.html.erb +38 -0
  114. data/app/views/layouts/barkest_core/_html_mailer.html.erb +11 -0
  115. data/app/views/layouts/barkest_core/_menu_account.html.erb +14 -0
  116. data/app/views/layouts/barkest_core/_menu_sample.html.erb +1 -0
  117. data/app/views/layouts/barkest_core/_messages.html.erb +4 -0
  118. data/app/views/layouts/barkest_core/_shim.html.erb +4 -0
  119. data/app/views/layouts/barkest_core/_subheader.html.erb +1 -0
  120. data/app/views/layouts/barkest_core/_text_mailer.text.erb +4 -0
  121. data/app/views/layouts/mailer.html.erb +1 -0
  122. data/app/views/layouts/mailer.text.erb +1 -0
  123. data/app/views/log_view/index.html.erb +100 -0
  124. data/app/views/password_resets/edit.html.erb +20 -0
  125. data/app/views/password_resets/new.html.erb +14 -0
  126. data/app/views/sessions/new.html.erb +27 -0
  127. data/app/views/shared/_error_messages.html.erb +29 -0
  128. data/app/views/shared/_generic_user_alert.html.erb +4 -0
  129. data/app/views/status/current.html.erb +34 -0
  130. data/app/views/status/test.html.erb +50 -0
  131. data/app/views/system_config/index.html.erb +25 -0
  132. data/app/views/system_config/show_auth.html.erb +28 -0
  133. data/app/views/system_config/show_database.html.erb +36 -0
  134. data/app/views/system_config/show_email.html.erb +21 -0
  135. data/app/views/system_config/show_self_update.html.erb +13 -0
  136. data/app/views/system_update/index.html.erb +31 -0
  137. data/app/views/system_update/new.html.erb +2 -0
  138. data/app/views/test_access/allow_anon.html.erb +2 -0
  139. data/app/views/test_access/require_admin.html.erb +2 -0
  140. data/app/views/test_access/require_group_x.html.erb +2 -0
  141. data/app/views/test_access/require_user.html.erb +2 -0
  142. data/app/views/test_report/index.csv.csvrb +23 -0
  143. data/app/views/test_report/index.html.erb +6 -0
  144. data/app/views/test_report/index.pdf.prawn +50 -0
  145. data/app/views/test_report/index.xlsx.axlsx +28 -0
  146. data/app/views/users/_user.html.erb +57 -0
  147. data/app/views/users/_user_details.html.erb +15 -0
  148. data/app/views/users/_user_details_for_list.html.erb +1 -0
  149. data/app/views/users/_user_form.html.erb +13 -0
  150. data/app/views/users/disable_confirm.html.erb +19 -0
  151. data/app/views/users/edit.html.erb +15 -0
  152. data/app/views/users/index.html.erb +9 -0
  153. data/app/views/users/new.html.erb +10 -0
  154. data/app/views/users/show.html.erb +46 -0
  155. data/bin/rails +12 -0
  156. data/config/routes.rb +3 -0
  157. data/db/migrate/20160617172539_create_access_groups.rb +10 -0
  158. data/db/migrate/20160617172725_create_users.rb +26 -0
  159. data/db/migrate/20160617172833_create_user_login_histories.rb +12 -0
  160. data/db/migrate/20160622151720_create_access_group_user_members.rb +9 -0
  161. data/db/migrate/20160622151925_create_access_group_group_members.rb +9 -0
  162. data/db/migrate/20160701005706_create_ldap_access_groups.rb +11 -0
  163. data/db/migrate/20161108155029_create_system_configs.rb +11 -0
  164. data/db/seeds/barkest_core_01_create_users.rb +42 -0
  165. data/db/seeds.rb +53 -0
  166. data/lib/barkest_core/concerns/association_with_defaults.rb +55 -0
  167. data/lib/barkest_core/concerns/boolean_parser.rb +88 -0
  168. data/lib/barkest_core/concerns/date_parser.rb +181 -0
  169. data/lib/barkest_core/concerns/email_tester.rb +55 -0
  170. data/lib/barkest_core/concerns/encrypted_fields.rb +156 -0
  171. data/lib/barkest_core/concerns/named_model.rb +73 -0
  172. data/lib/barkest_core/concerns/number_parser.rb +145 -0
  173. data/lib/barkest_core/concerns/utc_conversion.rb +60 -0
  174. data/lib/barkest_core/engine.rb +105 -0
  175. data/lib/barkest_core/extensions/active_record_extensions.rb +120 -0
  176. data/lib/barkest_core/extensions/application_configuration_extensions.rb +38 -0
  177. data/lib/barkest_core/extensions/application_extensions.rb +50 -0
  178. data/lib/barkest_core/extensions/axlsx_extenstions.rb +157 -0
  179. data/lib/barkest_core/extensions/fixture_set_extensions.rb +107 -0
  180. data/lib/barkest_core/extensions/generator_extensions.rb +271 -0
  181. data/lib/barkest_core/extensions/main_app_extensions.rb +35 -0
  182. data/lib/barkest_core/extensions/prawn_document_extensions.rb +367 -0
  183. data/lib/barkest_core/extensions/prawn_table_extensions.rb +131 -0
  184. data/lib/barkest_core/extensions/router_extensions.rb +106 -0
  185. data/lib/barkest_core/extensions/simple_formatter_extensions.rb +66 -0
  186. data/lib/barkest_core/extensions/test_case_extensions.rb +348 -0
  187. data/lib/barkest_core/extensions/time_extensions.rb +164 -0
  188. data/lib/barkest_core/handlers/csv_handler.rb +30 -0
  189. data/lib/barkest_core/version.rb +3 -0
  190. data/lib/barkest_core.rb +324 -0
  191. data/lib/generators/barkest/install_generator.rb +102 -0
  192. data/lib/generators/barkest_core/actions/01_patch_application_controller.rb +55 -0
  193. data/lib/generators/barkest_core/actions/02_patch_application_mailer.rb +56 -0
  194. data/lib/generators/barkest_core/actions/03_patch_assets.rb +62 -0
  195. data/lib/generators/barkest_core/actions/04_patch_layouts.rb +36 -0
  196. data/lib/generators/barkest_core/actions/05_patch_routes.rb +93 -0
  197. data/lib/generators/barkest_core/actions/06_patch_seeds.rb +60 -0
  198. data/lib/generators/barkest_core/actions/07_copy_migrations.rb +51 -0
  199. data/lib/generators/barkest_core/actions/08_configure_database.rb +52 -0
  200. data/lib/generators/barkest_core/actions/09_configure_secrets.rb +29 -0
  201. data/lib/generators/barkest_core/actions/99_patch_gitignore.rb +57 -0
  202. data/lib/generators/barkest_core/install_generator.rb +17 -0
  203. data/test/barkest_core_test.rb +83 -0
  204. data/test/controllers/access_groups_controller_test.rb +53 -0
  205. data/test/controllers/contact_controller_test.rb +10 -0
  206. data/test/controllers/sessions_controller_test.rb +10 -0
  207. data/test/controllers/users_controller_test.rb +10 -0
  208. data/test/dummy/.gitignore +10 -0
  209. data/test/dummy/README.rdoc +28 -0
  210. data/test/dummy/Rakefile +6 -0
  211. data/test/dummy/app/assets/images/.keep +0 -0
  212. data/test/dummy/app/assets/javascripts/application.js +14 -0
  213. data/test/dummy/app/assets/stylesheets/application.css +16 -0
  214. data/test/dummy/app/controllers/application_controller.rb +5 -0
  215. data/test/dummy/app/controllers/concerns/.keep +0 -0
  216. data/test/dummy/app/helpers/application_helper.rb +2 -0
  217. data/test/dummy/app/mailers/.keep +0 -0
  218. data/test/dummy/app/mailers/application_mailer.rb +3 -0
  219. data/test/dummy/app/models/.keep +0 -0
  220. data/test/dummy/app/models/concerns/.keep +0 -0
  221. data/test/dummy/app/views/layouts/application.html.erb +1 -0
  222. data/test/dummy/app/views/layouts/mailer.html.erb +1 -0
  223. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  224. data/test/dummy/app/views/system_config/show_fake.html.erb +3 -0
  225. data/test/dummy/bin/bundle +3 -0
  226. data/test/dummy/bin/rails +4 -0
  227. data/test/dummy/bin/rake +4 -0
  228. data/test/dummy/bin/setup +29 -0
  229. data/test/dummy/config/application.rb +27 -0
  230. data/test/dummy/config/boot.rb +5 -0
  231. data/test/dummy/config/environment.rb +5 -0
  232. data/test/dummy/config/environments/development.rb +47 -0
  233. data/test/dummy/config/environments/production.rb +79 -0
  234. data/test/dummy/config/environments/test.rb +44 -0
  235. data/test/dummy/config/initializers/assets.rb +11 -0
  236. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  237. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  238. data/test/dummy/config/initializers/db_updater_ext.rb +33 -0
  239. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  240. data/test/dummy/config/initializers/inflections.rb +16 -0
  241. data/test/dummy/config/initializers/mime_types.rb +4 -0
  242. data/test/dummy/config/initializers/session_store.rb +3 -0
  243. data/test/dummy/config/initializers/sys_config_ext.rb +12 -0
  244. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  245. data/test/dummy/config/locales/en.yml +23 -0
  246. data/test/dummy/config/routes.rb +60 -0
  247. data/test/dummy/config.ru +4 -0
  248. data/test/dummy/db/schema.rb +95 -0
  249. data/test/dummy/db/seeds/barkest_core_01_create_users.rb +42 -0
  250. data/test/dummy/db/seeds.rb +51 -0
  251. data/test/dummy/lib/assets/.keep +0 -0
  252. data/test/dummy/log/.keep +0 -0
  253. data/test/dummy/public/404.html +67 -0
  254. data/test/dummy/public/422.html +67 -0
  255. data/test/dummy/public/500.html +66 -0
  256. data/test/dummy/public/favicon.ico +0 -0
  257. data/test/dummy/sql/my_test_view.sql +3 -0
  258. data/test/fixtures/access_groups.yml +21 -0
  259. data/test/fixtures/users.yml +71 -0
  260. data/test/helpers/barkest_core/sessions_helper_test.rb +22 -0
  261. data/test/integration/access_group_mgmt_test.rb +33 -0
  262. data/test/integration/access_test.rb +24 -0
  263. data/test/integration/account_activations_access_test.rb +12 -0
  264. data/test/integration/contact_test.rb +98 -0
  265. data/test/integration/extra_partial_test.rb +41 -0
  266. data/test/integration/log_view_access_test.rb +12 -0
  267. data/test/integration/password_resets_test.rb +101 -0
  268. data/test/integration/reports_test.rb +53 -0
  269. data/test/integration/status_access_test.rb +27 -0
  270. data/test/integration/system_config_access_test.rb +24 -0
  271. data/test/integration/system_update_access_test.rb +19 -0
  272. data/test/integration/users_access_test.rb +34 -0
  273. data/test/integration/users_edit_test.rb +178 -0
  274. data/test/integration/users_index_test.rb +62 -0
  275. data/test/integration/users_login_test.rb +67 -0
  276. data/test/integration/users_signup_test.rb +54 -0
  277. data/test/mailers/.keep +0 -0
  278. data/test/mailers/barkest_core/contact_form_test.rb +28 -0
  279. data/test/mailers/barkest_core/user_mailer_test.rb +43 -0
  280. data/test/mailers/previews/barkest_core/contact_form_preview.rb +17 -0
  281. data/test/mailers/previews/barkest_core/user_mailer_preview.rb +26 -0
  282. data/test/models/access_group_group_member_test.rb +28 -0
  283. data/test/models/access_group_test.rb +114 -0
  284. data/test/models/access_group_user_member_test.rb +28 -0
  285. data/test/models/barkest_core/auth_config_test.rb +57 -0
  286. data/test/models/barkest_core/bool_parser_test.rb +28 -0
  287. data/test/models/barkest_core/contact_message_test.rb +61 -0
  288. data/test/models/barkest_core/database_config_test.rb +33 -0
  289. data/test/models/barkest_core/date_parser_test.rb +110 -0
  290. data/test/models/barkest_core/email_config_test.rb +57 -0
  291. data/test/models/barkest_core/global_status_test.rb +50 -0
  292. data/test/models/barkest_core/ms_sql_db_updater_test.rb +115 -0
  293. data/test/models/barkest_core/ms_sql_definition_test.rb +102 -0
  294. data/test/models/barkest_core/ms_sql_function_test.rb +131 -0
  295. data/test/models/barkest_core/number_parser_test.rb +29 -0
  296. data/test/models/barkest_core/self_update_config_test.rb +29 -0
  297. data/test/models/barkest_core/user_alert_test.rb +19 -0
  298. data/test/models/barkest_core/user_manager_test.rb +34 -0
  299. data/test/models/barkest_core/work_path_test.rb +26 -0
  300. data/test/models/disable_user_test.rb +27 -0
  301. data/test/models/generic_time_test.rb +66 -0
  302. data/test/models/ldap_access_group_test.rb +31 -0
  303. data/test/models/pdf_table_builder_test.rb +6 -0
  304. data/test/models/system_config_test.rb +78 -0
  305. data/test/models/user_login_history_test.rb +37 -0
  306. data/test/models/user_test.rb +130 -0
  307. data/test/test_helper.rb +63 -0
  308. metadata +798 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f0c84d8efafd80566ca7f2571995f75de2bc0f79
4
+ data.tar.gz: a5be63bbde5502268c0db143eb720f5d0e2d86e5
5
+ SHA512:
6
+ metadata.gz: 7a4480425a4c39e15c695f911db0cfc2d367d7420d7a6b9fecbc15ed57b384962bf346ec6fdb1ef04d8ad7cbc35ffd7708c2919efb2f7229842c6bb16c192a92
7
+ data.tar.gz: '08fddf489c959a5defa7f7a38e024f720087d98f641268e02a1264b40bc5e8ae2ff78b6c182e0d91775caa1ea615badf1f56af762dd0fcb6d102ba6ab07e6a58'
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ config/*.yml
5
+ test/dummy/db/*.sqlite3
6
+ test/dummy/db/*.sqlite3-journal
7
+ test/dummy/log/*.log
8
+ test/dummy/tmp/
9
+ test/dummy/.sass-cache
10
+ test/dummy/config/*.yml
11
+ .idea/
12
+ **/.DS_Store
13
+ **/.byebug*
data/Gemfile ADDED
@@ -0,0 +1,22 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Declare your gem's dependencies in barkest_core.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
6
+ gemspec
7
+
8
+ # Declare any dependencies that are still in development here instead of in
9
+ # your gemspec. These might include edge Rails or gems from your path or
10
+ # Git. Remember to move these dependencies to your gemspec before releasing
11
+ # your gem to rubygems.org.
12
+
13
+ # To use a debugger
14
+ gem 'byebug', group: [:development, :test]
15
+
16
+ group :test do
17
+ gem 'minitest-reporters'
18
+ gem 'mini_backtrace'
19
+ gem 'tiny_tds', '~> 1.0.4'
20
+ gem 'activerecord-sqlserver-adapter', '~> 4.2.5'
21
+ end
22
+
data/Gemfile.lock ADDED
@@ -0,0 +1,254 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ barkest_core (1.5.3.0)
5
+ activerecord-sqlserver-adapter (~> 4.2.1)
6
+ axlsx (~> 2.0.1)
7
+ axlsx_rails (>= 0.4.0)
8
+ barkest_ssh (>= 1.1.12)
9
+ bcrypt (~> 3.1.11)
10
+ bootstrap-sass (~> 3.3.6)
11
+ bootstrap-will_paginate (>= 0.0.10)
12
+ carrierwave (~> 0.11.2)
13
+ coffee-rails (~> 4.1.1)
14
+ encrypted_strings (~> 0.3.3)
15
+ exception_notification (~> 4.1.4)
16
+ hex_string (~> 1.0.1)
17
+ jbuilder (~> 2.5.0)
18
+ jquery-rails (~> 4.1.1)
19
+ net-ldap (>= 0.14.0)
20
+ nokogiri (~> 1.6.8)
21
+ prawn (~> 2.1.0)
22
+ prawn-rails (>= 0.1.1)
23
+ prawn-table (>= 0.2.2)
24
+ rails (~> 4.2.7.1)
25
+ ruby-ntlm (= 0.0.3)
26
+ rubyzip (~> 1.0.0)
27
+ sass-rails (~> 5.0.4)
28
+ spawnling (~> 2.1.6)
29
+ thor
30
+ tiny_tds (~> 1.0.4)
31
+ tzinfo-data
32
+ uglifier (~> 3.0.0)
33
+ will_paginate (~> 3.1.0)
34
+
35
+ GEM
36
+ remote: https://rubygems.org/
37
+ specs:
38
+ actionmailer (4.2.7.1)
39
+ actionpack (= 4.2.7.1)
40
+ actionview (= 4.2.7.1)
41
+ activejob (= 4.2.7.1)
42
+ mail (~> 2.5, >= 2.5.4)
43
+ rails-dom-testing (~> 1.0, >= 1.0.5)
44
+ actionpack (4.2.7.1)
45
+ actionview (= 4.2.7.1)
46
+ activesupport (= 4.2.7.1)
47
+ rack (~> 1.6)
48
+ rack-test (~> 0.6.2)
49
+ rails-dom-testing (~> 1.0, >= 1.0.5)
50
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
51
+ actionview (4.2.7.1)
52
+ activesupport (= 4.2.7.1)
53
+ builder (~> 3.1)
54
+ erubis (~> 2.7.0)
55
+ rails-dom-testing (~> 1.0, >= 1.0.5)
56
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
57
+ activejob (4.2.7.1)
58
+ activesupport (= 4.2.7.1)
59
+ globalid (>= 0.3.0)
60
+ activemodel (4.2.7.1)
61
+ activesupport (= 4.2.7.1)
62
+ builder (~> 3.1)
63
+ activerecord (4.2.7.1)
64
+ activemodel (= 4.2.7.1)
65
+ activesupport (= 4.2.7.1)
66
+ arel (~> 6.0)
67
+ activerecord-sqlserver-adapter (4.2.15)
68
+ activerecord (~> 4.2.1)
69
+ activesupport (4.2.7.1)
70
+ i18n (~> 0.7)
71
+ json (~> 1.7, >= 1.7.7)
72
+ minitest (~> 5.1)
73
+ thread_safe (~> 0.3, >= 0.3.4)
74
+ tzinfo (~> 1.1)
75
+ ansi (1.5.0)
76
+ arel (6.0.4)
77
+ autoprefixer-rails (6.6.1)
78
+ execjs
79
+ axlsx (2.0.1)
80
+ htmlentities (~> 4.3.1)
81
+ nokogiri (>= 1.4.1)
82
+ rubyzip (~> 1.0.0)
83
+ axlsx_rails (0.5.0)
84
+ actionpack (>= 3.1)
85
+ axlsx (>= 2.0.1)
86
+ barkest_ssh (1.1.13)
87
+ net-sftp (~> 2.1.2)
88
+ net-ssh (~> 3.0.2)
89
+ bcrypt (3.1.11)
90
+ bootstrap-sass (3.3.7)
91
+ autoprefixer-rails (>= 5.2.1)
92
+ sass (>= 3.3.4)
93
+ bootstrap-will_paginate (0.0.10)
94
+ will_paginate
95
+ builder (3.2.3)
96
+ byebug (9.0.6)
97
+ carrierwave (0.11.2)
98
+ activemodel (>= 3.2.0)
99
+ activesupport (>= 3.2.0)
100
+ json (>= 1.7)
101
+ mime-types (>= 1.16)
102
+ mimemagic (>= 0.3.0)
103
+ coffee-rails (4.1.1)
104
+ coffee-script (>= 2.2.0)
105
+ railties (>= 4.0.0, < 5.1.x)
106
+ coffee-script (2.4.1)
107
+ coffee-script-source
108
+ execjs
109
+ coffee-script-source (1.12.2)
110
+ concurrent-ruby (1.0.4)
111
+ debug_inspector (0.0.2)
112
+ encrypted_strings (0.3.3)
113
+ erubis (2.7.0)
114
+ exception_notification (4.1.4)
115
+ actionmailer (~> 4.0)
116
+ activesupport (~> 4.0)
117
+ execjs (2.7.0)
118
+ faker (1.7.2)
119
+ i18n (~> 0.5)
120
+ globalid (0.3.7)
121
+ activesupport (>= 4.1.0)
122
+ hex_string (1.0.1)
123
+ htmlentities (4.3.4)
124
+ i18n (0.7.0)
125
+ jbuilder (2.5.0)
126
+ activesupport (>= 3.0.0, < 5.1)
127
+ multi_json (~> 1.2)
128
+ jquery-rails (4.1.1)
129
+ rails-dom-testing (>= 1, < 3)
130
+ railties (>= 4.2.0)
131
+ thor (>= 0.14, < 2.0)
132
+ json (1.8.6)
133
+ loofah (2.0.3)
134
+ nokogiri (>= 1.5.9)
135
+ mail (2.6.4)
136
+ mime-types (>= 1.16, < 4)
137
+ mime-types (3.1)
138
+ mime-types-data (~> 3.2015)
139
+ mime-types-data (3.2016.0521)
140
+ mimemagic (0.3.2)
141
+ mini_backtrace (0.1.3)
142
+ minitest (> 1.2.0)
143
+ rails (>= 2.3.3)
144
+ mini_portile2 (2.1.0)
145
+ minitest (5.10.1)
146
+ minitest-reporters (1.1.13)
147
+ ansi
148
+ builder
149
+ minitest (>= 5.0)
150
+ ruby-progressbar
151
+ multi_json (1.12.1)
152
+ net-ldap (0.15.0)
153
+ net-sftp (2.1.2)
154
+ net-ssh (>= 2.6.5)
155
+ net-ssh (3.0.2)
156
+ nokogiri (1.6.8.1)
157
+ mini_portile2 (~> 2.1.0)
158
+ nokogiri (1.6.8.1-x86-mingw32)
159
+ mini_portile2 (~> 2.1.0)
160
+ pdf-core (0.6.1)
161
+ prawn (2.1.0)
162
+ pdf-core (~> 0.6.1)
163
+ ttfunk (~> 1.4.0)
164
+ prawn-rails (0.1.1)
165
+ prawn
166
+ prawn-table
167
+ rails (>= 3.1.0)
168
+ prawn-table (0.2.2)
169
+ prawn (>= 1.3.0, < 3.0.0)
170
+ rack (1.6.5)
171
+ rack-test (0.6.3)
172
+ rack (>= 1.0)
173
+ rails (4.2.7.1)
174
+ actionmailer (= 4.2.7.1)
175
+ actionpack (= 4.2.7.1)
176
+ actionview (= 4.2.7.1)
177
+ activejob (= 4.2.7.1)
178
+ activemodel (= 4.2.7.1)
179
+ activerecord (= 4.2.7.1)
180
+ activesupport (= 4.2.7.1)
181
+ bundler (>= 1.3.0, < 2.0)
182
+ railties (= 4.2.7.1)
183
+ sprockets-rails
184
+ rails-deprecated_sanitizer (1.0.3)
185
+ activesupport (>= 4.2.0.alpha)
186
+ rails-dom-testing (1.0.8)
187
+ activesupport (>= 4.2.0.beta, < 5.0)
188
+ nokogiri (~> 1.6)
189
+ rails-deprecated_sanitizer (>= 1.0.1)
190
+ rails-html-sanitizer (1.0.3)
191
+ loofah (~> 2.0)
192
+ railties (4.2.7.1)
193
+ actionpack (= 4.2.7.1)
194
+ activesupport (= 4.2.7.1)
195
+ rake (>= 0.8.7)
196
+ thor (>= 0.18.1, < 2.0)
197
+ rake (12.0.0)
198
+ ruby-ntlm (0.0.3)
199
+ ruby-progressbar (1.8.1)
200
+ rubyzip (1.0.0)
201
+ sass (3.4.23)
202
+ sass-rails (5.0.6)
203
+ railties (>= 4.0.0, < 6)
204
+ sass (~> 3.1)
205
+ sprockets (>= 2.8, < 4.0)
206
+ sprockets-rails (>= 2.0, < 4.0)
207
+ tilt (>= 1.1, < 3)
208
+ spawnling (2.1.6)
209
+ sprockets (3.7.1)
210
+ concurrent-ruby (~> 1.0)
211
+ rack (> 1, < 3)
212
+ sprockets-rails (3.2.0)
213
+ actionpack (>= 4.0)
214
+ activesupport (>= 4.0)
215
+ sprockets (>= 3.0.0)
216
+ sqlite3 (1.3.13)
217
+ sqlite3 (1.3.13-x86-mingw32)
218
+ thor (0.19.4)
219
+ thread_safe (0.3.5)
220
+ tilt (2.0.5)
221
+ tiny_tds (1.0.5)
222
+ mini_portile2 (~> 2.0)
223
+ tiny_tds (1.0.5-x86-mingw32)
224
+ mini_portile2 (~> 2.0)
225
+ ttfunk (1.4.0)
226
+ tzinfo (1.2.2)
227
+ thread_safe (~> 0.1)
228
+ tzinfo-data (1.2016.10)
229
+ tzinfo (>= 1.0.0)
230
+ uglifier (3.0.4)
231
+ execjs (>= 0.3.0, < 3)
232
+ web-console (3.3.0)
233
+ activemodel (>= 4.2)
234
+ debug_inspector
235
+ railties (>= 4.2)
236
+ will_paginate (3.1.5)
237
+
238
+ PLATFORMS
239
+ ruby
240
+ x86-mingw32
241
+
242
+ DEPENDENCIES
243
+ activerecord-sqlserver-adapter (~> 4.2.5)
244
+ barkest_core!
245
+ byebug
246
+ faker
247
+ mini_backtrace
248
+ minitest-reporters
249
+ sqlite3
250
+ tiny_tds (~> 1.0.4)
251
+ web-console
252
+
253
+ BUNDLED WITH
254
+ 1.13.7
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2016 Beau Barker
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,364 @@
1
+ # BarkestCore
2
+
3
+ The BarkestCore project gets a web application off to a quick start by building on the Rails 4 framework.
4
+
5
+ This project includes basic user management, group based authorization, and a number of helper methods.
6
+
7
+ Most Barker EST web applications use this gem for authentication, authorization, and helper routines.
8
+ There are customizations added to controllers, models, and test cases. There is also a customization added
9
+ to the configuration system that ensures a database configuration exists for test and development environments.
10
+ This allows you to leave the YAML files out of your git repository without having to worry about the out-of-box
11
+ experience that this would normally cause issues with.
12
+
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ gem 'barkest_core'
20
+ ```
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install barkest_core
29
+
30
+ Once installed, you will want to configure the gem:
31
+
32
+ $ bundle exec rails generate barkest_core:install
33
+
34
+ The configuration will go through everything that BarkestCore needs to function, but will also
35
+ offer to provide you with some reasonable defaults and protections (removing YAML config files from repo).
36
+ Only certain parts are required for BarkestCore to function.
37
+
38
+
39
+ ## Usage
40
+
41
+ This gem provides the foundation for a Rails application. It is somewhat mean in that it is not fully namespaced. It
42
+ uses the `User` model for, well, users, and the `AccessGroup` model for user-group memberships. This would be important
43
+ to keep in mind when developing your application. For Barker EST applications, this happens to be exactly what I want,
44
+ so there was no need to support namespacing these models or controllers.
45
+
46
+ During configuration, BarkestCore offers to update your `ApplicationController` class and your application layout files.
47
+ If you opted to let BarkestCore perform these updates, then your application should be ready to go. If not, then there
48
+ may be some issues. To truly take advantage of BarkestCore, you should have your `ApplicationController` inherit from
49
+ `::BarkestCore::ApplicationControllerBase`. This gives you all the session and user based helper functionality as well
50
+ as the `authorize!` method inside your controllers. The layouts are less important, BarkestCore provides some generic
51
+ layouts as default, but you can easily use your own layouts.
52
+
53
+ ---
54
+ There are a few special layouts you can create to modify parts of the layout easily. Create these files in your
55
+ __views/layouts__ folder to have them get used automatically. These views will override
56
+ the default views for the library. See the next two sections for other ways to customize the application.
57
+ Use the _ prefixed notation.
58
+ ie: "_nav_logo.html.erb" for "nav_logo"
59
+
60
+ * __nav_logo__ Defines the logo in the top left corner of the webpage. This should be an image tag inside of
61
+ a link tag.
62
+ ie: `<a href="..."><img src="..."></a>`
63
+ * __footer_copyright__ Defines the copyright text presented in the footer. This can be anything you want
64
+ it to be.
65
+ * __menu_admin__ Defines the administration menu. You probably won't need to do anything with this
66
+ particular menu, but just in case, it is one of the easily overridable views.
67
+ Menus would be `<li>...</li>` items. The container `<ul>...</ul>` is defined in the parent view.
68
+ * __menu_anon__ Defines the menu available to all users, aka: the anonymous menu. If you want to
69
+ provide menu options to everyone, you would want to place them here.
70
+ Menus would be `<li>...</li>` items. The container `<ul>...</ul>` is defined in the parent view.
71
+ * __menu_auth__ Defines the menu available to authenticated users. The default is just a link to the
72
+ users list. Your app may not even desire that link. This is the view that is most likely to be
73
+ adjusted on a per-project basis since it defines the menu for users.
74
+ Menus would be `<li>...</li>` items. The container `<ul>...</ul>` is defined in the parent view.
75
+
76
+ ---
77
+ **Namespaced Partials**
78
+
79
+ If you are designing a gem based on this gem, and you are namespacing your controllers, you can make use of this
80
+ automatic behavior.
81
+
82
+ Let's say your controller is MyNamespace::MySpecialController. Your route might be 'my_special/action'. The router
83
+ should define the parameter 'controller' to be 'my_namespace/my_special'. The default layouts look for this format
84
+ and then try to include some namespaced partials automatically.
85
+
86
+ The _menu_auth_, _menu_anon_, _menu_footer_, and _subheader_ partials are looked for automatically. The _menu_footer_
87
+ partial is just like _menu_auth_ and _menu_anon_ except it goes in the footer.
88
+
89
+ The __subheader__ partial is specific to namespaced controllers. This partial gets rendered immediately after the
90
+ header before any messages. This allows you to define navigation tokens for your gem that won't interfere with the
91
+ rest of the application. Although you are free to use the partial for anything else you might want to stick right
92
+ under the main menu bar.
93
+
94
+ The _menu_auth_ and _menu_anon_ partials are rendered after the default partials. The _menu_footer_ partial is rendered
95
+ before the default partials.
96
+
97
+ All of these partials are stored under 'layouts/{namespace}'. So in our example, we would create
98
+ 'views/layouts/my_namespace/menu_auth' and include related commands in the main menu. These commands would only be
99
+ included while we are in the namespace, see the next section about registering views.
100
+
101
+ ---
102
+ **Registered Partials**
103
+
104
+ You may want to add to the main menu when your gem is loaded to make navigating to your gem's controllers easier.
105
+ BarkestCore now includes methods to register partials to do just that.
106
+
107
+ `BarkestCore.register_anon_menu`, `BarkestCore.register_auth_menu`, and `BarkestCore.register_footer_menu` register
108
+ partials to be rendered in those three menu locations. The _anon_ and _footer_ menus are always rendered, while the
109
+ _auth_ menu is only rendered once a user is authenticated. The _anon_ and _auth_ menus are rendered in the order of
110
+ registration. The _footer_ menus are rendered in reverse order.
111
+
112
+
113
+ ---
114
+ Utility models are namespaced. These include the `UserManager` (which you shouldn't need to use directly), `WorkPath`,
115
+ `GlobalStatus`, and `PdfTableBuilder` classes, among others.
116
+
117
+ The `WorkPath` class gives you a simple way to work with
118
+ an application specific temporary directory. It looks for shared memory locations before defaulting to "/tmp" so on
119
+ systems that have shared memory ("/dev/shm") the temporary files will be stored there.
120
+
121
+ ```ruby
122
+ my_temp_file = BarkestCore::WorkPath.path_for('some.file')
123
+ ```
124
+
125
+ The `GlobalStatus` class allows you to "lock" the system in one process/thread and provide status updates to another
126
+ process/thread. This is useful if you have long running processes. In one session you can use the `GlobalStatus` class
127
+ to lock the system to perform the work. In another you can monitor the status to determine when the other session has
128
+ finished.
129
+
130
+ ```ruby
131
+ BarkestCore::GlobalStatus.lock_for do
132
+ # do some long running code here...
133
+ end
134
+ ```
135
+
136
+ ---
137
+ A `SystemConfig` (not namespaced) class exists that can be used to store configuration data for various
138
+ services. For instance, by default the LDAP and email configurations are stored within `SystemConfig`.
139
+
140
+ This is handled by the `system_config` controller since the `SystemConfig` class doesn't care what is
141
+ getting stored. It does however offer the lovely capability to encrypt the stored configuration.
142
+
143
+ ```ruby
144
+ my_config = {
145
+ :some_int => 1234,
146
+ :some_string => 'hello world',
147
+ :some_bool => true
148
+ }
149
+
150
+ # Save the hash to the database in plain text.
151
+ SystemConfig.set :some_config, my_config
152
+
153
+ # Save the hash to the database in encrypted format.
154
+ SystemConfig.set :some_config, my_config, true
155
+
156
+ # Read the hash from the database (decrypted automatically if needed).
157
+ my_config = SystemConfig.get(:some_config)
158
+ ```
159
+
160
+ The encryption key used by `SystemConfig` comes from the __secrets.yml__ configuration file. If the
161
+ `encrypted_config_key` is specified, that value will be used, otherwise the `secret_key_base` value
162
+ will be used. If the value for the encryption key is changed, any stored encrypted configurations
163
+ will be lost. The `SystemConfig` class will return __nil__ if the value does not exist or cannot be
164
+ decrypted.
165
+
166
+ ---
167
+ Because I generally have a need to interface with MS SQL for reporting purposes, I decided to build the
168
+ necessary models as well. The models would be `MsSqlDbDefinition`, `MsSqlDefinition`, and `MsSqlFunction`.
169
+ ---
170
+ The `MsSqlFunction` model basically allows you to use the output from a user-defined function in SQL to
171
+ populate an ActiveRecord-like model. These are read-only models, which fits in nicely with the output
172
+ from a user-defined function. There are 3 steps to using the `MsSqlFunction`.
173
+ 1. Inherit from `BarkestCore::MsSqlFunction`.
174
+ 2. Tell it what connection to use.
175
+ 3. Tell it the name of the user-defined function.
176
+
177
+ ```sql
178
+ CREATE FUNCTION [my_function] (
179
+ @alpha INTEGER,
180
+ @bravo VARCHAR(100),
181
+ @charlie DATETIME
182
+ ) RETURNS TABLE AS RETURN
183
+ SELECT
184
+ LEN(ISNULL(@bravo,'')) AS [bravo_len],
185
+ LEN(ISNULL(@bravo,'')) * ISNULL(@alpha,0) AS [alpha_bravo],
186
+ CONVERT(FLOAT, LEN(ISNULL(@bravo, ''))) / 100.0 AS [bravo_len_pct],
187
+ CONVERT(BIT, CASE
188
+ WHEN @alpha > 25 THEN 1
189
+ ELSE 0
190
+ END) AS [alpha_gt_25],
191
+ ISNULL(@alpha,0) AS [alpha],
192
+ ISNULL(@bravo,'') AS [bravo],
193
+ ISNULL(@charlie, GETDATE()) AS [charlie]
194
+ ```
195
+
196
+ ```ruby
197
+ class MyFunction < BarkestCore::MsSqlFunction
198
+ use_connection 'ActiveRecord::Base'
199
+ self.function_name = 'my_function'
200
+ end
201
+ ```
202
+
203
+ Setting the function name causes the model to be built. The name cannot be changed once set.
204
+ After the model has been built, you can view the parameters, set their default values, view the columns,
205
+ and select from the function.
206
+
207
+ ```ruby
208
+ MyFunction.parameters.inspect
209
+ # "{ :alpha=>{ :type=>:integer, :data_type=>'integer' ... }, ... }"
210
+
211
+ # Set some default parameter values.
212
+ MyFunction.parameters = { :alpha => 10, :bravo => 'yes' }
213
+
214
+ # The output from .parameters can be fed back into .parameters=, just set the :default keys.
215
+ p = MyFunction.parameters
216
+ p[:alpha][:default] = 10
217
+ p[:bravo][:default] = 'yes'
218
+ MyFunction.parameters = p
219
+
220
+ MyFunction.columns.inspect
221
+ # "{ { :name=>'bravo_len', :key=>:bravo_len, :data_type=>'int', :type=>:integer ...}, ...}"
222
+
223
+ results = MyFunction.select( :alpha => 25, :bravo => 'Hello', :charlie => 5.days.ago )
224
+ ```
225
+
226
+ ---
227
+ The `MsSqlDefinition` model is used primarily to load table, view, function, and procedure definitions
228
+ for the `MsSqlDbDefinition` model. If the source used to create the `MsSqlDefinition` model was for a
229
+ function, then the model will attempt to figure out the return value. But other than that, it doesn't
230
+ try to figure out what you're trying to do with the code.
231
+
232
+ The `MsSqlDbDefinition` model is the model more likely to be used directly. And the easiest way to use this
233
+ model is to use the `MsSqlDbDefinition.register` method.
234
+
235
+ ```ruby
236
+ updater = MsSqlDbDefinition.register(
237
+ :my_db,
238
+ :source_paths => [ 'sql/my_db' ],
239
+ :extra_params => {
240
+ :extra_1 => {
241
+ :name => 'some_connection_param',
242
+ :label => 'Enter a value for some connection param',
243
+ :type => 'text',
244
+ :value => 'my default'
245
+ }
246
+ },
247
+ :before_update => Proc.new do |db_conn, user|
248
+ ...
249
+ end,
250
+ :after_update => Proc.new do |db_conn, user|
251
+ ...
252
+ end
253
+ )
254
+ ```
255
+
256
+ Only the first parameter is required, that would be the database name. The `source_paths` key would
257
+ define the paths to search for SQL files when the updater is created. You can add more sources later
258
+ using `add_source`, `add_source_definition`, and `add_source_path`.
259
+
260
+ ```ruby
261
+ # Add one source to the updater.
262
+ # The first comment should define the timestamp for the source.
263
+ updater.add_source "-- 2016-12-19\nCREATE VIEW [my_view] AS SELECT ..."
264
+
265
+ # The definition can be created in any valid manner, this option allows for maximum
266
+ # flexibility since you can tweak the actual definition going into the updater.
267
+ # The third param is the timestamp here, but it can also be included in the source directly.
268
+ # Note that the timestamp is an integer number here.
269
+ my_def = MsSqlDefinition.new "CREATE VIEW [my_view] AS SELECT ...", nil, 201612121400
270
+ updater.add_source_definition my_def
271
+
272
+ # Just like in the constructor, search for all SQL files in the specified path.
273
+ # Neither the `source_paths` constructor key not this method are recursive.
274
+ # You need to add subdirectories individually.
275
+ # The source files should set the timestamp in the first comment as shown above.
276
+ # If they don't then they will use the file modification time. Since git doesn't
277
+ # track the modification time, this essentially becomes the project's creation time
278
+ # so it would be best to include the comments.
279
+ updater.add_source_path "sql/my_db"
280
+ ```
281
+
282
+ The `extra_params` key allows you to specify up to 5 extra configuration parameters for this database's
283
+ connection. Each extra param must have a name and type. The label and value are optional, but recommended.
284
+
285
+ The `type` could be "text", "password", "integer", "float", "boolean", or the special "in:" type. The "in:"
286
+ type allows you to specify a range of valid options for the parameter.
287
+
288
+ ```ruby
289
+ { :type => "in:MyCustomModel::VALID_EXTRA_PARAM_OPTIONS" }
290
+ ```
291
+
292
+ The text after the "in:" will be evaluated and should return an enumerable object.
293
+
294
+ The `before_update` and `after_update` callbacks are executed repectively before or after the update
295
+ is performed. The `db_conn` param is the current connection adapter. The `user` param is the user executing
296
+ the update. The `before_update` and `after_update` callbacks can also reference a method defined elsewhere.
297
+
298
+ ```ruby
299
+ { :before_update => "MyCustomModel.before_db_update(db_conn, user)" }
300
+ ```
301
+
302
+ The `MsSqlDbDefinition.register` method registers the database configuration with the system so that the
303
+ SystemConfigController can configure it, and also so that once it is configured the boot code can perform
304
+ the update.
305
+
306
+ It would be horrible to perform the update every time the app was started, which is where the timestamps
307
+ come into play. The system generates a unique version for each source file based on the timestamp and the
308
+ CRC32 of the source contents. The timestamps have a 1 minute resolution, and the CRC32 ensures the contents
309
+ haven't changed. The timestamps are the real determiner for whether the object needs updated or not. The
310
+ CRC32 would be just a quick check that everything is good.
311
+
312
+ When using the source paths, the modified time for the files is used for the timestamps. When adding the
313
+ definition directly, you are providing the timestamp.
314
+
315
+ Once an object is created, the unique version is stored for the object. The next time the update runs, it
316
+ checks the stored version against the computed versions and only updates the objects it decides need to be
317
+ updated.
318
+
319
+ ---
320
+ #### DateTime Handling
321
+
322
+ I find that I have to accurately work with Dates and Times frequently. A common problem I had on a previous project
323
+ was "TimeZone Interference". This was only a problem with user provided dates/times. For instance, a user enters
324
+ an employee's hire date as '2000-10-15', ActiveRecord parses that according to the local time zone (-0500) so we have
325
+ '2000-10-15 00:00:00 -0500' which becomes '2000-10-16 05:00:00 UTC' when stored. So far, not really a problem if we
326
+ work solely in one time zone, big problem if we start working across time zones.
327
+
328
+ So I implemented a few changes. `Date.to_time` returns UTC. `Date.today.to_time` used to return TimeZoned values,
329
+ not with this gem. `Date.today.to_time` returns '2000-01-01 00:00:00 UTC'. In my mind, a date should not be time zoned.
330
+ I also added a `Time.date` method that returns the date with the time stripped off. The time will be converted to UTC
331
+ first and then a date in UTC is returned. So '2000-01-01 22:00:00 -0500'.date == '2000-01-02 00:00:00 UTC'.
332
+
333
+ The `Time.utc_parse` static method is a parser capable of parsing either Y-M-D or M/D/Y dates, supports AM/PM values and time
334
+ zone offsets. The returned time is always UTC.
335
+
336
+ The `Time.as_utc` method strips the time zone info from a time and simply returns a UTC time with the same raw values.
337
+ This can be useful in some instances, but unlike other methods the returned value does not equal the source value unless
338
+ the source value was also in UTC.
339
+
340
+ So, that's all great, but what about the real crux: ActiveRecord. Well, it actually wasn't too hard. After tracing my
341
+ way through the ActiveRecord::Base class, and looking at the included modules, it became clear where I needed to make
342
+ a change. ActiveRecord::Base includes the TimeZoneConversion module. I wrote up the UtcConversion module to replace
343
+ and disable the TimeZoneConversion module, and then included it into ActiveRecord::Base. The UtcConverter class used
344
+ to convert :datetime values simply runs all values past Time.utc_parse.
345
+
346
+ So what does all of this do for me? All handling of dates and times is done in UTC, _as it should be_. This avoids
347
+ mistakes due to time zone offsets and only adds one level of hinderance. If you want to show the user a localtime,
348
+ you have to call the `in_time_zone` method on the time value. This will return a Rails TimeWithZone under your
349
+ configured time zone, which you can then display to the user.
350
+
351
+
352
+
353
+
354
+
355
+ ## Contributing
356
+
357
+ Bug reports and pull requests are welcome on GitHub at https://github.com/barkerest/barkest_core.
358
+
359
+
360
+ ## License
361
+
362
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
363
+
364
+ Copyright (c) 2016 [Beau Barker](mailto:beau@barkerest.com)