Class: Blacklight::Allmaps::ConfigGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Blacklight::Allmaps::ConfigGenerator
- Defined in:
- lib/generators/blacklight/allmaps/config_generator.rb
Instance Method Summary collapse
- #add_assets_initialier ⇒ Object
- #add_importmap_pins ⇒ Object
- #add_javascript ⇒ Object
- #add_yarn_package ⇒ Object
- #asset_config_manifest ⇒ Object
- #copy_rake_tasks ⇒ Object
- #prioritize_blacklight_allmaps_views ⇒ Object
- #set_active_job_config ⇒ Object
- #set_routes ⇒ Object
Instance Method Details
#add_assets_initialier ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/generators/blacklight/allmaps/config_generator.rb', line 19 def add_assets_initialier append_to_file "config/initializers/assets.rb" do " # Blacklight Allmaps Rails.application.config.assets.paths << Rails.root.join('node_modules') Rails.application.config.assets.paths << Rails.root.join('vendor', 'assets', 'images') Rails.application.config.assets.precompile += %w( blacklight/allmaps/allmaps-logo.svg )" end end |
#add_importmap_pins ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/generators/blacklight/allmaps/config_generator.rb', line 38 def add_importmap_pins append_to_file "config/importmap.rb" do <<~CONTENT pin "leaflet", to: "https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.js", preload: true pin "leaflet-fullscreen", to: "https://cdn.jsdelivr.net/npm/[email protected]/dist/Leaflet.fullscreen.min.js", preload: true pin "@allmaps/leaflet", to: "https://cdn.jsdelivr.net/npm/@allmaps/leaflet/dist/bundled/allmaps-leaflet-1.9.umd.js", preload: true pin_all_from File.expand_path("../app/javascript/blacklight/allmaps", __dir__), under: "blacklight-allmaps" CONTENT end end |
#add_javascript ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/generators/blacklight/allmaps/config_generator.rb', line 49 def add_javascript inject_into_file "app/assets/javascripts/application.js", after: "//= require blacklight/blacklight" do "\n // Required by Blacklight::Allmaps //= require blacklight-allmaps/app/assets/javascripts/blacklight/allmaps/blacklight-allmaps.js" end end |
#add_yarn_package ⇒ Object
57 58 59 |
# File 'lib/generators/blacklight/allmaps/config_generator.rb', line 57 def add_yarn_package run "yarn add blacklight-allmaps" end |
#asset_config_manifest ⇒ Object
15 16 17 |
# File 'lib/generators/blacklight/allmaps/config_generator.rb', line 15 def asset_config_manifest copy_file "manifest.js", "app/assets/config/manifest.js", force: true end |
#copy_rake_tasks ⇒ Object
29 30 31 |
# File 'lib/generators/blacklight/allmaps/config_generator.rb', line 29 def copy_rake_tasks append_to_file "Rakefile", "require 'blacklight/allmaps/rake_task'\n" end |
#prioritize_blacklight_allmaps_views ⇒ Object
33 34 35 36 |
# File 'lib/generators/blacklight/allmaps/config_generator.rb', line 33 def prioritize_blacklight_allmaps_views inject_into_file "config/application.rb", "\nrequire \"blacklight/allmaps/engine\"\n", before: "# Require the gems listed in Gemfile" inject_into_file "config/application.rb", "\n config.railties_order = [Blacklight::Allmaps::Engine, :main_app, :all]\n", after: "class Application < Rails::Application\n" end |
#set_active_job_config ⇒ Object
65 66 67 |
# File 'lib/generators/blacklight/allmaps/config_generator.rb', line 65 def set_active_job_config inject_into_file "config/environments/development.rb", " config.active_job.queue_adapter = :inline\n", after: "Rails.application.configure do\n" end |
#set_routes ⇒ Object
61 62 63 |
# File 'lib/generators/blacklight/allmaps/config_generator.rb', line 61 def set_routes inject_into_file "config/routes.rb", "mount Blacklight::Allmaps::Engine => '/'\n", before: /^end/ end |