adminos 1.0.0.pre.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +14 -0
- data/.gitignore +25 -0
- data/.gitlab-ci.yml +18 -0
- data/.rspec +2 -0
- data/.rubocop.yml +120 -0
- data/.rubocop_todo.yml +58 -0
- data/Gemfile +25 -0
- data/Guardfile +70 -0
- data/LICENSE.txt +22 -0
- data/README.md +88 -0
- data/Rakefile +20 -0
- data/adminos.gemspec +37 -0
- data/adminos.png +0 -0
- data/app/assets/images/.keep +0 -0
- data/app/assets/images/apple-touch-icon.png +0 -0
- data/app/assets/images/favicon-16x16.png +0 -0
- data/app/assets/images/favicon-32x32.png +0 -0
- data/app/assets/images/favicon.ico +0 -0
- data/app/assets/images/safari-pinned-tab.svg +23 -0
- data/app/inputs/cropp_input.rb +45 -0
- data/bin/bundle +105 -0
- data/bin/gem +39 -0
- data/bin/rspec +29 -0
- data/exe/adminos +5 -0
- data/lib/adminos/cli.rb +71 -0
- data/lib/adminos/controllers/admin_extension.rb +34 -0
- data/lib/adminos/controllers/helpers.rb +24 -0
- data/lib/adminos/controllers/resource.rb +169 -0
- data/lib/adminos/extensions/globalize_actiontext.rb +28 -0
- data/lib/adminos/extensions/globalize_fields.rb +19 -0
- data/lib/adminos/extensions/nested_set.rb +27 -0
- data/lib/adminos/extensions/string.rb +5 -0
- data/lib/adminos/generators/gemfile_merge.rb +85 -0
- data/lib/adminos/generators/utilities.rb +87 -0
- data/lib/adminos/helpers/admin.rb +190 -0
- data/lib/adminos/helpers/bootstrap.rb +64 -0
- data/lib/adminos/helpers/models/apply_sortable_order.rb +10 -0
- data/lib/adminos/helpers/models/array_attrs.rb +17 -0
- data/lib/adminos/helpers/models/cropped.rb +20 -0
- data/lib/adminos/helpers/models/dom_id.rb +16 -0
- data/lib/adminos/helpers/models/flag_attrs.rb +43 -0
- data/lib/adminos/helpers/models/if_blank_set_to_nil_params.rb +19 -0
- data/lib/adminos/helpers/models/move_to.rb +17 -0
- data/lib/adminos/helpers/models/nested_set/duplication.rb +31 -0
- data/lib/adminos/helpers/models/nested_set/materialize_path.rb +50 -0
- data/lib/adminos/helpers/models/nested_set/place_to.rb +35 -0
- data/lib/adminos/helpers/models/nested_set/safe_destroy.rb +34 -0
- data/lib/adminos/helpers/models/recognizable.rb +28 -0
- data/lib/adminos/helpers/models/slugged.rb +20 -0
- data/lib/adminos/helpers/models/soft_destroy.rb +61 -0
- data/lib/adminos/helpers/models/wysiwyg.rb +105 -0
- data/lib/adminos/helpers/view.rb +137 -0
- data/lib/adminos/operations/check_environment.rb +18 -0
- data/lib/adminos/operations/extract_environment.rb +42 -0
- data/lib/adminos/operations/load_environment.rb +30 -0
- data/lib/adminos/stateful_link/action_any_of.rb +76 -0
- data/lib/adminos/stateful_link/helper.rb +31 -0
- data/lib/adminos.rb +42 -0
- data/lib/adminos_template.rb +15 -0
- data/lib/generators/adminos/adminos_generator.rb +164 -0
- data/lib/generators/adminos/ci_generator.rb +124 -0
- data/lib/generators/adminos/field_generator.rb +105 -0
- data/lib/generators/adminos/i18n_generator.rb +76 -0
- data/lib/generators/adminos/install_generator.rb +238 -0
- data/lib/generators/templates/adminos/adminos.ru.yml +15 -0
- data/lib/generators/templates/adminos/fields.slim +21 -0
- data/lib/generators/templates/adminos/locales/general_fields.slim +7 -0
- data/lib/generators/templates/adminos/locales/locale_fields.slim +10 -0
- data/lib/generators/templates/adminos/locales/migration.rb.erb +18 -0
- data/lib/generators/templates/adminos/locales/model.rb.erb +6 -0
- data/lib/generators/templates/adminos/sidebar.slim +2 -0
- data/lib/generators/templates/adminos/sorts/body.slim +3 -0
- data/lib/generators/templates/adminos/sorts/headers.slim +3 -0
- data/lib/generators/templates/adminos/types/default/controller.rb.erb +18 -0
- data/lib/generators/templates/adminos/types/default/migration.rb +5 -0
- data/lib/generators/templates/adminos/types/default/model.rb +20 -0
- data/lib/generators/templates/adminos/types/default/model_includes.rb +4 -0
- data/lib/generators/templates/adminos/types/default/views/index.slim +14 -0
- data/lib/generators/templates/adminos/types/section/controller.rb.erb +10 -0
- data/lib/generators/templates/adminos/types/section/migration.rb +12 -0
- data/lib/generators/templates/adminos/types/section/model.rb +62 -0
- data/lib/generators/templates/adminos/types/section/model_includes.rb +7 -0
- data/lib/generators/templates/adminos/types/section/views/_object.slim +24 -0
- data/lib/generators/templates/adminos/types/section/views/_objects.slim +6 -0
- data/lib/generators/templates/adminos/types/section/views/index.slim +7 -0
- data/lib/generators/templates/adminos/types/sortable/controller.rb.erb +10 -0
- data/lib/generators/templates/adminos/types/sortable/migration.rb +9 -0
- data/lib/generators/templates/adminos/types/sortable/model.rb +35 -0
- data/lib/generators/templates/adminos/types/sortable/model_includes.rb +6 -0
- data/lib/generators/templates/adminos/types/sortable/views/_object.slim +17 -0
- data/lib/generators/templates/adminos/types/sortable/views/_objects.slim +6 -0
- data/lib/generators/templates/adminos/types/sortable/views/index.slim +7 -0
- data/lib/generators/templates/adminos/types/table/controller.rb.erb +19 -0
- data/lib/generators/templates/adminos/types/table/views/index.slim +31 -0
- data/lib/generators/templates/ci/.gitlab-ci.yml +40 -0
- data/lib/generators/templates/ci/audit/Gemfile +3 -0
- data/lib/generators/templates/ci/lint/Gemfile +3 -0
- data/lib/generators/templates/ci/lint/rubocop.yml +116 -0
- data/lib/generators/templates/ci/rakelib/audit.rake +13 -0
- data/lib/generators/templates/ci/rakelib/lint.rake +13 -0
- data/lib/generators/templates/ci/spec/Gemfile +9 -0
- data/lib/generators/templates/field/locales/locale_fields.slim +4 -0
- data/lib/generators/templates/field/locales/migration.rb.erb +13 -0
- data/lib/generators/templates/field/locales/model.rb.erb +6 -0
- data/lib/generators/templates/i18n/Gemfile +1 -0
- data/lib/generators/templates/i18n/add_translation_table_to_page.rb +15 -0
- data/lib/generators/templates/i18n/auto/app/validators/locale_validator.rb +23 -0
- data/lib/generators/templates/i18n/auto/app/views/admin/base/_fields.slim +1 -0
- data/lib/generators/templates/i18n/auto/app/views/admin/base/_pills.slim +19 -0
- data/lib/generators/templates/i18n/auto/app/views/admin/pages/_general_fields.slim +8 -0
- data/lib/generators/templates/i18n/auto/app/views/admin/pages/_locale_fields.slim +13 -0
- data/lib/generators/templates/i18n/auto/config/initializers/globalize_fields.rb +1 -0
- data/lib/generators/templates/i18n/controller.rb +12 -0
- data/lib/generators/templates/i18n/devise/devise.ru.yml +60 -0
- data/lib/generators/templates/i18n/devise/views/_links.erb +25 -0
- data/lib/generators/templates/i18n/devise/views/confirmations/new.slim +8 -0
- data/lib/generators/templates/i18n/devise/views/mailer/confirmation_instructions.slim +4 -0
- data/lib/generators/templates/i18n/devise/views/mailer/reset_password_instructions.slim +5 -0
- data/lib/generators/templates/i18n/devise/views/mailer/unlock_instructions.slim +4 -0
- data/lib/generators/templates/i18n/devise/views/passwords/edit.slim +7 -0
- data/lib/generators/templates/i18n/devise/views/passwords/new.slim +5 -0
- data/lib/generators/templates/i18n/devise/views/registrations/edit.slim +25 -0
- data/lib/generators/templates/i18n/devise/views/registrations/new.slim +7 -0
- data/lib/generators/templates/i18n/devise/views/sessions/new.slim +22 -0
- data/lib/generators/templates/i18n/devise/views/unlocks/new.slim +11 -0
- data/lib/generators/templates/i18n/locales.slim +3 -0
- data/lib/generators/templates/i18n/page.rb +5 -0
- data/lib/generators/templates/install/.gitignore +11 -0
- data/lib/generators/templates/install/Gemfile +57 -0
- data/lib/generators/templates/install/Procfile +1 -0
- data/lib/generators/templates/install/_sidebar.slim.erb +44 -0
- data/lib/generators/templates/install/add_authentications/authentication.rb +7 -0
- data/lib/generators/templates/install/add_authentications/authentications_controller.rb +95 -0
- data/lib/generators/templates/install/add_authentications/authentications_migration.rb +12 -0
- data/lib/generators/templates/install/add_authentications/views/authentications/_form.slim +5 -0
- data/lib/generators/templates/install/add_authentications/views/authentications/_modal.slim +7 -0
- data/lib/generators/templates/install/add_pages/page.rb +116 -0
- data/lib/generators/templates/install/add_pages/pages_controller.rb +6 -0
- data/lib/generators/templates/install/add_pages/pages_migration.rb +25 -0
- data/lib/generators/templates/install/add_pages/views/pages/show.slim +4 -0
- data/lib/generators/templates/install/admin.slim +36 -0
- data/lib/generators/templates/install/admin_panel/pages/admin_pages_controller.rb +9 -0
- data/lib/generators/templates/install/admin_panel/pages/views/admin_pages/_fields.slim +26 -0
- data/lib/generators/templates/install/admin_panel/pages/views/admin_pages/_object.slim +25 -0
- data/lib/generators/templates/install/admin_panel/pages/views/admin_pages/_objects.slim +6 -0
- data/lib/generators/templates/install/admin_panel/pages/views/admin_pages/index.slim +7 -0
- data/lib/generators/templates/install/admin_panel/users/admin_users_controller.rb +29 -0
- data/lib/generators/templates/install/admin_panel/users/views/admin_users/_fields.slim +4 -0
- data/lib/generators/templates/install/admin_panel/users/views/admin_users/index.slim +33 -0
- data/lib/generators/templates/install/admin_panel/versions/admin_versions_controller.rb +29 -0
- data/lib/generators/templates/install/admin_panel/versions/views/admin_versions/index.slim +47 -0
- data/lib/generators/templates/install/admin_panel/versions/views/admin_versions/show.slim +18 -0
- data/lib/generators/templates/install/application.slim.erb +31 -0
- data/lib/generators/templates/install/auto/.editorconfig +14 -0
- data/lib/generators/templates/install/auto/.env.staging +2 -0
- data/lib/generators/templates/install/auto/Capfile +14 -0
- data/lib/generators/templates/install/auto/Guardfile +18 -0
- data/lib/generators/templates/install/auto/Procfile +1 -0
- data/lib/generators/templates/install/auto/Procfile.local +2 -0
- data/lib/generators/templates/install/auto/app/assets/javascripts/admin/application.js +3 -0
- data/lib/generators/templates/install/auto/app/assets/javascripts/admin/cocoon_fields.js +43 -0
- data/lib/generators/templates/install/auto/app/assets/javascripts/application.js +1 -0
- data/lib/generators/templates/install/auto/app/assets/stylesheets/admin/application.scss +1 -0
- data/lib/generators/templates/install/auto/app/controllers/admin/base_controller.rb +16 -0
- data/lib/generators/templates/install/auto/app/controllers/admin/helps_controller.rb +4 -0
- data/lib/generators/templates/install/auto/app/controllers/admin/settings_controller.rb +26 -0
- data/lib/generators/templates/install/auto/app/controllers/application_controller.rb +50 -0
- data/lib/generators/templates/install/auto/app/controllers/index_controller.rb +2 -0
- data/lib/generators/templates/install/auto/app/helpers/nested_helper.rb +75 -0
- data/lib/generators/templates/install/auto/app/helpers/versions_helper.rb +33 -0
- data/lib/generators/templates/install/auto/app/inputs/carrierwave_input.rb +52 -0
- data/lib/generators/templates/install/auto/app/inputs/checkbox_input.rb +13 -0
- data/lib/generators/templates/install/auto/app/inputs/rich_text_input.rb +9 -0
- data/lib/generators/templates/install/auto/app/mailers/notifier.rb +9 -0
- data/lib/generators/templates/install/auto/app/models/settings.rb +27 -0
- data/lib/generators/templates/install/auto/app/services/export_xlsx.rb +76 -0
- data/lib/generators/templates/install/auto/app/views/active_storage/blobs/_blob.html.erb +17 -0
- data/lib/generators/templates/install/auto/app/views/admin/base/_form.slim +33 -0
- data/lib/generators/templates/install/auto/app/views/admin/base/_object.slim +27 -0
- data/lib/generators/templates/install/auto/app/views/admin/base/_objects.slim +19 -0
- data/lib/generators/templates/install/auto/app/views/admin/base/drop.js.erb +1 -0
- data/lib/generators/templates/install/auto/app/views/admin/base/edit.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/admin/base/index.slim +14 -0
- data/lib/generators/templates/install/auto/app/views/admin/base/new.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/admin/helps/index.slim +29 -0
- data/lib/generators/templates/install/auto/app/views/admin/settings/edit.slim +27 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/_first_page.slim +10 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/_gap.slim +7 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/_last_page.slim +10 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/_next_page.slim +9 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/_page.slim +10 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/_paginator.slim +16 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/_prev_page.slim +9 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/admin/_first_page.slim +10 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/admin/_gap.slim +8 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/admin/_last_page.slim +10 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/admin/_next_page.slim +10 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/admin/_page.slim +10 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/admin/_paginator.slim +16 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/admin/_prev_page.slim +10 -0
- data/lib/generators/templates/install/auto/app/views/layouts/admin/base.slim +17 -0
- data/lib/generators/templates/install/auto/app/views/shared/admin/_back_button.slim +3 -0
- data/lib/generators/templates/install/auto/app/views/shared/admin/_footer.slim +3 -0
- data/lib/generators/templates/install/auto/app/views/shared/admin/_search_form.slim +6 -0
- data/lib/generators/templates/install/auto/app/views/shared/admin/_topbar.slim +11 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_alert_close.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_contacts_page_link_tag.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_link_button_to.slim +2 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_method_ajax_request_link_to.slim +2 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_method_link_to.slim +12 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_navigation_menu.html.slim +3 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_print_tag.slim +2 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_search_tag_for.slim +16 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_show_breadcrumbs.slim +7 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_show_flash_alert.slim +9 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_sortable_column.slim +3 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_span_link_to.slim +3 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_sub_navigation.slim +14 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_batch_actions_tag.slim +16 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_collection_button_new.slim +5 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_collection_header.slim +4 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_locked_sign.slim +3 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_nav_published_sign.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_object_link_children.slim +2 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_object_link_duplication.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_object_link_edit.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_object_link_new.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_page_header.slim +5 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_published_sign.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_show_breadcrumbs.slim +6 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_top_menu_item.slim +5 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_unpublished_sign.slim +1 -0
- data/lib/generators/templates/install/auto/browserslist +3 -0
- data/lib/generators/templates/install/auto/config/deploy/shared/database.yml.erb +10 -0
- data/lib/generators/templates/install/auto/config/deploy/shared/nginx.conf.erb +28 -0
- data/lib/generators/templates/install/auto/config/deploy/shared/unicorn.rb.erb +35 -0
- data/lib/generators/templates/install/auto/config/deploy/staging.rb +12 -0
- data/lib/generators/templates/install/auto/config/environments/staging.rb +84 -0
- data/lib/generators/templates/install/auto/config/initializers/awesome_nested_set.rb +1 -0
- data/lib/generators/templates/install/auto/config/initializers/content_security_policy.rb +26 -0
- data/lib/generators/templates/install/auto/config/initializers/friendly_id.rb +1 -0
- data/lib/generators/templates/install/auto/config/initializers/kaminari_config.rb +15 -0
- data/lib/generators/templates/install/auto/config/initializers/simple_form.rb +238 -0
- data/lib/generators/templates/install/auto/config/initializers/slim.rb +2 -0
- data/lib/generators/templates/install/auto/config/locales/adminos.en.yml +164 -0
- data/lib/generators/templates/install/auto/config/locales/adminos.ru.yml +292 -0
- data/lib/generators/templates/install/auto/lib/capistrano/substitute_strings.rb +12 -0
- data/lib/generators/templates/install/auto/lib/capistrano/tasks/setup_config.cap +39 -0
- data/lib/generators/templates/install/auto/lib/capistrano/template.rb +33 -0
- data/lib/generators/templates/install/auto/public/404.html +26 -0
- data/lib/generators/templates/install/auto/public/500.html +25 -0
- data/lib/generators/templates/install/database.yml +19 -0
- data/lib/generators/templates/install/deploy.rb.erb +21 -0
- data/lib/generators/templates/install/install_devise/ability.rb +49 -0
- data/lib/generators/templates/install/install_devise/application.rb +7 -0
- data/lib/generators/templates/install/install_devise/prepare_users.rb +1 -0
- data/lib/generators/templates/install/install_devise/user.rb +21 -0
- data/lib/generators/templates/install/prepare_settings.rb +4 -0
- data/lib/generators/templates/install/routes/pages.rb +18 -0
- data/lib/generators/templates/install/routes.rb.erb +53 -0
- data/lib/generators/templates/install/settings_migration.rb +16 -0
- data/lib/generators/templates/install/webpack/custom.js +36 -0
- data/lib/generators/templates/install/webpack/environment.js +4 -0
- data/lib/generators/templates/install/webpack/javascript/admin/js/index.js +2 -0
- data/lib/generators/templates/install/webpack/javascript/admin/styles/admin.scss +2 -0
- data/lib/generators/templates/install/webpack/javascript/packs/admin.js +2 -0
- data/package-lock.json +3 -0
- data/spec/config/database.yml +2 -0
- data/spec/db/schema.rb +0 -0
- data/spec/lib/adminos/helpers/models/apply_sortable_order.rb +26 -0
- data/spec/lib/adminos/helpers/models/array_attrs_spec.rb +38 -0
- data/spec/lib/adminos/helpers/models/dom_id_spec.rb +41 -0
- data/spec/lib/adminos/helpers/models/flag_attrs_spec.rb +115 -0
- data/spec/lib/adminos/helpers/models/if_blank_set_to_nil_params_spec.rb +36 -0
- data/spec/lib/adminos/helpers/models/recognizable_spec.rb +40 -0
- data/spec/lib/adminos/helpers/models/slugged.rb +40 -0
- data/spec/lib/generators/adminos/adminos_generator_spec.rb +106 -0
- data/spec/lib/generators/adminos/ci_generator_spec.rb +88 -0
- data/spec/lib/generators/adminos/i18n_generator_spec.rb +31 -0
- data/spec/lib/generators/adminos/install_generator_rspec.rb +322 -0
- data/spec/spec_helper.rb +122 -0
- data/spec/support/ammeter.rb +14 -0
- data/spec/support/database.rb +29 -0
- data/spec/support/generators.rb +99 -0
- data/spec/support/post.rb +8 -0
- data/spec/support/shared/generator.rb +35 -0
- metadata +632 -0
data/bin/bundle
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'bundle' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "rubygems"
|
12
|
+
|
13
|
+
m = Module.new do
|
14
|
+
module_function
|
15
|
+
|
16
|
+
def invoked_as_script?
|
17
|
+
File.expand_path($0) == File.expand_path(__FILE__)
|
18
|
+
end
|
19
|
+
|
20
|
+
def env_var_version
|
21
|
+
ENV["BUNDLER_VERSION"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def cli_arg_version
|
25
|
+
return unless invoked_as_script? # don't want to hijack other binstubs
|
26
|
+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
|
27
|
+
bundler_version = nil
|
28
|
+
update_index = nil
|
29
|
+
ARGV.each_with_index do |a, i|
|
30
|
+
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
|
31
|
+
bundler_version = a
|
32
|
+
end
|
33
|
+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
34
|
+
bundler_version = $1 || ">= 0.a"
|
35
|
+
update_index = i
|
36
|
+
end
|
37
|
+
bundler_version
|
38
|
+
end
|
39
|
+
|
40
|
+
def gemfile
|
41
|
+
gemfile = ENV["BUNDLE_GEMFILE"]
|
42
|
+
return gemfile if gemfile && !gemfile.empty?
|
43
|
+
|
44
|
+
File.expand_path("../../Gemfile", __FILE__)
|
45
|
+
end
|
46
|
+
|
47
|
+
def lockfile
|
48
|
+
lockfile =
|
49
|
+
case File.basename(gemfile)
|
50
|
+
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
|
51
|
+
else "#{gemfile}.lock"
|
52
|
+
end
|
53
|
+
File.expand_path(lockfile)
|
54
|
+
end
|
55
|
+
|
56
|
+
def lockfile_version
|
57
|
+
return unless File.file?(lockfile)
|
58
|
+
lockfile_contents = File.read(lockfile)
|
59
|
+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
|
60
|
+
Regexp.last_match(1)
|
61
|
+
end
|
62
|
+
|
63
|
+
def bundler_version
|
64
|
+
@bundler_version ||= begin
|
65
|
+
env_var_version || cli_arg_version ||
|
66
|
+
lockfile_version || "#{Gem::Requirement.default}.a"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def load_bundler!
|
71
|
+
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
72
|
+
|
73
|
+
# must dup string for RG < 1.8 compatibility
|
74
|
+
activate_bundler(bundler_version.dup)
|
75
|
+
end
|
76
|
+
|
77
|
+
def activate_bundler(bundler_version)
|
78
|
+
if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
|
79
|
+
bundler_version = "< 2"
|
80
|
+
end
|
81
|
+
gem_error = activation_error_handling do
|
82
|
+
gem "bundler", bundler_version
|
83
|
+
end
|
84
|
+
return if gem_error.nil?
|
85
|
+
require_error = activation_error_handling do
|
86
|
+
require "bundler/version"
|
87
|
+
end
|
88
|
+
return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
89
|
+
warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
|
90
|
+
exit 42
|
91
|
+
end
|
92
|
+
|
93
|
+
def activation_error_handling
|
94
|
+
yield
|
95
|
+
nil
|
96
|
+
rescue StandardError, LoadError => e
|
97
|
+
e
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
m.load_bundler!
|
102
|
+
|
103
|
+
if m.invoked_as_script?
|
104
|
+
load Gem.bin_path("bundler", "bundle")
|
105
|
+
end
|
data/bin/gem
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/Users/alex/.rbenv/versions/2.5.1/bin/ruby
|
2
|
+
#--
|
3
|
+
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
4
|
+
# All rights reserved.
|
5
|
+
# See LICENSE.txt for permissions.
|
6
|
+
#++
|
7
|
+
|
8
|
+
require 'pathname'
|
9
|
+
ENV['BUNDLE_GEMFILE'] ||= Pathname.new(__dir__).join('../Gemfile').realpath.to_s
|
10
|
+
|
11
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
12
|
+
|
13
|
+
if File.file?(bundle_binstub)
|
14
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
15
|
+
load(bundle_binstub)
|
16
|
+
else
|
17
|
+
abort('Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
18
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'rubygems'
|
23
|
+
require 'bundler/setup'
|
24
|
+
require 'rubygems/gem_runner'
|
25
|
+
require 'rubygems/exceptions'
|
26
|
+
|
27
|
+
required_version = Gem::Requirement.new ">= 1.8.7"
|
28
|
+
|
29
|
+
unless required_version.satisfied_by? Gem.ruby_version then
|
30
|
+
abort "Expected Ruby version #{required_version}, is #{Gem.ruby_version}"
|
31
|
+
end
|
32
|
+
|
33
|
+
args = ARGV.clone
|
34
|
+
|
35
|
+
begin
|
36
|
+
Gem::GemRunner.new.run args
|
37
|
+
rescue Gem::SystemExitException => e
|
38
|
+
exit e.exit_code
|
39
|
+
end
|
data/bin/rspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rspec' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rspec-core", "rspec")
|
data/exe/adminos
ADDED
data/lib/adminos/cli.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'thor/actions'
|
3
|
+
require 'bundler'
|
4
|
+
require 'pathname'
|
5
|
+
require_relative 'operations/extract_environment'
|
6
|
+
require_relative 'operations/check_environment'
|
7
|
+
require_relative 'operations/load_environment'
|
8
|
+
|
9
|
+
module Adminos
|
10
|
+
class CLI < Thor
|
11
|
+
include Thor::Actions
|
12
|
+
|
13
|
+
desc 'new NAME', 'Creates new Rails application enhanced with Adminos'
|
14
|
+
def new(name)
|
15
|
+
Bundler.with_clean_env do
|
16
|
+
run "rails new #{name} --template #{Pathname(__dir__).join('../adminos_template.rb')}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'env', 'Checks environment variables'
|
21
|
+
def env
|
22
|
+
load_environment.()
|
23
|
+
missing = check_environment.()
|
24
|
+
# TODO: Use variables mapping from extract_environment
|
25
|
+
|
26
|
+
unless missing.any?
|
27
|
+
puts "No variables missing"
|
28
|
+
return
|
29
|
+
end
|
30
|
+
|
31
|
+
puts "Missing environment variables:"
|
32
|
+
missing.map do |name|
|
33
|
+
puts "* #{name}: #{ENV[name]}"
|
34
|
+
end
|
35
|
+
|
36
|
+
abort "Please fill in variables according to suggestions above"
|
37
|
+
end
|
38
|
+
|
39
|
+
desc 'extract_env', 'Checks ruby code for ENV vars used'
|
40
|
+
def extract_env
|
41
|
+
puts "Checking for possibly missed environment variables..."
|
42
|
+
|
43
|
+
local_env = Pathname('.env.local')
|
44
|
+
|
45
|
+
extract_environment.().inject([]) do |result, (variable, usage)|
|
46
|
+
next result if ENV.key?(variable)
|
47
|
+
|
48
|
+
puts "#{variable}:"
|
49
|
+
usage.each do |location|
|
50
|
+
puts " * #{location.values.join(':')}"
|
51
|
+
end
|
52
|
+
|
53
|
+
local_env.open('a') { |f| f.puts "# #{variable}='' # #{usage.first.values.join(':')}" }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def check_environment
|
60
|
+
@check_environment ||= Operations::CheckEnvironment.new
|
61
|
+
end
|
62
|
+
|
63
|
+
def extract_environment
|
64
|
+
@extract_environment ||= Operations::ExtractEnvironment.new
|
65
|
+
end
|
66
|
+
|
67
|
+
def load_environment
|
68
|
+
@load_environment ||= Operations::LoadEnvironment.new
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Adminos::Controllers::AdminExtension
|
2
|
+
def batch_action
|
3
|
+
objects = resource_class.where(id: params[:id_eq])
|
4
|
+
if objects.empty?
|
5
|
+
flash[:error] = I18n.t('flash.actions.batch_action.none')
|
6
|
+
redirect_to url_for(action: :index)
|
7
|
+
else
|
8
|
+
objects.destroy_all if params[:destroy]
|
9
|
+
objects.set_each_published_off if params[:set_published_off]
|
10
|
+
objects.set_each_published_on if params[:set_published_on]
|
11
|
+
objects.set_each_nav_published_off if params[:set_nav_published_off]
|
12
|
+
objects.set_each_nav_published_on if params[:set_nav_published_on]
|
13
|
+
flash[:notice] = I18n.t('flash.actions.batch_action.notice')
|
14
|
+
redirect_to url_for(action: :index)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def drop
|
19
|
+
resource.place_to(params[:parent_id], params[:prev_id])
|
20
|
+
resource.reload
|
21
|
+
respond_to do |format|
|
22
|
+
format.html { redirect_to action: :index }
|
23
|
+
format.js { render layout: false }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def duplication
|
28
|
+
resource.duplication
|
29
|
+
resource.reload
|
30
|
+
respond_to do |format|
|
31
|
+
format.html { redirect_to action: :index }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Adminos::Controllers::Helpers
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
helper_method :settings, :top_navigation, :current_page, :title_default
|
6
|
+
end
|
7
|
+
|
8
|
+
def settings
|
9
|
+
@settings ||= Settings.get
|
10
|
+
end
|
11
|
+
|
12
|
+
def top_navigation
|
13
|
+
@top_navigation ||= Page.navigation_top
|
14
|
+
end
|
15
|
+
|
16
|
+
def current_page
|
17
|
+
@current_page ||= Page.published.find params[:page_id] if params[:page_id]
|
18
|
+
end
|
19
|
+
|
20
|
+
def title_default
|
21
|
+
title ||= settings.index_meta_title
|
22
|
+
title.present? ? title : current_page.name rescue nil
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,169 @@
|
|
1
|
+
module Adminos::Controllers::Resource
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
module ClassMethods
|
5
|
+
protected
|
6
|
+
|
7
|
+
def resource(klass, *args)
|
8
|
+
options = args.extract_options!
|
9
|
+
finder = options.delete(:finder) || :find_by_id!
|
10
|
+
location = options.delete(:location) || proc { nil }
|
11
|
+
collection_scope = options.delete(:collection_scope) || :all
|
12
|
+
resource_scope = options.delete(:resource_scope) || :all
|
13
|
+
filter_by_locale = options.delete(:filter_by_locale) || false
|
14
|
+
parent_resource_klass = options.delete(:parent_resource)
|
15
|
+
resource_instance = options.delete(:resource_instance)
|
16
|
+
parent_resource_instance = options.delete(:parent_resource_instance)
|
17
|
+
with_parent_resource = parent_resource_klass.present? || parent_resource_instance.present?
|
18
|
+
namespace = options.delete(:namespace)
|
19
|
+
with_move_to = options.delete(:with_move_to)
|
20
|
+
with_apply_sortable_order = options.delete(:with_apply_sortable_order)
|
21
|
+
|
22
|
+
helper_method :resource, :collection, :resource_class, :resource_params
|
23
|
+
helper_method(:parent_resource) if with_parent_resource
|
24
|
+
|
25
|
+
define_method :create do
|
26
|
+
if resource.save
|
27
|
+
respond_with(resource, location: self.instance_eval(&location))
|
28
|
+
else
|
29
|
+
render :new
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
define_method :update do
|
34
|
+
resource.update_attributes(parameters)
|
35
|
+
respond_with(resource, location: self.instance_eval(&location))
|
36
|
+
end
|
37
|
+
|
38
|
+
protected
|
39
|
+
|
40
|
+
define_method(:resource_class) { klass }
|
41
|
+
|
42
|
+
define_method(:resource_params) { klass.name.pathalize }
|
43
|
+
|
44
|
+
if with_parent_resource
|
45
|
+
define_method :resource_as_association do
|
46
|
+
self.resource_params.pluralize
|
47
|
+
end
|
48
|
+
|
49
|
+
define_method :parent_resource_params do
|
50
|
+
parent_resource_klass.name.pathalize
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
define_method :resource do
|
55
|
+
return @resource if @resource.present?
|
56
|
+
return(@resource = get_instance(resource_instance)) if resource_instance.present?
|
57
|
+
|
58
|
+
@resource =
|
59
|
+
if %w(new create).include?(action_name)
|
60
|
+
self.build_resource
|
61
|
+
else
|
62
|
+
self.find_resource
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
if with_parent_resource
|
67
|
+
define_method :parent_resource do
|
68
|
+
return @parent_resource if @parent_resource.present?
|
69
|
+
return(@parent_resource = get_instance(parent_resource_instance)) if parent_resource_instance.present?
|
70
|
+
|
71
|
+
@parent_resource = parent_resource_klass.
|
72
|
+
find(params["#{parent_resource_params}_id"])
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
define_method :collection do
|
77
|
+
return @collection if @collection.present?
|
78
|
+
|
79
|
+
collection =
|
80
|
+
if with_parent_resource
|
81
|
+
parent_resource.send(self.resource_as_association)
|
82
|
+
elsif filter_by_locale
|
83
|
+
resource_class.with_translations(I18n.locale)
|
84
|
+
else
|
85
|
+
resource_class
|
86
|
+
end
|
87
|
+
|
88
|
+
@collection =
|
89
|
+
if collection_scope.is_a?(Array)
|
90
|
+
collection_scope.inject(collection) do |collection, method|
|
91
|
+
collection.send(method)
|
92
|
+
end
|
93
|
+
else
|
94
|
+
collection.send(collection_scope)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
define_method :build_resource do
|
99
|
+
self.resource_class_scope.new(parameters)
|
100
|
+
end
|
101
|
+
|
102
|
+
define_method :parameters do
|
103
|
+
if action_name == ('create') || action_name == ('update')
|
104
|
+
strong_params
|
105
|
+
else
|
106
|
+
params[resource_params]
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
define_method :strong_params do
|
111
|
+
|
112
|
+
ids_attributes = resource_class.reflections.values.select do |ref|
|
113
|
+
[
|
114
|
+
ActiveRecord::Reflection::HasManyReflection,
|
115
|
+
ActiveRecord::Reflection::HasAndBelongsToManyReflection
|
116
|
+
].include? ref.class
|
117
|
+
end.map(&:plural_name).map(&:singularize).map { |val| { "#{val}_ids".to_sym => [] } }
|
118
|
+
|
119
|
+
reflect_has_one = resource_class.reflect_on_all_associations(:has_one)
|
120
|
+
rich_text_attributes = reflect_has_one.map(&:name).map { |name| name.to_s.gsub('rich_text_', '') }.compact
|
121
|
+
|
122
|
+
_attribute_names = self.resource_class_scope.attribute_names + ids_attributes + rich_text_attributes
|
123
|
+
|
124
|
+
if params[resource_params][:translations_attributes]
|
125
|
+
_translated_attributes = resource_class.translated_attribute_names
|
126
|
+
attrs = _attribute_names + _translated_attributes
|
127
|
+
attrs.push(translations_attributes: _translated_attributes + [:id, :locale]) unless _translated_attributes.blank?
|
128
|
+
|
129
|
+
result = params.require(resource_params).permit(attrs)
|
130
|
+
else
|
131
|
+
result = params.require(resource_params).permit(*_attribute_names)
|
132
|
+
end
|
133
|
+
|
134
|
+
result
|
135
|
+
end
|
136
|
+
|
137
|
+
define_method :find_resource do
|
138
|
+
if resource_scope.is_a?(Array)
|
139
|
+
resource_scope.inject(resource_class_scope) do |resource_class_scope, method|
|
140
|
+
resource_class_scope.send(method)
|
141
|
+
end
|
142
|
+
else
|
143
|
+
resource_class_scope.send(resource_scope)
|
144
|
+
end.send(finder, params[:id])
|
145
|
+
end
|
146
|
+
|
147
|
+
define_method :resource_class_scope do
|
148
|
+
return parent_resource.send(self.resource_as_association) if with_parent_resource
|
149
|
+
resource_class
|
150
|
+
end
|
151
|
+
|
152
|
+
define_method(:get_instance) { |instance| self.instance_eval(&instance) }
|
153
|
+
|
154
|
+
if with_move_to || with_apply_sortable_order
|
155
|
+
define_method :sort do
|
156
|
+
if with_move_to
|
157
|
+
resource.move_to(params[:to])
|
158
|
+
elsif with_apply_sortable_order
|
159
|
+
resource_class.apply_sortable_order(params[:id])
|
160
|
+
end
|
161
|
+
|
162
|
+
respond_to do |format|
|
163
|
+
format.js { head :ok }
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module GlobalizeActiontext
|
2
|
+
module ActionText
|
3
|
+
def setup_translates!(options)
|
4
|
+
super
|
5
|
+
|
6
|
+
self.after_initialize do
|
7
|
+
reflect_has_one = self.class.reflect_on_all_associations(:has_one)
|
8
|
+
rich_text_attributes = reflect_has_one.map(&:name).map { |name| name.to_s.gsub('rich_text_', '') }.compact
|
9
|
+
|
10
|
+
self.class.translation_class.class_eval do
|
11
|
+
rich_text_attributes.each do |rich_text_attribute|
|
12
|
+
attribute rich_text_attribute
|
13
|
+
has_rich_text rich_text_attribute
|
14
|
+
define_method "#{rich_text_attribute}=" do |value|
|
15
|
+
send(rich_text_attribute).body = value
|
16
|
+
|
17
|
+
return unless public_send(rich_text_attribute).changed?
|
18
|
+
|
19
|
+
attribute_will_change! rich_text_attribute
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
ActiveRecord::Base.singleton_class.prepend(GlobalizeActiontext::ActionText)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ActionView
|
2
|
+
module Helpers
|
3
|
+
class FormBuilder
|
4
|
+
def globalize_fields_for(locale, *args, &proc)
|
5
|
+
raise ArgumentError, "Missing block" unless block_given?
|
6
|
+
@globalize_index = @globalize_index ? @globalize_index + 1 : 1
|
7
|
+
object_name = "#{@object_name}[translations_attributes][#{@globalize_index}]"
|
8
|
+
object = @object.translation_for locale
|
9
|
+
@template.concat @template.hidden_field_tag("#{object_name}[id]", object ? object.id : "")
|
10
|
+
@template.concat @template.hidden_field_tag("#{object_name}[locale]", locale)
|
11
|
+
if @template.respond_to? :simple_fields_for
|
12
|
+
@template.simple_fields_for(object_name, object, *args, &proc)
|
13
|
+
else
|
14
|
+
@template.fields_for(object_name, object, *args, &proc)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module CollectiveIdea #:nodoc:
|
2
|
+
module Acts #:nodoc:
|
3
|
+
module NestedSet #:nodoc:
|
4
|
+
module Model
|
5
|
+
module ClassMethods
|
6
|
+
def arrange
|
7
|
+
depth = 0
|
8
|
+
arranged = ActiveSupport::OrderedHash.new
|
9
|
+
insertion = [arranged]
|
10
|
+
|
11
|
+
each_with_level(order(quoted_order_column_full_name)) do |node, level|
|
12
|
+
next if level > depth && insertion.last.keys.last &&
|
13
|
+
node.parent_id != insertion.last.keys.last.id
|
14
|
+
|
15
|
+
insertion.push insertion.last.values.last if level > depth
|
16
|
+
(depth - level).times { insertion.pop } if level < depth
|
17
|
+
insertion.last.merge! node => ActiveSupport::OrderedHash.new
|
18
|
+
depth = level
|
19
|
+
end
|
20
|
+
|
21
|
+
arranged
|
22
|
+
end
|
23
|
+
end # end class methods
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module Adminos
|
2
|
+
module Generators
|
3
|
+
class GemfileMerge
|
4
|
+
GROUP_NAME_PATTERN = /^group(\D+)do$/
|
5
|
+
GEM_NAME_PATTERN = /^gem\s+\'([^\']+)\'/
|
6
|
+
|
7
|
+
def initialize(from, to)
|
8
|
+
@from_lines = from.each_line.map { |line| line.chomp.tr('"', "'") }
|
9
|
+
@to_lines = to.each_line.map { |line| line.chomp.tr('"', "'") }
|
10
|
+
end
|
11
|
+
|
12
|
+
def merge
|
13
|
+
current_group = nil
|
14
|
+
@from_lines.each do |line|
|
15
|
+
current_group = new_current_group(line, current_group)
|
16
|
+
|
17
|
+
if gem?(line)
|
18
|
+
merge_gem(line, current_group)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
@to_lines.map do |line|
|
23
|
+
line.gsub(/'([^']*\#{[^']+}[^']*)'/, '"\\1"')
|
24
|
+
end.join("\n")
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def gem?(line)
|
30
|
+
GEM_NAME_PATTERN.match(line.strip)
|
31
|
+
end
|
32
|
+
|
33
|
+
def new_current_group(line, current_group)
|
34
|
+
if current_group
|
35
|
+
line == 'end' ? nil : current_group
|
36
|
+
elsif GROUP_NAME_PATTERN.match(line)
|
37
|
+
GROUP_NAME_PATTERN.match(line)[1].strip
|
38
|
+
else
|
39
|
+
nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def merge_gem(from_line, group)
|
44
|
+
gem_name = GEM_NAME_PATTERN.match(from_line.strip)[1]
|
45
|
+
|
46
|
+
current_group = nil
|
47
|
+
# ищем и заменяем гем
|
48
|
+
@to_lines.each_with_index do |to_line, index|
|
49
|
+
old_group = current_group
|
50
|
+
current_group = new_current_group(to_line, current_group)
|
51
|
+
|
52
|
+
if old_group && old_group == group && current_group != group
|
53
|
+
@to_lines.insert(index, "#{from_line} # from adminos")
|
54
|
+
return
|
55
|
+
end
|
56
|
+
|
57
|
+
if current_group == group && gem?(to_line.strip)
|
58
|
+
# нужная группа
|
59
|
+
current_gem_name = GEM_NAME_PATTERN.match(to_line.strip)[1]
|
60
|
+
if current_gem_name == gem_name
|
61
|
+
# нужный гем
|
62
|
+
if from_line == to_line
|
63
|
+
# гемы совпали
|
64
|
+
# @to_lines[index] +=" # adminos coincidence"
|
65
|
+
return
|
66
|
+
else
|
67
|
+
@to_lines.insert(index + 1, "# #{from_line} # adminos conflict")
|
68
|
+
return
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# добавляем гем
|
75
|
+
if group.blank?
|
76
|
+
@to_lines.push("#{from_line} # from adminos")
|
77
|
+
else
|
78
|
+
@to_lines.push("group #{group} do")
|
79
|
+
@to_lines.push("#{from_line} # from adminos")
|
80
|
+
@to_lines.push("end")
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|