 (ns clj-formal-specifications-app.examples
   (:require [clojure.string :as str]
             [clojure.java.io :as io]))
-
-; Getting a list of files named public/examples/something.clj is quite a task.
 
 (def example-dir "public/examples/")
 

  (rest (file-seq (io/file (io/resource uri)))))

(defn filename-as-text
  [filename]
  (str/capitalize
   (str/replace (str/replace filename #"_" " ") #".clj" "")))

  [entry]
  (re-matches (re-pattern (str example-dir ".*.clj")) (.getName entry)))

; Getting a list of files named public/examples/something.clj is quite a task.

(defn examples-in-jar
  "Opens a jar file at uri and returns a list of example specification
  files inside of it."
  [uri]
  (with-open [jar (java.util.jar.JarFile. uri)]
    (doall (filter example-entry? (enumeration-seq (.entries jar))))))

(defn get-jar-path
  "If uri points inside to a jar file, returns uri to the jar file itself."
  [uri]
  (re-find #"(?<=jar:file:).+(?=[!])" uri))

