minitar-cli 0.9 → 1.0.0
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.
- checksums.yaml +4 -4
- data/Code-of-Conduct.md +128 -0
- data/Contributing.md +33 -34
- data/History.md +17 -8
- data/Licence.md +4 -4
- data/Manifest.txt +1 -0
- data/README.rdoc +1 -6
- data/Rakefile +16 -24
- data/bin/minitar +3 -3
- data/lib/minitar/cli/command/create.rb +16 -16
- data/lib/minitar/cli/command/extract.rb +29 -29
- data/lib/minitar/cli/command/help.rb +6 -6
- data/lib/minitar/cli/command/list.rb +42 -42
- data/lib/minitar/cli/command.rb +2 -2
- data/lib/minitar/cli/commander.rb +7 -7
- data/lib/minitar/cli.rb +23 -21
- data/test/fixtures/spaces.tar.gz +0 -0
- data/test/minitest_helper.rb +6 -5
- data/test/support/minitar_cli_test_helper.rb +7 -1
- data/test/test_cli_help.rb +11 -11
- data/test/test_cli_list.rb +42 -57
- metadata +53 -39
@@ -5,14 +5,14 @@
|
|
5
5
|
# support have been dropped.
|
6
6
|
class Minitar::CLI::Command::List < Minitar::CLI::Command
|
7
7
|
def name
|
8
|
-
|
8
|
+
"list"
|
9
9
|
end
|
10
10
|
|
11
11
|
def altname
|
12
|
-
|
12
|
+
"ls"
|
13
13
|
end
|
14
14
|
|
15
|
-
HELP = <<-EOH
|
15
|
+
HELP = <<-EOH
|
16
16
|
minitar list [OPTIONS] <tarfile|-> [<file>+]
|
17
17
|
|
18
18
|
Lists files in an existing tarfile. If the tarfile is named .tar.gz or
|
@@ -36,32 +36,32 @@ Sort Fields:
|
|
36
36
|
EOH
|
37
37
|
|
38
38
|
def modestr(mode)
|
39
|
-
s = String.new(
|
40
|
-
s[0] =
|
41
|
-
s[1] =
|
42
|
-
s[2] =
|
39
|
+
s = String.new("---")
|
40
|
+
s[0] = "r" if (mode & 4) == 4
|
41
|
+
s[1] = "w" if (mode & 2) == 2
|
42
|
+
s[2] = "x" if (mode & 1) == 1
|
43
43
|
s
|
44
44
|
end
|
45
45
|
|
46
46
|
include CatchMinitarErrors
|
47
47
|
|
48
48
|
def run(args, opts = {})
|
49
|
-
argv
|
50
|
-
output
|
51
|
-
files
|
52
|
-
opts[:field] =
|
49
|
+
argv = []
|
50
|
+
output = nil
|
51
|
+
files = []
|
52
|
+
opts[:field] = "name"
|
53
53
|
|
54
54
|
while (arg = args.shift)
|
55
55
|
case arg
|
56
|
-
when
|
57
|
-
opts[:sort]
|
58
|
-
opts[:field]
|
59
|
-
when
|
56
|
+
when "--sort", "-S"
|
57
|
+
opts[:sort] = true
|
58
|
+
opts[:field] = args.shift
|
59
|
+
when "--reverse", "-R"
|
60
60
|
opts[:reverse] = true
|
61
|
-
opts[:sort]
|
62
|
-
when
|
61
|
+
opts[:sort] = true
|
62
|
+
when "--uncompress", "-z"
|
63
63
|
opts[:uncompress] = true
|
64
|
-
when
|
64
|
+
when "-l"
|
65
65
|
opts[:verbose] = true
|
66
66
|
else
|
67
67
|
argv << arg
|
@@ -70,35 +70,35 @@ Sort Fields:
|
|
70
70
|
|
71
71
|
if argv.empty?
|
72
72
|
ioe[:output] << "Not enough arguments.\n\n"
|
73
|
-
commander.command(
|
73
|
+
commander.command("help").call(%w(list))
|
74
74
|
return 255
|
75
75
|
end
|
76
76
|
|
77
77
|
input = argv.shift
|
78
|
-
if
|
79
|
-
opts[:name] =
|
78
|
+
if input == "-"
|
79
|
+
opts[:name] = "STDIN"
|
80
80
|
input = ioe[:input]
|
81
81
|
else
|
82
82
|
opts[:name] = input
|
83
|
-
input = File.open(input,
|
83
|
+
input = File.open(input, "rb")
|
84
84
|
end
|
85
85
|
|
86
|
-
if
|
87
|
-
require
|
86
|
+
if /\.tar\.gz$|\.tgz$/ =~ opts[:name] || opts[:uncompress]
|
87
|
+
require "zlib"
|
88
88
|
input = Zlib::GzipReader.new(input)
|
89
89
|
end
|
90
90
|
|
91
91
|
files << argv.to_a
|
92
92
|
files.flatten!
|
93
93
|
|
94
|
-
if opts[:verbose]
|
95
|
-
format
|
96
|
-
datefmt =
|
97
|
-
timefmt =
|
98
|
-
fields
|
94
|
+
if opts[:verbose] || opts[:progress]
|
95
|
+
format = "%10s %4d %8s %8s %8d %12s %s"
|
96
|
+
datefmt = "%b %d %Y"
|
97
|
+
timefmt = "%b %d %H:%M"
|
98
|
+
fields = %w(permissions inodes user group size date fullname)
|
99
99
|
else
|
100
|
-
format
|
101
|
-
fields
|
100
|
+
format = "%s"
|
101
|
+
fields = %w(fullname)
|
102
102
|
end
|
103
103
|
|
104
104
|
opts[:field] = opts[:field].to_sym
|
@@ -109,44 +109,44 @@ Sort Fields:
|
|
109
109
|
today = Time.now
|
110
110
|
oneyear = Time.mktime(today.year - 1, today.month, today.day)
|
111
111
|
|
112
|
-
|
112
|
+
Minitar::Input.each_entry(input) do |entry|
|
113
113
|
next unless files.empty? || files.include?(entry.full_name)
|
114
114
|
|
115
115
|
value = format % fields.map { |ff|
|
116
116
|
case ff
|
117
|
-
when
|
118
|
-
s = String.new(entry.directory? ?
|
117
|
+
when "permissions"
|
118
|
+
s = String.new(entry.directory? ? "d" : "-")
|
119
119
|
s << modestr(entry.mode / 0o100)
|
120
120
|
s << modestr(entry.mode / 0o010)
|
121
121
|
s << modestr(entry.mode)
|
122
|
-
when
|
122
|
+
when "inodes"
|
123
123
|
entry.size / 512
|
124
|
-
when
|
124
|
+
when "user"
|
125
125
|
entry.uname || entry.uid || 0
|
126
|
-
when
|
126
|
+
when "group"
|
127
127
|
entry.gname || entry.gid || 0
|
128
|
-
when
|
128
|
+
when "size"
|
129
129
|
entry.size
|
130
|
-
when
|
130
|
+
when "date"
|
131
131
|
if Time.at(entry.mtime) > oneyear
|
132
132
|
Time.at(entry.mtime).strftime(timefmt)
|
133
133
|
else
|
134
134
|
Time.at(entry.mtime).strftime(datefmt)
|
135
135
|
end
|
136
|
-
when
|
136
|
+
when "fullname"
|
137
137
|
entry.full_name
|
138
138
|
end
|
139
139
|
}
|
140
140
|
|
141
141
|
if opts[:sort]
|
142
|
-
output << [
|
142
|
+
output << [entry.send(opts[:field]), value]
|
143
143
|
else
|
144
144
|
ioe[:output] << value << "\n"
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
148
148
|
if opts[:sort]
|
149
|
-
output = output.
|
149
|
+
output = output.sort_by { |a| a[0] }
|
150
150
|
if opts[:reverse]
|
151
151
|
output.reverse_each { |oo| ioe[:output] << oo[1] << "\n" }
|
152
152
|
else
|
data/lib/minitar/cli/command.rb
CHANGED
@@ -20,7 +20,7 @@ class Minitar::CLI::Command
|
|
20
20
|
module CatchMinitarErrors # :nodoc:
|
21
21
|
def call(args, opts)
|
22
22
|
run(args, opts)
|
23
|
-
rescue
|
23
|
+
rescue Minitar::Error => error
|
24
24
|
ioe[:error] << "#{error}\n"
|
25
25
|
5
|
26
26
|
end
|
@@ -38,7 +38,7 @@ class Minitar::CLI::Command
|
|
38
38
|
def call(_args, _opts = {})
|
39
39
|
raise Minitar::CLI::AbstractCommandError
|
40
40
|
end
|
41
|
-
|
41
|
+
alias_method :[], :call
|
42
42
|
|
43
43
|
def help
|
44
44
|
raise Minitar::CLI::AbstractCommandError
|
@@ -15,7 +15,7 @@ class Minitar::CLI::Commander
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def register(command)
|
18
|
-
command = command.new(self) if command.
|
18
|
+
command = command.new(self) if command.is_a?(Class)
|
19
19
|
raise CommandAlreadyExists if command.commander != self
|
20
20
|
raise CommandAlreadyExists if command?(command.name)
|
21
21
|
|
@@ -29,10 +29,10 @@ class Minitar::CLI::Commander
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def default_command=(command)
|
32
|
-
command = command.new if command.
|
32
|
+
command = command.new if command.is_a?(Class)
|
33
33
|
|
34
34
|
@default_command =
|
35
|
-
if command.
|
35
|
+
if command.is_a?(Minitar::CLI::Command)
|
36
36
|
register(command) unless command?(command.name)
|
37
37
|
command
|
38
38
|
elsif command?(command)
|
@@ -53,12 +53,12 @@ class Minitar::CLI::Commander
|
|
53
53
|
default_command
|
54
54
|
end
|
55
55
|
end
|
56
|
-
|
56
|
+
alias_method :[], :command
|
57
57
|
|
58
58
|
def default_ioe(ioe = {})
|
59
|
-
ioe[:input]
|
60
|
-
ioe[:output]
|
61
|
-
ioe[:error]
|
59
|
+
ioe[:input] ||= $stdin
|
60
|
+
ioe[:output] ||= $stdout
|
61
|
+
ioe[:error] ||= $stderr
|
62
62
|
ioe
|
63
63
|
end
|
64
64
|
end
|
data/lib/minitar/cli.rb
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "minitar"
|
4
4
|
|
5
5
|
# The Minitar command-line application.
|
6
6
|
class Minitar::CLI
|
7
|
-
VERSION =
|
7
|
+
VERSION = "1.0.0" # :nodoc:
|
8
8
|
|
9
9
|
# rubocop:disable Lint/InheritException
|
10
10
|
class AbstractCommandError < Exception; end
|
11
|
+
|
11
12
|
# rubocop:enable Lint/InheritException
|
12
13
|
class UnknownCommandError < StandardError; end
|
14
|
+
|
13
15
|
class CommandAlreadyExists < StandardError; end
|
14
16
|
|
15
17
|
def self.run(argv, input = $stdin, output = $stdout, error = $stderr)
|
@@ -21,44 +23,44 @@ class Minitar::CLI
|
|
21
23
|
|
22
24
|
def initialize(input = $stdin, output = $stdout, error = $stderr)
|
23
25
|
@ioe = {
|
24
|
-
:input
|
26
|
+
:input => input,
|
25
27
|
:output => output,
|
26
|
-
:error
|
28
|
+
:error => error
|
27
29
|
}
|
28
30
|
@commander = Minitar::CLI::Commander.new(ioe)
|
29
31
|
Minitar::CLI::Command.children.each do |command|
|
30
32
|
commander.register(command)
|
31
33
|
end
|
32
|
-
commander.default_command =
|
34
|
+
commander.default_command = "help"
|
33
35
|
end
|
34
36
|
|
35
37
|
def run(argv)
|
36
38
|
opts = {}
|
37
39
|
|
38
|
-
output << "minitar #{VERSION}\n" if argv.include?(
|
40
|
+
output << "minitar #{VERSION}\n" if argv.include?("--version")
|
39
41
|
|
40
|
-
if argv.include?(
|
42
|
+
if argv.include?("--verbose") || argv.include?("-V")
|
41
43
|
opts[:verbose] = true
|
42
|
-
argv.delete(
|
43
|
-
argv.delete(
|
44
|
+
argv.delete("--verbose")
|
45
|
+
argv.delete("-V")
|
44
46
|
end
|
45
47
|
|
46
|
-
if argv.include?(
|
48
|
+
if argv.include?("--progress") || argv.include?("-P")
|
47
49
|
opts[:progress] = true
|
48
|
-
opts[:verbose]
|
49
|
-
argv.delete(
|
50
|
-
argv.delete(
|
50
|
+
opts[:verbose] = false
|
51
|
+
argv.delete("--progress")
|
52
|
+
argv.delete("-P")
|
51
53
|
end
|
52
54
|
|
53
|
-
command = commander[(argv.shift or
|
54
|
-
command ||= commander[
|
55
|
+
command = commander[(argv.shift or "").downcase]
|
56
|
+
command ||= commander["help"]
|
55
57
|
command.call(argv, opts)
|
56
58
|
end
|
57
59
|
end
|
58
60
|
|
59
|
-
require
|
60
|
-
require
|
61
|
-
require
|
62
|
-
require
|
63
|
-
require
|
64
|
-
require
|
61
|
+
require "minitar/cli/command"
|
62
|
+
require "minitar/cli/commander"
|
63
|
+
require "minitar/cli/command/help"
|
64
|
+
require "minitar/cli/command/create"
|
65
|
+
require "minitar/cli/command/extract"
|
66
|
+
require "minitar/cli/command/list"
|
data/test/fixtures/spaces.tar.gz
CHANGED
Binary file
|
data/test/minitest_helper.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "fileutils"
|
4
|
+
require "minitar"
|
5
5
|
|
6
|
-
gem
|
7
|
-
require
|
6
|
+
gem "minitest"
|
7
|
+
require "minitest/autorun"
|
8
|
+
require "minitest/focus"
|
8
9
|
|
9
|
-
Dir.glob(File.join(File.dirname(__FILE__),
|
10
|
+
Dir.glob(File.join(File.dirname(__FILE__), "support/*.rb")).sort.each do |support|
|
10
11
|
require support
|
11
12
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "minitar/cli"
|
4
4
|
|
5
5
|
module MinitarCLITestHelper
|
6
6
|
def cli(*args)
|
@@ -11,5 +11,11 @@ module MinitarCLITestHelper
|
|
11
11
|
Regexp.union(*r)
|
12
12
|
end
|
13
13
|
|
14
|
+
def assert_cli_output(first, last, &block)
|
15
|
+
out, _err = capture_io(&block)
|
16
|
+
assert_match first, out, "first line of output"
|
17
|
+
assert_match last, out, "last line of output"
|
18
|
+
end
|
19
|
+
|
14
20
|
Minitest::Test.send(:include, self)
|
15
21
|
end
|
data/test/test_cli_help.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "minitest_helper"
|
4
4
|
|
5
5
|
class TestCLIHelp < Minitest::Test
|
6
6
|
def test_help_output_with_no_args
|
@@ -11,61 +11,61 @@ class TestCLIHelp < Minitest::Test
|
|
11
11
|
|
12
12
|
def test_help_output_with_help
|
13
13
|
assert_output Minitar::CLI::Command::Help::BASIC do
|
14
|
-
assert_equal 0, cli(
|
14
|
+
assert_equal 0, cli("help")
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_help_output_with_bad_command
|
19
19
|
assert_output Minitar::CLI::Command::Help::BASIC do
|
20
|
-
assert_equal 0, cli(
|
20
|
+
assert_equal 0, cli("foo")
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_help_output_with_help_bad_command
|
25
25
|
assert_output "Unknown command: foo\n#{Minitar::CLI::Command::Help::BASIC}" do
|
26
|
-
assert_equal 0, cli(
|
26
|
+
assert_equal 0, cli("help", "foo")
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_help_output_commands
|
31
31
|
assert_output Minitar::CLI::Command::Help::COMMANDS do
|
32
|
-
assert_equal 0, cli(
|
32
|
+
assert_equal 0, cli("help", "commands")
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_help_output_create
|
37
37
|
assert_output Minitar::CLI::Command::Create::HELP do
|
38
|
-
assert_equal 0, cli(
|
38
|
+
assert_equal 0, cli("help", "create")
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
def test_help_output_create_minargs
|
43
43
|
assert_output "Not enough arguments.\n\n#{Minitar::CLI::Command::Create::HELP}" do
|
44
|
-
assert_equal 255, cli(
|
44
|
+
assert_equal 255, cli("create")
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
def test_help_output_list
|
49
49
|
assert_output Minitar::CLI::Command::List::HELP do
|
50
|
-
assert_equal 0, cli(
|
50
|
+
assert_equal 0, cli("help", "list")
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
54
|
def test_help_output_list_minargs
|
55
55
|
assert_output "Not enough arguments.\n\n#{Minitar::CLI::Command::List::HELP}" do
|
56
|
-
assert_equal 255, cli(
|
56
|
+
assert_equal 255, cli("list")
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
def test_help_output_extract
|
61
61
|
assert_output Minitar::CLI::Command::Extract::HELP do
|
62
|
-
assert_equal 0, cli(
|
62
|
+
assert_equal 0, cli("help", "extract")
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
66
|
def test_help_output_extract_minargs
|
67
67
|
assert_output "Not enough arguments.\n\n#{Minitar::CLI::Command::Extract::HELP}" do
|
68
|
-
assert_equal 255, cli(
|
68
|
+
assert_equal 255, cli("extract")
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
data/test/test_cli_list.rb
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "minitest_helper"
|
4
|
+
|
3
5
|
class TestCLIList < Minitest::Test
|
4
6
|
def list_bad_dir(args = [])
|
5
|
-
cli_list(
|
7
|
+
cli_list("bad-dir", args)
|
6
8
|
end
|
7
9
|
|
8
10
|
def list_spaces(args = [])
|
9
|
-
cli_list(
|
11
|
+
cli_list("spaces", args)
|
10
12
|
end
|
11
13
|
|
12
14
|
def cli_list(name, args = [])
|
13
|
-
args = %W
|
15
|
+
args = %W[list test/fixtures/#{name}.tar.gz] + Array(args)
|
14
16
|
cli(*args)
|
15
17
|
end
|
16
18
|
|
@@ -21,103 +23,86 @@ class TestCLIList < Minitest::Test
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def test_list_output_spaces
|
24
|
-
|
26
|
+
assert_cli_output %r{\Afirst-added$}, %r{^last-added\n\z} do
|
25
27
|
assert_equal 0, list_spaces
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
29
31
|
def test_list_output_spaces_verbose
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
assert_output r(patterns) do
|
35
|
-
assert_equal 0, list_spaces('--verbose')
|
32
|
+
first = %r{\A-rw-r--r--\s+0\s+austin\s+staff\s+2\s+Feb\s+15\s+2007\s+first-added$}
|
33
|
+
last = %r{^-rw-r--r--\s+0\s+austin\s+staff\s+3\s+Feb\s+15\s+2008\s+last-added\n\z}
|
34
|
+
assert_cli_output first, last do
|
35
|
+
assert_equal 0, list_spaces("--verbose")
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_list_output_spaces_verbose_sort_size
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
assert_equal 0, list_spaces(%w(--verbose --sort size))
|
40
|
+
first = %r{\A-rw-r--r--\s+0\s+austin\s+staff\s+0\s+Feb\s+15\s+2005\s+000-bytes$}
|
41
|
+
last = %r{^-rw-r--r--\s+0\s+austin\s+staff\s+16\s+Feb\s+15\s+2006\s+largest\n\z}
|
42
|
+
|
43
|
+
assert_cli_output first, last do
|
44
|
+
assert_equal 0, list_spaces(%w[--verbose --sort size])
|
46
45
|
end
|
47
46
|
end
|
48
47
|
|
49
48
|
def test_list_output_spaces_verbose_sort_size_reverse
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
assert_output r(patterns) do
|
56
|
-
assert_equal 0, list_spaces(%w(--verbose --sort size --reverse))
|
49
|
+
first = %r{\A-rw-r--r--\s+0\s+austin\s+staff\s+16\s+Feb\s+15\s+2006\s+largest$}
|
50
|
+
last = %r{^-rw-r--r--\s+0\s+austin\s+staff\s+0\s+Feb\s+15\s+2005\s+000-bytes\n\z}
|
51
|
+
assert_cli_output first, last do
|
52
|
+
assert_equal 0, list_spaces(%w[--verbose --sort size --reverse])
|
57
53
|
end
|
58
54
|
end
|
59
55
|
|
60
56
|
def test_list_output_spaces_verbose_sort_name
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
assert_output r(patterns) do
|
66
|
-
assert_equal 0, list_spaces(%w(--verbose --sort name))
|
57
|
+
first = %r{\A-rw-r--r--\s+0\s+austin\s+staff\s+4\s+Feb\s+15\s+2009\s+00-name$}
|
58
|
+
last = %r{^-rw-r--r--\s+0\s+austin\s+staff\s+5\s+Feb\s+15\s+2010\s+zz-name\n\z}
|
59
|
+
assert_cli_output first, last do
|
60
|
+
assert_equal 0, list_spaces(%w[--verbose --sort name])
|
67
61
|
end
|
68
62
|
end
|
69
63
|
|
70
64
|
def test_list_output_spaces_verbose_sort_name_reverse
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
assert_output r(patterns) do
|
77
|
-
assert_equal 0, list_spaces(%w(--verbose --sort name --reverse))
|
65
|
+
first = %r{\A-rw-r--r--\s+0\s+austin\s+staff\s+5\s+Feb\s+15\s+2010\s+zz-name$}
|
66
|
+
last = %r{^-rw-r--r--\s+0\s+austin\s+staff\s+4\s+Feb\s+15\s+2009\s+00-name\n\z}
|
67
|
+
assert_cli_output first, last do
|
68
|
+
assert_equal 0, list_spaces(%w[--verbose --sort name --reverse])
|
78
69
|
end
|
79
70
|
end
|
80
71
|
|
81
72
|
def test_list_output_spaces_verbose_sort_mtime
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
assert_output r(patterns) do
|
87
|
-
assert_equal 0, list_spaces(%w(--verbose --sort mtime))
|
73
|
+
first = %r{\A-rw-r--r--\s+0\s+austin\s+staff\s+6\s+Feb\s+15\s+2004\s+earliest$}
|
74
|
+
last = %r{^-rw-r--r--\s+0\s+austin\s+staff\s+7\s+Feb\s+15\s+2014\s+latest\n\z}
|
75
|
+
assert_cli_output first, last do
|
76
|
+
assert_equal 0, list_spaces(%w[--verbose --sort mtime])
|
88
77
|
end
|
89
78
|
end
|
90
79
|
|
91
80
|
def test_list_output_spaces_verbose_sort_mtime_reverse
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
assert_output r(patterns) do
|
98
|
-
assert_equal 0, list_spaces(%w(--verbose --sort mtime --reverse))
|
81
|
+
first = %r{\A-rw-r--r--\s+0\s+austin\s+staff\s+7\s+Feb\s+15\s+2014\s+latest$}
|
82
|
+
last = %r{^-rw-r--r--\s+0\s+austin\s+staff\s+6\s+Feb\s+15\s+2004\s+earliest\n\z}
|
83
|
+
assert_cli_output first, last do
|
84
|
+
assert_equal 0, list_spaces(%w[--verbose --sort mtime --reverse])
|
99
85
|
end
|
100
86
|
end
|
101
87
|
|
102
88
|
def test_list_stdin
|
103
89
|
assert_output "../qwerty\n" do
|
104
|
-
File.open(
|
105
|
-
assert_equal 0, Minitar::CLI.run(%w
|
90
|
+
File.open("test/fixtures/bad-dir.tar.gz") do |f|
|
91
|
+
assert_equal 0, Minitar::CLI.run(%w[list - --uncompress], f)
|
106
92
|
end
|
107
93
|
end
|
108
94
|
end
|
109
95
|
|
110
96
|
def test_list_output_spaces_filtered
|
111
|
-
assert_output "
|
112
|
-
assert_equal 0, list_spaces(
|
97
|
+
assert_output "zz-name\n" do
|
98
|
+
assert_equal 0, list_spaces("zz-name")
|
113
99
|
end
|
114
100
|
end
|
115
101
|
|
116
102
|
def test_list_output_spaces_filtered_verbose
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
assert_equal 0, list_spaces(['./bin/minitar', '--verbose'])
|
103
|
+
pattern = %r{\A-rw-r--r--\s+0\s+austin\s+staff\s+5\s+Feb\s+15\s+2010\s+zz-name\n\z}
|
104
|
+
assert_output pattern do
|
105
|
+
assert_equal 0, list_spaces(["zz-name", "--verbose"])
|
121
106
|
end
|
122
107
|
end
|
123
108
|
end
|