sbt/plugin/src/main/scala-2.10/coursier/InterProjectRepository.scala

27 lines
602 B
Scala
Raw Normal View History

2015-12-30 01:34:34 +01:00
package coursier
import scalaz.{ -\/, \/-, Monad, EitherT }
case class InterProjectRepository(projects: Seq[Project]) extends Repository {
2015-12-30 01:34:34 +01:00
private val map = projects
.map { proj => proj.moduleVersion -> proj }
2015-12-30 01:34:34 +01:00
.toMap
def find[F[_]](
module: Module,
version: String,
fetch: Fetch.Content[F]
)(implicit
F: Monad[F]
): EitherT[F, String, (Artifact.Source, Project)] = {
val res = map.get((module, version)) match {
case Some(proj) =>
\/-((Artifact.Source.empty, proj))
2015-12-30 01:34:34 +01:00
case None =>
2015-12-30 01:34:43 +01:00
-\/("Not found")
2015-12-30 01:34:34 +01:00
}
EitherT(F.point(res))
}
}