barkest_core 1.5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/Gemfile +22 -0
- data/Gemfile.lock +254 -0
- data/MIT-LICENSE +20 -0
- data/README.md +364 -0
- data/Rakefile +37 -0
- data/app/assets/fonts/barkest_core/ArchivoNarrow-Bold.ttf +0 -0
- data/app/assets/fonts/barkest_core/ArchivoNarrow-BoldItalic.ttf +0 -0
- data/app/assets/fonts/barkest_core/ArchivoNarrow-Italic.ttf +0 -0
- data/app/assets/fonts/barkest_core/ArchivoNarrow-Regular.ttf +0 -0
- data/app/assets/images/barkest_core/.keep +0 -0
- data/app/assets/images/barkest_core/barcode-B.svg +181 -0
- data/app/assets/javascripts/barkest_core/.keep +0 -0
- data/app/assets/javascripts/barkest_core/application.js +22 -0
- data/app/assets/javascripts/barkest_core/bootstrap-datepicker.js +1800 -0
- data/app/assets/javascripts/barkest_core/field_init.js +7 -0
- data/app/assets/javascripts/barkest_core/jquery.doubleScroll.js +112 -0
- data/app/assets/javascripts/barkest_core/masked_edit.js +25 -0
- data/app/assets/javascripts/barkest_core/system_status.js.erb +201 -0
- data/app/assets/stylesheets/barkest_core/.keep +0 -0
- data/app/assets/stylesheets/barkest_core/application.css +17 -0
- data/app/assets/stylesheets/barkest_core/custom.css.scss +264 -0
- data/app/assets/stylesheets/barkest_core/datepicker3.css +790 -0
- data/app/controllers/.keep +0 -0
- data/app/controllers/access_groups_controller.rb +74 -0
- data/app/controllers/account_activations_controller.rb +29 -0
- data/app/controllers/application_controller.rb +5 -0
- data/app/controllers/barkest_core/application_controller_base.rb +113 -0
- data/app/controllers/barkest_core/engine_controller_base.rb +15 -0
- data/app/controllers/barkest_core/testsub_controller.rb +21 -0
- data/app/controllers/contact_controller.rb +32 -0
- data/app/controllers/log_view_controller.rb +31 -0
- data/app/controllers/password_resets_controller.rb +126 -0
- data/app/controllers/sessions_controller.rb +64 -0
- data/app/controllers/status_controller.rb +150 -0
- data/app/controllers/system_config_controller.rb +238 -0
- data/app/controllers/system_update_controller.rb +164 -0
- data/app/controllers/test_access_controller.rb +44 -0
- data/app/controllers/test_report_controller.rb +75 -0
- data/app/controllers/users_controller.rb +218 -0
- data/app/helpers/.keep +0 -0
- data/app/helpers/barkest_core/application_helper.rb +134 -0
- data/app/helpers/barkest_core/form_helper.rb +469 -0
- data/app/helpers/barkest_core/html_helper.rb +70 -0
- data/app/helpers/barkest_core/misc_helper.rb +68 -0
- data/app/helpers/barkest_core/pdf_helper.rb +180 -0
- data/app/helpers/barkest_core/recaptcha_helper.rb +115 -0
- data/app/helpers/barkest_core/sessions_helper.rb +94 -0
- data/app/helpers/barkest_core/status_helper.rb +118 -0
- data/app/helpers/barkest_core/users_helper.rb +32 -0
- data/app/mailers/.keep +0 -0
- data/app/mailers/application_mailer.rb +5 -0
- data/app/mailers/barkest_core/application_mailer_base.rb +30 -0
- data/app/mailers/barkest_core/contact_form.rb +20 -0
- data/app/mailers/barkest_core/user_mailer.rb +44 -0
- data/app/models/.keep +0 -0
- data/app/models/access_group.rb +121 -0
- data/app/models/access_group_group_member.rb +13 -0
- data/app/models/access_group_user_member.rb +11 -0
- data/app/models/barkest_core/auth_config.rb +95 -0
- data/app/models/barkest_core/authorize_failure.rb +7 -0
- data/app/models/barkest_core/contact_message.rb +37 -0
- data/app/models/barkest_core/database_config.rb +223 -0
- data/app/models/barkest_core/db_table.rb +21 -0
- data/app/models/barkest_core/email_config.rb +132 -0
- data/app/models/barkest_core/global_status.rb +267 -0
- data/app/models/barkest_core/log_entry.rb +101 -0
- data/app/models/barkest_core/log_view_options.rb +51 -0
- data/app/models/barkest_core/ms_sql_db_definition.rb +441 -0
- data/app/models/barkest_core/ms_sql_definition.rb +221 -0
- data/app/models/barkest_core/ms_sql_function.rb +423 -0
- data/app/models/barkest_core/not_logged_in.rb +7 -0
- data/app/models/barkest_core/pdf_table_builder.rb +407 -0
- data/app/models/barkest_core/self_update_config.rb +37 -0
- data/app/models/barkest_core/user_alert.rb +29 -0
- data/app/models/barkest_core/user_alert_generators.rb +58 -0
- data/app/models/barkest_core/user_manager.rb +404 -0
- data/app/models/barkest_core/work_path.rb +74 -0
- data/app/models/disable_user.rb +18 -0
- data/app/models/ldap_access_group.rb +15 -0
- data/app/models/system_config.rb +99 -0
- data/app/models/user.rb +405 -0
- data/app/models/user_login_history.rb +11 -0
- data/app/views/.keep +0 -0
- data/app/views/access_groups/_form.html.erb +19 -0
- data/app/views/access_groups/edit.html.erb +2 -0
- data/app/views/access_groups/index.html.erb +32 -0
- data/app/views/access_groups/new.html.erb +2 -0
- data/app/views/access_groups/show.html.erb +4 -0
- data/app/views/barkest_core/contact_form/contact.html.erb +16 -0
- data/app/views/barkest_core/contact_form/contact.text.erb +13 -0
- data/app/views/barkest_core/testsub/_links.html.erb +5 -0
- data/app/views/barkest_core/testsub/page1.html.erb +3 -0
- data/app/views/barkest_core/testsub/page2.html.erb +2 -0
- data/app/views/barkest_core/testsub/page3.html.erb +2 -0
- data/app/views/barkest_core/user_mailer/account_activation.html.erb +7 -0
- data/app/views/barkest_core/user_mailer/account_activation.text.erb +6 -0
- data/app/views/barkest_core/user_mailer/invalid_password_reset.html.erb +3 -0
- data/app/views/barkest_core/user_mailer/invalid_password_reset.text.erb +5 -0
- data/app/views/barkest_core/user_mailer/password_reset.html.erb +8 -0
- data/app/views/barkest_core/user_mailer/password_reset.text.erb +7 -0
- data/app/views/contact/index.html.erb +24 -0
- data/app/views/layouts/_footer_copyright.html.erb +1 -0
- data/app/views/layouts/_menu_admin.html.erb +5 -0
- data/app/views/layouts/_menu_anon.html.erb +0 -0
- data/app/views/layouts/_menu_auth.html.erb +3 -0
- data/app/views/layouts/_menu_footer.html.erb +1 -0
- data/app/views/layouts/_nav_logo.html.erb +1 -0
- data/app/views/layouts/application.html.erb +2 -0
- data/app/views/layouts/barkest_core/_application.html.erb +24 -0
- data/app/views/layouts/barkest_core/_footer.html.erb +18 -0
- data/app/views/layouts/barkest_core/_header.html.erb +38 -0
- data/app/views/layouts/barkest_core/_html_mailer.html.erb +11 -0
- data/app/views/layouts/barkest_core/_menu_account.html.erb +14 -0
- data/app/views/layouts/barkest_core/_menu_sample.html.erb +1 -0
- data/app/views/layouts/barkest_core/_messages.html.erb +4 -0
- data/app/views/layouts/barkest_core/_shim.html.erb +4 -0
- data/app/views/layouts/barkest_core/_subheader.html.erb +1 -0
- data/app/views/layouts/barkest_core/_text_mailer.text.erb +4 -0
- data/app/views/layouts/mailer.html.erb +1 -0
- data/app/views/layouts/mailer.text.erb +1 -0
- data/app/views/log_view/index.html.erb +100 -0
- data/app/views/password_resets/edit.html.erb +20 -0
- data/app/views/password_resets/new.html.erb +14 -0
- data/app/views/sessions/new.html.erb +27 -0
- data/app/views/shared/_error_messages.html.erb +29 -0
- data/app/views/shared/_generic_user_alert.html.erb +4 -0
- data/app/views/status/current.html.erb +34 -0
- data/app/views/status/test.html.erb +50 -0
- data/app/views/system_config/index.html.erb +25 -0
- data/app/views/system_config/show_auth.html.erb +28 -0
- data/app/views/system_config/show_database.html.erb +36 -0
- data/app/views/system_config/show_email.html.erb +21 -0
- data/app/views/system_config/show_self_update.html.erb +13 -0
- data/app/views/system_update/index.html.erb +31 -0
- data/app/views/system_update/new.html.erb +2 -0
- data/app/views/test_access/allow_anon.html.erb +2 -0
- data/app/views/test_access/require_admin.html.erb +2 -0
- data/app/views/test_access/require_group_x.html.erb +2 -0
- data/app/views/test_access/require_user.html.erb +2 -0
- data/app/views/test_report/index.csv.csvrb +23 -0
- data/app/views/test_report/index.html.erb +6 -0
- data/app/views/test_report/index.pdf.prawn +50 -0
- data/app/views/test_report/index.xlsx.axlsx +28 -0
- data/app/views/users/_user.html.erb +57 -0
- data/app/views/users/_user_details.html.erb +15 -0
- data/app/views/users/_user_details_for_list.html.erb +1 -0
- data/app/views/users/_user_form.html.erb +13 -0
- data/app/views/users/disable_confirm.html.erb +19 -0
- data/app/views/users/edit.html.erb +15 -0
- data/app/views/users/index.html.erb +9 -0
- data/app/views/users/new.html.erb +10 -0
- data/app/views/users/show.html.erb +46 -0
- data/bin/rails +12 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20160617172539_create_access_groups.rb +10 -0
- data/db/migrate/20160617172725_create_users.rb +26 -0
- data/db/migrate/20160617172833_create_user_login_histories.rb +12 -0
- data/db/migrate/20160622151720_create_access_group_user_members.rb +9 -0
- data/db/migrate/20160622151925_create_access_group_group_members.rb +9 -0
- data/db/migrate/20160701005706_create_ldap_access_groups.rb +11 -0
- data/db/migrate/20161108155029_create_system_configs.rb +11 -0
- data/db/seeds/barkest_core_01_create_users.rb +42 -0
- data/db/seeds.rb +53 -0
- data/lib/barkest_core/concerns/association_with_defaults.rb +55 -0
- data/lib/barkest_core/concerns/boolean_parser.rb +88 -0
- data/lib/barkest_core/concerns/date_parser.rb +181 -0
- data/lib/barkest_core/concerns/email_tester.rb +55 -0
- data/lib/barkest_core/concerns/encrypted_fields.rb +156 -0
- data/lib/barkest_core/concerns/named_model.rb +73 -0
- data/lib/barkest_core/concerns/number_parser.rb +145 -0
- data/lib/barkest_core/concerns/utc_conversion.rb +60 -0
- data/lib/barkest_core/engine.rb +105 -0
- data/lib/barkest_core/extensions/active_record_extensions.rb +120 -0
- data/lib/barkest_core/extensions/application_configuration_extensions.rb +38 -0
- data/lib/barkest_core/extensions/application_extensions.rb +50 -0
- data/lib/barkest_core/extensions/axlsx_extenstions.rb +157 -0
- data/lib/barkest_core/extensions/fixture_set_extensions.rb +107 -0
- data/lib/barkest_core/extensions/generator_extensions.rb +271 -0
- data/lib/barkest_core/extensions/main_app_extensions.rb +35 -0
- data/lib/barkest_core/extensions/prawn_document_extensions.rb +367 -0
- data/lib/barkest_core/extensions/prawn_table_extensions.rb +131 -0
- data/lib/barkest_core/extensions/router_extensions.rb +106 -0
- data/lib/barkest_core/extensions/simple_formatter_extensions.rb +66 -0
- data/lib/barkest_core/extensions/test_case_extensions.rb +348 -0
- data/lib/barkest_core/extensions/time_extensions.rb +164 -0
- data/lib/barkest_core/handlers/csv_handler.rb +30 -0
- data/lib/barkest_core/version.rb +3 -0
- data/lib/barkest_core.rb +324 -0
- data/lib/generators/barkest/install_generator.rb +102 -0
- data/lib/generators/barkest_core/actions/01_patch_application_controller.rb +55 -0
- data/lib/generators/barkest_core/actions/02_patch_application_mailer.rb +56 -0
- data/lib/generators/barkest_core/actions/03_patch_assets.rb +62 -0
- data/lib/generators/barkest_core/actions/04_patch_layouts.rb +36 -0
- data/lib/generators/barkest_core/actions/05_patch_routes.rb +93 -0
- data/lib/generators/barkest_core/actions/06_patch_seeds.rb +60 -0
- data/lib/generators/barkest_core/actions/07_copy_migrations.rb +51 -0
- data/lib/generators/barkest_core/actions/08_configure_database.rb +52 -0
- data/lib/generators/barkest_core/actions/09_configure_secrets.rb +29 -0
- data/lib/generators/barkest_core/actions/99_patch_gitignore.rb +57 -0
- data/lib/generators/barkest_core/install_generator.rb +17 -0
- data/test/barkest_core_test.rb +83 -0
- data/test/controllers/access_groups_controller_test.rb +53 -0
- data/test/controllers/contact_controller_test.rb +10 -0
- data/test/controllers/sessions_controller_test.rb +10 -0
- data/test/controllers/users_controller_test.rb +10 -0
- data/test/dummy/.gitignore +10 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +14 -0
- data/test/dummy/app/assets/stylesheets/application.css +16 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/mailers/.keep +0 -0
- data/test/dummy/app/mailers/application_mailer.rb +3 -0
- data/test/dummy/app/models/.keep +0 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +1 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +1 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/app/views/system_config/show_fake.html.erb +3 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config/application.rb +27 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +47 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +44 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/db_updater_ext.rb +33 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/sys_config_ext.rb +12 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +60 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/schema.rb +95 -0
- data/test/dummy/db/seeds/barkest_core_01_create_users.rb +42 -0
- data/test/dummy/db/seeds.rb +51 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/sql/my_test_view.sql +3 -0
- data/test/fixtures/access_groups.yml +21 -0
- data/test/fixtures/users.yml +71 -0
- data/test/helpers/barkest_core/sessions_helper_test.rb +22 -0
- data/test/integration/access_group_mgmt_test.rb +33 -0
- data/test/integration/access_test.rb +24 -0
- data/test/integration/account_activations_access_test.rb +12 -0
- data/test/integration/contact_test.rb +98 -0
- data/test/integration/extra_partial_test.rb +41 -0
- data/test/integration/log_view_access_test.rb +12 -0
- data/test/integration/password_resets_test.rb +101 -0
- data/test/integration/reports_test.rb +53 -0
- data/test/integration/status_access_test.rb +27 -0
- data/test/integration/system_config_access_test.rb +24 -0
- data/test/integration/system_update_access_test.rb +19 -0
- data/test/integration/users_access_test.rb +34 -0
- data/test/integration/users_edit_test.rb +178 -0
- data/test/integration/users_index_test.rb +62 -0
- data/test/integration/users_login_test.rb +67 -0
- data/test/integration/users_signup_test.rb +54 -0
- data/test/mailers/.keep +0 -0
- data/test/mailers/barkest_core/contact_form_test.rb +28 -0
- data/test/mailers/barkest_core/user_mailer_test.rb +43 -0
- data/test/mailers/previews/barkest_core/contact_form_preview.rb +17 -0
- data/test/mailers/previews/barkest_core/user_mailer_preview.rb +26 -0
- data/test/models/access_group_group_member_test.rb +28 -0
- data/test/models/access_group_test.rb +114 -0
- data/test/models/access_group_user_member_test.rb +28 -0
- data/test/models/barkest_core/auth_config_test.rb +57 -0
- data/test/models/barkest_core/bool_parser_test.rb +28 -0
- data/test/models/barkest_core/contact_message_test.rb +61 -0
- data/test/models/barkest_core/database_config_test.rb +33 -0
- data/test/models/barkest_core/date_parser_test.rb +110 -0
- data/test/models/barkest_core/email_config_test.rb +57 -0
- data/test/models/barkest_core/global_status_test.rb +50 -0
- data/test/models/barkest_core/ms_sql_db_updater_test.rb +115 -0
- data/test/models/barkest_core/ms_sql_definition_test.rb +102 -0
- data/test/models/barkest_core/ms_sql_function_test.rb +131 -0
- data/test/models/barkest_core/number_parser_test.rb +29 -0
- data/test/models/barkest_core/self_update_config_test.rb +29 -0
- data/test/models/barkest_core/user_alert_test.rb +19 -0
- data/test/models/barkest_core/user_manager_test.rb +34 -0
- data/test/models/barkest_core/work_path_test.rb +26 -0
- data/test/models/disable_user_test.rb +27 -0
- data/test/models/generic_time_test.rb +66 -0
- data/test/models/ldap_access_group_test.rb +31 -0
- data/test/models/pdf_table_builder_test.rb +6 -0
- data/test/models/system_config_test.rb +78 -0
- data/test/models/user_login_history_test.rb +37 -0
- data/test/models/user_test.rb +130 -0
- data/test/test_helper.rb +63 -0
- metadata +798 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
|
|
3
|
+
module Barkest
|
|
4
|
+
|
|
5
|
+
##
|
|
6
|
+
# Installs Barkest modules into an application.
|
|
7
|
+
class InstallGenerator < Rails::Generators::Base
|
|
8
|
+
|
|
9
|
+
desc 'Installs the Barkest functionality into your application.'
|
|
10
|
+
|
|
11
|
+
argument :action_name, type: :string, default: '', desc: 'Specific action to run.'
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def install_modules
|
|
15
|
+
meth = action_name.to_s == '' ? nil : action_name.to_sym
|
|
16
|
+
|
|
17
|
+
installers.each do |inst|
|
|
18
|
+
sep = '-' + ('=---' * 19) + '=-'
|
|
19
|
+
tell "#{sep}\nProcessing #{inst.class}\n#{sep}", :bold
|
|
20
|
+
if meth
|
|
21
|
+
inst.send(meth) if inst.respond_to?(meth)
|
|
22
|
+
else
|
|
23
|
+
inst.public_methods(false).each { |method| inst.send(method) }
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
# override this to process additional gems.
|
|
32
|
+
def gem_should_be_checked?(gem_name)
|
|
33
|
+
gem_name.index('barkest_') == 0
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def installers
|
|
37
|
+
@installers ||= find_modules
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def find_modules
|
|
41
|
+
ret = []
|
|
42
|
+
verbose_module_scan = (ENV['VERBOSE_MODULE_SCAN'].to_s.to_i != 0)
|
|
43
|
+
|
|
44
|
+
# generator is run from root of app directory
|
|
45
|
+
Gem::Specification.each do |gem|
|
|
46
|
+
if gem_should_be_checked?(gem.name)
|
|
47
|
+
puts "Checking for installer in '#{gem.name}' gem." if verbose_module_scan
|
|
48
|
+
installer =
|
|
49
|
+
begin
|
|
50
|
+
# ensure the gem has been loaded.
|
|
51
|
+
require gem.name
|
|
52
|
+
# then ensure the install_generator (if any) has been loaded.
|
|
53
|
+
inst_path = "generators/#{gem.name}/install_generator"
|
|
54
|
+
begin
|
|
55
|
+
require inst_path
|
|
56
|
+
# finally load the class and generate an instance.
|
|
57
|
+
klass_name = "#{gem.name.camelcase}::InstallGenerator"
|
|
58
|
+
begin
|
|
59
|
+
klass = Object.const_get(klass_name)
|
|
60
|
+
inst = klass.new
|
|
61
|
+
puts "Generated instance of class '#{klass_name}'." if verbose_module_scan
|
|
62
|
+
inst
|
|
63
|
+
rescue NameError
|
|
64
|
+
puts "Failed to load class '#{klass_name}'." if verbose_module_scan
|
|
65
|
+
nil
|
|
66
|
+
end
|
|
67
|
+
rescue LoadError
|
|
68
|
+
puts "Failed to load file '#{inst_path}'." if verbose_module_scan
|
|
69
|
+
nil
|
|
70
|
+
end
|
|
71
|
+
rescue LoadError
|
|
72
|
+
puts "Failed to load gem '#{gem.name}'." if verbose_module_scan
|
|
73
|
+
nil
|
|
74
|
+
end
|
|
75
|
+
ret << installer unless installer.nil?
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
ret.sort do |a,b|
|
|
80
|
+
ka = a.class.name
|
|
81
|
+
kb = b.class.name
|
|
82
|
+
|
|
83
|
+
# ensure Core installers run first.
|
|
84
|
+
kac = ka.index('BarkestCore::') == 0
|
|
85
|
+
kbc = kb.index('BarkestCore::') == 0
|
|
86
|
+
|
|
87
|
+
if kac && kbc
|
|
88
|
+
ka <=> kb
|
|
89
|
+
elsif kac
|
|
90
|
+
-1
|
|
91
|
+
elsif kbc
|
|
92
|
+
1
|
|
93
|
+
else
|
|
94
|
+
ka <=> kb
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
ret
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
end
|
|
102
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
BarkestCore::InstallGenerator.class_eval do
|
|
2
|
+
MissingApplicationController = Class.new(::Thor::Error)
|
|
3
|
+
|
|
4
|
+
##
|
|
5
|
+
# Patches the ApplicationController class to inherit from BarkestCore::ApplicationController.
|
|
6
|
+
def patch_application_controller
|
|
7
|
+
app_file = 'app/controllers/application_controller.rb'
|
|
8
|
+
dest_source = '::BarkestCore::ApplicationControllerBase'
|
|
9
|
+
|
|
10
|
+
if File.exist?(app_file)
|
|
11
|
+
regex = /^(?<NAME>\s*class ApplicationController\s*<\s*)(?<ORIG>\S+)\s*(?<COMMENT>#.*)?$/
|
|
12
|
+
|
|
13
|
+
found = false
|
|
14
|
+
changed = false
|
|
15
|
+
|
|
16
|
+
lines = File.read(app_file).split("\n").map do |line|
|
|
17
|
+
match = regex.match(line)
|
|
18
|
+
found = true if match
|
|
19
|
+
if match && match['ORIG'] != dest_source
|
|
20
|
+
changed = true
|
|
21
|
+
"#{match['NAME']}#{dest_source} # #{match['ORIG']} #{match['COMMENT']}"
|
|
22
|
+
else
|
|
23
|
+
line
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
raise MissingApplicationController.new('ApplicationController class not found') unless found
|
|
28
|
+
|
|
29
|
+
if changed
|
|
30
|
+
if ask_for_bool("Your ApplicationController does not currently inherit from BarkestCore.\nWould you like to change this?", true)
|
|
31
|
+
perform "> updating '#{app_file}'..." do
|
|
32
|
+
File.write app_file, lines.join("\n")
|
|
33
|
+
end
|
|
34
|
+
else
|
|
35
|
+
tell "> '#{app_file}' is unchanged.", :bright_green
|
|
36
|
+
end
|
|
37
|
+
else
|
|
38
|
+
tell "> '#{app_file}' is good.", :bright_green
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
else
|
|
42
|
+
|
|
43
|
+
if ask_for_bool("Your application is missing an ApplicationController.\nWould you like to create one?", true)
|
|
44
|
+
perform "> creating '#{app_file}'..." do
|
|
45
|
+
File.write app_file, <<-APPCTRLR
|
|
46
|
+
class ApplicationController < #{dest_source}
|
|
47
|
+
# This is your application controller, it inherits functionality from BarkestCore.
|
|
48
|
+
end
|
|
49
|
+
APPCTRLR
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
BarkestCore::InstallGenerator.class_eval do
|
|
2
|
+
|
|
3
|
+
MissingApplicationMailer = Class.new(::Thor::Error)
|
|
4
|
+
|
|
5
|
+
##
|
|
6
|
+
# Patches the ApplicationMailer class to inherit from BarkestCore::ApplicationMailer.
|
|
7
|
+
def patch_application_mailer
|
|
8
|
+
app_file = 'app/mailers/application_mailer.rb'
|
|
9
|
+
dest_source = '::BarkestCore::ApplicationMailerBase'
|
|
10
|
+
|
|
11
|
+
if File.exist?(app_file)
|
|
12
|
+
regex = /^(?<NAME>\s*class ApplicationMailer\s*<\s*)(?<ORIG>\S+)\s*(?<COMMENT>#.*)?$/
|
|
13
|
+
|
|
14
|
+
found = false
|
|
15
|
+
changed = false
|
|
16
|
+
|
|
17
|
+
lines = File.read(app_file).split("\n").map do |line|
|
|
18
|
+
match = regex.match(line)
|
|
19
|
+
found = true if match
|
|
20
|
+
if match && match['ORIG'] != dest_source
|
|
21
|
+
changed = true
|
|
22
|
+
"#{match['NAME']}#{dest_source} # #{match['ORIG']} #{match['COMMENT']}"
|
|
23
|
+
else
|
|
24
|
+
line
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
raise MissingApplicationMailer.new('ApplicationMailer class not found') unless found
|
|
29
|
+
|
|
30
|
+
if changed
|
|
31
|
+
if ask_for_bool("Your ApplicationMailer does not currently inherit from BarkestCore.\nWould you like to change this?", true)
|
|
32
|
+
perform "> updating '#{app_file}'..." do
|
|
33
|
+
File.write app_file, lines.join("\n")
|
|
34
|
+
end
|
|
35
|
+
else
|
|
36
|
+
tell "> '#{app_file}' is unchanged.", :bright_green
|
|
37
|
+
end
|
|
38
|
+
else
|
|
39
|
+
tell "> '#{app_file}' is good.", :bright_green
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
else
|
|
43
|
+
|
|
44
|
+
if ask_for_bool("Your application is missing an ApplicationMailer.\nWould you like to create one?", true)
|
|
45
|
+
perform "> creating '#{app_file}'..." do
|
|
46
|
+
File.write app_file, <<-APPMLR
|
|
47
|
+
class ApplicationMailer < #{dest_source}
|
|
48
|
+
# This is your application mailer, it inherits functionality from BarkestCore.
|
|
49
|
+
end
|
|
50
|
+
APPMLR
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
BarkestCore::InstallGenerator.class_eval do
|
|
2
|
+
##
|
|
3
|
+
# Patches application.js and application.css
|
|
4
|
+
def patch_assets
|
|
5
|
+
target = 'barkest_core/application'
|
|
6
|
+
|
|
7
|
+
[
|
|
8
|
+
[ 'app/assets/javascripts/application.js', '//=', "// Application.js\n//= require_tree .\n" ],
|
|
9
|
+
[ 'app/assets/stylesheets/application.css', '*=', "/*\n * Application.css\n *= require_tree .\n *= require_self\n */\n" ]
|
|
10
|
+
].each do |(path, line_tag, def_contents)|
|
|
11
|
+
|
|
12
|
+
lines = if File.exist?(path)
|
|
13
|
+
File.read(path)
|
|
14
|
+
else
|
|
15
|
+
def_contents
|
|
16
|
+
end.split("\n")
|
|
17
|
+
|
|
18
|
+
first_tag = -1
|
|
19
|
+
first_pass = true
|
|
20
|
+
loop do
|
|
21
|
+
lines.each_with_index do |line, index|
|
|
22
|
+
if line.strip[0...line_tag.length] == line_tag
|
|
23
|
+
first_tag = index
|
|
24
|
+
break
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
if first_tag < 0
|
|
28
|
+
if first_pass
|
|
29
|
+
lines += def_contents.split("\n")
|
|
30
|
+
else
|
|
31
|
+
raise StandardError.new("Failed to locate line starting with '#{line_tag}' in '#{path}'.")
|
|
32
|
+
end
|
|
33
|
+
else
|
|
34
|
+
break
|
|
35
|
+
end
|
|
36
|
+
first_pass = false
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
regex = /^\s*#{line_tag.gsub('*',"\\*")}\s*require\s*['"]?#{target}['"]?\s*$/
|
|
40
|
+
|
|
41
|
+
tag_index = -1
|
|
42
|
+
lines.each_with_index do |line, index|
|
|
43
|
+
if regex.match(line)
|
|
44
|
+
tag_index = index
|
|
45
|
+
break
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
if tag_index < 0
|
|
49
|
+
if ask_for_bool("Would you like to add a reference to BarkestCore in '#{path}'?", true)
|
|
50
|
+
lines.insert first_tag, "#{line_tag} require #{target}"
|
|
51
|
+
perform "> updating '#{path}'..." do
|
|
52
|
+
File.write path, lines.join("\n")
|
|
53
|
+
end
|
|
54
|
+
else
|
|
55
|
+
tell "> '#{path}' is unchanged.", :bright_green
|
|
56
|
+
end
|
|
57
|
+
else
|
|
58
|
+
tell "> '#{path}' is good.", :bright_green
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
BarkestCore::InstallGenerator.class_eval do
|
|
2
|
+
##
|
|
3
|
+
# Patches the default layouts to inherit from the BarkestCore layouts.
|
|
4
|
+
def patch_layouts
|
|
5
|
+
{
|
|
6
|
+
'app/views/layouts/application.html.erb' => 'layouts/barkest_core/application',
|
|
7
|
+
'app/views/layouts/mailer.html.erb' => 'layouts/barkest_core/html_mailer',
|
|
8
|
+
'app/views/layouts/mailer.text.erb' => 'layouts/barkest_core/text_mailer'
|
|
9
|
+
}.each do |file,layout|
|
|
10
|
+
|
|
11
|
+
if File.exist?(file)
|
|
12
|
+
regex = /<%=\s+render[\s\(]+['"]#{layout}['"][\)\s]*%>/
|
|
13
|
+
if regex.match(File.read(file))
|
|
14
|
+
tell "> '#{file}' is good.", :bright_green
|
|
15
|
+
else
|
|
16
|
+
if ask_for_bool("Your '#{file}' layout does not reference the BarkestCore layout.\nWould you like to change it to use the BarkestCore layout?", true)
|
|
17
|
+
perform "> updating '#{file}'..." do
|
|
18
|
+
File.write file, "<%= render '#{layout}' %>\n"
|
|
19
|
+
end
|
|
20
|
+
else
|
|
21
|
+
tell "> '#{file}' is unchanged.", :bright_green
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
else
|
|
25
|
+
if ask_for_bool("Your application is missing '#{file}'.\nWould you like to add one?", true)
|
|
26
|
+
perform "> creating '#{file}'..." do
|
|
27
|
+
File.write file, "<%= render '#{layout}' %>\n"
|
|
28
|
+
end
|
|
29
|
+
else
|
|
30
|
+
tell "> '#{file}' is missing.", :yellow
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
BarkestCore::InstallGenerator.class_eval do
|
|
2
|
+
##
|
|
3
|
+
# Patches routes.rb to include BarkestCore::Engine and session management paths.
|
|
4
|
+
def patch_routes
|
|
5
|
+
route_file = 'config/routes.rb'
|
|
6
|
+
|
|
7
|
+
unless File.exist?(route_file)
|
|
8
|
+
|
|
9
|
+
if ask_for_bool("Your application is missing a 'routes.rb' configuration file.\nWould you like to create one?", true)
|
|
10
|
+
perform '> creating \'routes.rb\'...' do
|
|
11
|
+
File.write route_file, <<-DEFRTS
|
|
12
|
+
Rails.application.routes.draw do
|
|
13
|
+
# Enter your routes in this file.
|
|
14
|
+
end
|
|
15
|
+
DEFRTS
|
|
16
|
+
end
|
|
17
|
+
else
|
|
18
|
+
tell '> missing \'routes.rb\'.', :yellow
|
|
19
|
+
return
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
lines = File.exist?(route_file) ? File.read(route_file).split("\n") : ['Rails.application.routes.draw do','end']
|
|
25
|
+
|
|
26
|
+
insert_at = -1
|
|
27
|
+
|
|
28
|
+
regex = /.*\.routes\.draw\s+do\s*(#.*)?$/
|
|
29
|
+
lines.each_with_index do |line, index|
|
|
30
|
+
if regex.match(line)
|
|
31
|
+
insert_at = index + 1
|
|
32
|
+
break
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
raise MissingRoutes.new('routes not found') unless insert_at >= 0
|
|
37
|
+
|
|
38
|
+
changed = false
|
|
39
|
+
|
|
40
|
+
core_regex = /^\s*barkest_core([\s\(]+(?<OPTIONS>[^\s\)#][^\)#]+)\)?)?\s*(?<COMMENT>#.*)?$/
|
|
41
|
+
root_regex = /^\s*root([\s\(]+(?<OPTIONS>[^\s\)#][^\)#]+)\)?)?\s*(?<COMMENT>#.*)?$/
|
|
42
|
+
core = nil
|
|
43
|
+
root = nil
|
|
44
|
+
|
|
45
|
+
lines.each_with_index do |line, index|
|
|
46
|
+
line = line.strip
|
|
47
|
+
if (match = core_regex.match(line))
|
|
48
|
+
opts = match['OPTIONS'].to_s.strip
|
|
49
|
+
core = {
|
|
50
|
+
index: index,
|
|
51
|
+
path: if (path_offset = opts.index(':path'))
|
|
52
|
+
opts[path_offset..-1].partition('=>')[2].partition(',')[0].strip[1...-1]
|
|
53
|
+
elsif (path_offset = opts.index('path:'))
|
|
54
|
+
opts[path_offset..-1].partition(':')[2].partition(',')[0].strip[1...-1]
|
|
55
|
+
else
|
|
56
|
+
opts[1...-1] # strip '...' or "..." to ...
|
|
57
|
+
end.to_s
|
|
58
|
+
}
|
|
59
|
+
elsif (match = root_regex.match(line))
|
|
60
|
+
opts = match['OPTIONS'].to_s.strip
|
|
61
|
+
root = {
|
|
62
|
+
index: index,
|
|
63
|
+
path: opts[1...-1].to_s # strip '...' or "..." to ...
|
|
64
|
+
}
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
unless core
|
|
69
|
+
if ask_for_bool('Would you like to add the \'barkest_core\' routes to your application?', true)
|
|
70
|
+
path = ask_for_string('What path prefix would you like?', '/')
|
|
71
|
+
lines.insert insert_at, "\n barkest_core #{path.inspect}"
|
|
72
|
+
changed = true
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
unless root
|
|
77
|
+
if ask_for_bool("Your application is missing a root route.\nWould you like to add one?", true)
|
|
78
|
+
path = ask_for_string('What controller#action would you like for your root route?', 'test_access#allow_anon')
|
|
79
|
+
lines.insert insert_at, "\n root #{path.inspect}"
|
|
80
|
+
changed = true
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
if changed
|
|
85
|
+
perform '> updating \'routes.rb\'...' do
|
|
86
|
+
File.write route_file, lines.join("\n")
|
|
87
|
+
end
|
|
88
|
+
else
|
|
89
|
+
tell '> \'routes.rb\' is good.', :bright_green
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
BarkestCore::InstallGenerator.class_eval do
|
|
2
|
+
##
|
|
3
|
+
# Patches the db/seeds to allow multiple seeding files and includes the seeds necessary for BarkestCore.
|
|
4
|
+
def patch_seeds
|
|
5
|
+
files = Dir.glob(File.expand_path('../../../../../db/{seeds.rb,seeds/*.rb}', __FILE__))
|
|
6
|
+
|
|
7
|
+
unless Dir.exists?('db/seeds')
|
|
8
|
+
if ask_for_bool("Your application does not currently have a 'db/seeds' directory.\nBarkestCore can alter your application to make use of multiple seeding files.\nDo you want to create the 'db/seeds' directory to enable this behavior?", true)
|
|
9
|
+
perform '> creating \'db/seeds\' directory.' do
|
|
10
|
+
Dir.mkdir 'db' unless Dir.exists?('db')
|
|
11
|
+
Dir.mkdir 'db/seeds'
|
|
12
|
+
end
|
|
13
|
+
else
|
|
14
|
+
tell "> 'db/seeds' directory is missing.", :yellow
|
|
15
|
+
return
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
source = files.find{|v| v[-11..-1] == 'db/seeds.rb'}
|
|
20
|
+
prefix_dir_len = source.length - 11
|
|
21
|
+
dest = source[prefix_dir_len..-1]
|
|
22
|
+
|
|
23
|
+
if File.exist?(dest)
|
|
24
|
+
current_contents = File.read(dest).strip
|
|
25
|
+
|
|
26
|
+
# if 'seeds.rb' defines a 'Seeds' class, then we assuming it to be a seeder.
|
|
27
|
+
is_seeder = false
|
|
28
|
+
current_contents.split("\n").each do |line|
|
|
29
|
+
is_seeder = true if /^\s*class\s+Seeds(\s.*)?$/.match(line)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
unless is_seeder
|
|
33
|
+
if ask_for_bool('Would you like to move your \'db/seeds.rb\' file into the \'db/seeds\' directory?', true)
|
|
34
|
+
perform "> moving '#{dest}' into 'db/seeds' directory..." do
|
|
35
|
+
File.rename dest, 'db/seeds/' + File.basename(dest)
|
|
36
|
+
end
|
|
37
|
+
else
|
|
38
|
+
tell "> 'db/seeds.rb' is not being moved.", :yellow
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
files.each do |source|
|
|
44
|
+
dest = source[prefix_dir_len..-1]
|
|
45
|
+
contents = File.read(source)
|
|
46
|
+
|
|
47
|
+
if File.exist?(dest) && File.read(dest).strip == contents.strip
|
|
48
|
+
tell "> '#{dest}' is good.", :bright_green
|
|
49
|
+
else
|
|
50
|
+
if !File.exist?(dest) || ask_for_bool("Would you like to update '#{dest}'?", true)
|
|
51
|
+
perform "> #{File.exist?(dest) ? 'creating' : 'updating'} \'#{dest}\'..." do
|
|
52
|
+
File.write dest, contents
|
|
53
|
+
end
|
|
54
|
+
else
|
|
55
|
+
tell "> '#{dest}' is unchanged.", :bright_green
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|