Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add aliases: ns->path and path->ns #36

Closed
wants to merge 2 commits into from

2 participants

@myguidingstar

So I added aliases for backward compatibility

@Raynes
Owner

I don't see any really compelling reason to add these aliases. Aliases don't work well anyways, because of metadata. I don't think either of these names are better than the other.

@Raynes Raynes closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 4 deletions.
  1. +4 −2 src/fs/core.clj
  2. +2 −2 test/fs/core_test.clj
View
6 src/fs/core.clj
@@ -398,7 +398,7 @@ If 'trim-ext' is true, any extension is trimmed."
of the second."
[p c] (some #{(file p)} (parents c)))
-(defn ns-path
+(defn ns->path
"Takes a namespace symbol and creates a path to it. Replaces hyphens with
underscores. Assumes the path should be relative to cwd."
[n]
@@ -408,7 +408,7 @@ If 'trim-ext' is true, any extension is trimmed."
(replace \. \/))
".clj")))
-(defn path-ns
+(defn path->ns
"Takes a path to a Clojure file and constructs a namespace symbol
out of the path."
[path]
@@ -448,3 +448,5 @@ If 'trim-ext' is true, any extension is trimmed."
[path]
(set! *cwd* (file path)))
+(def ns-path ns->path)
+(def path-ns path->ns)
View
4 test/fs/core_test.clj
@@ -301,10 +301,10 @@
(child-of? "/foo/bar/baz" "/foo/bar") => falsey)
(fact
- (path-ns "foo/bar/baz_quux.clj") => 'foo.bar.baz-quux)
+ (path->ns "foo/bar/baz_quux.clj") => 'foo.bar.baz-quux)
(fact
- (str (ns-path 'foo.bar.baz-quux)) => (has-suffix "foo/bar/baz_quux.clj"))
+ (str (ns->path 'foo.bar.baz-quux)) => (has-suffix "foo/bar/baz_quux.clj"))
(fact
(absolute? "/foo/bar") => true
Something went wrong with that request. Please try again.