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