Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

share clojure count function between clojure & clojurescript file types

  • Loading branch information...
commit 4cda0456b22cebe87a04b0cbf27182eb614452ed 1 parent e946aaf
@Wonko7 Wonko7 authored
Showing with 14 additions and 10 deletions.
  1. +1 −1  src/sloccount/files.clj
  2. +13 −9 src/sloccount/line_types.clj
View
2  src/sloccount/files.clj
@@ -70,7 +70,7 @@
(let [filename (.toString file)]
(or
(and (clojure-file-name? filename) :clojure)
- (and (clojurescript-file-name? filename) :clojurescipt)
+ (and (clojurescript-file-name? filename) :clojurescript)
(and (css-file-name? filename) :css)
(and (html-file-name? filename) :html)
(and (javascript-file-name? filename) :javascript)
View
22 src/sloccount/line_types.clj
@@ -37,16 +37,20 @@
;; line-types Returns a seq of keywords indicating line types
(defmulti line-types sloccount.files/file-type :default :text)
-(defmethod line-types :clojure [file]
+(defn clojure-file-parse [file clojure-dialect]
(with-open [rdr (reader file)]
- (map
- (fn [line]
- (cond
- (blank? line) :blank
- (.startsWith line "#!/") :shebang
- (.startsWith line ";") :comment
- true :clojure))
- (doall (line-seq rdr)))))
+ (map (fn [line]
+ (cond (blank? line) :blank
+ (.startsWith line "#!/") :shebang
+ (.startsWith line ";") :comment
+ :else clojure-dialect))
+ (-> rdr line-seq doall))))
+
+(defmethod line-types :clojure [file]
+ (clojure-file-parse file :clojure))
+
+(defmethod line-types :clojurescript [file]
+ (clojure-file-parse file :clojurescript))
(defmethod line-types :mason-html [file]
(let [state (atom :html)]
Please sign in to comment.
Something went wrong with that request. Please try again.