mirror of
https://github.com/librecaptcha/lc-core.git
synced 2025-01-13 23:04:59 -05:00
Extract to case class
Signed-off-by: Rahul Rudragoudar <rr83019@gmail.com>
This commit is contained in:
parent
2c0f3deb8a
commit
e931e43bb9
@ -1,9 +1,8 @@
|
|||||||
package lc.core
|
package lc.core
|
||||||
|
|
||||||
import scala.io.Source.fromFile
|
import scala.io.Source.fromFile
|
||||||
import org.json4s.{DefaultFormats, JValue, JObject, JField}
|
import org.json4s.{DefaultFormats, JValue, JObject, JField, JString}
|
||||||
import org.json4s.jackson.JsonMethods.parse
|
import org.json4s.jackson.JsonMethods.parse
|
||||||
import scala.collection.immutable.HashMap
|
|
||||||
|
|
||||||
object Config {
|
object Config {
|
||||||
|
|
||||||
@ -20,12 +19,15 @@ object Config {
|
|||||||
val seed: Int = (configJson \ "randomSeed").extract[Int]
|
val seed: Int = (configJson \ "randomSeed").extract[Int]
|
||||||
val captchaExpiryTimeLimit: Int = (configJson \ "captchaExpiryTimeLimit").extract[Int]
|
val captchaExpiryTimeLimit: Int = (configJson \ "captchaExpiryTimeLimit").extract[Int]
|
||||||
val threadDelay: Int = (configJson \ "threadDelay").extract[Int]
|
val threadDelay: Int = (configJson \ "threadDelay").extract[Int]
|
||||||
private val captchaConfig = (configJson \ "captchas")
|
|
||||||
val captchaConfigMap: Map[String,HashMap[String,List[String]]] = captchaConfig.values.asInstanceOf[Map[String, HashMap[String, List[String]]]]
|
|
||||||
|
|
||||||
val supportedLevels: Set[String] = getAllValues(configJson, "supportedLevels")
|
private val captchaConfigJson = (configJson \ "captchas")
|
||||||
val supportedMedia: Set[String] = getAllValues(configJson, "supportedMedia")
|
val captchaConfigTransform: JValue = captchaConfigJson transformField {
|
||||||
val supportedinputType: Set[String] = getAllValues(configJson, "supportedinputType")
|
case JField("config", JObject(config)) => ("config", JString(config.toString))
|
||||||
|
}
|
||||||
|
val captchaConfig: List[CaptchaConfig] = captchaConfigTransform.extract[List[CaptchaConfig]]
|
||||||
|
val allowedLevels: Set[String] = getAllValues(configJson, ParametersEnum.ALLOWEDLEVELS.toString)
|
||||||
|
val allowedMedia: Set[String] = getAllValues(configJson, ParametersEnum.ALLOWEDMEDIA.toString)
|
||||||
|
val allowedInputType: Set[String] = getAllValues(configJson, ParametersEnum.ALLOWEDINPUTTYPE.toString)
|
||||||
|
|
||||||
private def getAllValues(config: JValue, param: String): Set[String] = {
|
private def getAllValues(config: JValue, param: String): Set[String] = {
|
||||||
val configValues = (config \\ param)
|
val configValues = (config \\ param)
|
||||||
|
Loading…
Reference in New Issue
Block a user