28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/rails3_artifactor/artifact/file_name/migration.rb', line 28
def find_migration name, options={}
root_path = options[:root_path]
migration_dir_name = File.expand_path(DIR.migration_dir options)
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 = (options[:last]) ? matching_migrations.last : matching_migrations.first
end
|