Sha256: 3f7e8877b24df28d790b3cb1d343b52f2615d303b307b1f3042762a77d2308d4

Contents?: true

Size: 1.09 KB

Versions: 4

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

4 entries across 4 versions & 1 rubygems

Version Path
polygallery-0.1.6 lib/generators/polygallery/install/install_generator.rb
polygallery-0.1.4 lib/generators/polygallery/install/install_generator.rb
polygallery-0.1.2 lib/generators/polygallery/install/install_generator.rb
polygallery-0.1.1 lib/generators/polygallery/install/install_generator.rb