Skip to content

Commit

Permalink
lichess-org#10726 renamed everything Pimped* to Lila* (lichess-org#10735
Browse files Browse the repository at this point in the history
)

* renamed everything Pimped* to Lila*

renamed everything Pimped* to Lila*

* Update LilaController.scala

LilaLilaResult -> LilaResult
  • Loading branch information
schlawg authored Apr 1, 2022
1 parent f70492b commit 51907ab
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 64 deletions.
2 changes: 1 addition & 1 deletion app/controllers/LilaController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ abstract private[controllers] class LilaController(val env: Env)

implicit protected val LilaResultZero = Zero.instance[Result](Results.NotFound)

implicit final protected class LilaPimpedResult(result: Result) {
implicit final protected class LilaResult(result: Result) {
def fuccess = scala.concurrent.Future successful result
def flashSuccess(msg: String): Result = result.flashing("success" -> msg)
def flashSuccess: Result = flashSuccess("")
Expand Down
50 changes: 25 additions & 25 deletions modules/common/src/main/Lilaisms.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,34 @@ trait Lilaisms
type StringValue = lila.base.LilaTypes.StringValue
type IntValue = lila.base.LilaTypes.IntValue

@inline implicit def toPimpedFuture[A](f: Fu[A]) = new PimpedFuture(f)
@inline implicit def toPimpedFutureBoolean(f: Fu[Boolean]) = new PimpedFutureBoolean(f)
@inline implicit def toPimpedFutureOption[A](f: Fu[Option[A]]) = new PimpedFutureOption(f)
@inline implicit def toPimpedIterableFuture[A, M[X] <: IterableOnce[X]](t: M[Fu[A]]) =
new PimpedIterableFuture(t)
@inline implicit def toLilaFuture[A](f: Fu[A]) = new LilaFuture(f)
@inline implicit def toLilaFutureBoolean(f: Fu[Boolean]) = new LilaFutureBoolean(f)
@inline implicit def toLilaFutureOption[A](f: Fu[Option[A]]) = new LilaFutureOption(f)
@inline implicit def toLilaIterableFuture[A, M[X] <: IterableOnce[X]](t: M[Fu[A]]) =
new LilaIterableFuture(t)

@inline implicit def toPimpedJsObject(jo: JsObject) = new PimpedJsObject(jo)
@inline implicit def toPimpedJsValue(jv: JsValue) = new PimpedJsValue(jv)
@inline implicit def toLilaJsObject(jo: JsObject) = new LilaJsObject(jo)
@inline implicit def toLilaJsValue(jv: JsValue) = new LilaJsValue(jv)

@inline implicit def toAugmentedAny(b: Any) = new AugmentedAny(b)
@inline implicit def toPimpedBoolean(b: Boolean) = new PimpedBoolean(b)
@inline implicit def toPimpedInt(i: Int) = new PimpedInt(i)
@inline implicit def toPimpedLong(l: Long) = new PimpedLong(l)
@inline implicit def toPimpedFloat(f: Float) = new PimpedFloat(f)
@inline implicit def toPimpedDouble(d: Double) = new PimpedDouble(d)

@inline implicit def toPimpedTryList[A](l: List[Try[A]]) = new PimpedTryList(l)
@inline implicit def toPimpedList[A](l: List[A]) = new PimpedList(l)
@inline implicit def toPimpedSeq[A](l: Seq[A]) = new PimpedSeq(l)
@inline implicit def toPimpedByteArray(ba: Array[Byte]) = new PimpedByteArray(ba)

@inline implicit def toPimpedOption[A](a: Option[A]) = new PimpedOption(a)
@inline implicit def toPimpedString(s: String) = new PimpedString(s)
@inline implicit def toPimpedConfig(c: Config) = new PimpedConfig(c)
@inline implicit def toPimpedDateTime(d: DateTime) = new PimpedDateTime(d)
@inline implicit def toPimpedTry[A](t: Try[A]) = new PimpedTry(t)
@inline implicit def toPimpedEither[A, B](e: Either[A, B]) = new PimpedEither(e)
@inline implicit def toPimpedFiniteDuration(d: FiniteDuration) = new PimpedFiniteDuration(d)
@inline implicit def toLilaBoolean(b: Boolean) = new LilaBoolean(b)
@inline implicit def toLilaInt(i: Int) = new LilaInt(i)
@inline implicit def toLilaLong(l: Long) = new LilaLong(l)
@inline implicit def toLilaFloat(f: Float) = new LilaFloat(f)
@inline implicit def toLilaDouble(d: Double) = new LilaDouble(d)

@inline implicit def toLilaTryList[A](l: List[Try[A]]) = new LilaTryList(l)
@inline implicit def toLilaList[A](l: List[A]) = new LilaList(l)
@inline implicit def toLilaSeq[A](l: Seq[A]) = new LilaSeq(l)
@inline implicit def toLilaByteArray(ba: Array[Byte]) = new LilaByteArray(ba)

@inline implicit def toLilaOption[A](a: Option[A]) = new LilaOption(a)
@inline implicit def toLilaString(s: String) = new LilaString(s)
@inline implicit def toLilaConfig(c: Config) = new LilaConfig(c)
@inline implicit def toLilaDateTime(d: DateTime) = new LilaDateTime(d)
@inline implicit def toLilaTry[A](t: Try[A]) = new LilaTry(t)
@inline implicit def toLilaEither[A, B](e: Either[A, B]) = new LilaEither(e)
@inline implicit def toLilaFiniteDuration(d: FiniteDuration) = new LilaFiniteDuration(d)

@inline implicit def toRichValidated[E, A](v: Validated[E, A]) = new RichValidated(v)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import scala.util.Try
import lila.common.Chronometer
import LilaTypes._

final class PimpedFuture[A](private val fua: Fu[A]) extends AnyVal {
final class LilaFuture[A](private val fua: Fu[A]) extends AnyVal {

@inline def dmap[B](f: A => B): Fu[B] = fua.map(f)(EC.parasitic)
@inline def dforeach[B](f: A => Unit): Unit = fua.foreach(f)(EC.parasitic)
Expand Down Expand Up @@ -180,7 +180,7 @@ final class PimpedFuture[A](private val fua: Fu[A]) extends AnyVal {
}
}

final class PimpedFutureBoolean(private val fua: Fu[Boolean]) extends AnyVal {
final class LilaFutureBoolean(private val fua: Fu[Boolean]) extends AnyVal {

def >>&(fub: => Fu[Boolean]): Fu[Boolean] =
fua.flatMap { if (_) fub else fuFalse }(EC.parasitic)
Expand All @@ -191,7 +191,7 @@ final class PimpedFutureBoolean(private val fua: Fu[Boolean]) extends AnyVal {
@inline def unary_! = fua.map { !_ }(EC.parasitic)
}

final class PimpedFutureOption[A](private val fua: Fu[Option[A]]) extends AnyVal {
final class LilaFutureOption[A](private val fua: Fu[Option[A]]) extends AnyVal {

def orFail(msg: => String)(implicit ec: EC): Fu[A] =
fua flatMap {
Expand Down Expand Up @@ -222,13 +222,13 @@ final class PimpedFutureOption[A](private val fua: Fu[Option[A]]) extends AnyVal
}
}

// final class PimpedFutureValid[A](private val fua: Fu[Valid[A]]) extends AnyVal {
// final class LilaFutureValid[A](private val fua: Fu[Valid[A]]) extends AnyVal {

// def flatten: Fu[A] = fua.flatMap {
// _.fold[Fu[A]](fufail(_), fuccess(_))
// }(EC.parasitic)
// }

final class PimpedIterableFuture[A, M[X] <: IterableOnce[X]](private val t: M[Fu[A]]) extends AnyVal {
final class LilaIterableFuture[A, M[X] <: IterableOnce[X]](private val t: M[Fu[A]]) extends AnyVal {
def sequenceFu(implicit bf: BuildFrom[M[Fu[A]], A, M[A]], ec: EC): Fu[M[A]] = Future.sequence(t)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package lila.base

import play.api.libs.json._

final class PimpedJsObject(private val js: JsObject) extends AnyVal {
final class LilaJsObject(private val js: JsObject) extends AnyVal {

def str(key: String): Option[String] =
(js \ key).asOpt[String]
Expand Down Expand Up @@ -62,7 +62,7 @@ final class PimpedJsObject(private val js: JsObject) extends AnyVal {
}
}

final class PimpedJsValue(private val js: JsValue) extends AnyVal {
final class LilaJsValue(private val js: JsValue) extends AnyVal {

def str(key: String): Option[String] =
js.asOpt[JsObject] flatMap { obj =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ final class AugmentedAny(private val self: Any) extends AnyVal {
def unit: Unit = ()
}

final class PimpedBoolean(private val self: Boolean) extends AnyVal {
final class LilaBoolean(private val self: Boolean) extends AnyVal {

/** Replaces scalaz boolean ops
* so ?? works on Zero and not Monoid
Expand All @@ -21,7 +21,7 @@ final class PimpedBoolean(private val self: Boolean) extends AnyVal {
def option[A](a: => A): Option[A] = if (self) Some(a) else None
}

final class PimpedLong(private val self: Long) extends AnyVal {
final class LilaLong(private val self: Long) extends AnyVal {

def atLeast(bottomValue: Long): Long = max(self, bottomValue)

Expand All @@ -35,7 +35,7 @@ final class PimpedLong(private val self: Long) extends AnyVal {
else Integer.MIN_VALUE
}

final class PimpedInt(private val self: Int) extends AnyVal {
final class LilaInt(private val self: Int) extends AnyVal {

def atLeast(bottomValue: Int): Int = max(self, bottomValue)

Expand All @@ -44,7 +44,7 @@ final class PimpedInt(private val self: Int) extends AnyVal {
def squeeze(bottom: Int, top: Int): Int = max(min(self, top), bottom)
}

final class PimpedFloat(private val self: Float) extends AnyVal {
final class LilaFloat(private val self: Float) extends AnyVal {

def atLeast(bottomValue: Float): Float = max(self, bottomValue)

Expand All @@ -53,7 +53,7 @@ final class PimpedFloat(private val self: Float) extends AnyVal {
def squeeze(bottom: Float, top: Float): Float = max(min(self, top), bottom)
}

final class PimpedDouble(private val self: Double) extends AnyVal {
final class LilaDouble(private val self: Double) extends AnyVal {

def atLeast(bottomValue: Double): Double = max(self, bottomValue)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import java.util.Base64
import scala.util.Try
import cats.data.NonEmptyList

final class PimpedTryList[A](private val list: List[Try[A]]) extends AnyVal {
final class LilaTryList[A](private val list: List[Try[A]]) extends AnyVal {
def sequence: Try[List[A]] = Try(list map { _.get })
}

final class PimpedList[A](private val list: List[A]) extends AnyVal {
final class LilaList[A](private val list: List[A]) extends AnyVal {
def sortLike[B](other: List[B], f: A => B): List[A] =
list.sortWith { (x, y) =>
other.indexOf(f(x)) < other.indexOf(f(y))
Expand All @@ -20,10 +20,10 @@ final class PimpedList[A](private val list: List[A]) extends AnyVal {
}
}

final class PimpedSeq[A](private val seq: Seq[A]) extends AnyVal {
final class LilaSeq[A](private val seq: Seq[A]) extends AnyVal {
def has(a: A) = seq contains a
}

final class PimpedByteArray(private val self: Array[Byte]) extends AnyVal {
final class LilaByteArray(private val self: Array[Byte]) extends AnyVal {
def toBase64 = Base64.getEncoder.encodeToString(self)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import scala.util.Try

import LilaTypes._

final class PimpedOption[A](private val self: Option[A]) extends AnyVal {
final class LilaOption[A](private val self: Option[A]) extends AnyVal {

def fold[X](some: A => X, none: => X): X = self.fold(none)(some)

Expand All @@ -27,7 +27,7 @@ final class PimpedOption[A](private val self: Option[A]) extends AnyVal {
def has(a: A) = self contains a
}

final class PimpedString(private val s: String) extends AnyVal {
final class LilaString(private val s: String) extends AnyVal {

def replaceIf(t: Char, r: Char): String =
if (s.indexOf(t.toInt) >= 0) s.replace(t, r) else s
Expand All @@ -39,22 +39,22 @@ final class PimpedString(private val s: String) extends AnyVal {
if (s.contains(t)) s.replace(t, r) else s
}

final class PimpedConfig(private val config: Config) extends AnyVal {
final class LilaConfig(private val config: Config) extends AnyVal {

def millis(name: String): Int = config.getDuration(name, TimeUnit.MILLISECONDS).toInt
def seconds(name: String): Int = config.getDuration(name, TimeUnit.SECONDS).toInt
def duration(name: String): FiniteDuration = millis(name).millis
}

final class PimpedDateTime(private val date: DateTime) extends AnyVal {
final class LilaDateTime(private val date: DateTime) extends AnyVal {
def getSeconds: Long = date.getMillis / 1000
def getCentis: Long = date.getMillis / 10
def toNow = new Duration(date, DateTime.now)
def atMost(other: DateTime) = if (other isBefore date) other else date
def atLeast(other: DateTime) = if (other isAfter date) other else date
}

final class PimpedTry[A](private val v: Try[A]) extends AnyVal {
final class LilaTry[A](private val v: Try[A]) extends AnyVal {

def fold[B](fe: Exception => B, fa: A => B): B =
v match {
Expand All @@ -72,7 +72,7 @@ final class PimpedTry[A](private val v: Try[A]) extends AnyVal {
}
}

final class PimpedEither[A, B](private val v: Either[A, B]) extends AnyVal {
final class LilaEither[A, B](private val v: Either[A, B]) extends AnyVal {

def orElse(other: => Either[A, B]): Either[A, B] =
v match {
Expand All @@ -81,7 +81,7 @@ final class PimpedEither[A, B](private val v: Either[A, B]) extends AnyVal {
}
}

final class PimpedFiniteDuration(private val d: FiniteDuration) extends AnyVal {
final class LilaFiniteDuration(private val d: FiniteDuration) extends AnyVal {

def toCentis =
chess.Centis {
Expand Down
13 changes: 0 additions & 13 deletions modules/common/src/main/base/PimpedConfig.scala

This file was deleted.

2 changes: 1 addition & 1 deletion modules/pool/src/main/PoolList.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ object PoolList {

val json = Json toJson all

implicit private class PimpedInt(self: Int) {
implicit private class LilaInt(self: Int) {
def ++(increment: Int) = chess.Clock.Config(self * 60, increment)
def players = NbPlayers(self)
}
Expand Down
2 changes: 1 addition & 1 deletion modules/tree/src/main/tree.scala
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ object Node {
implicit val gamebookWriter = Json.writes[Node.Gamebook]
import Eval.JsonHandlers.evalWrites

@inline implicit private def toPimpedJsObject(jo: JsObject) = new lila.base.PimpedJsObject(jo)
@inline implicit private def toLilaJsObject(jo: JsObject) = new lila.base.LilaJsObject(jo)

implicit val defaultNodeJsonWriter: Writes[Node] =
makeNodeJsonWriter(alwaysChildren = true)
Expand Down

0 comments on commit 51907ab

Please sign in to comment.