Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit 2482a6e

Browse files
authored
Update prox to 0.6 (#258)
1 parent ea8502e commit 2482a6e

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ lazy val pitgull =
155155
"io.chrisdavenport" %% "cats-time" % "0.3.4",
156156
"com.github.valskalla" %% "odin-core" % "0.11.0",
157157
"com.github.valskalla" %% "odin-slf4j" % "0.11.0",
158-
"io.github.vigoo" %% "prox" % "0.5.2"
158+
"io.github.vigoo" %% "prox-fs2" % "0.6.0"
159159
)
160160
)
161161
.dependsOn(core, gitlab)

src/main/scala/io/pg/config/ProjectConfig.scala

+18-20
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
package io.pg.config
22

3-
import cats.effect.Blocker
3+
import cats.Applicative
4+
import cats.MonadThrow
45
import cats.effect.ExitCode
5-
import cats.effect.Concurrent
6-
import cats.effect.ContextShift
76
import cats.syntax.all._
8-
import java.nio.file.Paths
9-
import io.github.vigoo.prox._
10-
import scala.util.chaining._
11-
import cats.Applicative
127
import cats.tagless.finalAlg
8+
import io.github.vigoo.prox.ProxFS2
139
import io.pg.gitlab.webhook.Project
1410

11+
import java.nio.file.Paths
12+
import scala.util.chaining._
13+
1514
@finalAlg
1615
trait ProjectConfigReader[F[_]] {
1716
def readConfig(project: Project): F[ProjectConfig]
@@ -55,9 +54,10 @@ object ProjectConfigReader {
5554
def readConfig(project: Project): F[ProjectConfig] = config.pure[F]
5655
}
5756

58-
def dhallJsonStringConfig[F[_]: Concurrent: ContextShift](
59-
blocker: Blocker
60-
): F[ProjectConfigReader[F]] = {
57+
def dhallJsonStringConfig[F[_]: ProxFS2: MonadThrow]: F[ProjectConfigReader[F]] = {
58+
val prox: ProxFS2[F] = implicitly
59+
import prox.{contextShift => _, blocker => _, concurrent => _, _}
60+
6161
val dhallCommand = "dhall-to-json"
6262
//todo: not reading a local file
6363
val filePath = "./example.dhall"
@@ -67,27 +67,25 @@ object ProjectConfigReader {
6767
_.exitCode == ExitCode.Success
6868
)
6969

70-
implicit val runner: ProcessRunner[F] = new JVMProcessRunner
71-
val instance: ProjectConfigReader[F] = new ProjectConfigReader[F] {
70+
implicit val runner: ProcessRunner[JVMProcessInfo] = new JVMProcessRunner
7271

73-
def readConfig(project: Project): F[ProjectConfig] = {
74-
val input = fs2.io.file.readAll[F](Paths.get(filePath), blocker, 4096)
72+
val instance: ProjectConfigReader[F] = new ProjectConfigReader[F] {
7573

76-
Process[F](dhallCommand)
74+
def readConfig(project: Project): F[ProjectConfig] =
75+
Process(dhallCommand)
7776
.`with`("TOKEN" -> "demo-token")
78-
.fromStream(input, flushChunks = true)
77+
.fromFile(Paths.get(filePath))
7978
.toFoldMonoid(fs2.text.utf8Decode[F])
80-
.run(blocker)
79+
.run()
8180
.pipe(checkExitCode)
8281
.map(_.output)
8382
.flatMap(io.circe.parser.decode[ProjectConfig](_).liftTo[F])
84-
}
8583
}
8684

8785
val ensureCommandExists =
88-
Process[F]("bash", "-c" :: s"command -v $dhallCommand" :: Nil)
86+
Process("bash", "-c" :: s"command -v $dhallCommand" :: Nil)
8987
.drainOutput(_.drain)
90-
.run(blocker)
88+
.run()
9189
.pipe(checkExitCode)
9290
.adaptError { case e =>
9391
new Throwable(s"Command $dhallCommand not found", e)

0 commit comments

Comments
 (0)