"mob next [ci-skip]"

This commit is contained in:
Jan Krebs 2019-12-13 15:25:52 +01:00
parent c7006a8477
commit 5ad40301bf
2 changed files with 26 additions and 22 deletions

View file

@ -8,7 +8,7 @@
(ns cryogen-core.classpath-able-io (ns cryogen-core.classpath-able-io
(:require [clojure.java.io :as io] (:require [clojure.java.io :as io]
[clojure.string :as s] [clojure.string :as st]
[schema.core :as s])) [schema.core :as s]))
(def public "resources/public") (def public "resources/public")
@ -17,26 +17,13 @@
"Creates path from given parts, ignore empty elements" "Creates path from given parts, ignore empty elements"
[& path-parts] [& path-parts]
(->> path-parts (->> path-parts
(remove s/blank?) (remove st/blank?)
(s/join "/") (st/join "/")
(#(s/replace % #"/+" "/")))) (#(st/replace % #"/+" "/"))))
(defn filter-for-ignore-patterns (defn filter-for-ignore-patterns
[ignore-patterns source-list] [ignore-patterns source-list]
(filter #(not (re-matches ignore-patterns %)) source -list)) (filter #(not (re-matches ignore-patterns %)) source-list))
; TODO: Datenstruktur [s/Str]
(s/defn get-file-paths-recursive :- [s/Str]
[base-path :- s/Str
paths :- [s/Str]]
(loop [paths paths
result []]
(when (not (empty? paths))
(let [path-to-work-with (first paths)
path-content (.list (io/file (str base-path "/" path-to-work-with)))
file-list (filter #(.isFile %) path-content)
dir-list (filter #(not (.isFile %)) path-content)]))))
; (defn delete-file-recursive ; (defn delete-file-recursive
; [folders] ; [folders]
@ -75,6 +62,23 @@
from-fs from-fs
(file-from-cp resource-path)))) (file-from-cp resource-path))))
(s/defn get-file-paths-recursive :- [s/Str]
[fs-prefix :- s/Str
base-path :- s/Str
paths :- [s/Str]]
(loop [paths paths
result []]
(when (not (empty? paths))
(let [path-to-work-with (first paths)
path-content (.list (io/file (file-from-cp-or-filesystem
fs-prefix
(str base-path "/" path-to-work-with))))
file-list (filter #(.isFile (io/file %)) path-content)
dir-list (filter #(not (.isFile %)) path-content)]
(println path-content)
;(println file-list)
(into result file-list)))))
(defn copy-file (defn copy-file
[source-file [source-file
target-file] target-file]

View file

@ -8,11 +8,11 @@
(ns cryogen-core.classpath-able-io-test (ns cryogen-core.classpath-able-io-test
(:require [clojure.test :refer :all] (:require [clojure.test :refer :all]
[clojure.string :as s]
[clojure.java.io :as io] [clojure.java.io :as io]
[schema.core :as s]
[cryogen-core.classpath-able-io :as sut])) [cryogen-core.classpath-able-io :as sut]))
(set-fn-validation! true) (s/set-fn-validation! true)
(def theme "bootstrap4-test") (def theme "bootstrap4-test")
@ -28,7 +28,7 @@
(deftest test-get-file-paths-recursive (deftest test-get-file-paths-recursive
(is (= (is (=
["js/dummy.js"] ["js/dummy.js"]
(sut/get-file-paths-recursive "templates/themes/bootstrap4-test" ["js/dummy.js"])) (sut/get-file-paths-recursive "" "templates/themes/bootstrap4-test" ["js/dummy.js"]))
(is (= (is (=
["/css/dummy.css" ["/css/dummy.css"
"css" "css"
@ -41,7 +41,7 @@
"js/subdir" "js/subdir"
"js/dummy.js" "js/dummy.js"
"js"] "js"]
(sut/get-file-paths-recursive "templates/themes/bootstrap4-test" [""]))))) (sut/get-file-paths-recursive "" "templates/themes/bootstrap4-test" [""])))))
; (deftest test-delete-file-recursive ; (deftest test-delete-file-recursive
; (is ; (is