File tree Expand file tree Collapse file tree 4 files changed +15
-7
lines changed
main/scala/org/hammerlab/paths
test/scala/org/hammerlab/paths Expand file tree Collapse file tree 4 files changed +15
-7
lines changed Original file line number Diff line number Diff line change 1
1
name := " paths"
2
- version := " 1.0.0 "
2
+ version := " 1.0.1 "
3
3
deps += libs.value(' commons_io )
4
4
addScala212
Original file line number Diff line number Diff line change 1
- addSbtPlugin(" org.hammerlab" % " sbt-parent" % " 1.7.2 " )
1
+ addSbtPlugin(" org.hammerlab" % " sbt-parent" % " 1.7.3 " )
Original file line number Diff line number Diff line change @@ -13,11 +13,11 @@ class Path(val path: JPath)
13
13
extends AnyVal
14
14
with Serializable {
15
15
16
- override def toString : String = path .toString
16
+ override def toString : String = uri .toString
17
17
18
18
def uri : URI = path.toUri
19
19
20
- def extension : String = getExtension(path. toString)
20
+ def extension : String = getExtension(toString)
21
21
22
22
def exists : Boolean = Files .exists(path)
23
23
@@ -80,7 +80,7 @@ class Path(val path: JPath)
80
80
/**
81
81
* Append `suffix` to the basename of this [[Path ]].
82
82
*/
83
- def + (suffix : String ): Path = Path (path. toString + suffix)
83
+ def + (suffix : String ): Path = Path (toString + suffix)
84
84
85
85
def / (basename : String ): Path = Path (path.resolve(basename))
86
86
@@ -108,7 +108,15 @@ class Path(val path: JPath)
108
108
109
109
object Path {
110
110
def apply (path : JPath ): Path = new Path (path)
111
- def apply (pathStr : String ): Path = new Path (Paths .get(pathStr))
111
+
112
+ def apply (pathStr : String ): Path = {
113
+ val uri = new URI (pathStr)
114
+ if (uri.getScheme == null )
115
+ new Path (Paths .get(pathStr))
116
+ else
117
+ Path (uri)
118
+ }
119
+
112
120
def apply (uri : URI ): Path = new Path (Paths .get(uri))
113
121
114
122
implicit def toJava (path : Path ): JPath = path.path
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ class PathTest
12
12
test(" extensions" ) {
13
13
" abc.def" .extension should be(" def" )
14
14
" /abc/def.gh.ij" .extension should be(" ij" )
15
- " hdfs: //foo/bar.baz" .extension should be(" baz" )
15
+ " file:/ //foo/bar.baz" .extension should be(" baz" )
16
16
}
17
17
18
18
test(" removals" ) {
You can’t perform that action at this time.
0 commit comments