File tree Expand file tree Collapse file tree
circe-utils/src/main/scala/ru/tinkoff/tcb/utils/circe
main/scala/ru/tinkoff/tcb/bson/optics
test/scala/ru/tinkoff/tcb/bson
mockingbird/src/main/scala/ru/tinkoff/tcb
main/scala/ru/tinkoff/tcb/utils/regex
test/scala/ru/tinkoff/tcb/utils/regex Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,16 +10,18 @@ ThisBuild / semanticdbEnabled := true
1010val utils = (project in file(" utils" ))
1111 .settings(Settings .common)
1212 .settings(
13- libraryDependencies ++= Dependencies .cats ++ Dependencies .zio ++ Dependencies .scalatest ++ Dependencies .metrics
13+ libraryDependencies ++= Dependencies .cats ++ Dependencies .zio ++ Dependencies .scalatest ++ Dependencies .metrics ++ Dependencies .literally
1414 )
1515
1616val circeUtils = (project in file(" circe-utils" ))
17+ .dependsOn(utils)
1718 .settings(Settings .common)
1819 .settings(
1920 libraryDependencies ++= Dependencies .json ++ Dependencies .zio ++ Dependencies .scalatest
2021 )
2122
2223val dataAccess = (project in file(" dataAccess" ))
24+ .dependsOn(utils)
2325 .settings(Settings .common)
2426 .settings(
2527 libraryDependencies ++= Dependencies .alleycats ++ Dependencies .cats ++ Dependencies .zio ++ Dependencies .mouse ++ Dependencies .oolong ++ Seq (
Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ package ru.tinkoff.tcb.utils.circe.optics
33import io .circe .ACursor
44import io .circe .Json
55
6+ import ru .tinkoff .tcb .utils .regex .literals .*
7+
68final case class JsonOptic private [optics] (private val jsonPath : Seq [PathPart ]) {
79 def \ (field : String ): JsonOptic = new JsonOptic (jsonPath :+ Field (field))
810 def \ (index : Int ): JsonOptic = new JsonOptic (jsonPath :+ Index (index))
@@ -111,7 +113,7 @@ final case class JsonOptic private[optics] (private val jsonPath: Seq[PathPart])
111113}
112114
113115object JsonOptic {
114- private val IndexPattern = """ \[(\d+)\]""" .r
116+ private val IndexPattern = rx """ \[(\d+)\] """
115117
116118 def forPath (path : String * ): JsonOptic = new JsonOptic (path.map(Field (_)))
117119 def forIndex (index : Int ): JsonOptic = new JsonOptic (Seq (Index (index)))
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import cats.instances.vector.*
77import io .circe .*
88
99import ru .tinkoff .tcb .utils .circe .optics .JsonOptic
10+ import ru .tinkoff .tcb .utils .regex .literals .*
1011
1112package object circe {
1213 object JsonString {
@@ -71,7 +72,7 @@ package object circe {
7172 )
7273
7374 def camelizeKeys : Json =
74- transformKeys(in => " _([a-z\\ d])" .r .replaceAllIn(in, _.group(1 ).toUpperCase)).result
75+ transformKeys(in => rx " _([a-z \d ]) " .replaceAllIn(in, _.group(1 ).toUpperCase)).result
7576
7677 /**
7778 * Merges two Json objects
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ import scala.util.Try
55import oolong .bson .*
66import org .mongodb .scala .bson .*
77
8+ import ru .tinkoff .tcb .utils .regex .literals .*
9+
810final case class BsonOptic private [optics] (private val BsonPath : Seq [Either [Int , String ]]) {
911 def \ (field : String ): BsonOptic = new BsonOptic (BsonPath :+ Right (field))
1012 def \ (index : Int ): BsonOptic = new BsonOptic (BsonPath :+ Left (index))
@@ -84,7 +86,7 @@ final case class BsonOptic private[optics] (private val BsonPath: Seq[Either[Int
8486}
8587
8688object BsonOptic {
87- private val Index = """ \[(\d+)\]""" .r
89+ private val Index = rx """ \[(\d+)\] """
8890
8991 def forPath (path : String * ): BsonOptic = new BsonOptic (path.map(Right (_)))
9092 def forIndex (index : Int ): BsonOptic = new BsonOptic (Seq (Left (index)))
Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ package ru.tinkoff.tcb.bson
33import scala .util .matching .Regex
44
55import oolong .bson .*
6+
7+ import ru .tinkoff .tcb .utils .regex .literals .*
68import oolong .bson .given
79import org .scalactic .Equality
810import org .scalatest .TryValues
@@ -18,7 +20,7 @@ class RoundRobinSpec extends AnyFunSuite with Matchers with TryValues {
1820 }
1921
2022 test(" Regex serialization" ) {
21- val group = " <(?<name>[a-zA-Z0-9]+)>" .r
23+ val group = rx " <(?<name>[a-zA-Z0-9]+)> "
2224
2325 val sut = BsonDecoder [Regex ].fromBson(group.bson)
2426
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import ru.tinkoff.tcb.protocol.json.*
2323import ru .tinkoff .tcb .protocol .schema .*
2424import ru .tinkoff .tcb .utils .circe .optics .JsonOptic
2525import ru .tinkoff .tcb .utils .id .SID
26+ import ru .tinkoff .tcb .utils .regex .literals .*
2627import ru .tinkoff .tcb .validation .Rule
2728
2829final case class GrpcStub (
@@ -45,7 +46,7 @@ final case class GrpcStub(
4546 Schema
4647
4748object GrpcStub {
48- private val indexRegex = " \\ [([ \\ d] +)\\ ] " .r
49+ private val indexRegex = rx """ \[(\d +)\] """
4950
5051 inline given QueryMeta [GrpcStub ] = queryMeta(_.id -> " _id" )
5152
Original file line number Diff line number Diff line change @@ -2,8 +2,10 @@ package ru.tinkoff.tcb.utils
22
33import scala .util .matching .Regex
44
5+ import ru .tinkoff .tcb .utils .regex .literals .*
6+
57package object regex {
6- private val Group = " <(?<name>[a-zA-Z0-9]+)>" .r
8+ private val Group = rx " <(?<name>[a-zA-Z0-9]+)> "
79
810 implicit class RegexExt (private val rx : Regex ) {
911 def groups : Seq [String ] = Group .findAllMatchIn(rx.pattern.pattern()).map(_.group(" name" )).to(Seq )
Original file line number Diff line number Diff line change @@ -13,13 +13,14 @@ import ru.tinkoff.tcb.utils.circe.*
1313import ru .tinkoff .tcb .utils .circe .optics .JsonOptic
1414import ru .tinkoff .tcb .utils .json .json2StringFolder
1515import ru .tinkoff .tcb .utils .regex .OneOrMore
16+ import ru .tinkoff .tcb .utils .regex .literals .*
1617import ru .tinkoff .tcb .utils .resource .Resource
1718import ru .tinkoff .tcb .utils .sandboxing .GraalJsSandbox
1819import ru .tinkoff .tcb .utils .sandboxing .conversion .circe2js
1920import ru .tinkoff .tcb .utils .transformation .xml .nodeTemplater
2021
2122package object json {
22- private val JORx = """ \$([\:~])?\{([\p{L}\d\.\[\]\-_]+)\}""" .r
23+ private val JORx = rx """ \ $$ ([\:~])?\{([\p{L}\d\.\[\]\-_]+)\} """
2324
2425 private object JORxs extends OneOrMore (JORx )
2526
Original file line number Diff line number Diff line change @@ -2,7 +2,9 @@ package ru.tinkoff.tcb.utils
22
33import scala .util .matching .Regex
44
5+ import ru .tinkoff .tcb .utils .regex .literals .*
6+
57package object transformation {
6- val SubstRx : Regex = """ \$\{(.+?)\}""" .r
7- val CodeRx : Regex = """ %\{(.+?)\}""" .r
8+ val SubstRx : Regex = rx """ \ $$ \{(.+?)\} """
9+ val CodeRx : Regex = rx """ %\{(.+?)\} """
810}
Original file line number Diff line number Diff line change @@ -91,6 +91,10 @@ object Dependencies {
9191 " io.github.mweirauch" % " micrometer-jvm-extras" % " 0.2.2"
9292 )
9393
94+ lazy val literally = Seq (
95+ " org.typelevel" %% " literally" % " 1.2.0"
96+ )
97+
9498 lazy val glass = Seq (
9599 " glass-core" ,
96100 " glass-macro" ,
You can’t perform that action at this time.
0 commit comments