Sha256: ef07f900a11dfc0f8cd475bda5bb0d15afdceb2612b56b7aa77df86952a6eff6

Contents?: true

Size: 906 Bytes

Versions: 5

Compression:

Stored size: 906 Bytes

Contents

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

    def mount_routes
      return if File.read('config/routes.rb').include? 'mount Carload::Engine'
      inject_into_file 'config/routes.rb', after: "Rails.application.routes.draw do\n" do <<-RUBY
  mount Carload::Engine => '/carload'
      RUBY
      end
    end

    def add_require
      return if File.read('config/application.rb') =~ /require ['|"]carload['|"]/
      inject_into_file 'config/application.rb', after: "Bundler.require(*Rails.groups)\n" do <<-RUBY
require 'carload'
      RUBY
      end
    end

    def copy_initializer
      return if File.exist? 'config/initializers/carload.rb'
      copy_file 'carload.rb', 'config/initializers/carload.rb'
    end

    def copy_dashboard_file
      copy_file 'dashboard.rb', 'app/carload/dashboard.rb'
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
carload-0.3.0 lib/generators/carload/install_generator.rb
carload-0.2.2 lib/generators/carload/install_generator.rb
carload-0.2.1 lib/generators/carload/install_generator.rb
carload-0.2.0 lib/generators/carload/install_generator.rb
carload-0.1.0 lib/generators/carload/install_generator.rb