Sha256: 97e2dc861775d32a69462be11f5a7bc84b383dc6f6a2505cd0323ba58f960f70

Contents?: true

Size: 804 Bytes

Versions: 3

Compression:

Stored size: 804 Bytes

Contents

# frozen_string_literal: true

require 'rails/generators'

module Scrapbook
  # Initial default setup of Scrapbook
  class InstallGenerator < Rails::Generators::Base
    class_option 'path-with-name', default: 'scrapbook'

    def install
      name = Pathname.new(options.fetch('path-with-name')).basename.to_s

      generate 'scrapbook:routes', name
      generate 'scrapbook:new', options.fetch('path-with-name')
      sprockets_support
    end

    private

    def sprockets_support
      relative_path = 'app/assets/config/manifest.js'
      return unless FileTest.exist?(File.expand_path(relative_path, destination_root))

      insert_into_file(relative_path, "//= link scrapbook/application.css\n")
      insert_into_file(relative_path, "//= link scrapbook/application.js\n")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
scrapbook-0.3.2 lib/generators/scrapbook/install_generator.rb
scrapbook-0.3.1 lib/generators/scrapbook/install_generator.rb
scrapbook-0.3.0 lib/generators/scrapbook/install_generator.rb