Skip to content

Commit

Permalink
delay converting to strings
Browse files Browse the repository at this point in the history
  • Loading branch information
joegallo committed Nov 12, 2011
1 parent 3885145 commit 9ad0722
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/doric/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@
(map str data))))))

(defn format-cell [col s]
(str ((:format col) s)))
((:format col) s))

(defn align-cell [col s align]
(let [width (:width col)
s (str s)
s (cond (<= (count s) width) s
(:ellipsis col) (str (subs s 0 (- width 3)) "...")
:else (subs s 0 width))
Expand Down
2 changes: 1 addition & 1 deletion src/doric/csv.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
(def td unaligned-td)

(defn escape [s]
(let [s (.replaceAll s "\"" "\"\"")]
(let [s (.replaceAll (str s) "\"" "\"\"")]
(if (re-find #"[,\n\"]" s)
(str "\"" s "\"")
s)))
Expand Down
2 changes: 1 addition & 1 deletion test/doric/test/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
(is (= 7 (width {:name :foobar} ["foobar2"]))))

(deftest test-format-cell
(is (= "2" (format-cell {:format inc} 1))))
(is (= 2 (format-cell {:format inc} 1))))

(deftest test-align-cell
(is (= "." (align-cell {:width 1} "." :left)))
Expand Down

0 comments on commit 9ad0722

Please sign in to comment.