Sha256: d8eefc05f792fd995f53dee6d0f1bb7ef5ffb72b6761019fa7bae81896cf77dd

Contents?: true

Size: 1.09 KB

Versions: 10

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 => 'Application.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

10 entries across 10 versions & 1 rubygems

Version Path
polygallery-0.1.0 lib/generators/polygallery/install/install_generator.rb
polygallery-0.0.9 lib/generators/polygallery/install/install_generator.rb
polygallery-0.0.8 lib/generators/polygallery/install/install_generator.rb
polygallery-0.0.7 lib/generators/polygallery/install/install_generator.rb
polygallery-0.0.6 lib/generators/polygallery/install/install_generator.rb
polygallery-0.0.5 lib/generators/polygallery/install/install_generator.rb
polygallery-0.0.4 lib/generators/polygallery/install/install_generator.rb
polygallery-0.0.3 lib/generators/polygallery/install/install_generator.rb
polygallery-0.0.2 lib/generators/polygallery/install/install_generator.rb
polygallery-0.0.1 lib/generators/polygallery/install/install_generator.rb