Class: Iudex::DA::ORM::ProfileMigrator
- Inherits:
-
Sequel::TimestampMigrator
- Object
- Sequel::TimestampMigrator
- Iudex::DA::ORM::ProfileMigrator
- Defined in:
- lib/iudex-da/orm.rb
Overview
Custom migrator handling “profile” directories (optional migrations)
Instance Method Summary collapse
- #get_migration_files ⇒ Object
-
#initialize(db, profiles, opts) ⇒ ProfileMigrator
constructor
A new instance of ProfileMigrator.
Constructor Details
#initialize(db, profiles, opts) ⇒ ProfileMigrator
Returns a new instance of ProfileMigrator.
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/iudex-da/orm.rb', line 152 def initialize( db, profiles, opts ) base = File.join( LIB_DIR, '..', '..', 'db' ) paths = [ base ] paths += profiles.compact.map do |p| p = p.to_s if p =~ %r{^/} p else File.join( base, p ) end end @pattern = if paths.size > 1 '{' + paths.join( ',' ) + '}' else paths.first end super( db, base, opts ) end |
Instance Method Details
#get_migration_files ⇒ Object
175 176 177 178 |
# File 'lib/iudex-da/orm.rb', line 175 def get_migration_files files = Dir.glob( "#{@pattern}/[0-9]*_*.rb" ) files.sort_by { |p| File.basename( p ) } end |