Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/services/CatShelter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ object CatShelter {
* @return An array containing all cats
*/
def createCats(): Array[Cat] = {
Logger.info("[ImgurService] Creating cats...")
Logger.info("[CatShelter] Creating cats...")

// Retrieve images from the album "imgur.album"
// Map each image to create a list with Cat instances
val cats = imgur.albumImages(configuration.getString("imgur.album").get)
.map(Cat(_))
.toArray

Logger.info("[ImgurService] Cats created!")
Logger.info("[CatShelter] Cats created!")

cats
}
Expand Down
35 changes: 35 additions & 0 deletions app/services/RedisService.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package services

import scredis.Redis

/** May contains Redis configuration */
trait RedisConfig {

}

/** Handle cats business logic with the power of Redis */
object RedisService extends RedisConfig {
// A direct access to redis should **really** not be possible
private val redis = Redis()

/** Well... if you insist */
def flushAll: Unit = redis.flushAll()
}

/** "Keeper of Keys and Grounds of Redis" (aka Rubeus Hagrid) */
object RedisSchema {

/** Get the key to retrieve every single cats
*
* @ return The key
*/
def cats: String = "cats"

/** Get the key to retrieve a single cat
*
* @param id Cat identifier
*
* @return The key
*/
def cat(id: String): String = s"cats:$id"
}
2 changes: 2 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ lazy val imgur = RootProject(uri("git://github.com/Cowa/Imgur-Scala.git#master")
scalaVersion := "2.11.5"

libraryDependencies ++= Seq(
"org.scalatestplus" %% "play" % "1.1.0" % "test",
"com.livestream" %% "scredis" % "2.0.6",
cache
)

Expand Down
12 changes: 12 additions & 0 deletions test/RedisServiceTest.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package test

import services.RedisService
import org.scalatestplus.play._

class RedisServiceTest extends PlaySpec {
"RedisService" must {
"test stuff to prove it works" in {
1 mustBe 1
}
}
}