ruby_ex 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +177 -0
- data/NEWS +20 -11
- data/SPEC.dyn.yml +4 -4
- data/SPEC.gemspec +4 -4
- data/SPEC.yml +4 -1
- data/lib/cache.rb +2 -2
- data/lib/commands.rb +19 -1
- data/lib/commands/command.rb +5 -5
- data/lib/commands/datas/composite.rb +26 -4
- data/lib/commands/datas/data.rb +6 -5
- data/lib/commands/pipe.rb +55 -14
- data/lib/commands/runners/fork.rb +6 -2
- data/lib/commands/runners/{mock.rb → mockable.rb} +21 -22
- data/lib/commands/runners/runner.rb +13 -1
- data/lib/d_logger.rb +11 -5
- data/lib/diff_tools.rb +141 -0
- data/lib/drb/insecure_protected_methods.rb +2 -2
- data/lib/file_type.rb +29 -21
- data/lib/hookable.rb +17 -2
- data/lib/md5sum.rb +2 -2
- data/lib/module/autoload_tree.rb +2 -2
- data/lib/ordered_hash.rb +28 -1
- data/lib/regex_list.rb +192 -0
- data/lib/ruby_ex.rb +8 -5
- data/lib/sendmail.rb +8 -1
- data/lib/sym_tbl_gsub.rb +44 -18
- data/lib/uri/file.rb +2 -2
- data/lib/uri/ftp_ex.rb +2 -2
- data/lib/uri/http_ex.rb +2 -2
- data/lib/uri/ssh.rb +1 -1
- data/lib/uri/svn.rb +2 -2
- data/lib/uri_ex.rb +4 -7
- data/lib/yaml/chop_header.rb +1 -1
- data/test/check-pkg-ruby_ex.yml +5 -7
- data/test/check-ruby_ex.yml +6 -10
- data/test/{resources → fixtures}/autoload_tree/A.rb +0 -0
- data/test/{resources → fixtures}/autoload_tree/B.rb +0 -0
- data/test/{resources → fixtures}/autoload_tree/foo/C.rb +0 -0
- data/test/fixtures/foo.bz2 +0 -0
- data/test/fixtures/foo.gz.zip +0 -0
- data/test/fixtures/foo.rb.gz +0 -0
- data/test/fixtures/foo.tar +0 -0
- data/test/fixtures/foo.tar.bz2 +0 -0
- data/test/{resources → fixtures}/foo.tar.gz +0 -0
- data/test/{resources → fixtures}/foo.txt +0 -0
- data/test/fixtures/my_diff.patch +164 -0
- data/test/{resources → fixtures}/tar.gz.log +0 -0
- data/test/sanity/multiple-requires.yml +1 -1
- data/test/sanity/single-requires.yml +1 -1
- metadata +23 -16
data/lib/commands/pipe.rb
CHANGED
@@ -1,36 +1,61 @@
|
|
1
1
|
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
2
|
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
3
3
|
# License:: GNU General Public License (GPL).
|
4
|
-
# Revision:: $Id: pipe.rb
|
4
|
+
# Revision:: $Id: pipe.rb 365 2005-09-24 17:24:01Z ertai $
|
5
5
|
|
6
6
|
require 'commands'
|
7
7
|
|
8
|
+
class IO
|
9
|
+
|
10
|
+
def pipe?
|
11
|
+
false
|
12
|
+
end
|
13
|
+
|
14
|
+
class << self
|
15
|
+
|
16
|
+
alias_method :pipe_without_pipe?, :pipe
|
17
|
+
|
18
|
+
def pipe
|
19
|
+
ios = pipe_without_pipe?
|
20
|
+
ios.each do |io|
|
21
|
+
io.send(:define_singleton_method, :pipe?) { true }
|
22
|
+
end
|
23
|
+
ios
|
24
|
+
end
|
25
|
+
|
26
|
+
end # class << self
|
27
|
+
|
28
|
+
end # class IO
|
29
|
+
|
8
30
|
module Commands
|
9
31
|
|
10
32
|
class Pipe < Command
|
11
33
|
|
12
34
|
def initialize ( *cmds )
|
13
|
-
@cmds = cmds.map { |x| x.dup }
|
14
|
-
@input, @output, @error = nil, nil, nil
|
35
|
+
@cmds = cmds.flatten.map { |x| x.dup }
|
15
36
|
end
|
16
37
|
|
17
|
-
def run (
|
18
|
-
|
38
|
+
def run ( runner=@runner )
|
39
|
+
datas = Datas::Composite.new
|
40
|
+
runner = runner.dup
|
41
|
+
runner.hook_trigger :display_command, self
|
42
|
+
runner.disable_hook :display_command
|
43
|
+
runner.disable_hook :waitpid
|
19
44
|
([nil] + @cmds).zip(@cmds + [nil]).each do |cmd1, cmd2|
|
20
45
|
next if cmd1.nil? or cmd2.nil?
|
21
46
|
rd, wr = IO.pipe
|
47
|
+
cmd1_runner = runner.dup
|
48
|
+
cmd1_runner.disable_hook :waitpid
|
49
|
+
cmd1_runner.subscribe_hook(:son) { rd.close }
|
22
50
|
cmd1.output = wr
|
23
51
|
cmd2.input = rd
|
24
|
-
|
25
|
-
rd.close
|
26
|
-
cmd1.exec
|
27
|
-
end
|
52
|
+
datas << cmd1.run(cmd1_runner)
|
28
53
|
wr.close
|
29
54
|
end
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
55
|
+
runner = runner.dup
|
56
|
+
datas << @cmds.last.run(runner)
|
57
|
+
datas.waitpid if runner.is_a? Runners::System
|
58
|
+
datas
|
34
59
|
end
|
35
60
|
|
36
61
|
def input= ( arg )
|
@@ -65,11 +90,27 @@ module Commands
|
|
65
90
|
}
|
66
91
|
end
|
67
92
|
|
93
|
+
def [] ( *args )
|
94
|
+
new_cmds = @cmds.dup
|
95
|
+
new_cmds[-1] = new_cmds.last[*args]
|
96
|
+
Pipe.new(*new_cmds)
|
97
|
+
end
|
98
|
+
|
99
|
+
#
|
100
|
+
# Conversion methods
|
101
|
+
#
|
102
|
+
|
68
103
|
def to_sh
|
69
104
|
strs = @cmds.map { |cmd| "(#{cmd.to_sh})" }
|
70
|
-
"
|
105
|
+
"#{strs.join(' | ')}"
|
71
106
|
end
|
72
107
|
|
108
|
+
def to_s
|
109
|
+
to_sh
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
|
73
114
|
end # class Pipe
|
74
115
|
|
75
116
|
end # module Commands
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
2
|
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
3
3
|
# License:: GNU General Public License (GPL).
|
4
|
-
# Revision:: $Id: fork.rb
|
4
|
+
# Revision:: $Id: fork.rb 374 2005-09-29 19:25:47Z ertai $
|
5
5
|
|
6
6
|
require 'commands'
|
7
7
|
|
@@ -30,7 +30,7 @@ module Commands
|
|
30
30
|
def run_impl ( aCommand, data )
|
31
31
|
data.pid = Kernel.fork do
|
32
32
|
begin
|
33
|
-
TempPath.fork_init
|
33
|
+
TempPath.fork_init true
|
34
34
|
hook_trigger :son, aCommand, data
|
35
35
|
super
|
36
36
|
rescue Exception => ex
|
@@ -74,6 +74,10 @@ module Commands
|
|
74
74
|
self
|
75
75
|
end
|
76
76
|
|
77
|
+
def before_exec ( command, data )
|
78
|
+
TempPath.clean
|
79
|
+
end
|
80
|
+
|
77
81
|
end # class Fork
|
78
82
|
|
79
83
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
2
|
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
3
3
|
# License:: GNU General Public License (GPL).
|
4
|
-
# Revision:: $Id:
|
4
|
+
# Revision:: $Id: mockable.rb 365 2005-09-24 17:24:01Z ertai $
|
5
5
|
|
6
6
|
require 'commands'
|
7
7
|
|
@@ -9,41 +9,40 @@ module Commands
|
|
9
9
|
|
10
10
|
module Runners
|
11
11
|
|
12
|
-
|
13
|
-
concrete
|
12
|
+
module Mockable
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
def initialize ( *a, &b )
|
14
|
+
def make_mock ( &block )
|
18
15
|
@log = []
|
19
|
-
@
|
20
|
-
super
|
21
|
-
end
|
16
|
+
@block = block
|
22
17
|
|
23
|
-
|
24
|
-
|
18
|
+
class << self
|
19
|
+
attr_reader :log
|
20
|
+
attr_accessor :block
|
25
21
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
d.status = 0
|
30
|
-
d
|
31
|
-
end
|
22
|
+
def exec ( aCommand, aData )
|
23
|
+
@block[aCommand, aData]
|
24
|
+
end
|
32
25
|
|
33
|
-
|
34
|
-
|
35
|
-
|
26
|
+
def display_command ( m )
|
27
|
+
@log << m
|
28
|
+
end
|
29
|
+
end # class << self
|
36
30
|
|
37
|
-
|
31
|
+
self
|
32
|
+
end
|
38
33
|
|
34
|
+
end # module Mock
|
39
35
|
|
36
|
+
class Runner
|
37
|
+
include Mockable
|
38
|
+
end
|
40
39
|
|
41
40
|
test_section __FILE__ do
|
42
41
|
|
43
42
|
class MockTest < Test::Unit::TestCase
|
44
43
|
|
45
44
|
def setup
|
46
|
-
assert_nothing_raised { @runner =
|
45
|
+
assert_nothing_raised { @runner = System.new.make_mock }
|
47
46
|
end
|
48
47
|
|
49
48
|
def test_0_initialize
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
2
|
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
3
3
|
# License:: GNU General Public License (GPL).
|
4
|
-
# Revision:: $Id: runner.rb
|
4
|
+
# Revision:: $Id: runner.rb 374 2005-09-29 19:25:47Z ertai $
|
5
5
|
|
6
6
|
require 'commands'
|
7
7
|
|
@@ -46,6 +46,16 @@ module Commands
|
|
46
46
|
end
|
47
47
|
|
48
48
|
|
49
|
+
def initialize_copy ( copy )
|
50
|
+
super
|
51
|
+
if defined? @hookers
|
52
|
+
@hookers = @hookers.dup
|
53
|
+
else
|
54
|
+
@hookers = []
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
|
49
59
|
#
|
50
60
|
# Methods.
|
51
61
|
#
|
@@ -75,6 +85,8 @@ module Commands
|
|
75
85
|
STDIN.reopen(data.input.to_io_for_commands) unless data.input.nil?
|
76
86
|
STDOUT.reopen(data.output.to_io_for_commands) unless data.output.nil?
|
77
87
|
STDERR.reopen(data.error.to_io_for_commands) unless data.error.nil?
|
88
|
+
STDOUT.flush
|
89
|
+
STDERR.flush
|
78
90
|
|
79
91
|
hook_trigger :before_chdir, data
|
80
92
|
Dir.chdir(aCommand.dir) unless aCommand.dir.nil?
|
data/lib/d_logger.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# License: Gnu General Public License.
|
4
4
|
|
5
5
|
# $LastChangedBy: ertai $
|
6
|
-
# $Id: d_logger.rb
|
6
|
+
# $Id: d_logger.rb 389 2005-10-03 00:46:17Z ertai $
|
7
7
|
|
8
8
|
require 'logger'
|
9
9
|
|
@@ -29,8 +29,14 @@ class DLogger < Logger
|
|
29
29
|
end
|
30
30
|
|
31
31
|
Format = "%s, [%s#%d] %6s -- %s: %s\n"
|
32
|
-
|
33
|
-
|
32
|
+
if Logger.const_defined? :VERSION and Logger::VERSION >= '1.2.6'
|
33
|
+
def format_message(severity, timestamp, progname, msg)
|
34
|
+
Format % [severity[0..0], timestamp, $$, severity, progname, msg]
|
35
|
+
end
|
36
|
+
else
|
37
|
+
def format_message(severity, timestamp, msg, progname)
|
38
|
+
Format % [severity[0..0], timestamp, $$, severity, progname, msg]
|
39
|
+
end
|
34
40
|
end
|
35
41
|
private :format_message
|
36
42
|
|
@@ -51,8 +57,8 @@ test_section __FILE__ do
|
|
51
57
|
log.debug3 'You don\'t see me'
|
52
58
|
log.debug2 'You see me'
|
53
59
|
cout.rewind
|
54
|
-
ref = /D, \[\d
|
55
|
-
D, \[\d
|
60
|
+
ref = /D, \[[\d\w: .-]+#\d+\] DEBUG -- : You see me
|
61
|
+
D, \[[\d\w: .-]+#\d+\] DEBUG2 -- : You see me/
|
56
62
|
assert_match(ref, cout.readlines.join)
|
57
63
|
end
|
58
64
|
|
data/lib/diff_tools.rb
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
2
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
3
|
+
# License:: Gnu General Public License.
|
4
|
+
# Revision:: $Id: diff_tools.rb 380 2005-09-29 22:08:05Z ertai $
|
5
|
+
|
6
|
+
RegexList.import!
|
7
|
+
|
8
|
+
module DiffTools
|
9
|
+
|
10
|
+
class Diff
|
11
|
+
|
12
|
+
def initialize ( anObject=nil )
|
13
|
+
@chunks = {}
|
14
|
+
@path_list = PathList.new
|
15
|
+
case anObject
|
16
|
+
when String
|
17
|
+
anObject.split(/^Index: /m).each do |chunk|
|
18
|
+
self << 'Index: ' + chunk unless chunk.empty?
|
19
|
+
end
|
20
|
+
when Diff
|
21
|
+
merge! anObject
|
22
|
+
when Array
|
23
|
+
anObject.flatten.each { |chunk| self << chunk }
|
24
|
+
when NilClass
|
25
|
+
else
|
26
|
+
raise TypeError, "Unexpected type #{anObject.class}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def << ( chunk )
|
31
|
+
chunk = Chunk.new(chunk) unless chunk.is_a? Chunk
|
32
|
+
if @path_list.include? chunk.path
|
33
|
+
raise ArgumentError, "Already have the path `#{chunk.path}'"
|
34
|
+
end
|
35
|
+
@chunks[chunk.path] = chunk
|
36
|
+
@path_list << chunk.path
|
37
|
+
end
|
38
|
+
|
39
|
+
def [] ( *args )
|
40
|
+
grep(*args)
|
41
|
+
end
|
42
|
+
|
43
|
+
def create ( path_list )
|
44
|
+
result = Diff.new
|
45
|
+
path_list.each do |path|
|
46
|
+
result << @chunks[path]
|
47
|
+
end
|
48
|
+
result
|
49
|
+
end
|
50
|
+
protected :create
|
51
|
+
|
52
|
+
def grep ( *args )
|
53
|
+
create @path_list.grep_with_regex_list(RegexList.new(args))
|
54
|
+
end
|
55
|
+
|
56
|
+
def negative ( *args )
|
57
|
+
create @path_list.grep_with_negative_regex_list(RegexList.new(args))
|
58
|
+
end
|
59
|
+
|
60
|
+
def exclude ( *args )
|
61
|
+
create @path_list.exclude_with_regex_list(RegexList.new(args))
|
62
|
+
end
|
63
|
+
|
64
|
+
def to_s
|
65
|
+
@chunks.values.join
|
66
|
+
end
|
67
|
+
|
68
|
+
end # class Diff
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
class Chunk
|
73
|
+
|
74
|
+
attr_reader :path, :contents
|
75
|
+
|
76
|
+
def initialize ( anObject )
|
77
|
+
case anObject
|
78
|
+
when String
|
79
|
+
@path = anObject[/\AIndex: (.+)$/, 1]
|
80
|
+
raise ArgumentError, "The path cannot be empty (#{anObject})" if @path.nil? or @path.empty?
|
81
|
+
@contents = anObject
|
82
|
+
else
|
83
|
+
raise TypeError, "Unexpected type #{anObject.class}"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def to_s
|
88
|
+
@contents
|
89
|
+
end
|
90
|
+
|
91
|
+
def inspect
|
92
|
+
"#<#{self.class}: Index: #@path>"
|
93
|
+
end
|
94
|
+
|
95
|
+
end # class Chunk
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
class App
|
100
|
+
def initialize ( stdin, stdout, stderr, argv )
|
101
|
+
gre, neg, exc = [], [], []
|
102
|
+
argv.each do |arg|
|
103
|
+
case arg
|
104
|
+
when /^(.*)!$/ then exc << $1
|
105
|
+
when /^(.*)-$/ then neg << $1
|
106
|
+
else gre << arg
|
107
|
+
end
|
108
|
+
end
|
109
|
+
stdout.puts Diff.new(stdin.read).exclude(exc).negative(neg).grep(gre)
|
110
|
+
end
|
111
|
+
end # class App
|
112
|
+
|
113
|
+
end # module DiffTools
|
114
|
+
|
115
|
+
|
116
|
+
DiffTools::App.new(STDIN, STDOUT, STDERR, ARGV) if $0 == __FILE__
|
117
|
+
|
118
|
+
|
119
|
+
test_section __FILE__ do
|
120
|
+
|
121
|
+
class TestDiffTools < ::Test::Unit::TestCase
|
122
|
+
|
123
|
+
def setup
|
124
|
+
@fixtures = 'test'.to_path/'fixtures'
|
125
|
+
@my_diff = @fixtures/'my_diff.patch'
|
126
|
+
@output_diff = TempPath.new('output_diff.patch')
|
127
|
+
# @output_diff = '/tmp/output_diff.patch'.to_path
|
128
|
+
end
|
129
|
+
|
130
|
+
def teardown
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_example
|
134
|
+
diff = DiffTools::Diff.new(@my_diff.read)
|
135
|
+
sorted = diff[/NEWS/, /^[^.]*$/, /core_ex/, /ruby_ex/, //]
|
136
|
+
@output_diff.open('w') { |f| f.puts sorted.to_s }
|
137
|
+
end
|
138
|
+
|
139
|
+
end # class TestDiffTools
|
140
|
+
|
141
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# License: Gnu General Public License.
|
4
4
|
|
5
5
|
# $LastChangedBy: ertai $
|
6
|
-
# $Id: insecure_protected_methods.rb
|
6
|
+
# $Id: insecure_protected_methods.rb 385 2005-10-02 17:05:35Z ertai $
|
7
7
|
|
8
8
|
|
9
9
|
require 'drb/drb'
|
@@ -79,7 +79,7 @@ module DRb
|
|
79
79
|
# Test
|
80
80
|
#
|
81
81
|
def test_simple
|
82
|
-
assert_raises(NameError) { @drb_obj.send(:protected_resquest) }
|
82
|
+
assert_raises(NameError, NoMethodError) { @drb_obj.send(:protected_resquest) }
|
83
83
|
assert_nothing_raised { @drb_obj.public_request }
|
84
84
|
end
|
85
85
|
|
data/lib/file_type.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
2
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
3
|
+
# License:: Gnu General Public License.
|
4
|
+
# Revision:: $Id: file_type.rb 376 2005-09-29 21:46:32Z ertai $
|
5
|
+
|
6
|
+
Commands.import!
|
5
7
|
|
6
8
|
module FileType
|
7
9
|
|
@@ -133,8 +135,10 @@ module FileType
|
|
133
135
|
@tmp = TempPath.new(base.path.basename, ext)
|
134
136
|
cmd = mk_cmd(@tmp)
|
135
137
|
data = cmd.run(self.class.runner)
|
138
|
+
data.waitpid if data.status.nil?
|
136
139
|
if data.status != 0
|
137
140
|
@tmp.rmtree if @tmp.exist?
|
141
|
+
STDERR.puts data.error.read if data.error and data.error.exist?
|
138
142
|
raise ExtractError, "Cannot extract a file:
|
139
143
|
| path: #{to_s}
|
140
144
|
| type: #{self.class}
|
@@ -243,10 +247,7 @@ module FileType
|
|
243
247
|
|
244
248
|
class TarBz2 < Generic
|
245
249
|
filetype_extension(/\.(tar\.bz2|tbz2|tbz)$/)
|
246
|
-
|
247
|
-
# extractable_dir (BZIP2 + %w[-c -d]) | (TAR + %w[xvf - -C])
|
248
|
-
# problem: a pipe command doesn't properly implement `[]'
|
249
|
-
extractable_dir TAR + %w[xvjf %i -C]
|
250
|
+
extractable_dir((BZIP2 + %w[-c -d %i]) | (TAR + %w[xvf - -C]))
|
250
251
|
end # class TarBz2
|
251
252
|
|
252
253
|
|
@@ -340,16 +341,19 @@ end # module FileType
|
|
340
341
|
|
341
342
|
test_section __FILE__ do
|
342
343
|
|
344
|
+
Commands::Runners::Mockable.import!
|
345
|
+
|
343
346
|
class FileTypeTest < Test::Unit::TestCase
|
344
347
|
|
345
348
|
def setup
|
346
349
|
@tmp = TempPath.new
|
347
350
|
(@tmp + 'foo').mkpath
|
348
|
-
@mr = Commands::Runners::
|
349
|
-
|
351
|
+
@mr = Commands::Runners::System.new
|
352
|
+
@mr.make_mock do
|
353
|
+
puts "#@tmp/foo/bar/baz\n#@tmp/foo\n#@tmp/foo/f/f/foo/baz"
|
350
354
|
end
|
351
355
|
FileType::Generic.runner = @mr
|
352
|
-
@
|
356
|
+
@fixtures = __FILE__.to_path.dirname.parent + 'test/fixtures'
|
353
357
|
end
|
354
358
|
|
355
359
|
def assert_guess ( type, *files )
|
@@ -366,7 +370,8 @@ test_section __FILE__ do
|
|
366
370
|
assert(@inp.extractable?, "#@inp not extractable")
|
367
371
|
assert_nothing_raised { @res = @inp.extract }
|
368
372
|
assert_kind_of(FileType.const_get(type), @res)
|
369
|
-
assert_match(command, @mr.log.
|
373
|
+
assert_match(command, @mr.log.first.to_sh)
|
374
|
+
assert_equal(1, @mr.log.size, "Mock log size != 1")
|
370
375
|
end
|
371
376
|
|
372
377
|
def assert_real_extract ( type, file )
|
@@ -424,27 +429,30 @@ test_section __FILE__ do
|
|
424
429
|
end
|
425
430
|
|
426
431
|
def test_extract_gz
|
427
|
-
assert_extract :Ruby, /^"gzip" "-d" "-c" "[^%]*" > "[^%]*"$/, 'foo.rb.gz'
|
432
|
+
assert_extract :Ruby, /^"gzip" "-d" "-c" "[^%]*" > "[^%]*"$/, @fixtures/'foo.rb.gz'
|
428
433
|
end
|
429
434
|
def test_extract_bz2
|
430
|
-
assert_extract :Unknown, /^"bzip2" "-d" "-c" "[^%]*" > "[^%]*"$/, 'foo.bz2'
|
435
|
+
assert_extract :Unknown, /^"bzip2" "-d" "-c" "[^%]*" > "[^%]*"$/, @fixtures/'foo.bz2'
|
431
436
|
end
|
432
437
|
def test_extract_zip
|
433
|
-
assert_extract :Gz, /^"unzip" "-p" "[^%]*" > "[^%]*"$/, 'foo.gz.zip'
|
438
|
+
assert_extract :Gz, /^"unzip" "-p" "[^%]*" > "[^%]*"$/, @fixtures/'foo.gz.zip'
|
434
439
|
end
|
435
440
|
def test_extract_tar_bz2
|
436
441
|
assert_extract :Directory,
|
437
|
-
|
438
|
-
|
442
|
+
/^\("bzip2" "-c" "-d" "[^%]*foo.tar.bz2"\) \| \("tar" "xvf" "-" "-C" "[^%]*" > "[^%]*"\)$/,
|
443
|
+
@fixtures/'foo.tar.bz2'
|
444
|
+
end
|
445
|
+
def test_real_extract_tar_bz2
|
446
|
+
assert_real_extract :Directory, @fixtures/'foo.tar.bz2'
|
439
447
|
end
|
440
448
|
def test_extract_tar_gz
|
441
449
|
assert_extract :Directory,
|
442
|
-
/^"tar" "xvzf" "foo.tar.gz" "-C" ".*foo.*" > ".*log.*"$/, 'foo.tar.gz'
|
443
|
-
assert_real_extract :Directory, @
|
450
|
+
/^"tar" "xvzf" "[^%]*foo.tar.gz" "-C" ".*foo.*" > ".*log.*"$/, @fixtures/'foo.tar.gz'
|
451
|
+
assert_real_extract :Directory, @fixtures/'foo.tar.gz'
|
444
452
|
end
|
445
453
|
def test_extract_tar
|
446
454
|
assert_extract :Directory,
|
447
|
-
/^"tar" "xvf" "foo.tar" "-C" "[^%]*" > "[^%]*"$/, 'foo.tar'
|
455
|
+
/^"tar" "xvf" "[^%]*foo.tar" "-C" "[^%]*" > "[^%]*"$/, @fixtures/'foo.tar'
|
448
456
|
end
|
449
457
|
|
450
458
|
def test_install_gem
|
@@ -455,7 +463,7 @@ test_section __FILE__ do
|
|
455
463
|
|
456
464
|
def test_longest_common_path
|
457
465
|
assert_nothing_raised do
|
458
|
-
res = @
|
466
|
+
res = @fixtures/'tar.gz.log'
|
459
467
|
@longest = FileType::ExtractableDir.longest_common_path(res)
|
460
468
|
end
|
461
469
|
assert_equal(['core_ex-0.1.4'], @longest)
|