-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
952b858
commit fb72302
Showing
3 changed files
with
48 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
;; Copyright (c) James Reeves. All rights reserved. | ||
;; The use and distribution terms for this software are covered by the Eclipse | ||
;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which | ||
;; can be found in the file epl-v10.html at the root of this distribution. By | ||
;; using this software in any fashion, you are agreeing to be bound by the | ||
;; terms of this license. You must not remove this notice, or any other, from | ||
;; this software. | ||
|
||
;; fact.main | ||
;; | ||
;; Main method to finds and verify all facts in a directory. | ||
|
||
(ns fact.main | ||
(:gen-class) | ||
(:use fact.core) | ||
(:use fact.output.verbose) | ||
(:import java.io.File)) | ||
|
||
(defn resource-name | ||
"Returns the resource name of the Clojure file, or nil if the file does not | ||
have the .clj extension." | ||
[file] | ||
(second (re-matches #"(.*)\.clj" file))) | ||
|
||
(defn namespace-from-path | ||
"Given a path to a resource, return a symbol of the expected namespace." | ||
[file] | ||
(symbol | ||
(.. (resource-name file) | ||
(replace File/separator ".") | ||
(replace "_" "-")))) | ||
|
||
(defn -main [& files] | ||
(doseq [file files] | ||
(println file) | ||
(load-file file) | ||
(let [ns (namespace-from-path file) | ||
facts (verify-facts ns)] | ||
(when-not (empty? facts) | ||
(println ns) | ||
(print-results facts) | ||
(println))))) |