verfi_2.9.0.0.1.0.source-code.semver.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of semverfi_2.9.0 Show documentation
Show all versions of semverfi_2.9.0 Show documentation
Always Faithful, always loyal semantic versions
package semverfi
object Version {
def apply(in: String): SemVersion =
Parse(in) match {
case Parse.Success(v, _) => v
case _ => Invalid(in)
}
}
sealed trait SemVersion {
def major: Int
def minor: Int
def patch: Int
}
case class Invalid(raw: String) extends SemVersion {
def major = -1
def minor = -1
def patch = -1
}
abstract class Valid extends SemVersion with Bumping
case class NormalVersion(major: Int, minor: Int, patch: Int)
extends Valid
case class PreReleaseVersion(major: Int,
minor: Int,
patch: Int,
classifier: Seq[String])
extends Valid
case class BuildVersion(major: Int,
minor: Int,
patch: Int,
classifier: Seq[String],
build: Seq[String])
extends Valid {
lazy val classified = ! classifier.isEmpty
lazy val unclassified = ! classified
}