tabulo 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/README.md +71 -56
  4. data/lib/tabulo/version.rb +1 -1
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ee932d2d03998f4b0e537e8d5302887660326e4
4
- data.tar.gz: 3884ac4f5a066f67819423fd7ca0c86437b7e690
3
+ metadata.gz: 719b6855766058c0b5086c8d04f8e85b03532fcd
4
+ data.tar.gz: ade0250e9e1ae8d136d2863df2a21f8f1efda31e
5
5
  SHA512:
6
- metadata.gz: 23ea187faca64ed1343c42d82db8858bdda1ee219a53e93f6a1d2cb1dc14805d729cc5503e989df30f637ecb10807c59f051d7b48e8bc85527b9035b4b75beba
7
- data.tar.gz: 5170b8b8761296d4cb05d620bf98d9871a94ea32938b32945b98dc72b8f64f3d4fe9bed6df7444727364d0658816abf94e3b21e92065d9a140e9cbbca60e8774
6
+ metadata.gz: ac5a02ca95749e3efcc6209e713b6620aafd416aede395546a45dae337443f932e3f80d7de3084c3f94f8cfed780516892dd54d2a393756a030ccaf6a0eaf8fe
7
+ data.tar.gz: 446462cb31aa4547245ba05cbda0ba47260c9809f8c4de35d545080a1c0d407d99d3f016cdbf4d34f83331dec7b2526b7debb987ca464bc8b46adeee075761ec
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.4.1
4
+
5
+ * Update README to reflect default column width of 12.
6
+
3
7
  ## v0.4.0
4
8
 
5
9
  * Increase default column width from 8 to 12
data/README.md CHANGED
@@ -18,12 +18,12 @@ end
18
18
 
19
19
  ```
20
20
  > puts table
21
- +----------+----------+
22
- | N | Doubled |
23
- +----------+----------+
24
- | 1 | 2 |
25
- | 2 | 4 |
26
- | 50000000 | 10000000 |
21
+ +--------------+--------------+
22
+ | N | Doubled |
23
+ +--------------+--------------+
24
+ | 1 | 2 |
25
+ | 2 | 4 |
26
+ | 5000000 | 10000000 |
27
27
  ```
28
28
 
29
29
  A `Tabulo::Table` is an `Enumerable`, so you can process one row at a time:
@@ -89,17 +89,17 @@ end
89
89
  Or equivalently:
90
90
 
91
91
  ```ruby
92
- Tabulo::Table.new([1, 2, 5], columns: %i(itself even? odd?))
92
+ table = Tabulo::Table.new([1, 2, 5], columns: %i(itself even? odd?))
93
93
  ```
94
94
 
95
95
  ```
96
96
  > puts table
97
- +----------+----------+----------+
98
- | itself | even? | odd? |
99
- +----------+----------+----------+
100
- | 1 | false | true |
101
- | 2 | true | false |
102
- | 5 | false | true |
97
+ +--------------+--------------+--------------+
98
+ | itself | even? | odd? |
99
+ +--------------+--------------+--------------+
100
+ | 1 | false | true |
101
+ | 2 | true | false |
102
+ | 5 | false | true |
103
103
  ```
104
104
 
105
105
  Columns can also be initialized using a callable to which each object will be passed to determine
@@ -116,12 +116,12 @@ end
116
116
 
117
117
  ```
118
118
  > puts table
119
- +----------+----------+----------+
120
- | N | Doubled | odd? |
121
- +----------+----------+----------+
122
- | 1 | 2 | true |
123
- | 2 | 4 | false |
124
- | 5 | 10 | true |
119
+ +--------------+--------------+--------------+
120
+ | N | Doubled | odd? |
121
+ +--------------+--------------+--------------+
122
+ | 1 | 2 | true |
123
+ | 2 | 4 | false |
124
+ | 5 | 10 | true |
125
125
  ```
126
126
 
127
127
  ### Cell alignment
@@ -151,6 +151,15 @@ than 12, use the `column_width` option when initializing the table:
151
151
  Tabulo::Table.new([1, 2], columns: %i(itself even?), column_width: 6)
152
152
  ```
153
153
 
154
+ ```
155
+ > puts table
156
+ +--------+--------+
157
+ | itself | even? |
158
+ +--------+--------+
159
+ | 1 | false |
160
+ | 2 | true |
161
+ ```
162
+
154
163
  The widths set for individual columns will override the default column width for the table.
155
164
 
156
165
  ### Overflow handling
@@ -159,19 +168,21 @@ By default, if cell contents exceed their column width, they are wrapped for as
159
168
  required:
160
169
 
161
170
  ```ruby
162
- table = Tabulo::Table.new(["hello", "abcdefghijklmnopqrstuvwxyz"], columns: %i(itself length))
171
+ table = Tabulo::Table.new(
172
+ ["hello", "abcdefghijklmnopqrstuvwxyz"],
173
+ columns: %i(itself length)
174
+ )
163
175
  ```
164
176
 
165
177
  ```
166
178
  > puts table
167
- +----------+----------+
168
- | itself | length |
169
- +----------+----------+
170
- | hello | 5 |
171
- | abcdefgh | 26 |
172
- | ijklmnop | |
173
- | qrstuvwx | |
174
- | yz | |
179
+ +--------------+--------------+
180
+ | itself | length |
181
+ +--------------+--------------+
182
+ | hello | 5 |
183
+ | abcdefghijkl | 26 |
184
+ | mnopqrstuvwx | |
185
+ | yz | |
175
186
  ```
176
187
 
177
188
  Wrapping behaviour is configured for the table as a whole using the `wrap_header_cells_to` option
@@ -181,16 +192,20 @@ number of rows, with content truncated from that point on. The `~` character is
181
192
  outputted cell content to show that truncation has occurred:
182
193
 
183
194
  ```ruby
184
- table = Tabulo::Table.new(["hello", "abcdefghijklmnopqrstuvwxyz"], wrap_body_cells_to: 1, columns: %i(itself length))
195
+ table = Tabulo::Table.new(
196
+ ["hello", "abcdefghijklmnopqrstuvwxyz"],
197
+ wrap_body_cells_to: 1,
198
+ columns: %i(itself length)
199
+ )
185
200
  ```
186
201
 
187
202
  ```
188
203
  > puts table
189
- +----------+----------+
190
- | itself | length |
191
- +----------+----------+
192
- | hello | 5 |
193
- | abcdefgh~| 26 |
204
+ +--------------+--------------+
205
+ | itself | length |
206
+ +--------------+--------------+
207
+ | hello | 5 |
208
+ | abcdefghijkl~| 26 |
194
209
  ```
195
210
 
196
211
  ### Repeating headers
@@ -208,22 +223,22 @@ table = Tabulo::Table.new(1..10, columns: %i(itself even?), header_frequency: 5)
208
223
 
209
224
  ```
210
225
  > puts table
211
- +----------+----------+
212
- | itself | even? |
213
- +----------+----------+
214
- | 1 | false |
215
- | 2 | true |
216
- | 3 | false |
217
- | 4 | true |
218
- | 5 | false |
219
- +----------+----------+
220
- | itself | even? |
221
- +----------+----------+
222
- | 6 | true |
223
- | 7 | false |
224
- | 8 | true |
225
- | 9 | false |
226
- | 10 | true |
226
+ +--------------+--------------+
227
+ | itself | even? |
228
+ +--------------+--------------+
229
+ | 1 | false |
230
+ | 2 | true |
231
+ | 3 | false |
232
+ | 4 | true |
233
+ | 5 | false |
234
+ +--------------+--------------+
235
+ | itself | even? |
236
+ +--------------+--------------+
237
+ | 6 | true |
238
+ | 7 | false |
239
+ | 8 | true |
240
+ | 9 | false |
241
+ | 10 | true |
227
242
  ```
228
243
 
229
244
  ### Using a Table Enumerator
@@ -235,17 +250,17 @@ for example, you might do this:
235
250
  ```
236
251
  > e = Tabulo::Table.new(User.find_each) do |t|
237
252
  t.add_column(:id)
238
- t.add_column(:email, width: 25)
253
+ t.add_column(:email, width: 24)
239
254
  end.to_enum # <-- make an Enumerator
240
255
  ...
241
256
  > puts e.next
242
- +----------+--------------------------+
243
- | id | email |
244
- +----------+--------------------------+
245
- | 1 | jane@example.com |
257
+ +--------------+--------------------------+
258
+ | id | email |
259
+ +--------------+--------------------------+
260
+ | 1 | jane@example.com |
246
261
  => nil
247
262
  > puts e.next
248
- | 2 | betty@example.net |
263
+ | 2 | betty@example.net |
249
264
  => nil
250
265
  ```
251
266
 
@@ -1,3 +1,3 @@
1
1
  module Tabulo
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tabulo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Harvey