tb 0.6 → 0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README +7 -7
- data/lib/tb/{cmd_git_log.rb → cmd_git.rb} +30 -30
- data/lib/tb/{cmd_svn_log.rb → cmd_svn.rb} +15 -15
- data/lib/tb/{cmd_tar_tvf.rb → cmd_tar.rb} +41 -41
- data/lib/tb/cmdtop.rb +3 -3
- data/test/test_cmd_git_log.rb +13 -13
- data/test/test_cmd_svn_log.rb +5 -5
- data/test/test_cmd_tar_tvf.rb +18 -18
- metadata +6 -6
data/README
CHANGED
@@ -4,7 +4,7 @@ tb provides a command and a library for manipulating tables:
|
|
4
4
|
Unix filter like operations (grep, sort, cat, cut, ls, etc.),
|
5
5
|
SQL like operations (join, group, etc.),
|
6
6
|
other table operations (gsub, rename, cross, melt, unmelt, etc.),
|
7
|
-
information extractions (git
|
7
|
+
information extractions (git, svn, tar),
|
8
8
|
and more.
|
9
9
|
|
10
10
|
== Example
|
@@ -156,9 +156,9 @@ There are more subcommands.
|
|
156
156
|
tb mheader [OPTS] [TABLE]
|
157
157
|
tb crop [OPTS] [TABLE ...]
|
158
158
|
tb ls [OPTS] [FILE ...]
|
159
|
-
tb tar
|
160
|
-
tb svn
|
161
|
-
tb git
|
159
|
+
tb tar [OPTS] [TAR-FILE ...]
|
160
|
+
tb svn [OPTS] -- [SVN-LOG-ARGS]
|
161
|
+
tb git [OPTS] [GIT-DIR ...]
|
162
162
|
|
163
163
|
tb help -s shows one line summary of the subcommands.
|
164
164
|
|
@@ -189,9 +189,9 @@ tb help -s shows one line summary of the subcommands.
|
|
189
189
|
mheader : Collapse multi rows header.
|
190
190
|
crop : Extract rectangle in a table.
|
191
191
|
ls : List directory entries as a table.
|
192
|
-
tar
|
193
|
-
svn
|
194
|
-
git
|
192
|
+
tar : Show the file listing of tar file.
|
193
|
+
svn : Show the SVN log as a table.
|
194
|
+
git : Show the GIT log as a table.
|
195
195
|
|
196
196
|
== Install
|
197
197
|
|
@@ -26,20 +26,20 @@
|
|
26
26
|
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
27
27
|
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
28
28
|
|
29
|
-
Tb::Cmd.subcommands << 'git
|
29
|
+
Tb::Cmd.subcommands << 'git'
|
30
30
|
|
31
|
-
Tb::Cmd.default_option[:
|
32
|
-
Tb::Cmd.default_option[:
|
33
|
-
Tb::Cmd.default_option[:
|
31
|
+
Tb::Cmd.default_option[:opt_git_command] = nil
|
32
|
+
Tb::Cmd.default_option[:opt_git_debug_input] = nil
|
33
|
+
Tb::Cmd.default_option[:opt_git_debug_output] = nil
|
34
34
|
|
35
|
-
def (Tb::Cmd).
|
35
|
+
def (Tb::Cmd).op_git
|
36
36
|
op = OptionParser.new
|
37
|
-
op.banner = "Usage: tb git
|
37
|
+
op.banner = "Usage: tb git [OPTS] [GIT-DIR ...]\n" +
|
38
38
|
"Show the GIT log as a table."
|
39
39
|
define_common_option(op, "hNod", "--no-pager", '--debug')
|
40
|
-
op.def_option('--git-command COMMAND', 'specify the git command (default: git)') {|command| Tb::Cmd.
|
41
|
-
op.def_option('--debug-git-
|
42
|
-
op.def_option('--debug-git-
|
40
|
+
op.def_option('--git-command COMMAND', 'specify the git command (default: git)') {|command| Tb::Cmd.opt_git_command = command }
|
41
|
+
op.def_option('--debug-git-output FILE', 'store the raw output of git (for debug)') {|filename| Tb::Cmd.opt_git_debug_output = filename }
|
42
|
+
op.def_option('--debug-git-input FILE', 'use the file as output of git (for debug)') {|filename| Tb::Cmd.opt_git_debug_input = filename }
|
43
43
|
op
|
44
44
|
end
|
45
45
|
|
@@ -69,13 +69,13 @@ Tb::Cmd::GIT_LOG_PRETTY_FORMAT = 'format:%x01commit-separator%x01%n' +
|
|
69
69
|
|
70
70
|
Tb::Cmd::GIT_LOG_HEADER = Tb::Cmd::GIT_LOG_FORMAT_SPEC.map {|k, v| k } + ['files']
|
71
71
|
|
72
|
-
def (Tb::Cmd).
|
73
|
-
if Tb::Cmd.
|
74
|
-
File.open(Tb::Cmd.
|
72
|
+
def (Tb::Cmd).git_with_git_log(dir)
|
73
|
+
if Tb::Cmd.opt_git_debug_input
|
74
|
+
File.open(Tb::Cmd.opt_git_debug_input) {|f|
|
75
75
|
yield f
|
76
76
|
}
|
77
77
|
else
|
78
|
-
git = Tb::Cmd.
|
78
|
+
git = Tb::Cmd.opt_git_command || 'git'
|
79
79
|
# depends Ruby 1.9.
|
80
80
|
command = [
|
81
81
|
git,
|
@@ -89,11 +89,11 @@ def (Tb::Cmd).git_log_with_git_log(dir)
|
|
89
89
|
{:chdir=>dir}
|
90
90
|
]
|
91
91
|
$stderr.puts "git command line: #{command.inspect}" if 1 <= Tb::Cmd.opt_debug
|
92
|
-
if Tb::Cmd.
|
92
|
+
if Tb::Cmd.opt_git_debug_output
|
93
93
|
# File.realdirpath is required before Ruby 2.0.
|
94
|
-
command.last[:out] = File.realdirpath(Tb::Cmd.
|
94
|
+
command.last[:out] = File.realdirpath(Tb::Cmd.opt_git_debug_output)
|
95
95
|
system(*command)
|
96
|
-
File.open(Tb::Cmd.
|
96
|
+
File.open(Tb::Cmd.opt_git_debug_output) {|f|
|
97
97
|
yield f
|
98
98
|
}
|
99
99
|
else
|
@@ -104,7 +104,7 @@ def (Tb::Cmd).git_log_with_git_log(dir)
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
def (Tb::Cmd).
|
107
|
+
def (Tb::Cmd).git_unescape_filename(filename)
|
108
108
|
if /\A"/ =~ filename
|
109
109
|
$'.chomp('"').gsub(/\\((\d\d\d)|[abtnvfr"\\])/) {
|
110
110
|
str = $1
|
@@ -131,23 +131,23 @@ def (Tb::Cmd).git_log_unescape_filename(filename)
|
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
|
-
def (Tb::Cmd).
|
134
|
+
def (Tb::Cmd).git_parse_commit(commit_info, files)
|
135
135
|
commit_info = commit_info.split(/\n(?=[a-z])/)
|
136
136
|
files_raw = {}
|
137
137
|
files_numstat = {}
|
138
138
|
files.split(/\n/).each {|file_line|
|
139
139
|
if /\A:(\d+) (\d+) ([0-9a-f]+) ([0-9a-f]+) (\S+)\t(.+)\z/ =~ file_line
|
140
140
|
mode1, mode2, hash1, hash2, status, filename = $1, $2, $3, $4, $5, $6
|
141
|
-
filename =
|
141
|
+
filename = git_unescape_filename(filename)
|
142
142
|
files_raw[filename] = [mode1, mode2, hash1, hash2, status]
|
143
143
|
elsif /\A(\d+|-)\t(\d+|-)\t(.+)\z/ =~ file_line
|
144
144
|
add, del, filename = $1, $2, $3
|
145
145
|
add = add == '-' ? nil : add.to_i
|
146
146
|
del = del == '-' ? nil : del.to_i
|
147
|
-
filename =
|
147
|
+
filename = git_unescape_filename(filename)
|
148
148
|
files_numstat[filename] = [add, del]
|
149
149
|
else
|
150
|
-
warn "unexpected git
|
150
|
+
warn "unexpected git output (raw/numstat): #{file_line.inspect}"
|
151
151
|
end
|
152
152
|
}
|
153
153
|
Tb.csv_stream_output(files_csv="") {|gen|
|
@@ -160,7 +160,7 @@ def (Tb::Cmd).git_log_parse_commit(commit_info, files)
|
|
160
160
|
h = {}
|
161
161
|
commit_info.each {|s|
|
162
162
|
if /:/ !~ s
|
163
|
-
warn "unexpected git
|
163
|
+
warn "unexpected git output (header:value): #{s.inspect}"
|
164
164
|
next
|
165
165
|
end
|
166
166
|
k = $`
|
@@ -180,32 +180,32 @@ def (Tb::Cmd).git_log_parse_commit(commit_info, files)
|
|
180
180
|
h
|
181
181
|
end
|
182
182
|
|
183
|
-
def (Tb::Cmd).
|
183
|
+
def (Tb::Cmd).git_each_commit(f)
|
184
184
|
while chunk = f.gets("\x01commit-separator\x01\n")
|
185
185
|
chunk.chomp!("\x01commit-separator\x01\n")
|
186
186
|
next if chunk.empty? # beginning of the output
|
187
187
|
if /\nend-commit\n/ !~ chunk
|
188
|
-
warn "unexpected git
|
188
|
+
warn "unexpected git output (end-commit): #{chunk.inspect}"
|
189
189
|
next
|
190
190
|
end
|
191
191
|
commit_info, files = $`, $'
|
192
192
|
files.sub!(/\A\n/, '')
|
193
|
-
h =
|
193
|
+
h = git_parse_commit(commit_info, files)
|
194
194
|
yield h
|
195
195
|
end
|
196
196
|
|
197
197
|
end
|
198
198
|
|
199
|
-
def (Tb::Cmd).
|
200
|
-
|
201
|
-
exit_if_help('git
|
199
|
+
def (Tb::Cmd).main_git(argv)
|
200
|
+
op_git.parse!(argv)
|
201
|
+
exit_if_help('git')
|
202
202
|
argv = ['.'] if argv.empty?
|
203
203
|
er = Tb::Enumerator.new {|y|
|
204
204
|
y.set_header Tb::Cmd::GIT_LOG_HEADER
|
205
205
|
argv.each {|dir|
|
206
|
-
|
206
|
+
git_with_git_log(dir) {|f|
|
207
207
|
f.set_encoding("ASCII-8BIT") if f.respond_to? :set_encoding
|
208
|
-
|
208
|
+
git_each_commit(f) {|h|
|
209
209
|
y.yield h
|
210
210
|
}
|
211
211
|
}
|
@@ -28,27 +28,27 @@
|
|
28
28
|
|
29
29
|
require 'rexml/document'
|
30
30
|
|
31
|
-
Tb::Cmd.subcommands << 'svn
|
31
|
+
Tb::Cmd.subcommands << 'svn'
|
32
32
|
|
33
|
-
Tb::Cmd.default_option[:
|
33
|
+
Tb::Cmd.default_option[:opt_svn_command] = nil
|
34
34
|
Tb::Cmd.default_option[:opt_svn_log_xml] = nil
|
35
35
|
|
36
|
-
def (Tb::Cmd).
|
36
|
+
def (Tb::Cmd).op_svn
|
37
37
|
op = OptionParser.new
|
38
|
-
op.banner = "Usage: tb svn
|
38
|
+
op.banner = "Usage: tb svn [OPTS] -- [SVN-LOG-ARGS]\n" +
|
39
39
|
"Show the SVN log as a table."
|
40
40
|
define_common_option(op, "hNo", "--no-pager")
|
41
|
-
op.def_option('--svn-command COMMAND', 'specify the svn command (default: svn)') {|command| Tb::Cmd.
|
41
|
+
op.def_option('--svn-command COMMAND', 'specify the svn command (default: svn)') {|command| Tb::Cmd.opt_svn_command = command }
|
42
42
|
op.def_option('--svn-log-xml FILE', 'specify the result svn log --xml') {|filename| Tb::Cmd.opt_svn_log_xml = filename }
|
43
43
|
op
|
44
44
|
end
|
45
45
|
|
46
|
-
Tb::Cmd.def_vhelp('svn
|
46
|
+
Tb::Cmd.def_vhelp('svn', <<'End')
|
47
47
|
Example:
|
48
48
|
|
49
|
-
% tb svn
|
50
|
-
% tb svn
|
51
|
-
% tb svn
|
49
|
+
% tb svn
|
50
|
+
% tb svn -- -v
|
51
|
+
% tb svn -- -v http://svn.ruby-lang.org/repos/ruby/trunk
|
52
52
|
End
|
53
53
|
|
54
54
|
class Tb::Cmd::SVNLOGListener
|
@@ -157,24 +157,24 @@ class Tb::Cmd::SVNLOGListener
|
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
160
|
-
def (Tb::Cmd).
|
160
|
+
def (Tb::Cmd).svn_with_svn_log(argv)
|
161
161
|
if Tb::Cmd.opt_svn_log_xml
|
162
162
|
File.open(Tb::Cmd.opt_svn_log_xml) {|f|
|
163
163
|
yield f
|
164
164
|
}
|
165
165
|
else
|
166
|
-
svn = Tb::Cmd.
|
166
|
+
svn = Tb::Cmd.opt_svn_command || 'svn'
|
167
167
|
IO.popen([svn, 'log', '--xml', *argv]) {|f|
|
168
168
|
yield f
|
169
169
|
}
|
170
170
|
end
|
171
171
|
end
|
172
172
|
|
173
|
-
def (Tb::Cmd).
|
174
|
-
|
175
|
-
exit_if_help('svn
|
173
|
+
def (Tb::Cmd).main_svn(argv)
|
174
|
+
op_svn.parse!(argv)
|
175
|
+
exit_if_help('svn')
|
176
176
|
er = Tb::Enumerator.new {|y|
|
177
|
-
|
177
|
+
svn_with_svn_log(argv) {|f|
|
178
178
|
listener = Tb::Cmd::SVNLOGListener.new(y)
|
179
179
|
REXML::Parsers::StreamParser.new(f, listener).parse
|
180
180
|
}
|
@@ -26,20 +26,20 @@
|
|
26
26
|
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
27
27
|
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
28
28
|
|
29
|
-
Tb::Cmd.subcommands << 'tar
|
29
|
+
Tb::Cmd.subcommands << 'tar'
|
30
30
|
|
31
|
-
Tb::Cmd.default_option[:
|
32
|
-
Tb::Cmd.default_option[:
|
33
|
-
Tb::Cmd.default_option[:
|
31
|
+
Tb::Cmd.default_option[:opt_tar_l] = 0
|
32
|
+
Tb::Cmd.default_option[:opt_tar_ustar] = nil
|
33
|
+
Tb::Cmd.default_option[:opt_tar_hash] = []
|
34
34
|
|
35
|
-
def (Tb::Cmd).
|
35
|
+
def (Tb::Cmd).op_tar
|
36
36
|
op = OptionParser.new
|
37
|
-
op.banner = "Usage: tb tar
|
37
|
+
op.banner = "Usage: tb tar [OPTS] [TAR-FILE ...]\n" +
|
38
38
|
"Show the file listing of tar file."
|
39
39
|
define_common_option(op, "hNo", "--no-pager")
|
40
|
-
op.def_option('-l', 'show more attributes.') {|fs| Tb::Cmd.
|
41
|
-
op.def_option('--ustar', 'ustar format (POSIX.1-1988). No GNU and POSIX.1-2001 extension.') {|fs| Tb::Cmd.
|
42
|
-
op.def_option('--hash=ALGORITHMS', 'hash algorithms such as md5,sha256,sha384,sha512 (default: none)') {|hs| Tb::Cmd.
|
40
|
+
op.def_option('-l', 'show more attributes.') {|fs| Tb::Cmd.opt_tar_l += 1 }
|
41
|
+
op.def_option('--ustar', 'ustar format (POSIX.1-1988). No GNU and POSIX.1-2001 extension.') {|fs| Tb::Cmd.opt_tar_ustar = true }
|
42
|
+
op.def_option('--hash=ALGORITHMS', 'hash algorithms such as md5,sha256,sha384,sha512 (default: none)') {|hs| Tb::Cmd.opt_tar_hash.concat split_field_list_argument(hs) }
|
43
43
|
op
|
44
44
|
end
|
45
45
|
|
@@ -84,7 +84,7 @@ Tb::Cmd::TAR_HASH_ALGORITHMS = {
|
|
84
84
|
'sha512' => 'SHA512',
|
85
85
|
}
|
86
86
|
|
87
|
-
def (Tb::Cmd).
|
87
|
+
def (Tb::Cmd).tar_parse_seconds_from_epoch(val)
|
88
88
|
if /\./ =~ val
|
89
89
|
num = ($` + $').to_i
|
90
90
|
den = 10 ** $'.length
|
@@ -101,9 +101,9 @@ def (Tb::Cmd).tar_tvf_parse_seconds_from_epoch(val)
|
|
101
101
|
end
|
102
102
|
|
103
103
|
Tb::Cmd::TAR_PAX_KEYWORD_RECOGNIZERS = {
|
104
|
-
'atime' => [:atime, lambda {|val| Tb::Cmd.
|
105
|
-
'mtime' => [:mtime, lambda {|val| Tb::Cmd.
|
106
|
-
'ctime' => [:ctime, lambda {|val| Tb::Cmd.
|
104
|
+
'atime' => [:atime, lambda {|val| Tb::Cmd.tar_parse_seconds_from_epoch(val) }],
|
105
|
+
'mtime' => [:mtime, lambda {|val| Tb::Cmd.tar_parse_seconds_from_epoch(val) }],
|
106
|
+
'ctime' => [:ctime, lambda {|val| Tb::Cmd.tar_parse_seconds_from_epoch(val) }],
|
107
107
|
'gid' => [:gid, lambda {|val| val.to_i }],
|
108
108
|
'gname' => [:gname, lambda {|val| val }],
|
109
109
|
'uid' => [:uid, lambda {|val| val.to_i }],
|
@@ -116,7 +116,7 @@ Tb::Cmd::TAR_PAX_KEYWORD_RECOGNIZERS = {
|
|
116
116
|
Tb::Cmd::TAR_CSV_HEADER = %w[mode filemode uid user gid group devmajor devminor size mtime path linkname]
|
117
117
|
Tb::Cmd::TAR_CSV_LONG_HEADER = %w[mode filemode uid user gid group devmajor devminor size mtime atime ctime path linkname size_in_tar tar_typeflag tar_magic tar_version tar_chksum]
|
118
118
|
|
119
|
-
def (Tb::Cmd).
|
119
|
+
def (Tb::Cmd).tar_parse_header(header_record)
|
120
120
|
ary = header_record.unpack(Tb::Cmd::TAR_HEADER_TEPMLATE)
|
121
121
|
h = {}
|
122
122
|
Tb::Cmd::TAR_HEADER_STRUCTURE.each_with_index {|(k, _), i|
|
@@ -243,7 +243,7 @@ class Tb::Cmd::TarReader
|
|
243
243
|
end
|
244
244
|
end
|
245
245
|
|
246
|
-
def (Tb::Cmd).
|
246
|
+
def (Tb::Cmd).tar_read_end_of_archive_indicator(reader)
|
247
247
|
# The end of archive indicator is two consecutive records of NULs.
|
248
248
|
# The first record is already read.
|
249
249
|
second_end_of_archive_indicator_record = reader.get_single_record("second record of the end of archive indicator")
|
@@ -259,7 +259,7 @@ def (Tb::Cmd).tar_tvf_read_end_of_archive_indicator(reader)
|
|
259
259
|
# archive indicator. ("ustar Interchange Format" in POSIX)
|
260
260
|
end
|
261
261
|
|
262
|
-
def (Tb::Cmd).
|
262
|
+
def (Tb::Cmd).tar_check_extension_record(reader, h, content_blocklength)
|
263
263
|
prefix_parameters = {}
|
264
264
|
case h[:typeflag]
|
265
265
|
when 'L' # GNU
|
@@ -302,7 +302,7 @@ def (Tb::Cmd).tar_tvf_check_extension_record(reader, h, content_blocklength)
|
|
302
302
|
nil
|
303
303
|
end
|
304
304
|
|
305
|
-
def (Tb::Cmd).
|
305
|
+
def (Tb::Cmd).tar_each(f)
|
306
306
|
offset = 0
|
307
307
|
reader = Tb::Cmd::TarReader.new(f)
|
308
308
|
prefix_parameters = {}
|
@@ -312,14 +312,14 @@ def (Tb::Cmd).tar_tvf_each(f)
|
|
312
312
|
break
|
313
313
|
end
|
314
314
|
if /\A\0*\z/ =~ header_record
|
315
|
-
|
315
|
+
tar_read_end_of_archive_indicator(reader)
|
316
316
|
break
|
317
317
|
end
|
318
|
-
h =
|
318
|
+
h = tar_parse_header(header_record)
|
319
319
|
content_numrecords = (h[:size] + Tb::Cmd::TAR_RECORD_LENGTH - 1) / Tb::Cmd::TAR_RECORD_LENGTH
|
320
320
|
content_blocklength = content_numrecords * Tb::Cmd::TAR_RECORD_LENGTH
|
321
|
-
if !Tb::Cmd.
|
322
|
-
extension_params =
|
321
|
+
if !Tb::Cmd.opt_tar_ustar
|
322
|
+
extension_params = tar_check_extension_record(reader, h, content_blocklength)
|
323
323
|
if extension_params
|
324
324
|
prefix_parameters.update extension_params
|
325
325
|
next
|
@@ -336,10 +336,10 @@ def (Tb::Cmd).tar_tvf_each(f)
|
|
336
336
|
when :link, :symlink, :directory, :character_special, :block_special, :fifo
|
337
337
|
# xxx: hardlink may have contents for posix archive.
|
338
338
|
else
|
339
|
-
if Tb::Cmd.
|
339
|
+
if Tb::Cmd.opt_tar_hash.empty?
|
340
340
|
reader.skip(content_blocklength, 'file content')
|
341
341
|
else
|
342
|
-
reader.calculate_hash(content_blocklength, h[:size], Tb::Cmd.
|
342
|
+
reader.calculate_hash(content_blocklength, h[:size], Tb::Cmd.opt_tar_hash).each {|alg, result|
|
343
343
|
h[alg] = result
|
344
344
|
}
|
345
345
|
end
|
@@ -351,7 +351,7 @@ def (Tb::Cmd).tar_tvf_each(f)
|
|
351
351
|
end
|
352
352
|
end
|
353
353
|
|
354
|
-
def (Tb::Cmd).
|
354
|
+
def (Tb::Cmd).tar_open_with0(arg)
|
355
355
|
if arg == '-'
|
356
356
|
yield $stdin
|
357
357
|
else
|
@@ -361,8 +361,8 @@ def (Tb::Cmd).tar_tvf_open_with0(arg)
|
|
361
361
|
end
|
362
362
|
end
|
363
363
|
|
364
|
-
def (Tb::Cmd).
|
365
|
-
|
364
|
+
def (Tb::Cmd).tar_open_with(arg)
|
365
|
+
tar_open_with0(arg) {|f|
|
366
366
|
magic = f.read(8)
|
367
367
|
case magic
|
368
368
|
when /\A\x1f\x8b/, /\A\037\235/ # \x1f\x8b is gzip format. \037\235 is "compress" format of old Unix.
|
@@ -423,7 +423,7 @@ def (Tb::Cmd).tar_tvf_open_with(arg)
|
|
423
423
|
}
|
424
424
|
end
|
425
425
|
|
426
|
-
def (Tb::Cmd).
|
426
|
+
def (Tb::Cmd).tar_format_filemode(typeflag, mode)
|
427
427
|
entry_type =
|
428
428
|
case Tb::Cmd::TAR_TYPEFLAG[typeflag]
|
429
429
|
when :regular then '-'
|
@@ -453,34 +453,34 @@ def (Tb::Cmd).tar_tvf_format_filemode(typeflag, mode)
|
|
453
453
|
(m & 01000 == 0 ? ?x : ?t)))
|
454
454
|
end
|
455
455
|
|
456
|
-
def (Tb::Cmd).
|
457
|
-
|
458
|
-
exit_if_help('tar
|
459
|
-
if Tb::Cmd.
|
460
|
-
STDERR.puts "Unexpected hash algorithm: #{Tb::Cmd.
|
456
|
+
def (Tb::Cmd).main_tar(argv)
|
457
|
+
op_tar.parse!(argv)
|
458
|
+
exit_if_help('tar')
|
459
|
+
if Tb::Cmd.opt_tar_hash.any? {|alg| !Tb::Cmd::TAR_HASH_ALGORITHMS[alg] }
|
460
|
+
STDERR.puts "Unexpected hash algorithm: #{Tb::Cmd.opt_tar_hash.reject {|alg| Tb::Cmd::TAR_HASH_ALGORITHMS[alg] }.join(",")}"
|
461
461
|
exit false
|
462
462
|
end
|
463
463
|
argv = ['-'] if argv.empty?
|
464
464
|
er = Tb::Enumerator.new {|y|
|
465
|
-
if Tb::Cmd.
|
465
|
+
if Tb::Cmd.opt_tar_l == 0
|
466
466
|
header = Tb::Cmd::TAR_CSV_HEADER
|
467
467
|
else
|
468
468
|
header = Tb::Cmd::TAR_CSV_LONG_HEADER
|
469
469
|
end
|
470
|
-
header += Tb::Cmd.
|
470
|
+
header += Tb::Cmd.opt_tar_hash
|
471
471
|
y.set_header header
|
472
472
|
argv.each {|filename|
|
473
|
-
|
474
|
-
|
473
|
+
tar_open_with(filename) {|f|
|
474
|
+
tar_each(f) {|h|
|
475
475
|
formatted = {}
|
476
476
|
formatted["mode"] = sprintf("0%o", h[:mode])
|
477
|
-
formatted["filemode"] =
|
477
|
+
formatted["filemode"] = tar_format_filemode(h[:typeflag], h[:mode])
|
478
478
|
formatted["uid"] = h[:uid].to_s
|
479
479
|
formatted["gid"] = h[:gid].to_s
|
480
480
|
formatted["size"] = h[:size].to_s
|
481
|
-
formatted["mtime"] = h[:mtime].iso8601(0 < Tb::Cmd.
|
482
|
-
formatted["atime"] = h[:atime].iso8601(0 < Tb::Cmd.
|
483
|
-
formatted["ctime"] = h[:ctime].iso8601(0 < Tb::Cmd.
|
481
|
+
formatted["mtime"] = h[:mtime].iso8601(0 < Tb::Cmd.opt_tar_l ? 9 : 0)
|
482
|
+
formatted["atime"] = h[:atime].iso8601(0 < Tb::Cmd.opt_tar_l ? 9 : 0) if h[:atime]
|
483
|
+
formatted["ctime"] = h[:ctime].iso8601(0 < Tb::Cmd.opt_tar_l ? 9 : 0) if h[:ctime]
|
484
484
|
formatted["user"] = h[:uname]
|
485
485
|
formatted["group"] = h[:gname]
|
486
486
|
formatted["devmajor"] = h[:devmajor].to_s
|
@@ -492,7 +492,7 @@ def (Tb::Cmd).main_tar_tvf(argv)
|
|
492
492
|
formatted["tar_typeflag"] = h[:typeflag]
|
493
493
|
formatted["tar_magic"] = h[:magic]
|
494
494
|
formatted["tar_version"] = h[:version]
|
495
|
-
Tb::Cmd.
|
495
|
+
Tb::Cmd.opt_tar_hash.each {|alg| formatted[alg] = h[alg] }
|
496
496
|
y.yield Hash[header.map {|f2| [f2, formatted[f2]] }]
|
497
497
|
}
|
498
498
|
}
|
data/lib/tb/cmdtop.rb
CHANGED
@@ -61,9 +61,9 @@ require 'tb/cmd_shape'
|
|
61
61
|
require 'tb/cmd_mheader'
|
62
62
|
require 'tb/cmd_crop'
|
63
63
|
require 'tb/cmd_ls'
|
64
|
-
require 'tb/
|
65
|
-
require 'tb/
|
66
|
-
require 'tb/
|
64
|
+
require 'tb/cmd_tar'
|
65
|
+
require 'tb/cmd_svn'
|
66
|
+
require 'tb/cmd_git'
|
67
67
|
require 'tb/cmdmain'
|
68
68
|
|
69
69
|
Tb::Cmd.init_option
|
data/test/test_cmd_git_log.rb
CHANGED
@@ -30,7 +30,7 @@ class TestTbCmdGitLog < Test::Unit::TestCase
|
|
30
30
|
File.open("foo", "w") {|f| f.puts "bar" }
|
31
31
|
system("git add foo")
|
32
32
|
system("git commit -q -m msg foo")
|
33
|
-
Tb::Cmd.
|
33
|
+
Tb::Cmd.main_git(['-o', o="o.csv"])
|
34
34
|
result = File.read(o)
|
35
35
|
tb = Tb.parse_csv(result)
|
36
36
|
assert_equal(1, tb.size)
|
@@ -43,7 +43,7 @@ class TestTbCmdGitLog < Test::Unit::TestCase
|
|
43
43
|
File.open(filename, "w") {|f| f.puts "bar" }
|
44
44
|
system("git", "add", filename)
|
45
45
|
system("git", "commit", "-q", "-m", "msg", filename)
|
46
|
-
Tb::Cmd.
|
46
|
+
Tb::Cmd.main_git(['-o', o="o.csv"])
|
47
47
|
result = File.read(o)
|
48
48
|
tb = Tb.parse_csv(result)
|
49
49
|
assert_equal(1, tb.size)
|
@@ -53,12 +53,12 @@ class TestTbCmdGitLog < Test::Unit::TestCase
|
|
53
53
|
assert_equal(filename, ftb.get_record(0)["filename"])
|
54
54
|
end
|
55
55
|
|
56
|
-
def
|
56
|
+
def test_debug_git_output_input
|
57
57
|
system("git init -q")
|
58
58
|
File.open("foo", "w") {|f| f.puts "bar" }
|
59
59
|
system("git add foo")
|
60
60
|
system("git commit -q -m msg foo")
|
61
|
-
Tb::Cmd.
|
61
|
+
Tb::Cmd.main_git(['-o', o="o.csv", '--debug-git-output', g='gitlog'])
|
62
62
|
result = File.read(o)
|
63
63
|
tb = Tb.parse_csv(result)
|
64
64
|
assert_equal(1, tb.size)
|
@@ -66,7 +66,7 @@ class TestTbCmdGitLog < Test::Unit::TestCase
|
|
66
66
|
gresult = File.read(g)
|
67
67
|
assert(!gresult.empty?)
|
68
68
|
FileUtils.rmtree('.git')
|
69
|
-
Tb::Cmd.
|
69
|
+
Tb::Cmd.main_git(['-o', o="o.csv", '--debug-git-input', g])
|
70
70
|
result = File.read(o)
|
71
71
|
tb = Tb.parse_csv(result)
|
72
72
|
assert_equal(1, tb.size)
|
@@ -78,7 +78,7 @@ class TestTbCmdGitLog < Test::Unit::TestCase
|
|
78
78
|
File.open("foo", "w") {|f| f.puts "bar" }
|
79
79
|
system("git add foo")
|
80
80
|
system("git commit -q -m msg foo")
|
81
|
-
Tb::Cmd.
|
81
|
+
Tb::Cmd.main_git(['-o', o="o.csv", '--debug-git-output', g='gitlog'])
|
82
82
|
result = File.read(o)
|
83
83
|
tb = Tb.parse_csv(result)
|
84
84
|
assert_equal(1, tb.size)
|
@@ -91,7 +91,7 @@ class TestTbCmdGitLog < Test::Unit::TestCase
|
|
91
91
|
o2 = 'o2.csv'
|
92
92
|
File.open('log', 'w') {|log|
|
93
93
|
with_stderr(log) {
|
94
|
-
Tb::Cmd.
|
94
|
+
Tb::Cmd.main_git(['-o', o2, '--debug-git-input', g])
|
95
95
|
}
|
96
96
|
}
|
97
97
|
result = File.read(o2)
|
@@ -107,7 +107,7 @@ class TestTbCmdGitLog < Test::Unit::TestCase
|
|
107
107
|
File.open("foo", "w") {|f| f.puts "bar" }
|
108
108
|
system("git add foo")
|
109
109
|
system("git commit -q -m msg foo")
|
110
|
-
Tb::Cmd.
|
110
|
+
Tb::Cmd.main_git(['-o', o="o.csv", '--debug-git-output', g='gitlog'])
|
111
111
|
result = File.read(o)
|
112
112
|
tb = Tb.parse_csv(result)
|
113
113
|
assert_equal(1, tb.size)
|
@@ -120,7 +120,7 @@ class TestTbCmdGitLog < Test::Unit::TestCase
|
|
120
120
|
o2 = 'o2.csv'
|
121
121
|
File.open('log', 'w') {|log|
|
122
122
|
with_stderr(log) {
|
123
|
-
Tb::Cmd.
|
123
|
+
Tb::Cmd.main_git(['-o', o2, '--debug-git-input', g])
|
124
124
|
}
|
125
125
|
}
|
126
126
|
result = File.read(o2)
|
@@ -136,7 +136,7 @@ class TestTbCmdGitLog < Test::Unit::TestCase
|
|
136
136
|
File.open("foo", "w") {|f| f.puts "bar" }
|
137
137
|
system("git add foo")
|
138
138
|
system("git commit -q -m msg foo")
|
139
|
-
Tb::Cmd.
|
139
|
+
Tb::Cmd.main_git(['-o', o="o.csv", '--debug-git-output', g='gitlog'])
|
140
140
|
result = File.read(o)
|
141
141
|
tb = Tb.parse_csv(result)
|
142
142
|
assert_equal(1, tb.size)
|
@@ -149,7 +149,7 @@ class TestTbCmdGitLog < Test::Unit::TestCase
|
|
149
149
|
o2 = 'o2.csv'
|
150
150
|
File.open('log', 'w') {|log|
|
151
151
|
with_stderr(log) {
|
152
|
-
Tb::Cmd.
|
152
|
+
Tb::Cmd.main_git(['-o', o2, '--debug-git-input', g])
|
153
153
|
}
|
154
154
|
}
|
155
155
|
result = File.read(o2)
|
@@ -164,7 +164,7 @@ class TestTbCmdGitLog < Test::Unit::TestCase
|
|
164
164
|
File.open("foo", "w") {|f| f.print "\0\xff" }
|
165
165
|
system("git add foo")
|
166
166
|
system("git commit -q -m msg foo")
|
167
|
-
Tb::Cmd.
|
167
|
+
Tb::Cmd.main_git(['-o', o="o.csv"])
|
168
168
|
result = File.read(o)
|
169
169
|
tb = Tb.parse_csv(result)
|
170
170
|
assert_equal(1, tb.size)
|
@@ -180,7 +180,7 @@ class TestTbCmdGitLog < Test::Unit::TestCase
|
|
180
180
|
File.open("bar/baz", "w") {|f| f.print "baz" }
|
181
181
|
system("git add bar")
|
182
182
|
system("git commit -q -m msg bar")
|
183
|
-
Tb::Cmd.
|
183
|
+
Tb::Cmd.main_git(['-o', o="o.csv", "bar"])
|
184
184
|
result = File.read(o)
|
185
185
|
tb = Tb.parse_csv(result)
|
186
186
|
assert_equal(1, tb.size)
|
data/test/test_cmd_svn_log.rb
CHANGED
@@ -33,7 +33,7 @@ class TestTbCmdSvnLog < Test::Unit::TestCase
|
|
33
33
|
system("svn add -q foo hoge")
|
34
34
|
system("svn commit -q -m baz foo hoge")
|
35
35
|
system("svn update -q") # update the revision of the directory.
|
36
|
-
Tb::Cmd.
|
36
|
+
Tb::Cmd.main_svn(['-o', o="o.csv"])
|
37
37
|
result = File.read(o)
|
38
38
|
tb = Tb.parse_csv(result)
|
39
39
|
assert_equal(1, tb.size)
|
@@ -48,7 +48,7 @@ class TestTbCmdSvnLog < Test::Unit::TestCase
|
|
48
48
|
system("svn add -q foo hoge")
|
49
49
|
system("svn commit -q -m baz foo hoge")
|
50
50
|
system("svn update -q") # update the revision of the directory.
|
51
|
-
Tb::Cmd.
|
51
|
+
Tb::Cmd.main_svn(['-o', o="o.csv", '--', '-v'])
|
52
52
|
result = File.read(o)
|
53
53
|
tb = Tb.parse_csv(result)
|
54
54
|
assert_equal(2, tb.size)
|
@@ -70,7 +70,7 @@ class TestTbCmdSvnLog < Test::Unit::TestCase
|
|
70
70
|
system("svn commit -q -m baz foo hoge")
|
71
71
|
system("svn update -q") # update the revision of the directory.
|
72
72
|
###
|
73
|
-
Tb::Cmd.
|
73
|
+
Tb::Cmd.main_svn(['-o', o="o.csv"])
|
74
74
|
result = File.read(o)
|
75
75
|
tb = Tb.parse_csv(result)
|
76
76
|
assert_equal(1, tb.size)
|
@@ -78,7 +78,7 @@ class TestTbCmdSvnLog < Test::Unit::TestCase
|
|
78
78
|
###
|
79
79
|
system("svn log --xml > log.xml")
|
80
80
|
FileUtils.rmtree('.svn')
|
81
|
-
Tb::Cmd.
|
81
|
+
Tb::Cmd.main_svn(['-o', o="o.csv", '--svn-log-xml=log.xml'])
|
82
82
|
result = File.read(o)
|
83
83
|
tb = Tb.parse_csv(result)
|
84
84
|
assert_equal(1, tb.size)
|
@@ -97,7 +97,7 @@ class TestTbCmdSvnLog < Test::Unit::TestCase
|
|
97
97
|
system("svn propdel -q svn:date --revprop -r 1 .")
|
98
98
|
system("svn propdel -q svn:log --revprop -r 1 .")
|
99
99
|
###
|
100
|
-
Tb::Cmd.
|
100
|
+
Tb::Cmd.main_svn(['-o', o="o.csv"])
|
101
101
|
result = File.read(o)
|
102
102
|
tb = Tb.parse_csv(result)
|
103
103
|
assert_equal(1, tb.size)
|
data/test/test_cmd_tar_tvf.rb
CHANGED
@@ -54,7 +54,7 @@ class TestTbCmdTarTvf < Test::Unit::TestCase
|
|
54
54
|
def test_basic
|
55
55
|
open('foo', 'w') {|f| }
|
56
56
|
assert(system('tar cf bar.tar foo'))
|
57
|
-
Tb::Cmd.
|
57
|
+
Tb::Cmd.main_tar(['-o', o='o.csv', 'bar.tar'])
|
58
58
|
assert_match(/,foo,/, File.read(o))
|
59
59
|
end
|
60
60
|
|
@@ -64,7 +64,7 @@ class TestTbCmdTarTvf < Test::Unit::TestCase
|
|
64
64
|
o = nil
|
65
65
|
open('bar.tar') {|f|
|
66
66
|
with_stdin(f) {
|
67
|
-
Tb::Cmd.
|
67
|
+
Tb::Cmd.main_tar(['-o', o='o.csv'])
|
68
68
|
}
|
69
69
|
}
|
70
70
|
assert_match(/,foo,/, File.read(o))
|
@@ -77,7 +77,7 @@ class TestTbCmdTarTvf < Test::Unit::TestCase
|
|
77
77
|
o = nil
|
78
78
|
IO.popen('cat bar.tar') {|f|
|
79
79
|
with_stdin(f) {
|
80
|
-
Tb::Cmd.
|
80
|
+
Tb::Cmd.main_tar(['-o', o='o.csv'])
|
81
81
|
}
|
82
82
|
}
|
83
83
|
assert_match(/,foo,/, File.read(o))
|
@@ -88,7 +88,7 @@ class TestTbCmdTarTvf < Test::Unit::TestCase
|
|
88
88
|
open('foo', 'w') {|f| }
|
89
89
|
assert(system('tar cf bar.tar foo'))
|
90
90
|
assert(system('gzip bar.tar'))
|
91
|
-
Tb::Cmd.
|
91
|
+
Tb::Cmd.main_tar(['-o', o='o.csv', 'bar.tar.gz'])
|
92
92
|
assert_match(/,foo,/, File.read(o))
|
93
93
|
end
|
94
94
|
|
@@ -100,7 +100,7 @@ class TestTbCmdTarTvf < Test::Unit::TestCase
|
|
100
100
|
o = nil
|
101
101
|
open('bar.tar.gz') {|f|
|
102
102
|
with_stdin(f) {
|
103
|
-
Tb::Cmd.
|
103
|
+
Tb::Cmd.main_tar(['-o', o='o.csv'])
|
104
104
|
}
|
105
105
|
}
|
106
106
|
assert_match(/,foo,/, File.read(o))
|
@@ -114,7 +114,7 @@ class TestTbCmdTarTvf < Test::Unit::TestCase
|
|
114
114
|
o = nil
|
115
115
|
IO.popen('cat bar.tar.gz') {|f|
|
116
116
|
with_stdin(f) {
|
117
|
-
Tb::Cmd.
|
117
|
+
Tb::Cmd.main_tar(['-o', o='o.csv'])
|
118
118
|
}
|
119
119
|
}
|
120
120
|
assert_match(/,foo,/, File.read(o))
|
@@ -124,7 +124,7 @@ class TestTbCmdTarTvf < Test::Unit::TestCase
|
|
124
124
|
Dir.mkdir("d")
|
125
125
|
open('d/foo', 'w') {|f| f << "hahaha" }
|
126
126
|
assert(system('tar cf bar.tar d'))
|
127
|
-
Tb::Cmd.
|
127
|
+
Tb::Cmd.main_tar(['-o', o='o.csv', '-l', 'bar.tar'])
|
128
128
|
result = File.read(o)
|
129
129
|
assert_match(%r{,d/,}, result)
|
130
130
|
assert_match(%r{,d/foo,}, result)
|
@@ -134,7 +134,7 @@ class TestTbCmdTarTvf < Test::Unit::TestCase
|
|
134
134
|
open('foo', 'w') {|f| f << "hahaha" }
|
135
135
|
File.link('foo', 'baz')
|
136
136
|
assert(system('tar cf bar.tar foo baz'))
|
137
|
-
Tb::Cmd.
|
137
|
+
Tb::Cmd.main_tar(['-o', o='o.csv', '-l', 'bar.tar'])
|
138
138
|
result = File.read(o)
|
139
139
|
assert_match(/,foo,/, result)
|
140
140
|
assert_match(/,h/, result)
|
@@ -150,7 +150,7 @@ class TestTbCmdTarTvf < Test::Unit::TestCase
|
|
150
150
|
next unless tar_and_formats.last.include? format
|
151
151
|
tar = tar_and_formats.first
|
152
152
|
assert(system("#{tar} cf bar.tar --format=#{format} #{name}"))
|
153
|
-
Tb::Cmd.
|
153
|
+
Tb::Cmd.main_tar(['-o', o='o.csv', '-l', 'bar.tar'])
|
154
154
|
result = File.read(o)
|
155
155
|
assert_equal(2, result.count("\n"), "tar format: #{format}")
|
156
156
|
assert_match(/,#{name},/, result)
|
@@ -165,7 +165,7 @@ class TestTbCmdTarTvf < Test::Unit::TestCase
|
|
165
165
|
next unless tar_and_formats.last.include? format
|
166
166
|
tar = tar_and_formats.first
|
167
167
|
assert(system("#{tar} cf bar.tar --format=#{format} #{name}"))
|
168
|
-
Tb::Cmd.
|
168
|
+
Tb::Cmd.main_tar(['-o', o='o.csv', '-l', 'bar.tar'])
|
169
169
|
result = File.read(o)
|
170
170
|
assert_equal(2, result.count("\n"), "tar format: #{format}")
|
171
171
|
assert_match(/,#{name},/, result)
|
@@ -180,7 +180,7 @@ class TestTbCmdTarTvf < Test::Unit::TestCase
|
|
180
180
|
next unless tar_and_formats.last.include? format
|
181
181
|
tar = tar_and_formats.first
|
182
182
|
assert(system("#{tar} cf bar.tar --format=#{format} foo"))
|
183
|
-
Tb::Cmd.
|
183
|
+
Tb::Cmd.main_tar(['-o', o='o.csv', '-l', 'bar.tar'])
|
184
184
|
result = File.read(o)
|
185
185
|
assert_equal(2, result.count("\n"), "tar format: #{format}")
|
186
186
|
assert_match(/,#{link},/, result)
|
@@ -196,7 +196,7 @@ class TestTbCmdTarTvf < Test::Unit::TestCase
|
|
196
196
|
next unless tar_and_formats.last.include? format
|
197
197
|
tar = tar_and_formats.first
|
198
198
|
assert(system("#{tar} cf bar.tar --format=#{format} #{name}"))
|
199
|
-
Tb::Cmd.
|
199
|
+
Tb::Cmd.main_tar(['-o', o='o.csv', '-l', 'bar.tar'])
|
200
200
|
result = File.read(o)
|
201
201
|
assert_equal(2, result.count("\n"))
|
202
202
|
assert_match(/,#{name},/, result)
|
@@ -215,7 +215,7 @@ class TestTbCmdTarTvf < Test::Unit::TestCase
|
|
215
215
|
next unless tar_and_formats.last.include? format
|
216
216
|
tar = tar_and_formats.first
|
217
217
|
assert(system("#{tar} cf bar.tar --format=#{format} #{name}"))
|
218
|
-
Tb::Cmd.
|
218
|
+
Tb::Cmd.main_tar(['-o', o='o.csv', '-l', 'bar.tar'])
|
219
219
|
result = File.read(o)
|
220
220
|
assert_equal(2, result.count("\n"), "tar format: #{format}")
|
221
221
|
assert_match(/,#{Regexp.escape mtime.iso8601(9)},/, result, "tar format: #{format}")
|
@@ -233,7 +233,7 @@ class TestTbCmdTarTvf < Test::Unit::TestCase
|
|
233
233
|
next unless tar_and_formats.last.include? format
|
234
234
|
tar = tar_and_formats.first
|
235
235
|
assert(system("#{tar} cf bar.tar --format=#{format} #{name}"))
|
236
|
-
Tb::Cmd.
|
236
|
+
Tb::Cmd.main_tar(['-o', o='o.csv', '-l', 'bar.tar'])
|
237
237
|
result = File.read(o)
|
238
238
|
assert_equal(2, result.count("\n"), "tar format: #{format}")
|
239
239
|
assert_match(/,#{Regexp.escape atime.iso8601(9)},/, result, "tar format: #{format}")
|
@@ -252,7 +252,7 @@ class TestTbCmdTarTvf < Test::Unit::TestCase
|
|
252
252
|
next unless tar_and_formats.last.include? format
|
253
253
|
tar = tar_and_formats.first
|
254
254
|
assert(system("#{tar} cf bar.tar --format=#{format} #{name}"))
|
255
|
-
Tb::Cmd.
|
255
|
+
Tb::Cmd.main_tar(['-o', o='o.csv', '-l', 'bar.tar'])
|
256
256
|
result = File.read(o)
|
257
257
|
assert_equal(2, result.count("\n"), "tar format: #{format}")
|
258
258
|
assert_match(/,#{Regexp.escape mtime.iso8601(9)},/, result, "tar format: #{format}")
|
@@ -271,7 +271,7 @@ class TestTbCmdTarTvf < Test::Unit::TestCase
|
|
271
271
|
next unless tar_and_formats.last.include? format
|
272
272
|
tar = tar_and_formats.first
|
273
273
|
assert(system("#{tar} cf bar.tar --format=#{format} #{name}"))
|
274
|
-
Tb::Cmd.
|
274
|
+
Tb::Cmd.main_tar(['-o', o='o.csv', '-l', 'bar.tar'])
|
275
275
|
result = File.read(o)
|
276
276
|
assert_equal(2, result.count("\n"), "tar format: #{format}")
|
277
277
|
assert_match(/,#{Regexp.escape atime.iso8601(9)},/, result, "tar format: #{format}")
|
@@ -284,7 +284,7 @@ class TestTbCmdTarTvf < Test::Unit::TestCase
|
|
284
284
|
assert(system('tar cf foo.tar foo'))
|
285
285
|
%w[MD5 SHA1 SHA256 SHA384 SHA512].each {|cname|
|
286
286
|
alg = cname.downcase
|
287
|
-
Tb::Cmd.
|
287
|
+
Tb::Cmd.main_tar(['-o', o='o.csv', "--hash=#{alg}", 'foo.tar'])
|
288
288
|
result = File.read(o)
|
289
289
|
assert_equal(2, result.count("\n"), "hash algorithm: #{alg}")
|
290
290
|
assert_match(/,#{Regexp.escape Digest.const_get(cname).hexdigest(str)}$/, result, "hash algorithm: #{alg}")
|
@@ -297,7 +297,7 @@ class TestTbCmdTarTvf < Test::Unit::TestCase
|
|
297
297
|
assert(system('tar cf foo.tar foo'))
|
298
298
|
%w[MD5 SHA1 SHA256 SHA384 SHA512].each {|cname|
|
299
299
|
alg = cname.downcase
|
300
|
-
Tb::Cmd.
|
300
|
+
Tb::Cmd.main_tar(['-o', o='o.csv', "--hash=#{alg}", 'foo.tar'])
|
301
301
|
result = File.read(o)
|
302
302
|
assert_equal(2, result.count("\n"), "hash algorithm: #{alg}")
|
303
303
|
assert_match(/,#{Regexp.escape Digest.const_get(cname).hexdigest(str)}$/, result, "hash algorithm: #{alg}")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.7'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-29 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! 'tb is a manipulation tool for table: CSV, TSV, JSON, etc.
|
15
15
|
|
@@ -22,7 +22,7 @@ description: ! 'tb is a manipulation tool for table: CSV, TSV, JSON, etc.
|
|
22
22
|
|
23
23
|
other table operations (gsub, rename, cross, melt, unmelt, etc.),
|
24
24
|
|
25
|
-
information extractions (git
|
25
|
+
information extractions (git, svn, tar),
|
26
26
|
|
27
27
|
and more.
|
28
28
|
|
@@ -43,7 +43,7 @@ files:
|
|
43
43
|
- lib/tb/cmd_crop.rb
|
44
44
|
- lib/tb/cmd_cross.rb
|
45
45
|
- lib/tb/cmd_cut.rb
|
46
|
-
- lib/tb/
|
46
|
+
- lib/tb/cmd_git.rb
|
47
47
|
- lib/tb/cmd_grep.rb
|
48
48
|
- lib/tb/cmd_group.rb
|
49
49
|
- lib/tb/cmd_gsub.rb
|
@@ -57,8 +57,8 @@ files:
|
|
57
57
|
- lib/tb/cmd_rename.rb
|
58
58
|
- lib/tb/cmd_shape.rb
|
59
59
|
- lib/tb/cmd_sort.rb
|
60
|
-
- lib/tb/
|
61
|
-
- lib/tb/
|
60
|
+
- lib/tb/cmd_svn.rb
|
61
|
+
- lib/tb/cmd_tar.rb
|
62
62
|
- lib/tb/cmd_to_csv.rb
|
63
63
|
- lib/tb/cmd_to_json.rb
|
64
64
|
- lib/tb/cmd_to_pnm.rb
|