[keygenerator] Extract as a trait
This commit is contained in:
parent
b348f18142
commit
6af5b8cafc
2 changed files with 15 additions and 8 deletions
14
src/main/scala/net/kemitix/s3thorp/KeyGenerator.scala
Normal file
14
src/main/scala/net/kemitix/s3thorp/KeyGenerator.scala
Normal file
|
@ -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"
|
||||
}
|
||||
|
||||
}
|
|
@ -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)_
|
||||
|
|
Loading…
Reference in a new issue