columnize 0.3.1 → 0.3.2
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 +4 -0
- data/Makefile +8 -0
- data/NEWS +10 -2
- data/README +4 -6
- data/Rakefile +52 -85
- data/lib/Makefile +7 -0
- data/lib/columnize.rb +7 -5
- data/lib/version.rb +3 -0
- metadata +35 -35
- data/VERSION +0 -1
data/ChangeLog
CHANGED
data/Makefile
ADDED
data/NEWS
CHANGED
@@ -1,6 +1,14 @@
|
|
1
|
+
0.3.2
|
2
|
+
|
3
|
+
- Mostly Administrivia.
|
4
|
+
* Add .gemspec, correct description field and add a summary.
|
5
|
+
* Add Columnize::VERSION
|
6
|
+
* Simplify Rakefile
|
7
|
+
* Add stub Makefiles
|
8
|
+
|
1
9
|
0.3.1 (01-07-26)
|
2
10
|
|
3
|
-
- Correct for Ruby 1.9 (Mark
|
11
|
+
- Correct for Ruby 1.9 (Mark Moseley)
|
4
12
|
|
5
13
|
- add optional lineprefix parameter
|
6
14
|
|
@@ -21,4 +29,4 @@
|
|
21
29
|
- Initial release of Columnize, a module to print an Array in
|
22
30
|
column-sorted order
|
23
31
|
|
24
|
-
$Id: NEWS
|
32
|
+
$Id: NEWS 197 2010-09-20 16:27:05Z rockyb $
|
data/README
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
= Columnize - Module to
|
1
|
+
= Columnize - Module to show an Array formatted as a String aligned in columns.
|
2
2
|
|
3
3
|
== Summary
|
4
4
|
|
5
|
-
In showing a long lists, sometimes one would prefer to see the
|
6
|
-
|
7
|
-
or debugger commands.
|
5
|
+
In showing a long lists, sometimes one would prefer to see the value
|
6
|
+
arranged aligned in columns. Some examples include listing methods
|
7
|
+
of an object or debugger commands.
|
8
8
|
|
9
9
|
require 'columnize'
|
10
10
|
columnize([1, 2, 3])
|
@@ -37,5 +37,3 @@ This program is distributed in the hope that it will be useful,
|
|
37
37
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
38
38
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
39
39
|
GNU General Public License for more details.
|
40
|
-
|
41
|
-
$Id: README 14 2007-12-09 17:33:36Z rockyb $
|
data/Rakefile
CHANGED
@@ -4,114 +4,81 @@ require 'rubygems'
|
|
4
4
|
require 'rake/gempackagetask'
|
5
5
|
require 'rake/rdoctask'
|
6
6
|
require 'rake/testtask'
|
7
|
+
require 'fileutils'
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
ROOT_DIR = File.dirname(__FILE__)
|
10
|
+
require File.join(ROOT_DIR, '/lib/version')
|
11
|
+
|
12
|
+
def gemspec
|
13
|
+
@gemspec ||= eval(File.read('.gemspec'), binding, '.gemspec')
|
11
14
|
end
|
12
15
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
'test/*.rb'
|
23
|
-
]
|
16
|
+
desc "Build the gem"
|
17
|
+
task :package=>:gem
|
18
|
+
task :gem=>:gemspec do
|
19
|
+
Dir.chdir(ROOT_DIR) do
|
20
|
+
sh "gem build .gemspec"
|
21
|
+
FileUtils.mkdir_p 'pkg'
|
22
|
+
FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
|
23
|
+
end
|
24
|
+
end
|
24
25
|
|
25
|
-
desc "
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
t.pattern = 'test/test-*.rb'
|
30
|
-
t.verbose = true
|
26
|
+
desc "Install the gem locally"
|
27
|
+
task :install => :gem do
|
28
|
+
Dir.chdir(ROOT_DIR) do
|
29
|
+
sh %{gem install --local pkg/#{gemspec.name}-#{gemspec.version}}
|
31
30
|
end
|
32
31
|
end
|
33
32
|
|
34
|
-
desc "Test everything
|
33
|
+
desc "Test everything."
|
34
|
+
Rake::TestTask.new(:test) do |t|
|
35
|
+
t.libs << './lib'
|
36
|
+
t.pattern = 'test/test-*.rb'
|
37
|
+
t.verbose = true
|
38
|
+
end
|
39
|
+
task :test => :lib
|
40
|
+
|
41
|
+
desc "same as test"
|
35
42
|
task :check => :test
|
36
43
|
|
37
44
|
desc "Create a GNU-style ChangeLog via svn2cl"
|
38
45
|
task :ChangeLog do
|
39
|
-
system("svn2cl")
|
40
|
-
end
|
41
|
-
|
42
|
-
# Base GEM Specification
|
43
|
-
default_spec = Gem::Specification.new do |spec|
|
44
|
-
spec.name = "columnize"
|
45
|
-
|
46
|
-
spec.homepage = "http://rubyforge.org/projects/rocky-hacks/columnize"
|
47
|
-
spec.summary = "Read file with caching"
|
48
|
-
spec.description = <<-EOF
|
49
|
-
Return a list of strings as a set of arranged in columns.
|
50
|
-
|
51
|
-
For example, for a line width of 4 characters (arranged vertically):
|
52
|
-
['1', '2,', '3', '4'] => '1 3\n2 4\n'
|
53
|
-
|
54
|
-
or arranged horizontally:
|
55
|
-
['1', '2,', '3', '4'] => '1 2\n3 4\n'
|
56
|
-
|
57
|
-
Each column is only as wide as necessary. By default, columns are
|
58
|
-
separated by two spaces - one was not legible enough. Set "colsep"
|
59
|
-
to adjust the string separate columns. Set `displaywidth' to set
|
60
|
-
the line width.
|
61
|
-
|
62
|
-
Normally, consecutive items go down from the top to bottom from
|
63
|
-
the left-most column to the right-most. If +arrange_vertical+ is
|
64
|
-
set false, consecutive items will go across, left to right, top to
|
65
|
-
bottom.
|
66
|
-
EOF
|
67
|
-
|
68
|
-
spec.version = PACKAGE_VERSION
|
69
|
-
|
70
|
-
spec.author = "R. Bernstein"
|
71
|
-
spec.email = "rockyb@rubyforge.net"
|
72
|
-
spec.platform = Gem::Platform::RUBY
|
73
|
-
spec.require_path = "lib"
|
74
|
-
spec.files = FILES.to_a
|
75
|
-
|
76
|
-
spec.required_ruby_version = '>= 1.8.2'
|
77
|
-
spec.date = Time.now
|
78
|
-
spec.rubyforge_project = 'rocky-hacks'
|
79
|
-
|
80
|
-
# rdoc
|
81
|
-
spec.has_rdoc = true
|
82
|
-
spec.extra_rdoc_files = ['README', 'lib/columnize.rb']
|
83
|
-
end
|
84
|
-
|
85
|
-
# Rake task to build the default package
|
86
|
-
Rake::GemPackageTask.new(default_spec) do |pkg|
|
87
|
-
pkg.need_tar = true
|
46
|
+
system("svn2cl --authors=svn2cl_usermap")
|
88
47
|
end
|
89
48
|
|
90
49
|
task :default => [:test]
|
91
50
|
|
92
|
-
desc "
|
93
|
-
task :
|
94
|
-
require 'rake/contrib/sshpublisher'
|
95
|
-
|
96
|
-
# Get ruby-debug path
|
97
|
-
ruby_debug_path = File.expand_path(File.dirname(__FILE__))
|
51
|
+
desc "Remove built files"
|
52
|
+
task :clean => [:clobber_package, :clobber_rdoc]
|
98
53
|
|
99
|
-
|
100
|
-
|
54
|
+
desc "Generate the gemspec"
|
55
|
+
task :generate do
|
56
|
+
puts gemspec.to_ruby
|
101
57
|
end
|
102
58
|
|
103
|
-
desc "
|
104
|
-
task :
|
59
|
+
desc "Validate the gemspec"
|
60
|
+
task :gemspec do
|
61
|
+
gemspec.validate
|
62
|
+
end
|
105
63
|
|
106
64
|
# --------- RDoc Documentation ------
|
107
65
|
desc "Generate rdoc documentation"
|
108
66
|
Rake::RDocTask.new("rdoc") do |rdoc|
|
109
67
|
rdoc.rdoc_dir = 'doc'
|
110
|
-
rdoc.title = "
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
68
|
+
rdoc.title = "Columnize #{Columnize::VERSION} Documentation"
|
69
|
+
|
70
|
+
# Make the README file the start page for the generated html
|
71
|
+
rdoc.options += %w(--main README)
|
72
|
+
|
115
73
|
rdoc.rdoc_files.include('lib/*.rb', 'README', 'COPYING')
|
116
74
|
end
|
75
|
+
desc "Same as rdoc"
|
76
|
+
task :doc => :rdoc
|
117
77
|
|
78
|
+
task :clobber_package do
|
79
|
+
FileUtils.rm_rf File.join(ROOT_DIR, 'pkg')
|
80
|
+
end
|
81
|
+
|
82
|
+
task :clobber_rdoc do
|
83
|
+
FileUtils.rm_rf File.join(ROOT_DIR, 'doc')
|
84
|
+
end
|
data/lib/Makefile
ADDED
data/lib/columnize.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Copyright (C) 2007, 2008, 2009 Rocky Bernstein <rockyb@rubyforge.net>
|
1
|
+
# Copyright (C) 2007, 2008, 2009, 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
4
2
|
#
|
5
3
|
# This program is free software; you can redistribute it and/or modify
|
6
4
|
# it under the terms of the GNU General Public License as published by
|
@@ -20,6 +18,10 @@
|
|
20
18
|
|
21
19
|
# Author:: Rocky Bernstein (mailto:rockyb@rubyforge.net)
|
22
20
|
#
|
21
|
+
# = Columnize
|
22
|
+
# Module to format an Array as an Array of String aligned in columns.
|
23
|
+
#
|
24
|
+
# == SYNOPSIS
|
23
25
|
# Display a list of strings as a compact set of columns.
|
24
26
|
#
|
25
27
|
# For example, for a line width of 4 characters (arranged vertically):
|
@@ -72,7 +74,7 @@ module Columnize
|
|
72
74
|
colwidths = [] # Same for colwidths
|
73
75
|
displaywidth = [4, displaywidth - lineprefix.length].max
|
74
76
|
if arrange_vertical
|
75
|
-
array_index = lambda {|
|
77
|
+
array_index = lambda {|num_rows, row, col| num_rows*col + row }
|
76
78
|
# Try every row count from 1 upwards
|
77
79
|
1.upto(l.size-1) do |_nrows|
|
78
80
|
nrows = _nrows
|
@@ -138,7 +140,7 @@ module Columnize
|
|
138
140
|
end
|
139
141
|
return s
|
140
142
|
else
|
141
|
-
array_index = lambda {|
|
143
|
+
array_index = lambda {|num_rows, row, col| ncols*(row-1) + col }
|
142
144
|
# Try every column count from size downwards
|
143
145
|
# Assign to make enlarge scope of loop variables
|
144
146
|
totwidth = i = rounded_size = 0
|
data/lib/version.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: columnize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 3
|
8
|
+
- 2
|
9
|
+
version: 0.3.2
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- R. Bernstein
|
@@ -9,33 +14,16 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-11-04 00:00:00 -04:00
|
13
18
|
default_executable:
|
14
19
|
dependencies: []
|
15
20
|
|
16
|
-
description:
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
2 4
|
22
|
-
'
|
23
|
-
|
24
|
-
or arranged horizontally:
|
25
|
-
['1', '2,', '3', '4'] => '1 2
|
26
|
-
3 4
|
27
|
-
'
|
28
|
-
|
29
|
-
Each column is only as wide as necessary. By default, columns are
|
30
|
-
separated by two spaces - one was not legible enough. Set "colsep"
|
31
|
-
to adjust the string separate columns. Set `displaywidth' to set
|
32
|
-
the line width.
|
33
|
-
|
34
|
-
Normally, consecutive items go down from the top to bottom from
|
35
|
-
the left-most column to the right-most. If +arrange_vertical+ is
|
36
|
-
set false, consecutive items will go across, left to right, top to
|
37
|
-
bottom.
|
38
|
-
|
21
|
+
description: "\n\
|
22
|
+
In showing a long lists, sometimes one would prefer to see the value\n\
|
23
|
+
arranged aligned in columns. Some examples include listing methods\n\
|
24
|
+
of an object or debugger commands. \n\n\
|
25
|
+
An Example:\n\
|
26
|
+
require \"columnize\"\n print columnize((1..100).to_a.map{|x| \"%2d\" % x}, 60)\n\n 1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 \n 2 9 16 23 30 37 44 51 58 65 72 79 86 93 100\n 3 10 17 24 31 38 45 52 59 66 73 80 87 94\n 4 11 18 25 32 39 46 53 60 67 74 81 88 95\n 5 12 19 26 33 40 47 54 61 68 75 82 89 96\n 6 13 20 27 34 41 48 55 62 69 76 83 90 97\n 7 14 21 28 35 42 49 56 63 70 77 84 91 98\n"
|
39
27
|
email: rockyb@rubyforge.net
|
40
28
|
executables: []
|
41
29
|
|
@@ -44,43 +32,55 @@ extensions: []
|
|
44
32
|
extra_rdoc_files:
|
45
33
|
- README
|
46
34
|
- lib/columnize.rb
|
35
|
+
- COPYING
|
47
36
|
files:
|
48
37
|
- AUTHORS
|
49
38
|
- COPYING
|
50
39
|
- ChangeLog
|
40
|
+
- Makefile
|
51
41
|
- NEWS
|
52
42
|
- README
|
53
43
|
- Rakefile
|
54
|
-
- VERSION
|
55
44
|
- lib/columnize.rb
|
45
|
+
- lib/version.rb
|
46
|
+
- lib/Makefile
|
56
47
|
- test/test-columnize.rb
|
57
48
|
has_rdoc: true
|
58
49
|
homepage: http://rubyforge.org/projects/rocky-hacks/columnize
|
59
|
-
licenses:
|
60
|
-
|
50
|
+
licenses:
|
51
|
+
- GPL2
|
61
52
|
post_install_message:
|
62
|
-
rdoc_options:
|
63
|
-
|
53
|
+
rdoc_options:
|
54
|
+
- --main
|
55
|
+
- README
|
56
|
+
- --title
|
57
|
+
- Columnize 0.3.2 Documentation
|
64
58
|
require_paths:
|
65
59
|
- lib
|
66
60
|
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
67
62
|
requirements:
|
68
63
|
- - ">="
|
69
64
|
- !ruby/object:Gem::Version
|
65
|
+
segments:
|
66
|
+
- 1
|
67
|
+
- 8
|
68
|
+
- 2
|
70
69
|
version: 1.8.2
|
71
|
-
version:
|
72
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
73
72
|
requirements:
|
74
73
|
- - ">="
|
75
74
|
- !ruby/object:Gem::Version
|
75
|
+
segments:
|
76
|
+
- 0
|
76
77
|
version: "0"
|
77
|
-
version:
|
78
78
|
requirements: []
|
79
79
|
|
80
|
-
rubyforge_project:
|
81
|
-
rubygems_version: 1.3.
|
80
|
+
rubyforge_project: columnize
|
81
|
+
rubygems_version: 1.3.7
|
82
82
|
signing_key:
|
83
83
|
specification_version: 3
|
84
|
-
summary:
|
84
|
+
summary: Module to format an Array as an Array of String aligned in columns
|
85
85
|
test_files: []
|
86
86
|
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.3.1
|