Sha256: f482e8d590d89c5c96729ac10f602314bab46392aeaf32c4151e01e52bf14d12

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

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

module ControlledVersioning
  class InstallGenerator < Rails::Generators::Base
    include ::Rails::Generators::Migration

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

    desc 'Generates (but does not run) a migration to add a versions table.'

    def create_model_file
      template "version.rb", "app/models/controlled_versioning/version.rb"
      template "version_attribute.rb",
        "app/models/controlled_versioning/version_attribute.rb"
      template "version_child.rb",
        "app/models/controlled_versioning/version_child.rb"
      migration_template "create_versions.rb", "db/migrate/create_versions.rb"
      migration_template "create_version_attributes.rb",
        "db/migrate/create_version_attributes.rb"
      migration_template "create_version_children.rb",
        "db/migrate/create_version_children.rb"
    end

    def self.next_migration_number(dirname)
      ::ActiveRecord::Generators::Base.next_migration_number(dirname)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
controlled_versioning-0.6.3 lib/generators/controlled_versioning/install_generator.rb
controlled_versioning-0.6.2 lib/generators/controlled_versioning/install_generator.rb
controlled_versioning-0.6.1 lib/generators/controlled_versioning/install_generator.rb
controlled_versioning-0.6 lib/generators/controlled_versioning/install_generator.rb