Sha256: 9dd122e76c12bb3ac801057a1dfb0d3c97593963fc5946f3e6b29ba5fcdc7bb8

Contents?: true

Size: 933 Bytes

Versions: 8

Compression:

Stored size: 933 Bytes

Contents

require 'rails/generators'

module Openseadragon
  class Install < Rails::Generators::Base
    source_root File.expand_path('../templates', __FILE__)

    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"

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

          import "openseadragon-rails"

        CONTENT
      end
    end

    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

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
openseadragon-1.0.10 lib/generators/openseadragon/install_generator.rb
openseadragon-1.0.9 lib/generators/openseadragon/install_generator.rb
openseadragon-1.0.8 lib/generators/openseadragon/install_generator.rb
openseadragon-1.0.7 lib/generators/openseadragon/install_generator.rb
openseadragon-1.0.6 lib/generators/openseadragon/install_generator.rb
openseadragon-1.0.5 lib/generators/openseadragon/install_generator.rb
openseadragon-1.0.4 lib/generators/openseadragon/install_generator.rb
openseadragon-1.0.3 lib/generators/openseadragon/install_generator.rb