columnize 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +236 -59
- data/NEWS +6 -1
- data/{README → README.md} +8 -7
- data/Rakefile +13 -5
- data/lib/columnize.rb +43 -20
- data/lib/version.rb +1 -1
- data/test/test-columnize.rb +1 -1
- data/test/test-hashparm.rb +26 -0
- metadata +28 -26
data/ChangeLog
CHANGED
|
@@ -1,101 +1,278 @@
|
|
|
1
|
-
|
|
1
|
+
2011-04-27 r <rocky@gnu.org>
|
|
2
2
|
|
|
3
|
-
*
|
|
3
|
+
* README.md: Fix code example.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
2011-04-27 r <rocky@gnu.org>
|
|
6
6
|
|
|
7
|
-
*
|
|
7
|
+
* .gemspec, README, README.md, Rakefile: README->README.md
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
2011-04-27 r <rocky@gnu.org>
|
|
10
10
|
|
|
11
|
-
*
|
|
12
|
-
|
|
11
|
+
* .gemspec, AUTHORS, COPYING, ChangeLog, Makefile, NEWS, README,
|
|
12
|
+
Rakefile, lib/Makefile, lib/columnize.rb, lib/version.rb,
|
|
13
|
+
tags/release-0.2.1/AUTHORS, tags/release-0.2.1/COPYING,
|
|
14
|
+
tags/release-0.2.1/ChangeLog, tags/release-0.2.1/NEWS,
|
|
15
|
+
tags/release-0.2.1/README, tags/release-0.2.1/Rakefile,
|
|
16
|
+
tags/release-0.2.1/VERSION, tags/release-0.2.1/lib/columnize.rb,
|
|
17
|
+
tags/release-0.2.1/test/test-columnize.rb,
|
|
18
|
+
tags/release-0.3.0/AUTHORS, tags/release-0.3.0/COPYING,
|
|
19
|
+
tags/release-0.3.0/ChangeLog, tags/release-0.3.0/NEWS,
|
|
20
|
+
tags/release-0.3.0/README, tags/release-0.3.0/Rakefile,
|
|
21
|
+
tags/release-0.3.0/VERSION, tags/release-0.3.0/lib/columnize.rb,
|
|
22
|
+
tags/release-0.3.0/test/test-columnize.rb,
|
|
23
|
+
tags/release-0.3.1/AUTHORS, tags/release-0.3.1/COPYING,
|
|
24
|
+
tags/release-0.3.1/ChangeLog, tags/release-0.3.1/NEWS,
|
|
25
|
+
tags/release-0.3.1/README, tags/release-0.3.1/Rakefile,
|
|
26
|
+
tags/release-0.3.1/VERSION, tags/release-0.3.1/lib/columnize.rb,
|
|
27
|
+
tags/release-0.3.1/test/test-columnize.rb, test/test-columnize.rb,
|
|
28
|
+
test/test-hashparm.rb, trunk/.gemspec, trunk/AUTHORS,
|
|
29
|
+
trunk/COPYING, trunk/ChangeLog, trunk/Makefile, trunk/NEWS,
|
|
30
|
+
trunk/README, trunk/Rakefile, trunk/lib/Makefile,
|
|
31
|
+
trunk/lib/columnize.rb, trunk/lib/version.rb,
|
|
32
|
+
trunk/test/test-columnize.rb, trunk/test/test-hashparm.rb: Remove
|
|
33
|
+
trunk and tags.
|
|
13
34
|
|
|
14
|
-
|
|
35
|
+
2011-04-27 rockyb <rockyb>
|
|
15
36
|
|
|
16
|
-
* ChangeLog, lib/columnize.rb
|
|
37
|
+
* trunk/ChangeLog, trunk/lib/columnize.rb, trunk/lib/version.rb,
|
|
38
|
+
trunk/test/test-columnize.rb, trunk/test/test-hashparm.rb: Redo
|
|
39
|
+
columnize options processing to allow for a single hash of options
|
|
40
|
+
instead of the numerous optional arguments. This make future
|
|
41
|
+
expansion easier.
|
|
17
42
|
|
|
18
|
-
|
|
43
|
+
2010-09-22 rockyb <rockyb>
|
|
19
44
|
|
|
20
|
-
* Rakefile:
|
|
45
|
+
* trunk/Makefile, trunk/Rakefile: Rakefile: Remove bad test task
|
|
46
|
+
Makefile: simplify.
|
|
21
47
|
|
|
22
|
-
|
|
48
|
+
2010-09-21 rockyb <rockyb>
|
|
23
49
|
|
|
24
|
-
*
|
|
25
|
-
like no one reads this stuff.
|
|
50
|
+
* trunk/Makefile, trunk/Rakefile: Makefile was a little off
|
|
26
51
|
|
|
27
|
-
|
|
52
|
+
2010-09-21 rockyb <rockyb>
|
|
28
53
|
|
|
29
|
-
*
|
|
54
|
+
* trunk/.gemspec, trunk/Rakefile, trunk/lib/columnize.rb: Small
|
|
55
|
+
changes to Rakefile and rdoc and so on.
|
|
30
56
|
|
|
31
|
-
|
|
57
|
+
2010-09-20 rockyb <rockyb>
|
|
32
58
|
|
|
33
|
-
*
|
|
34
|
-
test/test-columnize.rb: Fix bad bug in arranging horizontally
|
|
59
|
+
* trunk/.gemspec, trunk/Rakefile: Forgot to add .gemspec
|
|
35
60
|
|
|
36
|
-
|
|
61
|
+
2010-09-20 rockyb <rockyb>
|
|
37
62
|
|
|
38
|
-
*
|
|
63
|
+
* trunk/ChangeLog, trunk/Makefile, trunk/NEWS, trunk/README,
|
|
64
|
+
trunk/Rakefile, trunk/VERSION, trunk/lib/Makefile,
|
|
65
|
+
trunk/lib/columnize.rb, trunk/lib/version.rb: Add .gemspec, correct
|
|
66
|
+
description field and add a summary. Add Columnize::VERSION Simplify
|
|
67
|
+
Rakefile Add stub Makefiles
|
|
39
68
|
|
|
40
|
-
|
|
69
|
+
2010-03-01 rockyb <rockyb>
|
|
41
70
|
|
|
42
|
-
*
|
|
71
|
+
* trunk/README: Better README description
|
|
43
72
|
|
|
44
|
-
|
|
73
|
+
2010-03-01 rockyb <rockyb>
|
|
45
74
|
|
|
46
|
-
*
|
|
75
|
+
* trunk/README: Update README
|
|
47
76
|
|
|
48
|
-
|
|
77
|
+
2010-02-22 rockyb <rockyb>
|
|
49
78
|
|
|
50
|
-
* ChangeLog,
|
|
51
|
-
|
|
79
|
+
* trunk/ChangeLog, trunk/VERSION, trunk/lib/columnize.rb: Remove
|
|
80
|
+
shadow variable warnings. Bump version number
|
|
52
81
|
|
|
53
|
-
|
|
82
|
+
2009-07-26 rockyb <rockyb>
|
|
54
83
|
|
|
55
|
-
*
|
|
84
|
+
* tags/release-0.3.1/AUTHORS, tags/release-0.3.1/COPYING,
|
|
85
|
+
tags/release-0.3.1/ChangeLog, tags/release-0.3.1/NEWS,
|
|
86
|
+
tags/release-0.3.1/README, tags/release-0.3.1/Rakefile,
|
|
87
|
+
tags/release-0.3.1/VERSION, tags/release-0.3.1/lib/columnize.rb,
|
|
88
|
+
tags/release-0.3.1/test/test-columnize.rb: Release 0.3.1
|
|
56
89
|
|
|
57
|
-
|
|
90
|
+
2009-07-26 rockyb <rockyb>
|
|
58
91
|
|
|
59
|
-
* lib/columnize.rb:
|
|
60
|
-
and rcov has an option)
|
|
92
|
+
* trunk/lib/columnize.rb: Small comment spelling typo.
|
|
61
93
|
|
|
62
|
-
|
|
94
|
+
2009-07-26 rockyb <rockyb>
|
|
63
95
|
|
|
64
|
-
*
|
|
96
|
+
* trunk/ChangeLog: Get ready for 0.3.1 release
|
|
65
97
|
|
|
66
|
-
|
|
98
|
+
2009-07-26 rockyb <rockyb>
|
|
67
99
|
|
|
68
|
-
*
|
|
69
|
-
|
|
100
|
+
* trunk/NEWS, trunk/lib/columnize.rb, trunk/test/test-columnize.rb:
|
|
101
|
+
Add lineprefix. Get ready for release.
|
|
70
102
|
|
|
71
|
-
|
|
103
|
+
2009-07-26 mark-moseley <mark-moseley>
|
|
72
104
|
|
|
73
|
-
* lib/columnize.rb:
|
|
105
|
+
* trunk/ChangeLog, trunk/lib/columnize.rb: Ruby 1.9 updates
|
|
74
106
|
|
|
75
|
-
|
|
107
|
+
2009-03-30 rockyb <rockyb>
|
|
76
108
|
|
|
77
|
-
*
|
|
78
|
-
columnize.rb: Allow one to specify a separator string. Remove
|
|
79
|
-
restriction that
|
|
80
|
-
all entries in the array have to be a string.
|
|
81
|
-
test-columnize.rb: more tests - invalid list, empty list, with
|
|
82
|
-
separator
|
|
83
|
-
string parameter.
|
|
109
|
+
* trunk/Rakefile: Revise for 1.9 version of rake
|
|
84
110
|
|
|
85
|
-
|
|
111
|
+
2009-01-16 rockyb <rockyb>
|
|
86
112
|
|
|
87
|
-
*
|
|
113
|
+
* trunk/ChangeLog, trunk/Rakefile, trunk/VERSION: package readme was
|
|
114
|
+
wonky. Looks like no one reads this stuff.
|
|
88
115
|
|
|
89
|
-
|
|
116
|
+
2009-01-10 rockyb <rockyb>
|
|
90
117
|
|
|
91
|
-
*
|
|
92
|
-
|
|
93
|
-
|
|
118
|
+
* tags/release-0.3.0/AUTHORS, tags/release-0.3.0/COPYING,
|
|
119
|
+
tags/release-0.3.0/ChangeLog, tags/release-0.3.0/NEWS,
|
|
120
|
+
tags/release-0.3.0/README, tags/release-0.3.0/Rakefile,
|
|
121
|
+
tags/release-0.3.0/VERSION, tags/release-0.3.0/lib/columnize.rb,
|
|
122
|
+
tags/release-0.3.0/test/test-columnize.rb: Release 0.3.0
|
|
94
123
|
|
|
95
|
-
|
|
124
|
+
2009-01-10 rockyb <rockyb>
|
|
96
125
|
|
|
97
|
-
*
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
126
|
+
* trunk/ChangeLog, trunk/NEWS: Get ready for release
|
|
127
|
+
|
|
128
|
+
2009-01-08 rockyb <rockyb>
|
|
129
|
+
|
|
130
|
+
* trunk/ChangeLog, trunk/NEWS, trunk/VERSION,
|
|
131
|
+
trunk/lib/columnize.rb, trunk/test/test-columnize.rb: Fix bad bug in
|
|
132
|
+
arranging horizontally
|
|
133
|
+
|
|
134
|
+
2009-01-01 rockyb <rockyb>
|
|
135
|
+
|
|
136
|
+
* columnize/trunk/AUTHORS, columnize/trunk/COPYING,
|
|
137
|
+
columnize/trunk/ChangeLog, columnize/trunk/NEWS,
|
|
138
|
+
columnize/trunk/README, columnize/trunk/Rakefile,
|
|
139
|
+
columnize/trunk/VERSION, columnize/trunk/lib/columnize.rb,
|
|
140
|
+
columnize/trunk/test/test-columnize.rb: Remove hacky
|
|
141
|
+
columnize/columnize
|
|
142
|
+
|
|
143
|
+
2009-01-01 rockyb <rockyb>
|
|
144
|
+
|
|
145
|
+
* tags/columnize-0.2/AUTHORS, tags/columnize-0.2/COPYING,
|
|
146
|
+
tags/columnize-0.2/ChangeLog, tags/columnize-0.2/NEWS,
|
|
147
|
+
tags/columnize-0.2/README, tags/columnize-0.2/Rakefile,
|
|
148
|
+
tags/columnize-0.2/VERSION, tags/columnize-0.2/lib/columnize.rb,
|
|
149
|
+
tags/columnize-0.2/test/test-columnize.rb: Regularize tags names
|
|
150
|
+
better
|
|
151
|
+
|
|
152
|
+
2009-01-01 rockyb <rockyb>
|
|
153
|
+
|
|
154
|
+
* tags/release-0.2.1/AUTHORS, tags/release-0.2.1/COPYING,
|
|
155
|
+
tags/release-0.2.1/ChangeLog, tags/release-0.2.1/NEWS,
|
|
156
|
+
tags/release-0.2.1/README, tags/release-0.2.1/Rakefile,
|
|
157
|
+
tags/release-0.2.1/VERSION, tags/release-0.2.1/lib/columnize.rb,
|
|
158
|
+
tags/release-0.2.1/test/test-columnize.rb: Release 0.2.1
|
|
159
|
+
|
|
160
|
+
2009-01-01 rockyb <rockyb>
|
|
161
|
+
|
|
162
|
+
* trunk/NEWS: Merge NEWS
|
|
163
|
+
|
|
164
|
+
2009-01-01 rockyb <rockyb>
|
|
165
|
+
|
|
166
|
+
* columnize/tags/columnize-0.2/AUTHORS,
|
|
167
|
+
columnize/tags/columnize-0.2/COPYING,
|
|
168
|
+
columnize/tags/columnize-0.2/ChangeLog,
|
|
169
|
+
columnize/tags/columnize-0.2/NEWS,
|
|
170
|
+
columnize/tags/columnize-0.2/README,
|
|
171
|
+
columnize/tags/columnize-0.2/Rakefile,
|
|
172
|
+
columnize/tags/columnize-0.2/VERSION,
|
|
173
|
+
columnize/tags/columnize-0.2/lib/columnize.rb,
|
|
174
|
+
columnize/tags/columnize-0.2/test/test-columnize.rb,
|
|
175
|
+
tags/columnize-0.2/AUTHORS, tags/columnize-0.2/COPYING,
|
|
176
|
+
tags/columnize-0.2/ChangeLog, tags/columnize-0.2/NEWS,
|
|
177
|
+
tags/columnize-0.2/README, tags/columnize-0.2/Rakefile,
|
|
178
|
+
tags/columnize-0.2/VERSION, tags/columnize-0.2/lib/columnize.rb,
|
|
179
|
+
tags/columnize-0.2/test/test-columnize.rb: Cleanup of
|
|
180
|
+
columnize/columnize crap
|
|
181
|
+
|
|
182
|
+
2009-01-01 rockyb <rockyb>
|
|
183
|
+
|
|
184
|
+
* : Add directory for releases
|
|
185
|
+
|
|
186
|
+
2009-01-01 rockyb <rockyb>
|
|
187
|
+
|
|
188
|
+
* trunk/NEWS, trunk/VERSION: Ooops 0.2 release done. Go for 0.2.1
|
|
189
|
+
|
|
190
|
+
2009-01-01 rockyb <rockyb>
|
|
191
|
+
|
|
192
|
+
* trunk/ChangeLog: Get ready for release 0.2
|
|
193
|
+
|
|
194
|
+
2009-01-01 rockyb <rockyb>
|
|
195
|
+
|
|
196
|
+
* trunk/ChangeLog, trunk/NEWS, trunk/VERSION,
|
|
197
|
+
trunk/lib/columnize.rb, trunk/test/test-columnize.rb: Get ready for
|
|
198
|
+
release 0.2
|
|
199
|
+
|
|
200
|
+
2008-09-22 rockyb <rockyb>
|
|
201
|
+
|
|
202
|
+
* columnize/tags/columnize-0.2/AUTHORS,
|
|
203
|
+
columnize/tags/columnize-0.2/COPYING,
|
|
204
|
+
columnize/tags/columnize-0.2/ChangeLog,
|
|
205
|
+
columnize/tags/columnize-0.2/NEWS,
|
|
206
|
+
columnize/tags/columnize-0.2/README,
|
|
207
|
+
columnize/tags/columnize-0.2/Rakefile,
|
|
208
|
+
columnize/tags/columnize-0.2/VERSION,
|
|
209
|
+
columnize/tags/columnize-0.2/lib/columnize.rb,
|
|
210
|
+
columnize/tags/columnize-0.2/test/test-columnize.rb: Tag 0.2
|
|
211
|
+
release.
|
|
212
|
+
|
|
213
|
+
2008-09-22 rockyb <rockyb>
|
|
214
|
+
|
|
215
|
+
* : Add tags directory for release
|
|
216
|
+
|
|
217
|
+
2008-09-22 rockyb <rockyb>
|
|
218
|
+
|
|
219
|
+
* columnize/trunk/ChangeLog, columnize/trunk/NEWS: Add directory for
|
|
220
|
+
tagging releases. Other Administrivia.
|
|
221
|
+
|
|
222
|
+
2008-09-22 rockyb <rockyb>
|
|
223
|
+
|
|
224
|
+
* columnize/trunk/VERSION, columnize/trunk/lib/columnize.rb: Get rid
|
|
225
|
+
of hacky $0 test.
|
|
226
|
+
|
|
227
|
+
2008-03-16 rockyb <rockyb>
|
|
228
|
+
|
|
229
|
+
* trunk/lib/columnize.rb: [no log message]
|
|
230
|
+
|
|
231
|
+
2008-03-16 rockyb <rockyb>
|
|
232
|
+
|
|
233
|
+
* trunk/lib/columnize.rb: Simplify __FILE__ == $0. (rdebug now
|
|
234
|
+
changes $0 and rcov has an option)
|
|
235
|
+
|
|
236
|
+
2008-02-11 rockyb <rockyb>
|
|
237
|
+
|
|
238
|
+
* trunk/lib/columnize.rb: Remove 1.9's shadow warning
|
|
239
|
+
|
|
240
|
+
2007-12-10 rockyb <rockyb>
|
|
241
|
+
|
|
242
|
+
* columnize/trunk/AUTHORS, columnize/trunk/COPYING,
|
|
243
|
+
columnize/trunk/ChangeLog, columnize/trunk/NEWS,
|
|
244
|
+
columnize/trunk/README, columnize/trunk/Rakefile,
|
|
245
|
+
columnize/trunk/VERSION, columnize/trunk/lib/columnize.rb,
|
|
246
|
+
columnize/trunk/test/test-columnize.rb: release 0.1
|
|
247
|
+
|
|
248
|
+
2007-12-09 rockyb <rockyb>
|
|
249
|
+
|
|
250
|
+
* trunk/README, trunk/Rakefile: Fix up doc a little. Make the
|
|
251
|
+
default rake task "test".
|
|
252
|
+
|
|
253
|
+
2007-12-09 rockyb <rockyb>
|
|
254
|
+
|
|
255
|
+
* trunk/lib/columnize.rb: Doc fix.
|
|
256
|
+
|
|
257
|
+
2007-12-09 rockyb <rockyb>
|
|
258
|
+
|
|
259
|
+
* trunk/ChangeLog, trunk/lib/columnize.rb,
|
|
260
|
+
trunk/test/test-columnize.rb: columnize.rb: Allow one to specify a
|
|
261
|
+
separator string. Remove restriction that all entries in the array
|
|
262
|
+
have to be a string. test-columnize.rb: more tests - invalid list,
|
|
263
|
+
empty list, with separator string parameter.
|
|
264
|
+
|
|
265
|
+
2007-12-09 rockyb <rockyb>
|
|
266
|
+
|
|
267
|
+
* trunk/test/test-columnize.rb: Typo.
|
|
268
|
+
|
|
269
|
+
2007-12-09 rockyb <rockyb>
|
|
270
|
+
|
|
271
|
+
* : Property changes for Id lines and to make test-columnize.rb
|
|
272
|
+
executable.
|
|
273
|
+
|
|
274
|
+
2007-12-09 rockyb <rockyb>
|
|
275
|
+
|
|
276
|
+
* Initial release of Columnize, a module to print an Array in
|
|
277
|
+
column-sorted order.
|
|
101
278
|
|
data/NEWS
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
0.3.3 June 12, 2011 Fleetwood release
|
|
2
|
+
|
|
3
|
+
- More general but simpler inteface using an options
|
|
4
|
+
hash. Compatibility is maintaind though.
|
|
5
|
+
|
|
1
6
|
0.3.2
|
|
2
7
|
|
|
3
8
|
- Mostly Administrivia.
|
|
@@ -29,4 +34,4 @@
|
|
|
29
34
|
- Initial release of Columnize, a module to print an Array in
|
|
30
35
|
column-sorted order
|
|
31
36
|
|
|
32
|
-
$Id
|
|
37
|
+
$Id$
|
data/{README → README.md}
RENAMED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
# Columnize - Module to show an Array formatted as a String aligned in columns.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Summary
|
|
4
4
|
|
|
5
5
|
In showing a long lists, sometimes one would prefer to see the value
|
|
6
6
|
arranged aligned in columns. Some examples include listing methods
|
|
7
7
|
of an object or debugger commands.
|
|
8
8
|
|
|
9
|
+
```
|
|
9
10
|
require 'columnize'
|
|
10
11
|
columnize([1, 2, 3])
|
|
11
12
|
1 2 3
|
|
@@ -19,19 +20,19 @@
|
|
|
19
20
|
5 12 19 26 33 40 47 54 61 68 75 82 89 96
|
|
20
21
|
6 13 20 27 34 41 48 55 62 69 76 83 90 97
|
|
21
22
|
7 14 21 28 35 42 49 56 63 70 77 84 91 98
|
|
23
|
+
```
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
== Credits
|
|
25
|
+
## Credits
|
|
25
26
|
|
|
26
27
|
This is adapted from a method of the same name from Python's cmd module.
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
## Other stuff
|
|
29
30
|
|
|
30
31
|
Author:: Rocky Bernstein <rockyb@rubyforge.net>
|
|
31
|
-
License:: Copyright (c) 2007 Rocky Bernstein
|
|
32
|
+
License:: Copyright (c) 2007, 2011 Rocky Bernstein
|
|
32
33
|
Released under the GNU GPL 2 license
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
## Warranty
|
|
35
36
|
|
|
36
37
|
This program is distributed in the hope that it will be useful,
|
|
37
38
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
data/Rakefile
CHANGED
|
@@ -41,15 +41,23 @@ task :test => :lib
|
|
|
41
41
|
desc "same as test"
|
|
42
42
|
task :check => :test
|
|
43
43
|
|
|
44
|
-
desc
|
|
44
|
+
desc 'Create a GNU-style ChangeLog via git2cl'
|
|
45
45
|
task :ChangeLog do
|
|
46
|
-
system(
|
|
46
|
+
system('git log --pretty --numstat --summary | git2cl > ChangeLog')
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
task :default => [:test]
|
|
50
50
|
|
|
51
|
+
task :clobber_rdoc do
|
|
52
|
+
FileUtils.rm_rf File.join(ROOT_DIR, 'doc')
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
task :rm_patch_residue do
|
|
56
|
+
FileUtils.rm_rf FileList['**/*.{rej,orig}'].to_a
|
|
57
|
+
end
|
|
58
|
+
|
|
51
59
|
desc "Remove built files"
|
|
52
|
-
task :clean => [:clobber_package, :clobber_rdoc]
|
|
60
|
+
task :clean => [:clobber_package, :clobber_rdoc, :rm_patch_residue]
|
|
53
61
|
|
|
54
62
|
desc "Generate the gemspec"
|
|
55
63
|
task :generate do
|
|
@@ -68,9 +76,9 @@ Rake::RDocTask.new("rdoc") do |rdoc|
|
|
|
68
76
|
rdoc.title = "Columnize #{Columnize::VERSION} Documentation"
|
|
69
77
|
|
|
70
78
|
# Make the README file the start page for the generated html
|
|
71
|
-
rdoc.options += %w(--main README)
|
|
79
|
+
rdoc.options += %w(--main README.md)
|
|
72
80
|
|
|
73
|
-
rdoc.rdoc_files.include('lib/*.rb', 'README', 'COPYING')
|
|
81
|
+
rdoc.rdoc_files.include('lib/*.rb', 'README.md', 'COPYING')
|
|
74
82
|
end
|
|
75
83
|
desc "Same as rdoc"
|
|
76
84
|
task :doc => :rdoc
|
data/lib/columnize.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
# Copyright (C) 2007, 2008, 2009, 2010 Rocky Bernstein
|
|
1
|
+
# Copyright (C) 2007, 2008, 2009, 2010, 2011 Rocky Bernstein
|
|
2
|
+
# <rockyb@rubyforge.net>
|
|
2
3
|
#
|
|
3
4
|
# This program is free software; you can redistribute it and/or modify
|
|
4
5
|
# it under the terms of the GNU General Public License as published by
|
|
@@ -39,6 +40,29 @@
|
|
|
39
40
|
|
|
40
41
|
module Columnize
|
|
41
42
|
|
|
43
|
+
DEFAULT_OPTS = {
|
|
44
|
+
:displaywidth => 80,
|
|
45
|
+
:colsep => ' ',
|
|
46
|
+
:ljust => true,
|
|
47
|
+
:lineprefix => '',
|
|
48
|
+
:arrange_vertical => true
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module_function
|
|
52
|
+
def parse_columnize_options(args)
|
|
53
|
+
list = args.shift
|
|
54
|
+
if 1 == args.size && args[0].kind_of?(Hash)
|
|
55
|
+
return list, DEFAULT_OPTS.merge(args[0])
|
|
56
|
+
else
|
|
57
|
+
opts = DEFAULT_OPTS.dup
|
|
58
|
+
%w(displaywidth colsep arrange_vertical ljust lineprefix).each do |field|
|
|
59
|
+
break if args.empty?
|
|
60
|
+
opts[field.to_sym] = args.shift
|
|
61
|
+
end
|
|
62
|
+
return list, opts
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
42
66
|
# Return a list of strings with embedded newlines (\n) as a compact
|
|
43
67
|
# set of columns arranged horizontally or vertically.
|
|
44
68
|
#
|
|
@@ -55,9 +79,9 @@ module Columnize
|
|
|
55
79
|
# columns. If +arrange_vertical+ is set false, consecutive items
|
|
56
80
|
# will go across, left to right, top to bottom.
|
|
57
81
|
|
|
58
|
-
def columnize(
|
|
59
|
-
arrange_vertical=true, ljust=true, lineprefix='')
|
|
82
|
+
def columnize(*args)
|
|
60
83
|
|
|
84
|
+
list, opts = parse_columnize_options(args)
|
|
61
85
|
# Some degenerate cases
|
|
62
86
|
if not list.is_a?(Array)
|
|
63
87
|
return ''
|
|
@@ -72,15 +96,15 @@ module Columnize
|
|
|
72
96
|
|
|
73
97
|
nrows = ncols = 0 # Make nrows, ncols have more global scope
|
|
74
98
|
colwidths = [] # Same for colwidths
|
|
75
|
-
displaywidth = [4, displaywidth - lineprefix.length].max
|
|
76
|
-
if arrange_vertical
|
|
99
|
+
opts[:displaywidth] = [4, opts[:displaywidth] - opts[:lineprefix].length].max
|
|
100
|
+
if opts[:arrange_vertical]
|
|
77
101
|
array_index = lambda {|num_rows, row, col| num_rows*col + row }
|
|
78
102
|
# Try every row count from 1 upwards
|
|
79
103
|
1.upto(l.size-1) do |_nrows|
|
|
80
104
|
nrows = _nrows
|
|
81
105
|
ncols = (l.size + nrows-1) / nrows
|
|
82
106
|
colwidths = []
|
|
83
|
-
totwidth = -colsep.length
|
|
107
|
+
totwidth = -opts[:colsep].length
|
|
84
108
|
|
|
85
109
|
0.upto(ncols-1) do |_col|
|
|
86
110
|
col = _col
|
|
@@ -95,13 +119,13 @@ module Columnize
|
|
|
95
119
|
colwidth = [colwidth, l[i].size].max
|
|
96
120
|
end
|
|
97
121
|
colwidths << colwidth
|
|
98
|
-
totwidth += colwidth + colsep.length
|
|
99
|
-
if totwidth > displaywidth
|
|
122
|
+
totwidth += colwidth + opts[:colsep].length
|
|
123
|
+
if totwidth > opts[:displaywidth]
|
|
100
124
|
ncols = col
|
|
101
125
|
break
|
|
102
126
|
end
|
|
103
127
|
end
|
|
104
|
-
if totwidth <= displaywidth
|
|
128
|
+
if totwidth <= opts[:displaywidth]
|
|
105
129
|
break
|
|
106
130
|
end
|
|
107
131
|
end
|
|
@@ -129,13 +153,13 @@ module Columnize
|
|
|
129
153
|
if texts.size > 0
|
|
130
154
|
0.upto(texts.size-1) do |_col|
|
|
131
155
|
col = _col
|
|
132
|
-
if ljust
|
|
156
|
+
if opts[:ljust]
|
|
133
157
|
texts[col] = texts[col].ljust(colwidths[col])
|
|
134
158
|
else
|
|
135
159
|
texts[col] = texts[col].rjust(colwidths[col])
|
|
136
160
|
end
|
|
137
161
|
end
|
|
138
|
-
s += "%s%s\n" % [lineprefix, texts.join(colsep)]
|
|
162
|
+
s += "%s%s\n" % [opts[:lineprefix], texts.join(opts[:colsep])]
|
|
139
163
|
end
|
|
140
164
|
end
|
|
141
165
|
return s
|
|
@@ -152,7 +176,7 @@ module Columnize
|
|
|
152
176
|
nrows = _nrows
|
|
153
177
|
rounded_size = nrows * ncols
|
|
154
178
|
colwidths = []
|
|
155
|
-
totwidth = -colsep.length
|
|
179
|
+
totwidth = -opts[:colsep].length
|
|
156
180
|
colwidth = row = 0
|
|
157
181
|
0.upto(ncols-1) do |_col|
|
|
158
182
|
col = _col
|
|
@@ -167,21 +191,21 @@ module Columnize
|
|
|
167
191
|
end
|
|
168
192
|
end
|
|
169
193
|
colwidths << colwidth
|
|
170
|
-
totwidth += colwidth + colsep.length
|
|
171
|
-
if totwidth > displaywidth
|
|
194
|
+
totwidth += colwidth + opts[:colsep].length
|
|
195
|
+
if totwidth > opts[:displaywidth]
|
|
172
196
|
break
|
|
173
197
|
end
|
|
174
198
|
end
|
|
175
|
-
if totwidth <= displaywidth
|
|
199
|
+
if totwidth <= opts[:displaywidth]
|
|
176
200
|
# Found the right nrows and ncols
|
|
177
201
|
nrows = row
|
|
178
202
|
break
|
|
179
|
-
elsif totwidth >= displaywidth
|
|
203
|
+
elsif totwidth >= opts[:displaywidth]
|
|
180
204
|
# Need to reduce ncols
|
|
181
205
|
break
|
|
182
206
|
end
|
|
183
207
|
end
|
|
184
|
-
if totwidth <= displaywidth and i >= rounded_size-1
|
|
208
|
+
if totwidth <= opts[:displaywidth] and i >= rounded_size-1
|
|
185
209
|
break
|
|
186
210
|
end
|
|
187
211
|
end
|
|
@@ -202,18 +226,17 @@ module Columnize
|
|
|
202
226
|
texts << x
|
|
203
227
|
end
|
|
204
228
|
0.upto(texts.size-1) do |col|
|
|
205
|
-
if ljust
|
|
229
|
+
if opts[:ljust]
|
|
206
230
|
texts[col] = texts[col].ljust(colwidths[col])
|
|
207
231
|
else
|
|
208
232
|
texts[col] = texts[col].rjust(colwidths[col])
|
|
209
233
|
end
|
|
210
234
|
end
|
|
211
|
-
s += "%s%s\n" % [lineprefix, texts.join(colsep)]
|
|
235
|
+
s += "%s%s\n" % [opts[:lineprefix], texts.join(opts[:colsep])]
|
|
212
236
|
end
|
|
213
237
|
return s
|
|
214
238
|
end
|
|
215
239
|
end
|
|
216
|
-
module_function :columnize
|
|
217
240
|
end
|
|
218
241
|
if __FILE__ == $0
|
|
219
242
|
#
|
data/lib/version.rb
CHANGED
data/test/test-columnize.rb
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
|
|
4
|
+
# Test of Columnize module
|
|
5
|
+
class TestHashFormat < Test::Unit::TestCase
|
|
6
|
+
TOP_SRC_DIR = File.join(File.expand_path(File.dirname(__FILE__)),
|
|
7
|
+
'..', 'lib')
|
|
8
|
+
require File.join(TOP_SRC_DIR, 'columnize.rb')
|
|
9
|
+
include Columnize
|
|
10
|
+
def test_parse_columnize_options
|
|
11
|
+
list, default_opts = parse_columnize_options([[], {}])
|
|
12
|
+
assert list.kind_of?(Array)
|
|
13
|
+
assert default_opts.kind_of?(Hash)
|
|
14
|
+
list, opts = parse_columnize_options([[], 90])
|
|
15
|
+
assert_equal 90, opts[:displaywidth]
|
|
16
|
+
list, opts = parse_columnize_options([[], 70, '|'])
|
|
17
|
+
assert_equal 70, opts[:displaywidth]
|
|
18
|
+
assert_equal '|', opts[:colsep]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def basic
|
|
22
|
+
opts = {:xxx => 10, :yyy => ', '}
|
|
23
|
+
assert_equal("1, 2, 3\n",
|
|
24
|
+
Columnize::columnize([1, 2, 3], opts))
|
|
25
|
+
end
|
|
26
|
+
end
|
metadata
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: columnize
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
5
|
-
segments:
|
|
6
|
-
- 0
|
|
7
|
-
- 3
|
|
8
|
-
- 2
|
|
9
|
-
version: 0.3.2
|
|
4
|
+
version: 0.3.3
|
|
10
5
|
platform: ruby
|
|
11
6
|
authors:
|
|
12
7
|
- R. Bernstein
|
|
@@ -14,23 +9,35 @@ autorequire:
|
|
|
14
9
|
bindir: bin
|
|
15
10
|
cert_chain: []
|
|
16
11
|
|
|
17
|
-
date:
|
|
12
|
+
date: 2011-06-11 00:00:00 -04:00
|
|
18
13
|
default_executable:
|
|
19
14
|
dependencies: []
|
|
20
15
|
|
|
21
|
-
description:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
description: |
|
|
17
|
+
|
|
18
|
+
In showing a long lists, sometimes one would prefer to see the value
|
|
19
|
+
arranged aligned in columns. Some examples include listing methods
|
|
20
|
+
of an object or debugger commands.
|
|
21
|
+
|
|
22
|
+
An Example:
|
|
23
|
+
require "columnize"
|
|
24
|
+
print columnize((1..100).to_a.map{|x| "%2d" % x}, 60)
|
|
25
|
+
|
|
26
|
+
1 8 15 22 29 36 43 50 57 64 71 78 85 92 99
|
|
27
|
+
2 9 16 23 30 37 44 51 58 65 72 79 86 93 100
|
|
28
|
+
3 10 17 24 31 38 45 52 59 66 73 80 87 94
|
|
29
|
+
4 11 18 25 32 39 46 53 60 67 74 81 88 95
|
|
30
|
+
5 12 19 26 33 40 47 54 61 68 75 82 89 96
|
|
31
|
+
6 13 20 27 34 41 48 55 62 69 76 83 90 97
|
|
32
|
+
7 14 21 28 35 42 49 56 63 70 77 84 91 98
|
|
33
|
+
|
|
27
34
|
email: rockyb@rubyforge.net
|
|
28
35
|
executables: []
|
|
29
36
|
|
|
30
37
|
extensions: []
|
|
31
38
|
|
|
32
39
|
extra_rdoc_files:
|
|
33
|
-
- README
|
|
40
|
+
- README.md
|
|
34
41
|
- lib/columnize.rb
|
|
35
42
|
- COPYING
|
|
36
43
|
files:
|
|
@@ -39,12 +46,13 @@ files:
|
|
|
39
46
|
- ChangeLog
|
|
40
47
|
- Makefile
|
|
41
48
|
- NEWS
|
|
42
|
-
- README
|
|
49
|
+
- README.md
|
|
43
50
|
- Rakefile
|
|
44
51
|
- lib/columnize.rb
|
|
45
52
|
- lib/version.rb
|
|
46
53
|
- lib/Makefile
|
|
47
54
|
- test/test-columnize.rb
|
|
55
|
+
- test/test-hashparm.rb
|
|
48
56
|
has_rdoc: true
|
|
49
57
|
homepage: http://rubyforge.org/projects/rocky-hacks/columnize
|
|
50
58
|
licenses:
|
|
@@ -52,33 +60,27 @@ licenses:
|
|
|
52
60
|
post_install_message:
|
|
53
61
|
rdoc_options:
|
|
54
62
|
- --main
|
|
55
|
-
- README
|
|
63
|
+
- README.md
|
|
56
64
|
- --title
|
|
57
|
-
- Columnize 0.3.
|
|
65
|
+
- Columnize 0.3.3 Documentation
|
|
58
66
|
require_paths:
|
|
59
67
|
- lib
|
|
60
68
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
61
|
-
none: false
|
|
62
69
|
requirements:
|
|
63
70
|
- - ">="
|
|
64
71
|
- !ruby/object:Gem::Version
|
|
65
|
-
segments:
|
|
66
|
-
- 1
|
|
67
|
-
- 8
|
|
68
|
-
- 2
|
|
69
72
|
version: 1.8.2
|
|
73
|
+
version:
|
|
70
74
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
|
-
none: false
|
|
72
75
|
requirements:
|
|
73
76
|
- - ">="
|
|
74
77
|
- !ruby/object:Gem::Version
|
|
75
|
-
segments:
|
|
76
|
-
- 0
|
|
77
78
|
version: "0"
|
|
79
|
+
version:
|
|
78
80
|
requirements: []
|
|
79
81
|
|
|
80
82
|
rubyforge_project: columnize
|
|
81
|
-
rubygems_version: 1.3.
|
|
83
|
+
rubygems_version: 1.3.5
|
|
82
84
|
signing_key:
|
|
83
85
|
specification_version: 3
|
|
84
86
|
summary: Module to format an Array as an Array of String aligned in columns
|