Sha256: 144b980c230a6ef55052203dca62a50ef51e9498483b3d406f68121cd707b8d9

Contents?: true

Size: 1.45 KB

Versions: 16

Compression:

Stored size: 1.45 KB

Contents

require 'rails/generators'
require 'rails/generators/migration'
require 'active_record'
require 'rails/generators/active_record'

module ActsAsMultipartForm
  module Generators
    # Generator for copying the InProgressForm model migration and an initializer to the including project
    #
    # @author Jeremiah Hemphill
    class InstallGenerator < Rails::Generators::Base
      include Rails::Generators::Migration

      source_root File.expand_path(File.join(File.dirname(__FILE__), "templates"))

      desc <<DESC
Description:
  Copies over migrations and config for the multipart form system.
DESC

      # Implement the required interface for Rails::Generators::Migration.
      # thanks Kaminari gem for this bit of code
      def self.next_migration_number(dirname) #:nodoc:
        next_migration_number = current_migration_number(dirname) + 1
        if ActiveRecord::Base.timestamped_migrations
          [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
        else
          "%.3d" % next_migration_number
        end
      end

      # Creates the config file
      # Commented out until the config actually has information
      def copy_config_file
        copy_file "config.rb", "config/initializers/acts_as_multipart_form.rb"
      end

      # Creates the migration
      def copy_migration
        migration_template "migrations/install_migration.rb.erb", "db/migrate/create_multipart_form_tables.rb"
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
acts_as_multipart_form-0.0.16 lib/generators/acts_as_multipart_form/install_generator.rb
acts_as_multipart_form-0.0.15 lib/generators/acts_as_multipart_form/install_generator.rb
acts_as_multipart_form-0.0.14 lib/generators/acts_as_multipart_form/install_generator.rb
acts_as_multipart_form-0.0.13 lib/generators/acts_as_multipart_form/install_generator.rb
acts_as_multipart_form-0.0.12 lib/generators/acts_as_multipart_form/install_generator.rb
acts_as_multipart_form-0.0.11 lib/generators/acts_as_multipart_form/install_generator.rb
acts_as_multipart_form-0.0.10 lib/generators/acts_as_multipart_form/install_generator.rb
acts_as_multipart_form-0.0.9 lib/generators/acts_as_multipart_form/install_generator.rb
acts_as_multipart_form-0.0.8 lib/generators/acts_as_multipart_form/install_generator.rb
acts_as_multipart_form-0.0.7 lib/generators/acts_as_multipart_form/install_generator.rb
acts_as_multipart_form-0.0.6 lib/generators/acts_as_multipart_form/install_generator.rb
acts_as_multipart_form-0.0.5 lib/generators/acts_as_multipart_form/install_generator.rb
acts_as_multipart_form-0.0.4 lib/generators/acts_as_multipart_form/install_generator.rb
acts_as_multipart_form-0.0.3 lib/generators/acts_as_multipart_form/install_generator.rb
acts_as_multipart_form-0.0.2 lib/generators/acts_as_multipart_form/install_generator.rb
acts_as_multipart_form-0.0.1 lib/generators/acts_as_multipart_form/install_generator.rb