Sha256: 9ecff890b9a37b8616670089cf031268cb1d40fb03bb0f92b44f115ad1a0a0f8

Contents?: true

Size: 1.25 KB

Versions: 14

Compression:

Stored size: 1.25 KB

Contents

module PushType
  class PushType::InstallGenerator < Rails::Generators::Base
    desc "Install and configure PushType for this application"

    source_root File.expand_path('../templates', __FILE__)

    class_option :migrate, type: :boolean, default: true

    def create_push_type_initializer
      template 'push_type.rb', 'config/initializers/push_type.rb'
    end

    def inject_push_type_routes
      inject_into_file 'config/routes.rb', "\n\n#{ mount_heredoc }", after: 'Rails.application.routes.draw do', verbose: true
    end

    def install_migrations
      say '- Copying migrations'
      rake 'railties:install:migrations'
    end

    def run_migrations
      if options[:migrate]
        say '- Running migrations'
        rake 'db:migrate'
      end
    end

    private

    def mount_heredoc
      <<-EOF.gsub /^\s+/, '  '
        # Mount all the registered PushType Rails Engines. This should be placed
        # at the end of your routes.rb file to ensure your application routes are
        # not overidden by PushType.
        #
        # Overide the default mount points by passing a hash of options.
        # Example:
        #
        #   mount_push_type admin: 'cms', front_end: 'blog'
        #
        mount_push_type

      EOF
    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
push_type_core-0.12.1 lib/generators/push_type/install/install_generator.rb
push_type_core-0.12.0 lib/generators/push_type/install/install_generator.rb
push_type_core-0.12.0.beta.1 lib/generators/push_type/install/install_generator.rb
push_type_core-0.11.2 lib/generators/push_type/install/install_generator.rb
push_type_core-0.11.1 lib/generators/push_type/install/install_generator.rb
push_type_core-0.11.0.beta.2 lib/generators/push_type/install/install_generator.rb
push_type_core-0.11.0.beta.1 lib/generators/push_type/install/install_generator.rb
push_type_core-0.10.4 lib/generators/push_type/install/install_generator.rb
push_type_core-0.10.3 lib/generators/push_type/install/install_generator.rb
push_type_core-0.10.2 lib/generators/push_type/install/install_generator.rb
push_type_core-0.10.1 lib/generators/push_type/install/install_generator.rb
push_type_core-0.10.0 lib/generators/push_type/install/install_generator.rb
push_type_core-0.10.0.beta.5 lib/generators/push_type/install/install_generator.rb
push_type_core-0.10.0.beta.3 lib/generators/push_type/install/install_generator.rb