12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/rails3_artifactor/base/file_name.rb', line 12
def existing_file_name name, type=nil, options = {}
finder_method = :"find_#{type}"
if respond_to?(finder_method)
result = send finder_method, name, options
if !result.kind_of? String
raise IOError, "The call to #find_#{type}(#{name}) didn't find an existing #{type} file. Error in find expression: #{result.find_expr}"
end
return result
elsif type == :migration
raise StandardError, "The method #find_#{type} to find the migration is not available!"
end
file_name = make_file_name name, type, options
raise IOError, "No file for :#{type} found at location: #{file_name}" if !File.file?(file_name)
file_name
end
|