Module: RailsAssist::Artifact::Migration::FileName
- Includes:
- FileName, BaseHelper, Migration::ClassMethods
- Defined in:
- lib/migration_assist/helper/migration.rb
Defined Under Namespace
Classes: FindError
Instance Method Summary collapse
Methods included from Migration::ClassMethods
#current_migration_number, #latest_migration_file, #migration_exists?, #migration_lookup_at, #next_migration_number
Instance Method Details
#find_migration(name, options = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/migration_assist/helper/migration.rb', line 28 def find_migration name, ={} root_path = [:root_path] migration_dir_name = File.(RailsAssist::Artifact::Directory.migration_dirpath ) migration_find_expr = "#{migration_dir_name}/[0-9]*_*.rb" migrations = Dir.glob(migration_find_expr) find_err = FindError.new migration_find_expr return find_err if migrations.empty? migration_find_expr = /\d+_#{name}\.rb$/ find_err.find_expr = migration_find_expr matching_migrations = migrations.grep_it(migration_find_expr) return find_err if matching_migrations.empty? migration_file = ([:last]) ? matching_migrations.last : matching_migrations.first end |
#migration_file_name(name, options = {}) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/migration_assist/helper/migration.rb', line 19 def migration_file_name name, ={} number = [:number] migration_dir_name = File.(RailsAssist::Artifact::Directory.migration_dirpath()) number = next_migration_number(migration_dir_name) if !number File.join(migration_dir_name, "#{number}_#{name}.rb") end |