A simple path matching utility for Kotlin Multi-platform.
val matches = Path("./Example.kt") matches {
when {
exact("Example.kt") -> true
glob("*/Example.kt") -> true
regex(".*\\.kt") -> true
else -> false
}
}
val matches = Path("./Example.kt") matches {
when {
exact("Example.kt") -> true
glob("*/Example.kt") -> true
regex(".*\\.kt") -> true
else -> false
}
}
val result = Path("./Example.kt") matchResult {
when {
exact("Example.kt") -> getExactMatchValue()
glob("*/Example.kt") -> getGlobMatchValue()
regex(".*\\.kt") -> getRegexMatchValue()
else -> null
}
}
val pathMatcher = PathMatcher("./Example.kt")
pathMatcher matchesExactly "Example.kt"
pathMatcher matchesGlob "*/Example.kt"
pathMatcher matchesRegex ".*\\.kt"
val glob = Glob("*/Example.kt")
glob.matches("/Example.kt")
The library is provided through Repsy.io. Checkout
the releases page to get the latest version.
repositories {
maven { url = "https://repo.repsy.io/mvn/chrynan/public" }
}
implementation "com.chrynan.pathmatcher:pathmatcher-core:$VERSION"
More detailed documentation is available in the docs folder. The entry point to the documentation can be found here.
Copyright 2021 chRyNaN
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.