Sha256: 4c87c585fae59e52e7b84b2087c8c912b6240e1d02d25b76eb9bf6c6a9b79758
Contents?: true
Size: 942 Bytes
Versions: 3
Compression:
Stored size: 942 Bytes
Contents
module MigrationHelper include Rails::Generators::Migration module ClassMethods def migration_lookup_at(dirname) #:nodoc: Dir.glob("#{dirname}/[0-9]*_*.rb") end def migration_exists?(dirname, file_name) #:nodoc: migration_lookup_at(dirname).grep(/\d+_#{file_name}.rb$/).first end def current_migration_number(dirname) #:nodoc: migration_lookup_at(dirname).collect do |file| File.basename(file).split("_").first.to_i end.max.to_i end def next_migration_number(dirname) #:nodoc: orm = Rails.configuration.generators.options[:rails][:orm] require "rails/generators/#{orm}" "#{orm.to_s.camelize}::Generators::Base".constantize.next_migration_number(dirname) rescue raise NotImplementedError end end def self.included(base) #:nodoc: puts "MigrationHelper included by #{base}" base.extend ClassMethods end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
netzke-core-0.6.2 | lib/generators/migration_helper.rb |
netzke-core-0.6.1 | lib/generators/migration_helper.rb |
netzke-core-0.6.0 | lib/generators/migration_helper.rb |