Advertisement
Guest User

Untitled

a guest
Jun 28th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.75 KB | None | 0 0
  1. protected def getMigrationPackages(modules: Seq[String] = Nil) = {
  2.   val migratedModules = if (modules.isEmpty) {
  3.     val deps = this.getClass.getClassLoader.getResources(".")
  4.     val modules = new mutable.HashSet[String]
  5.     val pattern = "^.*/modules/([A-Za-z0-9-_]+)/.*$".r
  6.     while (deps.hasMoreElements) {
  7.       val depPath = deps.nextElement.getPath
  8.       depPath match {
  9.         case pattern(module) =>
  10.           if (!modules.contains(module)) {
  11.             val migrationsDir = new File(s"$depPath$module/migrations")
  12.             if (migrationsDir.exists && migrationsDir.listFiles.length > 0) {
  13.               modules.add(module)
  14.             }
  15.           }
  16.         case _ =>
  17.       }
  18.     }
  19.  
  20.     modules.toSeq
  21.   } else {
  22.     modules
  23.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement