make source type configurable
This commit is contained in:
parent
b6d1b9adcd
commit
24b55040f0
2 changed files with 38 additions and 30 deletions
|
@ -35,21 +35,23 @@
|
||||||
|
|
||||||
(defn create-resource
|
(defn create-resource
|
||||||
([virtual-path
|
([virtual-path
|
||||||
java-path]
|
java-path
|
||||||
|
source-type]
|
||||||
(if (nil? java-path)
|
(if (nil? java-path)
|
||||||
nil
|
nil
|
||||||
{:virtual-path virtual-path
|
{:virtual-path virtual-path
|
||||||
:java-uri (.toUri java-path)
|
:java-uri (.toUri java-path)
|
||||||
:java-path java-path
|
:java-path java-path
|
||||||
:source-type :filesystem
|
:source-type source-type
|
||||||
:resource-type (cond
|
:resource-type (cond
|
||||||
(Files/isDirectory java-path follow-link-option) :dir
|
(Files/isDirectory java-path follow-link-option) :dir
|
||||||
(Files/isRegularFile java-path follow-link-option) :file
|
(Files/isRegularFile java-path follow-link-option) :file
|
||||||
:else :unknown)}))
|
:else :unknown)}))
|
||||||
([fs-prefix
|
([fs-prefix
|
||||||
base-path
|
base-path
|
||||||
virtual-path]
|
virtual-path
|
||||||
(create-resource virtual-path (path-if-exists fs-prefix base-path virtual-path))))
|
source-type]
|
||||||
|
(create-resource virtual-path (path-if-exists fs-prefix base-path virtual-path) source-type)))
|
||||||
|
|
||||||
(defn
|
(defn
|
||||||
list-entries-for-dir
|
list-entries-for-dir
|
||||||
|
@ -57,10 +59,10 @@
|
||||||
(.list (.toFile (:java-path resource))))
|
(.list (.toFile (:java-path resource))))
|
||||||
|
|
||||||
(defn get-resources ;:- [Resource]
|
(defn get-resources ;:- [Resource]
|
||||||
[fs-prefix ;:- Prefix
|
([fs-prefix ;:- Prefix
|
||||||
base-path ;:- VirtualPath
|
base-path ;:- VirtualPath
|
||||||
paths ;:- [VirtualPath]
|
paths ;:- [VirtualPath]
|
||||||
]
|
source-type]
|
||||||
(loop [paths paths
|
(loop [paths paths
|
||||||
result []]
|
result []]
|
||||||
(if (not (empty? paths))
|
(if (not (empty? paths))
|
||||||
|
@ -68,7 +70,8 @@
|
||||||
resource-to-work-with (create-resource
|
resource-to-work-with (create-resource
|
||||||
fs-prefix
|
fs-prefix
|
||||||
base-path
|
base-path
|
||||||
path-to-work-with)
|
path-to-work-with
|
||||||
|
source-type)
|
||||||
result (into result
|
result (into result
|
||||||
[resource-to-work-with])]
|
[resource-to-work-with])]
|
||||||
(cond
|
(cond
|
||||||
|
@ -82,3 +85,8 @@
|
||||||
result)
|
result)
|
||||||
:else []))
|
:else []))
|
||||||
(remove nil? result))))
|
(remove nil? result))))
|
||||||
|
([fs-prefix ;:- Prefix
|
||||||
|
base-path ;:- VirtualPath
|
||||||
|
paths ;:- [VirtualPath]
|
||||||
|
]
|
||||||
|
(get-resources fs-prefix base-path paths :filesystem)))
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
(= ["dummy2" "dummy_from_fs"]
|
(= ["dummy2" "dummy_from_fs"]
|
||||||
(seq
|
(seq
|
||||||
(sut/list-entries-for-dir
|
(sut/list-entries-for-dir
|
||||||
(sut/create-resource "dummy" (sut/path-if-exists fs-root "dummy")))))))
|
(sut/create-resource "dummy" (sut/path-if-exists fs-root "dummy") :filesytem))))))
|
||||||
|
|
||||||
(deftest test-get-resources
|
(deftest test-get-resources
|
||||||
(is
|
(is
|
||||||
|
|
Loading…
Reference in a new issue