vll 0.1.2 → 0.1.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/bin/vl +39 -12
- metadata +17 -14
- checksums.yaml +0 -7
data/bin/vl
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#TODO: add column colors
|
4
|
+
#TODO: chop long columns (option)
|
5
|
+
|
2
6
|
begin
|
3
7
|
|
4
8
|
require 'optparse'
|
@@ -11,6 +15,8 @@ $options = {
|
|
11
15
|
:comment => /^#/,
|
12
16
|
:probe_lines => 100,
|
13
17
|
:justify => 'l',
|
18
|
+
:alternate_color => false,
|
19
|
+
:chop_length => 1024,
|
14
20
|
}
|
15
21
|
|
16
22
|
|
@@ -18,7 +24,7 @@ $options = {
|
|
18
24
|
opts = OptionParser.new do |opts|
|
19
25
|
opts.set_banner ''
|
20
26
|
opts.set_summary_indent ' '
|
21
|
-
opts.set_summary_width
|
27
|
+
opts.set_summary_width 28
|
22
28
|
|
23
29
|
opts.separator '/==============================================================================\\'
|
24
30
|
opts.separator ''
|
@@ -46,7 +52,7 @@ opts = OptionParser.new do |opts|
|
|
46
52
|
$options[:skip] = k.to_i
|
47
53
|
end
|
48
54
|
|
49
|
-
opts.on('-
|
55
|
+
opts.on('-g', '--probe-lines <INT>', 'number of top lines used for estimation [100]') do |p|
|
50
56
|
$options[:probe_lines] = p.to_i
|
51
57
|
end
|
52
58
|
|
@@ -72,6 +78,14 @@ opts = OptionParser.new do |opts|
|
|
72
78
|
$options[:quote] = q
|
73
79
|
end
|
74
80
|
|
81
|
+
opts.on('-z', '--[no-]alternative-color', 'use alternative colors [no]') do |c|
|
82
|
+
$options[:alternate_color] = c
|
83
|
+
end
|
84
|
+
|
85
|
+
opts.on('-l', '--chop-length <INT>', 'chop columns longer than this length [1024]') do |l|
|
86
|
+
$options[:chop_length] = l.to_i
|
87
|
+
end
|
88
|
+
|
75
89
|
opts.separator ''
|
76
90
|
opts.separator '\==============================================================================/'
|
77
91
|
opts.separator ''
|
@@ -134,19 +148,32 @@ def print_line(line, lnum)
|
|
134
148
|
parsed_line.each_with_index do |c, i|
|
135
149
|
# damn you, 'csv' package!
|
136
150
|
c = '' if c == nil
|
137
|
-
|
151
|
+
|
152
|
+
if $max_widths.fetch(i, -1) < c.length then
|
153
|
+
$max_widths[i] = c.length
|
154
|
+
end
|
155
|
+
|
156
|
+
c = c[0..$options[:chop_length]]
|
157
|
+
$max_widths[i] = [$options[:chop_length], $max_widths[i]].min
|
158
|
+
|
138
159
|
case $options[:justify]
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
160
|
+
when 'l'
|
161
|
+
c = c.ljust($max_widths[i] + $options[:padding]) rescue break
|
162
|
+
when 'r'
|
163
|
+
c = c.rjust($max_widths[i] + $options[:padding]) rescue break
|
164
|
+
when 'a'
|
165
|
+
begin
|
166
|
+
if Float(c) then c = c.rjust($max_widths[i] + $options[:padding]) end
|
167
|
+
rescue
|
168
|
+
c = c.ljust($max_widths[i] + $options[:padding])
|
169
|
+
end
|
148
170
|
end
|
171
|
+
|
172
|
+
if $options[:alternate_color] then
|
173
|
+
c = c.colorize([:yellow, :blue][i % 2])
|
149
174
|
end
|
175
|
+
|
176
|
+
print c
|
150
177
|
end
|
151
178
|
puts
|
152
179
|
rescue
|
metadata
CHANGED
@@ -1,32 +1,34 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vll
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.3
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- xzhu
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2016-
|
12
|
+
date: 2016-08-26 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
15
|
+
type: :runtime
|
16
|
+
prerelease: false
|
14
17
|
name: colorize
|
15
18
|
requirement: !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
16
20
|
requirements:
|
17
|
-
- -
|
21
|
+
- - ! '>='
|
18
22
|
- !ruby/object:Gem::Version
|
19
23
|
version: 0.7.7
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- -
|
27
|
+
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: 0.7.7
|
27
30
|
description: Nicely format columns of a large CSV/TSV file according to their content
|
28
|
-
width, using first few lines as estimation thus extremely fast. Customizable.
|
29
|
-
useful terminal (CLI) tool.
|
31
|
+
width, using first few lines as estimation thus extremely fast. Customizable.
|
30
32
|
email:
|
31
33
|
- zhuxun2@gmail.com
|
32
34
|
executables:
|
@@ -40,25 +42,26 @@ files:
|
|
40
42
|
homepage:
|
41
43
|
licenses:
|
42
44
|
- MIT
|
43
|
-
metadata: {}
|
44
45
|
post_install_message:
|
45
46
|
rdoc_options: []
|
46
47
|
require_paths:
|
47
48
|
- lib
|
48
49
|
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
49
51
|
requirements:
|
50
|
-
- -
|
52
|
+
- - ! '>='
|
51
53
|
- !ruby/object:Gem::Version
|
52
54
|
version: '0'
|
53
55
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
54
57
|
requirements:
|
55
|
-
- -
|
58
|
+
- - ! '>='
|
56
59
|
- !ruby/object:Gem::Version
|
57
60
|
version: '0'
|
58
61
|
requirements: []
|
59
62
|
rubyforge_project:
|
60
|
-
rubygems_version:
|
63
|
+
rubygems_version: 1.8.23.2
|
61
64
|
signing_key:
|
62
|
-
specification_version:
|
63
|
-
summary:
|
65
|
+
specification_version: 3
|
66
|
+
summary: (V)iew (L)arge table. Format large table in a split of a second
|
64
67
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 1417d088eacb35ae76a8621b1c265f98fd812af4
|
4
|
-
data.tar.gz: 7284813ba2100f4bcf00af4f780bf79144853408
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: f531aa0cbe27a2f56e3026b464199b87b2f689df3902baea1d45162d6c31792d41f551a0e45a60c3844429e9405449e29171228c946247a0cd06f7e7e212487e
|
7
|
-
data.tar.gz: a069e85c5229cdf48e02b2dd99987bd202482ef7431afa0bbc980054d2ece900bd171524a1ff45e7e72d94fff31b030d772f7d65a1ac3b915f8b1a01a5758c0f
|