Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ignore more Emacs file artefacts.

- also remove comment by factoring code better. :-)
  • Loading branch information...
commit 97ce638242d54fe8022147d10231cb5512f55912 1 parent b44895f
@magnars authored
View
6 src/optimus/assets.clj
@@ -2,9 +2,9 @@
(:require [optimus.assets.creation :refer [load-asset]]
[optimus.assets.load-css]))
-(defmethod load-asset "css"
- [public-dir path]
- (optimus.assets.load-css/load-css-asset public-dir path))
+(defmethod load-asset "js" [public-dir path] (optimus.assets.creation/load-text-asset public-dir path))
+(defmethod load-asset "html" [public-dir path] (optimus.assets.creation/load-text-asset public-dir path))
+(defmethod load-asset "css" [public-dir path] (optimus.assets.load-css/load-css-asset public-dir path))
(def create-asset optimus.assets.creation/create-asset)
(def load-assets optimus.assets.creation/load-assets)
View
11 src/optimus/assets/creation.clj
@@ -56,7 +56,7 @@
:get-stream #(io/input-stream resource)
:last-modified (last-modified resource)}))
-(defn- load-text-asset [public-dir path]
+(defn load-text-asset [public-dir path]
(let [resource (existing-resource public-dir path)]
(create-asset path (slurp resource)
:last-modified (last-modified resource))))
@@ -72,10 +72,6 @@
[public-dir path]
(create-binary-asset public-dir path))
-(defmethod load-asset "js" [public-dir path] (load-text-asset public-dir path))
-(defmethod load-asset "html" [public-dir path] (load-text-asset public-dir path))
-;; css is covered by load-css
-
(defn- load-asset-and-refs [public-dir path]
(let [asset (load-asset public-dir path)]
(concat [asset] (mapcat #(load-asset-and-refs public-dir %) (:references asset)))))
@@ -88,7 +84,10 @@
(last (pathetic/split path)))
(defn- emacs-file-artefact? [#^String path]
- (.startsWith (just-the-filename path) ".#"))
+ (let [filename (just-the-filename path)]
+ (or (.startsWith filename ".#")
+ (and (.startsWith filename "#")
+ (.endsWith filename "#")))))
(defn realize-regex-paths [public-dir path]
(if (instance? java.util.regex.Pattern path)
View
3  test/optimus/assets_test.clj
@@ -69,9 +69,10 @@
"Emacs file artifacts are ignored by the regex matcher."
(with-files [["/app/code.js" ""]
+ ["/app/#code.js#" ""]
["/app/.#code.js" ""]]
- (->> (load-assets public-dir [#"/app/.+\.js$"])
+ (->> (load-assets public-dir [#"/app/*"])
(map :path)) => ["/app/code.js"]))
(with-files [["/main.css" "#id { background: url('/bg.png'); }"]
Please sign in to comment.
Something went wrong with that request. Please try again.