Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

looks like combinations of sets, lists, maps + vecs are good to go

  • Loading branch information...
commit e5ab284ccebacef2ac690a918f184296273977df 1 parent 2c9e977
Gabriel Horner authored
Showing with 18 additions and 5 deletions.
  1. +6 −5 README.md
  2. +12 −0 test/table/core_test.clj
11 README.md
View
@@ -15,23 +15,25 @@ To use as a library:
(use '[table.core :only [table]])
-Or in a repl:
+table handles rendering combinations of maps, vecs, lists and sets nested in one another.
```clojure
$ lein repl
user=> (table [["1" "2"] ["3" "4"]])
+user=> (table '((1 2) (3 4)))
+user=> (table #{[1 2] [3 4]})
+---+---+
| 1 | 2 |
+---+---+
| 3 | 4 |
+---+---+
-user=> (table [{:a 11 :b 22} {:a 3 :b 4}])
+user=> (table [{:a 11} {:a 3 :b 22}])
+----+----+
| a | b |
+----+----+
-| 11 | 22 |
-| 3 | 4 |
+| 11 | |
+| 3 | 22 |
+----+----+
```
@@ -40,7 +42,6 @@ user=> (table [{:a 11 :b 22} {:a 3 :b 4}])
* [doric](https://github.com/joegallo/doric) is more full-featured than print-table, supporting different formats. However it doesn't focus on features I'm interested in or have a thorough-enough test suite.
## TODO
-* Handle sets, lists, anything seqable
* Port features from [hirb](http://github.com/cldwalker/hirb)
* Ellipsis when column width exceeds allowed length
* Custom names for table fields
12 test/table/core_test.clj
View
@@ -106,6 +106,18 @@
")
(table-str '((1 2) (3 4))))))
+(deftest test-table-with-vecs-in-list
+ (is (=
+ (unindent
+ "
+ +---+---+
+ | 1 | 2 |
+ +---+---+
+ | 3 | 4 |
+ +---+---+
+ ")
+ (table-str '([1 2] [3 4])))))
+
(deftest test-table-with-sets-in-vec
(is (=
(unindent
Please sign in to comment.
Something went wrong with that request. Please try again.