diff --git a/src/main/scala/net/kemitix/s3thorp/KeyGenerator.scala b/src/main/scala/net/kemitix/s3thorp/KeyGenerator.scala new file mode 100644 index 0000000..fa6ca40 --- /dev/null +++ b/src/main/scala/net/kemitix/s3thorp/KeyGenerator.scala @@ -0,0 +1,14 @@ +package net.kemitix.s3thorp + +import java.io.File + +trait KeyGenerator { + + def generateKey(c: Config)(file: File): String = { + val otherPath = file.toPath.toAbsolutePath + val sourcePath = c.source.toPath + val relativePath = sourcePath.relativize(otherPath) + s"${c.prefix}/$relativePath" + } + +} diff --git a/src/main/scala/net/kemitix/s3thorp/S3MetaDataEnricher.scala b/src/main/scala/net/kemitix/s3thorp/S3MetaDataEnricher.scala index e8fb83e..153fc23 100644 --- a/src/main/scala/net/kemitix/s3thorp/S3MetaDataEnricher.scala +++ b/src/main/scala/net/kemitix/s3thorp/S3MetaDataEnricher.scala @@ -6,14 +6,7 @@ import fs2.Stream import cats.effect.IO import net.kemitix.s3thorp.awssdk.S3Client -trait S3MetaDataEnricher extends S3Client { - - def generateKey(c: Config)(file: File): String = { - val otherPath = file.toPath.toAbsolutePath - val sourcePath = c.source.toPath - val relativePath = sourcePath.relativize(otherPath) - s"${c.prefix}/$relativePath" - } +trait S3MetaDataEnricher extends S3Client with KeyGenerator { def enrichWithS3MetaData(c: Config): File => Stream[IO, Either[File, S3MetaData]] = { val fileToString = generateKey(c)_