This repository has been archived by the owner on Jun 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
80 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package eyrie.nio.ops | ||
|
||
import eyrie.nio.FilePath | ||
import simulacrum.typeclass | ||
|
||
@typeclass | ||
trait FilePathScheme[A] { | ||
def getPath(string: String): Option[FilePath[A]] | ||
} |
14 changes: 14 additions & 0 deletions
14
nio/src/main/scala/eyrie/nio/syntax/FilePathSchemeSyntax.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package eyrie.nio.syntax | ||
|
||
import eyrie.nio.FilePath | ||
import eyrie.nio.ops.FilePathScheme | ||
|
||
trait FilePathSchemeSyntax { | ||
implicit def toFilePathSchemeOps(s: String): FilePathSchemeOps = | ||
new FilePathSchemeOps(s) | ||
} | ||
|
||
final class FilePathSchemeOps(private val s: String) extends AnyVal { | ||
def toFilePath[A](implicit A: FilePathScheme[A]): Option[FilePath[A]] = | ||
A.getPath(s) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
nio/src/test/scala/eyrie/nio/test/FilePathSchemeSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package eyrie.nio.test | ||
|
||
import eyrie.nio.context.Sys | ||
import org.junit.runner.RunWith | ||
import org.scalatest.FreeSpec | ||
import org.scalatest.junit.JUnitRunner | ||
|
||
@RunWith(classOf[JUnitRunner]) | ||
class FilePathSchemeSpec extends FreeSpec { | ||
import eyrie.nio.syntax.filePathScheme._ | ||
|
||
"String" - { | ||
"toFilePath should work" in { | ||
"a/b/c".toFilePath[Sys] | ||
} | ||
} | ||
} |