archive-ar 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +2 -0
- data/Gemfile +1 -0
- data/NOTES.md +15 -0
- data/README.md +26 -2
- data/bin/ar.rb +20 -1
- data/ext/aaaaaaaaaaaaaaaa +1 -0
- data/ext/abcdefghijklmnopqrstuvwxyz +0 -0
- data/ext/bbbbbbbbbbbbbbbbb +1 -0
- data/ext/cccccccccccccccccc +0 -0
- data/ext/ddddddddddddddddddd +0 -0
- data/ext/eeeeeeeeeeeeeeeeeeee +0 -0
- data/ext/fffffffffffffffffffff +0 -0
- data/ext/gggggggggggggggggggggg +0 -0
- data/ext/integration.rb +45 -5
- data/ext/myfile.even +35 -0
- data/lib/archive/ar/format.rb +4 -70
- data/lib/archive/ar/format/bsd.rb +94 -0
- data/lib/archive/ar/format/gnu.rb +8 -0
- data/lib/archive/ar/reader.rb +4 -3
- data/lib/archive/ar/version.rb +1 -1
- data/lib/archive/ar/writer.rb +3 -1
- data/spec/fixtures/abcdefghijklmnopqrstuvwxyz +0 -0
- data/spec/lib/archive/ar/{format_spec.rb → format/bsd_spec.rb} +14 -7
- data/spec/lib/archive/ar_spec.rb +1 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjljZDM4OGY1Y2Y5OTViNjNmYjVlOGY4MzQzM2E3YmJiMWVkNWRjZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
M2Y1YjY1NDYzNTA0ZDZkNmIyMGMwOTY4ODNhYzc1YTAxY2Y5NWM2Yg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YmIxNDZkZjY0ZGY4ZWM2NTE1ODkzOTA3YjgwYWRkNDFlNWFlMmQ3YTk2ODIz
|
10
|
+
OGJlY2ZlMTY4YTJmN2I2ZWIyNDZiZWE4M2IwNTJjMmIwM2UxOTcxNjc0MmZj
|
11
|
+
MTVmZjk2YzI1NDYwZmExNmVjZDYyYzVjOWRlYTIzZjMwYzE2ZGQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjNhMjJhZDZkZjVkNTBhODI5YjVlNjI5OGYzMzc4MGZjYzg5ODFiNDc5YmUz
|
14
|
+
MTk1MjY3OGQzNmY2YTM3ZjRjMTUwOTZlY2U5ZDk0YTc2OGM2NjYzYWNhYTll
|
15
|
+
OTk1NmM0OTNkMDQyNTA0YzMxZTM4ZDJjNzY3MWJiMWJiOWEzNDg=
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/NOTES.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Global Header
|
2
|
+
|
3
|
+
<!arch>\n
|
4
|
+
|
5
|
+
# File Header
|
6
|
+
|
7
|
+
| Name | Offset | Length |
|
8
|
+
| ------------- | ------ | ------ |
|
9
|
+
| Filename | 0 | 16 |
|
10
|
+
| Modified Time | 16 | 12 |
|
11
|
+
| Owner | 28 | 6 |
|
12
|
+
| Group | 34 | 6 |
|
13
|
+
| File Mode | 40 | 8 |
|
14
|
+
| Size | 48 | 10 |
|
15
|
+
| Magic | 58 | 2 |
|
data/README.md
CHANGED
@@ -24,11 +24,35 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
27
|
-
|
27
|
+
### Create an archive
|
28
|
+
|
29
|
+
$ ar.rb -r somearchive.ar file1 file2
|
30
|
+
|
31
|
+
`````ruby
|
32
|
+
Archive::Ar.create("somearchive.ar", ["file1", "file2"])
|
33
|
+
`````
|
34
|
+
|
35
|
+
### Extract an archive
|
36
|
+
|
37
|
+
$ ar.rb -x somearchive.ar /tmp
|
38
|
+
|
39
|
+
`````ruby
|
40
|
+
Archive::Ar.extract("somearchive.ar", "/tmp")
|
41
|
+
`````
|
42
|
+
|
43
|
+
### Advanced
|
44
|
+
|
45
|
+
$ ar.rb -t somearchive.ar
|
46
|
+
|
47
|
+
`````ruby
|
48
|
+
Archive::Ar.traverse("somearchive.ar") do |file|
|
49
|
+
puts file.name
|
50
|
+
end
|
51
|
+
`````
|
28
52
|
|
29
53
|
## Contributing
|
30
54
|
|
31
|
-
1. Fork it ( http://github.com
|
55
|
+
1. Fork it ( http://github.com/jbussdieker/ruby-archive-ar/fork )
|
32
56
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
57
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
34
58
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/bin/ar.rb
CHANGED
@@ -51,6 +51,12 @@ OptionParser.new do |opts|
|
|
51
51
|
options[:p] = v
|
52
52
|
end
|
53
53
|
|
54
|
+
opts.on("-r", "Replace or add the specified files to the archive. If the archive does not exist a new archive file
|
55
|
+
is created. Files that replace existing files do not change the order of the files within the ar-
|
56
|
+
chive. New files are appended to the archive unless one of the options -a, -b or -i is specified.") do |v|
|
57
|
+
options[:r] = v
|
58
|
+
end
|
59
|
+
|
54
60
|
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
55
61
|
options[:verbose] = v
|
56
62
|
end
|
@@ -59,6 +65,7 @@ end.parse!
|
|
59
65
|
if options[:p]
|
60
66
|
raise "illegal option combination for -p" if options[:t]
|
61
67
|
raise "illegal option combination for -p" if options[:x]
|
68
|
+
raise "illegal option combination for -p" if options[:r]
|
62
69
|
|
63
70
|
Archive::Ar.traverse(ARGV[0]) do |header, data|
|
64
71
|
if options[:verbose]
|
@@ -68,6 +75,18 @@ if options[:p]
|
|
68
75
|
end
|
69
76
|
puts data
|
70
77
|
end
|
78
|
+
elsif options[:r]
|
79
|
+
raise "illegal option combination for -r" if options[:t]
|
80
|
+
raise "illegal option combination for -r" if options[:x]
|
81
|
+
|
82
|
+
filename = ARGV.shift
|
83
|
+
unless File.exists?(filename)
|
84
|
+
puts "ar: creating archive #{filename}"
|
85
|
+
Archive::Ar.create(filename, ARGV)
|
86
|
+
else
|
87
|
+
puts "we only support create"
|
88
|
+
exit 1
|
89
|
+
end
|
71
90
|
elsif options[:t]
|
72
91
|
raise "illegal option combination for -t" if options[:x]
|
73
92
|
|
@@ -92,7 +111,7 @@ elsif options[:x]
|
|
92
111
|
if options[:verbose]
|
93
112
|
Archive::Ar.traverse(ARGV[0]) do |header, data|
|
94
113
|
puts "x - #{header[:name]}"
|
95
|
-
Archive::Ar::Format.extract_file(Dir.pwd, header, data)
|
114
|
+
Archive::Ar::Format::BSD.extract_file(Dir.pwd, header, data)
|
96
115
|
end
|
97
116
|
else
|
98
117
|
Archive::Ar.extract(ARGV[0], Dir.pwd)
|
@@ -0,0 +1 @@
|
|
1
|
+
test
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
asdf
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/ext/integration.rb
CHANGED
@@ -1,25 +1,65 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
require 'digest/md5'
|
3
|
+
require 'fileutils'
|
4
|
+
|
2
5
|
AR_COMMAND = 'ar'
|
3
6
|
ARCHIVE_AR_COMMAND = 'bundle exec ../bin/ar.rb'
|
4
7
|
|
5
|
-
def run_test(cmd)
|
8
|
+
def run_test(cmd, md5file = nil)
|
9
|
+
pass = true
|
6
10
|
puts "Testing `ar #{cmd}`"
|
11
|
+
|
12
|
+
# Test original
|
7
13
|
out_ar = `#{AR_COMMAND} #{cmd} 2>&1`
|
14
|
+
if md5file
|
15
|
+
md5_ar = Digest::MD5.file(md5file)
|
16
|
+
file_ar = File.read(md5file)
|
17
|
+
FileUtils.rm_rf(md5file)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Test ruby version
|
8
21
|
out_archive_ar = `#{ARCHIVE_AR_COMMAND} #{cmd} 2>&1`
|
22
|
+
if md5file
|
23
|
+
md5_archive_ar = Digest::MD5.file(md5file)
|
24
|
+
file_archive_ar = File.read(md5file)
|
25
|
+
FileUtils.rm_rf(md5file)
|
26
|
+
end
|
27
|
+
|
28
|
+
if md5_ar != md5_archive_ar
|
29
|
+
pass = false
|
30
|
+
|
31
|
+
puts " Error #{cmd}"
|
32
|
+
puts " File mismatch:"
|
33
|
+
puts " Expected: #{md5_ar}"
|
34
|
+
puts " Got: #{md5_archive_ar}"
|
35
|
+
puts " Expected:"
|
36
|
+
puts "--------------------"
|
37
|
+
puts file_ar
|
38
|
+
puts "--------------------"
|
39
|
+
puts " Got:"
|
40
|
+
puts "--------------------"
|
41
|
+
puts file_archive_ar
|
42
|
+
puts "--------------------"
|
43
|
+
end
|
9
44
|
|
10
45
|
if out_ar != out_archive_ar
|
46
|
+
pass = false
|
47
|
+
|
11
48
|
puts " Error #{cmd}"
|
12
49
|
puts " Expected:"
|
13
50
|
out_ar.split("\n").each {|l| puts " | #{l}"}
|
14
51
|
puts " Got:"
|
15
52
|
out_archive_ar.split("\n").each {|l| puts " | #{l}"}
|
16
|
-
false
|
17
|
-
else
|
18
|
-
true
|
19
53
|
end
|
54
|
+
|
55
|
+
pass
|
20
56
|
end
|
21
57
|
|
22
|
-
|
58
|
+
run_test("-r integration-temp.ar myfile", "integration-temp.ar")
|
59
|
+
run_test("-r integration-temp.ar abcdefghijklmnopqrstuvwxyz", "integration-temp.ar")
|
60
|
+
run_test("-r integration-temp.ar myfile.even", "integration-temp.ar")
|
61
|
+
run_test("-r integration-temp.ar myfile myfile.even", "integration-temp.ar")
|
62
|
+
run_test("-r integration-temp.ar aaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbb cccccccccccccccccc ddddddddddddddddddd eeeeeeeeeeeeeeeeeeee fffffffffffffffffffff gggggggggggggggggggggg", "integration-temp.ar")
|
23
63
|
run_test("-t test.ar")
|
24
64
|
run_test("-tv test.ar")
|
25
65
|
run_test("-p test.ar")
|
data/ext/myfile.even
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
blahblahblahblahblahblah
|
2
|
+
blahblahblahblahblahblah
|
3
|
+
blahblahblahblahblahblah
|
4
|
+
blahblahblahblahblahblah
|
5
|
+
blahblahblahblahblahblah
|
6
|
+
blahblahblahblahblahblah
|
7
|
+
blahblahblahblahblahblah
|
8
|
+
blahblahblahblahblahblah
|
9
|
+
blahblahblahblahblahblah
|
10
|
+
blahblahblahblahblahblah
|
11
|
+
blahblahblahblahblahblah
|
12
|
+
blahblahblahblahblahblah
|
13
|
+
blahblahblahblahblahblah
|
14
|
+
blahblahblahblahblahblah
|
15
|
+
blahblahblahblahblahblah
|
16
|
+
blahblahblahblahblahblah
|
17
|
+
blahblahblahblahblahblah
|
18
|
+
blahblahblahblahblahblah
|
19
|
+
blahblahblahblahblahblah
|
20
|
+
blahblahblahblahblahblah
|
21
|
+
blahblahblahblahblahblah
|
22
|
+
blahblahblahblahblahblah
|
23
|
+
blahblahblahblahblahblah
|
24
|
+
blahblahblahblahblahblah
|
25
|
+
blahblahblahblahblahblah
|
26
|
+
blahblahblahblahblahblah
|
27
|
+
blahblahblahblahblahblah
|
28
|
+
blahblahblahblahblahblah
|
29
|
+
blahblahblahblahblahblah
|
30
|
+
blahblahblahblahblahblah
|
31
|
+
blahblahblahblahblahblah
|
32
|
+
blahblahblahblahblahblah
|
33
|
+
blahblahblahblahblahblah
|
34
|
+
blahblahblahblahblahblah
|
35
|
+
blahblahblahblahblahblah
|
data/lib/archive/ar/format.rb
CHANGED
@@ -1,75 +1,9 @@
|
|
1
|
+
require 'archive/ar/format/bsd'
|
2
|
+
require 'archive/ar/format/gnu'
|
3
|
+
|
1
4
|
module Archive
|
2
5
|
module Ar
|
3
|
-
|
4
|
-
class << self
|
5
|
-
def read_global_header(io)
|
6
|
-
io.read(8).tap do |global_header|
|
7
|
-
raise "Invalid header" unless global_header == Archive::Ar::MAGIC
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def build_header(file)
|
12
|
-
header = {
|
13
|
-
:name => File.basename(file),
|
14
|
-
:modified => File.mtime(file).to_i,
|
15
|
-
:owner => File.stat(file).uid,
|
16
|
-
:group => File.stat(file).gid,
|
17
|
-
:mode => File.stat(file).mode,
|
18
|
-
:size => File.size(file),
|
19
|
-
:magic => "`\n"
|
20
|
-
}
|
21
|
-
|
22
|
-
data = ""
|
23
|
-
data += "%-16s" % header[:name]
|
24
|
-
data += "%-12s" % header[:modified]
|
25
|
-
data += "%-6s" % header[:owner]
|
26
|
-
data += "%-6s" % header[:group]
|
27
|
-
data += "%-8s" % header[:mode].to_s(8)
|
28
|
-
data += "%-10s" % header[:size]
|
29
|
-
data += "%2s" % header[:magic]
|
30
|
-
data
|
31
|
-
end
|
32
|
-
|
33
|
-
def parse_header(data)
|
34
|
-
h = data.unpack("A16 Z12 a6 a6 A8 Z10 Z2")
|
35
|
-
{
|
36
|
-
:name => h.shift.chomp("/"), # Remove trailing slash. Some archives have this...
|
37
|
-
:modified => Time.at(h.shift.to_i),
|
38
|
-
:owner => h.shift.to_i,
|
39
|
-
:group => h.shift.to_i,
|
40
|
-
:mode => h.shift.to_i(8),
|
41
|
-
:size => h.shift.to_i,
|
42
|
-
:magic => h.shift,
|
43
|
-
}
|
44
|
-
end
|
45
|
-
|
46
|
-
def read_header(io)
|
47
|
-
block = io.read(60)
|
48
|
-
header = parse_header(block)
|
49
|
-
header.merge! :start => io.tell
|
50
|
-
|
51
|
-
if header[:name].start_with? "#1/"
|
52
|
-
long_size = header[:name][3..-1].to_i
|
53
|
-
header[:start] += long_size
|
54
|
-
header[:name] = io.read(long_size).strip
|
55
|
-
end
|
56
|
-
|
57
|
-
header
|
58
|
-
end
|
59
|
-
|
60
|
-
def extract_file(dest_dir, header, data, options = {})
|
61
|
-
file = File.join(dest_dir, header[:name])
|
62
|
-
|
63
|
-
File.open(file, "w") do |f|
|
64
|
-
f.write(data)
|
65
|
-
end
|
66
|
-
|
67
|
-
File.chmod(header[:mode], file)
|
68
|
-
#FileUtils.chown(header[:owner], header[:group], file)
|
69
|
-
|
70
|
-
true
|
71
|
-
end
|
72
|
-
end
|
6
|
+
module Format
|
73
7
|
end
|
74
8
|
end
|
75
9
|
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
module Archive
|
2
|
+
module Ar
|
3
|
+
module Format
|
4
|
+
class BSD
|
5
|
+
class << self
|
6
|
+
def read_global_header(io)
|
7
|
+
io.read(8).tap do |global_header|
|
8
|
+
raise "Invalid header" unless global_header == Archive::Ar::MAGIC
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def extract_file(dest_dir, header, data, options = {})
|
13
|
+
file = File.join(dest_dir, header[:name])
|
14
|
+
|
15
|
+
File.open(file, "w") do |f|
|
16
|
+
f.write(data)
|
17
|
+
end
|
18
|
+
|
19
|
+
File.chmod(header[:mode], file)
|
20
|
+
#FileUtils.chown(header[:owner], header[:group], file)
|
21
|
+
|
22
|
+
true
|
23
|
+
end
|
24
|
+
|
25
|
+
def read_header(io)
|
26
|
+
block = io.read(60)
|
27
|
+
header = parse_header(block)
|
28
|
+
header.merge! :start => io.tell
|
29
|
+
|
30
|
+
if header[:name].start_with? "#1/"
|
31
|
+
long_size = header[:name][3..-1].to_i
|
32
|
+
header[:start] += long_size
|
33
|
+
header[:name] = io.read(long_size).strip
|
34
|
+
end
|
35
|
+
|
36
|
+
header
|
37
|
+
end
|
38
|
+
|
39
|
+
def build_header(file)
|
40
|
+
header = read_file_header(file)
|
41
|
+
header_to_s(header)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def read_file_header(file)
|
47
|
+
{
|
48
|
+
:name => File.basename(file),
|
49
|
+
:modified => File.mtime(file).to_i,
|
50
|
+
:owner => File.stat(file).uid,
|
51
|
+
:group => File.stat(file).gid,
|
52
|
+
:mode => File.stat(file).mode,
|
53
|
+
:size => File.size(file),
|
54
|
+
:magic => "`\n"
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
def header_to_s(header)
|
59
|
+
data = ""
|
60
|
+
namebuf = header[:name]
|
61
|
+
if namebuf.length > 16
|
62
|
+
namebuf += "\0" * (4 - namebuf.length % 4) if (namebuf.length % 4) != 0
|
63
|
+
data += "%-16s" % "#1/#{namebuf.length}"
|
64
|
+
header[:size] += namebuf.length
|
65
|
+
else
|
66
|
+
data += "%-16s" % header[:name]
|
67
|
+
end
|
68
|
+
data += "%-12s" % header[:modified]
|
69
|
+
data += "%-6s" % header[:owner]
|
70
|
+
data += "%-6s" % header[:group]
|
71
|
+
data += "%-8s" % header[:mode].to_s(8)
|
72
|
+
data += "%-10s" % header[:size]
|
73
|
+
data += "%2s" % header[:magic]
|
74
|
+
data += namebuf if header[:name].length > 16
|
75
|
+
data
|
76
|
+
end
|
77
|
+
|
78
|
+
def parse_header(data)
|
79
|
+
h = data.unpack("A16 Z12 a6 a6 A8 Z10 Z2")
|
80
|
+
{
|
81
|
+
:name => h.shift.chomp("/"), # Remove trailing slash. Some archives have this...
|
82
|
+
:modified => Time.at(h.shift.to_i),
|
83
|
+
:owner => h.shift.to_i,
|
84
|
+
:group => h.shift.to_i,
|
85
|
+
:mode => h.shift.to_i(8),
|
86
|
+
:size => h.shift.to_i,
|
87
|
+
:magic => h.shift,
|
88
|
+
}
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
data/lib/archive/ar/reader.rb
CHANGED
@@ -4,11 +4,12 @@ module Archive
|
|
4
4
|
def initialize(source, options)
|
5
5
|
@source = source
|
6
6
|
@options = options
|
7
|
+
@format = Archive::Ar::Format::BSD
|
7
8
|
end
|
8
9
|
|
9
10
|
def extract(dest_dir, options)
|
10
11
|
each do |header, data|
|
11
|
-
|
12
|
+
@format.extract_file(dest_dir, header, data, options)
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
@@ -27,10 +28,10 @@ module Archive
|
|
27
28
|
@index = []
|
28
29
|
@records = {}
|
29
30
|
|
30
|
-
|
31
|
+
@format.read_global_header(io)
|
31
32
|
|
32
33
|
until io.eof?
|
33
|
-
header =
|
34
|
+
header = @format.read_header(io)
|
34
35
|
size = header[:size]
|
35
36
|
name = header[:name]
|
36
37
|
|
data/lib/archive/ar/version.rb
CHANGED
data/lib/archive/ar/writer.rb
CHANGED
@@ -3,11 +3,13 @@ module Archive
|
|
3
3
|
class Writer
|
4
4
|
def initialize(filenames)
|
5
5
|
@filenames = filenames
|
6
|
+
@format = Archive::Ar::Format::BSD
|
6
7
|
end
|
7
8
|
|
8
9
|
def build_ar_entry(file)
|
9
|
-
header =
|
10
|
+
header = @format.build_header(file)
|
10
11
|
data = File.read(file)
|
12
|
+
data += "\n" if (data.length + header.length) % 2 == 1
|
11
13
|
[header, data].join
|
12
14
|
end
|
13
15
|
|
File without changes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
describe Archive::Ar::Format do
|
2
|
+
describe Archive::Ar::Format::BSD do
|
3
3
|
describe "read_global_header" do
|
4
|
-
let(:read_global_header) { Archive::Ar::Format.read_global_header(io) }
|
4
|
+
let(:read_global_header) { Archive::Ar::Format::BSD.read_global_header(io) }
|
5
5
|
subject { read_global_header }
|
6
6
|
|
7
7
|
context "when valid" do
|
@@ -20,18 +20,25 @@ describe Archive::Ar::Format do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
describe "build_header" do
|
23
|
-
let(:file) { "spec/fixtures/file" }
|
24
23
|
let(:timestamp) { "%-12s" % File.mtime(file).to_i }
|
25
24
|
let(:owner) { "%-6s" % File.stat(file).uid }
|
26
25
|
let(:group) { "%-6s" % File.stat(file).gid }
|
27
26
|
let(:mode) { "%-8s" % File.stat(file).mode.to_s(8) }
|
28
|
-
let(:subject) { Archive::Ar::Format.build_header(file) }
|
27
|
+
let(:subject) { Archive::Ar::Format::BSD.build_header(file) }
|
29
28
|
|
30
|
-
|
29
|
+
context "normal single file" do
|
30
|
+
let(:file) { "spec/fixtures/file" }
|
31
|
+
it { should == "file #{timestamp}#{owner}#{group}#{mode}5 `\n" }
|
32
|
+
end
|
33
|
+
|
34
|
+
context "long name single file" do
|
35
|
+
let(:file) { "spec/fixtures/abcdefghijklmnopqrstuvwxyz" }
|
36
|
+
it { should == "#1/28 #{timestamp}#{owner}#{group}#{mode}28 `\nabcdefghijklmnopqrstuvwxyz\0\0" }
|
37
|
+
end
|
31
38
|
end
|
32
39
|
|
33
40
|
describe "read_header" do
|
34
|
-
let(:read_header) { Archive::Ar::Format.read_header(io) }
|
41
|
+
let(:read_header) { Archive::Ar::Format::BSD.read_header(io) }
|
35
42
|
let(:io) { StringIO.new(payload) }
|
36
43
|
subject { read_header }
|
37
44
|
|
@@ -75,7 +82,7 @@ describe Archive::Ar::Format do
|
|
75
82
|
let(:header) { { :name => "file", :mode => 0100644 } }
|
76
83
|
let(:data) { "test" }
|
77
84
|
let(:options) { {} }
|
78
|
-
subject { Archive::Ar::Format.extract_file(dest_dir, header, data, options) }
|
85
|
+
subject { Archive::Ar::Format::BSD.extract_file(dest_dir, header, data, options) }
|
79
86
|
|
80
87
|
it { should == true }
|
81
88
|
end
|
data/spec/lib/archive/ar_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: archive-ar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua B. Bussdieker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,22 +66,35 @@ files:
|
|
66
66
|
- Gemfile
|
67
67
|
- Guardfile
|
68
68
|
- LICENSE.txt
|
69
|
+
- NOTES.md
|
69
70
|
- README.md
|
70
71
|
- Rakefile
|
71
72
|
- archive-ar.gemspec
|
72
73
|
- bin/ar.rb
|
74
|
+
- ext/aaaaaaaaaaaaaaaa
|
75
|
+
- ext/abcdefghijklmnopqrstuvwxyz
|
76
|
+
- ext/bbbbbbbbbbbbbbbbb
|
77
|
+
- ext/cccccccccccccccccc
|
78
|
+
- ext/ddddddddddddddddddd
|
79
|
+
- ext/eeeeeeeeeeeeeeeeeeee
|
80
|
+
- ext/fffffffffffffffffffff
|
81
|
+
- ext/gggggggggggggggggggggg
|
73
82
|
- ext/integration.rb
|
74
83
|
- ext/myfile
|
84
|
+
- ext/myfile.even
|
75
85
|
- ext/test.ar
|
76
86
|
- lib/archive/ar.rb
|
77
87
|
- lib/archive/ar/format.rb
|
88
|
+
- lib/archive/ar/format/bsd.rb
|
89
|
+
- lib/archive/ar/format/gnu.rb
|
78
90
|
- lib/archive/ar/reader.rb
|
79
91
|
- lib/archive/ar/version.rb
|
80
92
|
- lib/archive/ar/writer.rb
|
93
|
+
- spec/fixtures/abcdefghijklmnopqrstuvwxyz
|
81
94
|
- spec/fixtures/archive.ar
|
82
95
|
- spec/fixtures/emptyfile
|
83
96
|
- spec/fixtures/file
|
84
|
-
- spec/lib/archive/ar/
|
97
|
+
- spec/lib/archive/ar/format/bsd_spec.rb
|
85
98
|
- spec/lib/archive/ar/reader_spec.rb
|
86
99
|
- spec/lib/archive/ar/writer_spec.rb
|
87
100
|
- spec/lib/archive/ar_spec.rb
|
@@ -112,10 +125,11 @@ signing_key:
|
|
112
125
|
specification_version: 4
|
113
126
|
summary: Simple AR file functions
|
114
127
|
test_files:
|
128
|
+
- spec/fixtures/abcdefghijklmnopqrstuvwxyz
|
115
129
|
- spec/fixtures/archive.ar
|
116
130
|
- spec/fixtures/emptyfile
|
117
131
|
- spec/fixtures/file
|
118
|
-
- spec/lib/archive/ar/
|
132
|
+
- spec/lib/archive/ar/format/bsd_spec.rb
|
119
133
|
- spec/lib/archive/ar/reader_spec.rb
|
120
134
|
- spec/lib/archive/ar/writer_spec.rb
|
121
135
|
- spec/lib/archive/ar_spec.rb
|