Class: Openseadragon::Install

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/openseadragon/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#append_image_pathsObject



24
25
26
27
28
# File 'lib/generators/openseadragon/install_generator.rb', line 24

def append_image_paths
  append_to_file 'config/initializers/assets.rb' do
    "\nRails.application.config.assets.paths << Rails.root.join('node_modules/openseadragon/build/openseadragon/images')\n"
  end
end

#append_javascriptObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/generators/openseadragon/install_generator.rb', line 7

def append_javascript
  run 'yarn init -y'
  gsub_file 'package.json', /\.internal_test_app/, 'internal_test_app' # name beginning with a dot is illegal
  run 'yarn add openseadragon-rails'

  run 'bin/importmap pin openseadragon' if File.exist?('bin/importmap')

  append_to_file 'app/javascript/application.js' do
    <<~CONTENT

      import "openseadragon"
      import "openseadragon-rails"

    CONTENT
  end
end

#inject_helperObject



30
31
32
33
34
# File 'lib/generators/openseadragon/install_generator.rb', line 30

def inject_helper
  inject_into_class 'app/controllers/application_controller.rb', ApplicationController do
    "  helper Openseadragon::OpenseadragonHelper\n"
  end
end