Permalink
Browse files

Ignore more Emacs file artefacts.

- also remove comment by factoring code better. :-)
  • Loading branch information...
1 parent b44895f commit 97ce638242d54fe8022147d10231cb5512f55912 @magnars committed Dec 30, 2013
Showing with 10 additions and 10 deletions.
  1. +3 −3 src/optimus/assets.clj
  2. +5 −6 src/optimus/assets/creation.clj
  3. +2 −1 test/optimus/assets_test.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)
@@ -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)
@@ -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'); }"]

0 comments on commit 97ce638

Please sign in to comment.