filters now work with vectors intead of strings

This commit is contained in:
lukas 2020-03-06 18:38:18 +01:00
parent afeef539b5
commit ee937e05fe
2 changed files with 14 additions and 7 deletions

View file

@ -34,12 +34,19 @@
[ignore-patterns source-list] [ignore-patterns source-list]
(filter #(not (re-matches (re-pattern ignore-patterns) %)) source-list)) (filter #(not (re-matches (re-pattern ignore-patterns) %)) source-list))
(defn filter-one-pattern
[ignore-patterns resources]
(if (not (empty? (:virtual-path (first resources))))
(filter #(not (re-matches ignore-patterns (:virtual-path %))) resources)
resources))
(defn filter-resources-for-ignore-patterns (defn filter-resources-for-ignore-patterns
[ignore-patterns resources] [ignore-patterns resources]
(if ignore-patterns (let [ignore-patterns (into [] ignore-patterns)
(filter #(not (re-matches (re-pattern ignore-patterns) (:virtual-path %))) pattern (peek ignore-patterns)]
resources) (if pattern
resources)) (filter-resources-for-ignore-patterns (pop ignore-patterns) (filter-one-pattern pattern resources))
resources)))
(defn resource-from-cp-or-fs ;:- Resource (defn resource-from-cp-or-fs ;:- Resource
[fs-prefix ;:- Prefix [fs-prefix ;:- Prefix

View file

@ -28,7 +28,7 @@
(sut/get-distinct-markup-dirs (sut/get-distinct-markup-dirs
"./not-existing-get-from-cp" "./not-existing-get-from-cp"
"test_posts" "test_pages" "test_posts" "test_pages"
"")))))) [#""]))))))
(deftest test-create-dirs-from-markup-folders! (deftest test-create-dirs-from-markup-folders!
(is (is
@ -38,7 +38,7 @@
"./not-existing-get-from-cp" "./not-existing-get-from-cp"
"test_posts" "test_posts"
"test_pages" "test_pages"
target-tmp "") target-tmp [#""])
(and (ftt/verify-dir-exists (and (ftt/verify-dir-exists
(str target-tmp "/test_pages")) (str target-tmp "/test_pages"))
(ftt/verify-dir-exists (ftt/verify-dir-exists
@ -50,7 +50,7 @@
(is (is
(let [target-tmp "target/tmp-test-copy-resources-from-theme"] (let [target-tmp "target/tmp-test-copy-resources-from-theme"]
(sut/delete-resources! target-tmp) (sut/delete-resources! target-tmp)
(sut/copy-resources-from-theme! "./" theme target-tmp "") (sut/copy-resources-from-theme! "./" theme target-tmp [#""])
(and (ftt/verify-dir-exists (and (ftt/verify-dir-exists
(str target-tmp "/js")) (str target-tmp "/js"))
(ftt/verify-file-exists (ftt/verify-file-exists