Skip to content

Commit

Permalink
clarify image writer as plantuml-specific
Browse files Browse the repository at this point in the history
  • Loading branch information
mcanlas committed Apr 2, 2024
1 parent 6e4d375 commit be2b9ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import cats.effect.*
import cats.syntax.all.*
import net.sourceforge.plantuml.SourceStringReader

trait ImageWriter[F[_]]:
trait PlantUmlImageWriter[F[_]]:
def writeFile(body: String, destination: String): F[Unit]

object ImageWriter:
object PlantUmlImageWriter:
private def fileOutputStream[F[_]: Sync](dest: String): Resource[F, FileOutputStream] =
Resource
.fromAutoCloseable:
Sync[F].blocking:
FileOutputStream(dest)

def sync[F[_]: Sync](using out: std.Console[F]): ImageWriter[F] =
new ImageWriter[F]:
def sync[F[_]: Sync](using out: std.Console[F]): PlantUmlImageWriter[F] =
new PlantUmlImageWriter[F]:
def writeFile(body: String, destination: String): F[Unit] =
fileOutputStream[F](destination)
.use: os =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ object TestImageWriting extends IOApp.Simple:
"@enduml"
)

ImageWriter
PlantUmlImageWriter
.sync[IO]
.writeFile(
diagram.mkString("\n"),
Expand Down

0 comments on commit be2b9ad

Please sign in to comment.