All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.specmatic.core.utilities.LocalFileSystemSource.kt Maven / Gradle / Ivy

Go to download

Turn your contracts into executable specifications. Contract Driven Development - Collaboratively Design & Independently Deploy MicroServices & MicroFrontends.

There is a newer version: 2.0.37
Show newest version
package io.specmatic.core.utilities

import io.specmatic.core.git.SystemGit
import io.specmatic.core.log.logger
import java.io.File

class LocalFileSystemSource(
    val directory: String = ".",
    override val testContracts: List,
    override val stubContracts: List
) : ContractSource {
    override val type = "filesystem"

    override fun pathDescriptor(path: String): String = path

    override fun install(workingDirectory: File) {
        logger.log("No installation needed as this source is a directory on the local file system")
    }

    override fun directoryRelativeTo(workingDirectory: File): File {
        if(File(directory).isAbsolute)
            return File(directory)

        return workingDirectory.resolve(directory)
    }

    override fun getLatest(sourceGit: SystemGit) {
        logger.log("No need to get latest as this source is a directory on the local file system")
    }

    override fun pushUpdates(sourceGit: SystemGit) {
        logger.log("No need to push updates as this source is a directory on the local file system")
    }

    override fun loadContracts(
        selector: ContractsSelectorPredicate,
        workingDirectory: String,
        configFilePath: String
    ): List {
        return selector.select(this).map {
            val resolvedPath = File(directory).resolve(it)

            ContractPathData(
                directory,
                resolvedPath.path,
                provider = type,
                specificationPath = resolvedPath.canonicalPath,
            )
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy