in.specmatic.core.utilities.LocalFileSystemSource.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of specmatic-core Show documentation
Show all versions of specmatic-core Show documentation
Turn your contracts into executable specifications. Contract Driven Development - Collaboratively Design & Independently Deploy MicroServices & MicroFrontends.
Deprecation Notice for group ID "in.specmatic"
******************************************************************************************************
Updates for "specmatic-core" will no longer be available under the deprecated group ID "in.specmatic".
Please update your dependencies to use the new group ID "io.specmatic".
******************************************************************************************************
package `in`.specmatic.core.utilities
import `in`.specmatic.core.git.SystemGit
import `in`.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,
)
}
}
}