Liking cljdoc? Tell your friends :D

hara.print.table


*properties-file*clj


attach-stateclj

(attach-state {:keys [state initial file log] :as struct})

used with component, adds watch on record that incorporates state

used with component, adds watch on record that incorporates state
raw docstring

detach-stateclj

(detach-state {:keys [state file log] :as struct})

used with component, remove watch on record that incorporates state

used with component, remove watch on record that incorporates state
raw docstring

file-outclj

(file-out atom {:keys [transform] :as opts :or {transform identity}})

adds watch to atom, saving its contents to file on every change

(def out-file (str (fs/create-tmpdir) "/test.txt"))

(swap! (file-out (atom 1) {:path out-file}) inc)

(read-string (slurp out-file)) => 2

adds watch to atom, saving its contents to file on every change

(def out-file (str (fs/create-tmpdir) "/test.txt"))

(swap! (file-out (atom 1) {:path out-file})
       inc)

(read-string (slurp out-file))
=> 2
raw docstring

generate-basic-tableclj

(generate-basic-table rows)
(generate-basic-table ks rows)

generates a table for output

(generate-basic-table [:id :value] [{:id 1 :value "a"} {:id 2 :value "b"}])

=> (ascii ["| :id | :value |" "|-----+--------|" "| 1 | "a" |" "| 2 | "b" |"])

generates a table for output

(generate-basic-table [:id :value]
                      [{:id 1 :value "a"}
                       {:id 2 :value "b"}])

=> (ascii ["| :id | :value |"
           "|-----+--------|"
           "|   1 |    \"a\" |"
           "|   2 |    \"b\" |"])
raw docstring

generate-single-tableclj

(generate-single-table m {:keys [id-key headers sort-key] :as opts})

generates a single table

(generate-single-table {"a@a.com" {:id 1 :value "a"} "b@b.com" {:id 2 :value "b"}} {:headers [:id :email :value] :sort-key :email :id-key :email}) => (ascii ["| :id | :email | :value |" "|-----+-----------+--------|" "| 1 | "a@a.com" | "a" |" "| 2 | "b@b.com" | "b" |"])

generates a single table

(generate-single-table {"a@a.com" {:id 1 :value "a"}
                        "b@b.com" {:id 2 :value "b"}}
                       {:headers [:id :email :value]
                        :sort-key :email
                        :id-key :email})
=> (ascii ["| :id |    :email | :value |"
           "|-----+-----------+--------|"
           "|   1 | \"a@a.com\" |    \"a\" |"
          "|   2 | \"b@b.com\" |    \"b\" |"])
raw docstring

log-outclj

(log-out atom {:keys [transform] :as opts :or {transform identity}})

adds watch to atom, logging the contents on every change

(with-out-str (swap! (log-out (atom 1) {}) inc))

adds watch to atom, logging the contents on every change

(with-out-str
  (swap! (log-out (atom 1) {})
         inc))
raw docstring

parse-basic-tableclj

(parse-basic-table s)

reads a table from a string

(parse-basic-table (ascii ["| :id | :value |" "|-----+--------|" "| 1 | "a" |" "| 2 | "b" |"])) => {:headers [:id :value] :data [{:id 1 :value "a"} {:id 2 :value "b"}]}

reads a table from a string

(parse-basic-table (ascii
                    ["| :id | :value |"
                     "|-----+--------|"
                     "|   1 |    \"a\" |"
                     "|   2 |    \"b\" |"]))
=> {:headers [:id :value]
    :data [{:id 1 :value "a"}
           {:id 2 :value "b"}]}
raw docstring

parse-single-tableclj

(parse-single-table s {:keys [id-key] :as opts})

generates a single table

(parse-single-table (ascii ["| :id | :email | :value |" "|-----+-----------+--------|" "| 1 | "a@a.com" | "a" |" "| 2 | "b@b.com" | "b" |"])

{:headers [:id :email :value] :sort-key :email :id-key :email}) => {"a@a.com" {:id 1 :value "a"} "b@b.com" {:id 2 :value "b"}}

generates a single table

(parse-single-table
 (ascii ["| :id |    :email | :value |"
         "|-----+-----------+--------|"
         "|   1 | \"a@a.com\" |    \"a\" |"
         "|   2 | \"b@b.com\" |    \"b\" |"])
 
 {:headers [:id :email :value]
  :sort-key :email
 :id-key :email})
=> {"a@a.com" {:id 1 :value "a"}
    "b@b.com" {:id 2 :value "b"}}
raw docstring

read-tableclj

(read-table {:keys [path suffix headers levels sort-key id-key body?] :as opts})

generates a single table

(read-table {:path "dev/scratch/test.db" :suffix "txt" :levels 1 :headers {:account [:id :email :value] :info [:id :name]} :sort-key {:info :name} :id-key {:account :email}}) => {:account {"a@a.com" {:id 1 :value "a"} "b@b.com" {:id 2 :value "b"}} :info {1 {:name "Chris"} 2 {:name "David"} 3 {:name "Cain"}}}

generates a single table

 (read-table
  {:path  "dev/scratch/test.db"
   :suffix "txt"
   :levels 1
   :headers {:account [:id :email :value]
             :info    [:id :name]}
   :sort-key {:info :name}
   :id-key {:account :email}})
=> {:account {"a@a.com" {:id 1 :value "a"}
               "b@b.com" {:id 2 :value "b"}}
     :info {1 {:name "Chris"}
            2 {:name "David"}
            3 {:name "Cain"}}}
raw docstring

read-valuecljmultimethod

reads a value from a file

(read-value {:path "dev/scratch/test.db" :format :table}) => {:account {"a@a.com" {:id 1, :value "a"}, "b@b.com" {:id 2, :value "b"}}, :info {3 {:name "Cain"}, 1 {:name "Chris"}, 2 {:name "David"}}}

reads a value from a file

(read-value {:path "dev/scratch/test.db"
             :format :table})
=> {:account {"a@a.com" {:id 1, :value "a"},
              "b@b.com" {:id 2, :value "b"}},
    :info {3 {:name "Cain"},
           1 {:name "Chris"},
           2 {:name "David"}}}
raw docstring

write-tableclj

(write-table data
             {:keys [path suffix headers levels sort-key id-key body?]
              :as opts})

generates a single table

(write-table {:account {"a@a.com" {:id 1 :value "a"} "b@b.com" {:id 2 :value "b"}} :info {1 {:name "Chris"} 2 {:name "David"} 3 {:name "Cain"}}} {:path "dev/scratch/test.db" :suffix "txt" :levels 1 :headers {:account [:id :email :value] :info [:id :name]} :sort-key {:info :name} :id-key {:account :email}}) => {:account (ascii ["| :id | :email | :value |" "|-----+-----------+--------|" "| 1 | "a@a.com" | "a" |" "| 2 | "b@b.com" | "b" |"])

:info (ascii
       ["| :id |   :name |"
        "|-----+---------|"
        "|   3 |  \"Cain\" |"
        "|   1 | \"Chris\" |"
        "|   2 | \"David\" |"])}
generates a single table

(write-table
 {:account {"a@a.com" {:id 1 :value "a"}
            "b@b.com" {:id 2 :value "b"}}
  :info {1 {:name "Chris"}
         2 {:name "David"}
         3 {:name "Cain"}}}
 {:path   "dev/scratch/test.db"
  :suffix "txt"
 :levels 1
  :headers {:account [:id :email :value]
            :info    [:id :name]}
  :sort-key {:info :name}
  :id-key {:account :email}})
=> {:account (ascii
              ["| :id |    :email | :value |"
               "|-----+-----------+--------|"
               "|   1 | \"a@a.com\" |    \"a\" |"
               "|   2 | \"b@b.com\" |    \"b\" |"])

    :info (ascii
           ["| :id |   :name |"
            "|-----+---------|"
            "|   3 |  \"Cain\" |"
            "|   1 | \"Chris\" |"
            "|   2 | \"David\" |"])}
raw docstring

write-valuecljmultimethod

write a value to file

(write-value {:account {"a@a.com" {:id 1 :value "a"} "b@b.com" {:id 2 :value "b"}} :info {3 {:name "Cain"} 1 {:name "Chris"} 2 {:name "David"}}} {:path "dev/scratch/test.db" :format :table :suffix "txt" :levels 1 :headers {:account [:id :email :value] :info [:id :name]} :sort-key {:info :name} :id-key {:account :email}})

write a value to file

(write-value {:account {"a@a.com" {:id 1 :value "a"}
                        "b@b.com" {:id 2 :value "b"}}
              :info {3 {:name "Cain"}
                     1 {:name "Chris"}
                    2 {:name "David"}}}
             {:path "dev/scratch/test.db"
              :format :table
              :suffix "txt"
              :levels 1
              :headers  {:account [:id :email :value]
                         :info    [:id :name]}
              :sort-key {:info    :name}
              :id-key   {:account :email}})
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close