 (ns doctopus.doctopus.tentacle
-  (:require [doctopus.shell :refer [make-html git-clone]]
+  (:require [clojure.string :as str]
+            [doctopus.shell :refer [make-html git-clone]]
             [doctopus.storage :refer [save-to-storage load-from-storage backend]]
             [me.raynes.fs :as fs]
             [taoensso.timbre :as log]))

  (load-html [this])
  (generate-html [this])
  (save-build-output [this dir])
  (routes [this]))

(defrecord Tentacle
    [name html-command html-args output-root source-location]
  TentacleMethods
  (load-html [this]
    (if (nil? (load-from-storage backend (:name this)))

  (save-build-output [this dir]
    (let [{:keys [name]} this])
    (save-to-storage backend name dir))
  (get-html-entrypoint [this]
    (str/join "/" ["" "docs" (:name this) (:entry-point this)]))
  (routes [this]
    (load-from-storage backend (:name this))))

