Sha256: 0017c133f0094d29111ba6ad20fc4aabae7a969bca7e153436e9fbe5951d8e0e

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

require 'rails/generators/migration'

module Polygallery
  module Generators
    class InstallGenerator < ::Rails::Generators::Base
      include Rails::Generators::Migration
      source_root File.expand_path('../templates', __FILE__)
      desc "Create a migration to add the Polygallery models to your project."

      def self.next_migration_number(path)
        unless @prev_migration_nr
          @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
        else
          @prev_migration_nr += 1
        end
        @prev_migration_nr.to_s
      end

      def copy_migrations
        migration_template "polygallery_migration.rb", "db/migrate/create_polygalleries.rb"
      end

      def inject_engine_routing
        inject_into_file 'config/routes.rb', :after => 'pplication.routes.draw do' do
          "\n\nmount Polygallery::Engine => '/polygallery'\n"
        end
      end

      def inject_js_initializer
        inject_into_file 'app/assets/javascripts/application.js',  :before => '//= require_tree .' do
          "//= require polygallery/init\n"
        end
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
polygallery-0.1.9 lib/generators/polygallery/install/install_generator.rb
polygallery-0.1.8 lib/generators/polygallery/install/install_generator.rb
polygallery-0.1.7 lib/generators/polygallery/install/install_generator.rb