# Extracts the actual mockup into a directory and makes URLs # relative. class Release::Extractor # Resolves an url to a true file on disk: # # * it will add index.html if it's a directory # * it will try to append .html or .htm if it's not a directory def resolve_path(path) path = Pathname.new(path) unless path.kind_of?(Pathname) # Append index.html/index.htm/index.rhtml if it's a diretory if path.directory? search_files = %w{.html .htm}.map!{|p| path + "index#{p}" } # If it ends with a slash or does not contain a . and it's not a directory # try to add .html/.htm/.rhtml to see if that exists. elsif (path.to_s =~ /\/$/) || (path.to_s =~ /^[^.]+$/) search_files = [path.to_s + ".html", path.to_s + ".htm"].map!{|p| Pathname.new(p) } else search_files = [path] end search_files.find{|p| p.exist? } end end