Sha256: 0ddab6988f8942742e79984c7530c1ce7583f2de298af0adf375860d44501e01
Contents?: true
Size: 1.3 KB
Versions: 4
Compression:
Stored size: 1.3 KB
Contents
module Merb::Generators class MigrationGenerator < Generator def self.source_root File.join(super, 'component', 'migration') end desc <<-DESC This is a migration generator DESC option :orm, :desc => 'Object-Relation Mapper to use (one of: none, activerecord, datamapper, sequel)' option :model, :as => :boolean, :desc => 'Specify this option to generate a migration which creates a table for the provided model' first_argument :name, :required => true second_argument :attributes, :as => :hash, :default => {} def table_name self.name.snake_case.pluralize end def class_name "#{self.name.camel_case}Migration" end def migration_name self.name.snake_case end def file_name "#{version}_#{migration_name}_migration" end def version # TODO: handle ActiveRecord timestamped migrations format("%03d", current_migration_nr + 1) end protected def destination_directory File.join(destination_root, 'schema', 'migrations') end def current_migration_nr current_migration_number = Dir["#{destination_directory}/*"].map{|f| File.basename(f).match(/^(\d+)/)[0].to_i }.max.to_i end end add :migration, MigrationGenerator end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
merb-gen-0.9.4 | lib/generators/migration.rb |
merb-gen-0.9.5 | lib/generators/migration.rb |
merb-gen-0.9.6 | lib/generators/migration.rb |
merb-gen-0.9.7 | lib/generators/migration.rb |