archive-ar 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Guardfile +24 -0
- data/bin/ar.rb +101 -0
- data/ext/integration.rb +29 -0
- data/ext/myfile +35 -0
- data/ext/test.ar +38 -0
- data/lib/archive/ar/format.rb +24 -0
- data/lib/archive/ar/version.rb +1 -1
- data/lib/archive/ar/writer.rb +18 -1
- data/spec/fixtures/archive.ar +2 -0
- data/spec/fixtures/emptyfile +0 -0
- data/spec/fixtures/file +1 -0
- data/spec/lib/archive/ar/format_spec.rb +53 -12
- data/spec/lib/archive/ar/reader_spec.rb +34 -5
- data/spec/lib/archive/ar/writer_spec.rb +24 -0
- data/spec/lib/archive/ar_spec.rb +38 -0
- metadata +30 -20
- data/bin/archive-ar +0 -82
- data/spec/fixtures/test-long.ar +0 -4
- data/spec/fixtures/test.ar +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4ab04343b793ea9fa4b2854f52c36fe85cd16ca
|
4
|
+
data.tar.gz: bd6fbfb6bfc8b808c996cde44f082fbe51863bcb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b811768447f57e58020a1cb8b26193d04c6324351295210d81fb7e89ca6db0deb3e34c2e03bcedbcac54ebe9c160bf2435b96dc4a29e555b8be2fb169e1f3648
|
7
|
+
data.tar.gz: 8a82fffa32cce8e4386d7d33888731309642cbe4b453b1e8f6d20ad18eb0feb65425769b8da6925447ecb82ec68390e92b91c092e3d02d5928b0f45596554b9a
|
data/Guardfile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard :rspec do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb') { "spec" }
|
8
|
+
|
9
|
+
# Rails example
|
10
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
11
|
+
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
12
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
13
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
14
|
+
watch('config/routes.rb') { "spec/routing" }
|
15
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
16
|
+
|
17
|
+
# Capybara features specs
|
18
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
19
|
+
|
20
|
+
# Turnip features and steps
|
21
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
22
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
23
|
+
end
|
24
|
+
|
data/bin/ar.rb
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'archive/ar'
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
######## HACK ALERT #################
|
6
|
+
# TODO: Make this a gem or something
|
7
|
+
#####################################
|
8
|
+
def short_mode(value)
|
9
|
+
str = "---"
|
10
|
+
str[0] = "r" if value & 4 == 4
|
11
|
+
str[1] = "w" if value & 2 == 2
|
12
|
+
str[2] = "x" if value & 1 == 1
|
13
|
+
str
|
14
|
+
end
|
15
|
+
|
16
|
+
def mode(value)
|
17
|
+
r = ""
|
18
|
+
everyone = short_mode(value)
|
19
|
+
value = value >> 3
|
20
|
+
group = short_mode(value)
|
21
|
+
value = value >> 3
|
22
|
+
owner = short_mode(value)
|
23
|
+
"#{owner}#{group}#{everyone}"
|
24
|
+
end
|
25
|
+
#####################################
|
26
|
+
|
27
|
+
options = {}
|
28
|
+
OptionParser.new do |opts|
|
29
|
+
opts.banner = "Usage: archive-ar [options]"
|
30
|
+
|
31
|
+
opts.on("-t", "display contents of archive") do |v|
|
32
|
+
options[:t] = v
|
33
|
+
end
|
34
|
+
|
35
|
+
opts.on("-x", "extract file(s) from the archive") do |v|
|
36
|
+
options[:x] = v
|
37
|
+
end
|
38
|
+
|
39
|
+
opts.on("-p", "print file(s) found in the archive") do |v|
|
40
|
+
options[:p] = v
|
41
|
+
end
|
42
|
+
|
43
|
+
opts.on("-v", "be verbose") do |v|
|
44
|
+
options[:verbose] = v
|
45
|
+
end
|
46
|
+
|
47
|
+
opts.on("-r", "replace existing or insert new file(s) into the archive") do |v|
|
48
|
+
options[:r] = v
|
49
|
+
end
|
50
|
+
end.parse!
|
51
|
+
|
52
|
+
if options[:r]
|
53
|
+
raise "two different operation options specified" if options[:t]
|
54
|
+
raise "two different operation options specified" if options[:x]
|
55
|
+
raise "two different operation options specified" if options[:p]
|
56
|
+
|
57
|
+
elsif options[:p]
|
58
|
+
raise "illegal option combination for -p" if options[:t]
|
59
|
+
raise "illegal option combination for -p" if options[:x]
|
60
|
+
|
61
|
+
Archive::Ar.traverse(ARGV[0]) do |header, data|
|
62
|
+
if options[:verbose]
|
63
|
+
puts
|
64
|
+
puts "<#{header[:name]}>"
|
65
|
+
puts
|
66
|
+
end
|
67
|
+
puts data
|
68
|
+
end
|
69
|
+
elsif options[:t]
|
70
|
+
raise "illegal option combination for -t" if options[:x]
|
71
|
+
|
72
|
+
Archive::Ar.traverse(ARGV[0]) do |header, data|
|
73
|
+
if options[:verbose]
|
74
|
+
print mode(header[:mode])
|
75
|
+
print " "
|
76
|
+
og = "#{header[:owner]}/#{header[:group]}"
|
77
|
+
print "%10s" % og
|
78
|
+
print " "
|
79
|
+
print "%12s" % header[:size]
|
80
|
+
print " "
|
81
|
+
print header[:modified].strftime("%b %e %R %Y")
|
82
|
+
print " "
|
83
|
+
print header[:name]
|
84
|
+
puts
|
85
|
+
else
|
86
|
+
puts header[:name]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
elsif options[:x]
|
90
|
+
if options[:verbose]
|
91
|
+
Archive::Ar.traverse(ARGV[0]) do |header, data|
|
92
|
+
puts "x - #{header[:name]}"
|
93
|
+
Archive::Ar::Format.extract_file(Dir.pwd, header, data)
|
94
|
+
end
|
95
|
+
else
|
96
|
+
Archive::Ar.extract(ARGV[0], Dir.pwd)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
#p options
|
101
|
+
#p ARGV
|
data/ext/integration.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
AR_COMMAND = 'ar'
|
3
|
+
ARCHIVE_AR_COMMAND = 'bundle exec ../bin/ar.rb'
|
4
|
+
|
5
|
+
def run_test(cmd)
|
6
|
+
puts "Testing `ar #{cmd}`"
|
7
|
+
out_ar = `#{AR_COMMAND} #{cmd} 2>&1`
|
8
|
+
out_archive_ar = `#{ARCHIVE_AR_COMMAND} #{cmd} 2>&1`
|
9
|
+
|
10
|
+
if out_ar != out_archive_ar
|
11
|
+
puts " Error #{cmd}"
|
12
|
+
puts " Expected:"
|
13
|
+
out_ar.split("\n").each {|l| puts " | #{l}"}
|
14
|
+
puts " Got:"
|
15
|
+
out_archive_ar.split("\n").each {|l| puts " | #{l}"}
|
16
|
+
false
|
17
|
+
else
|
18
|
+
true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
#run_test("-r test.ar myfile")
|
23
|
+
run_test("-t test.ar")
|
24
|
+
run_test("-tv test.ar")
|
25
|
+
run_test("-p test.ar")
|
26
|
+
run_test("-pv test.ar")
|
27
|
+
run_test("-x test.ar")
|
28
|
+
run_test("-xv test.ar")
|
29
|
+
run_test("-r test.ar myfile")
|
data/ext/myfile
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/ext/test.ar
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
!<arch>
|
2
|
+
myfile 1399173274 501 20 100644 875 `
|
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
|
36
|
+
blahblahblahblahblahblah
|
37
|
+
blahblahblahblahblahblah
|
38
|
+
|
data/lib/archive/ar/format.rb
CHANGED
@@ -8,6 +8,28 @@ module Archive
|
|
8
8
|
end
|
9
9
|
end
|
10
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
|
+
|
11
33
|
def parse_header(data)
|
12
34
|
h = data.unpack("A16 Z12 a6 a6 A8 Z10 Z2")
|
13
35
|
{
|
@@ -44,6 +66,8 @@ module Archive
|
|
44
66
|
|
45
67
|
File.chmod(header[:mode], file)
|
46
68
|
#FileUtils.chown(header[:owner], header[:group], file)
|
69
|
+
|
70
|
+
true
|
47
71
|
end
|
48
72
|
end
|
49
73
|
end
|
data/lib/archive/ar/version.rb
CHANGED
data/lib/archive/ar/writer.rb
CHANGED
@@ -5,7 +5,24 @@ module Archive
|
|
5
5
|
@filenames = filenames
|
6
6
|
end
|
7
7
|
|
8
|
-
def
|
8
|
+
def build_ar_entry(file)
|
9
|
+
header = Archive::Ar::Format.build_header(file)
|
10
|
+
data = File.read(file)
|
11
|
+
[header, data].join
|
12
|
+
end
|
13
|
+
|
14
|
+
def build_ar
|
15
|
+
@filenames.collect do |f|
|
16
|
+
build_ar_entry(f)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def write(dest_file, options = {})
|
21
|
+
File.open(dest_file, 'w') do |f|
|
22
|
+
data = build_ar.join("")
|
23
|
+
f.write(Archive::Ar::MAGIC)
|
24
|
+
f.write(data)
|
25
|
+
end
|
9
26
|
end
|
10
27
|
end
|
11
28
|
end
|
File without changes
|
data/spec/fixtures/file
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
test
|
@@ -20,22 +20,63 @@ describe Archive::Ar::Format do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
describe "build_header" do
|
24
|
+
let(:file) { "spec/fixtures/file" }
|
25
|
+
let(:timestamp) { "%-12s" % File.mtime(file).to_i }
|
26
|
+
let(:owner) { "%-6s" % File.stat(file).uid }
|
27
|
+
let(:group) { "%-6s" % File.stat(file).gid }
|
28
|
+
let(:subject) { Archive::Ar::Format.build_header(file) }
|
29
|
+
|
30
|
+
it { should == "file #{timestamp}#{owner}#{group}100664 5 `\n" }
|
31
|
+
end
|
32
|
+
|
23
33
|
describe "read_header" do
|
24
34
|
let(:read_header) { Archive::Ar::Format.read_header(io) }
|
25
|
-
let(:io) { StringIO.new(
|
35
|
+
let(:io) { StringIO.new(payload) }
|
26
36
|
subject { read_header }
|
27
37
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
+
context "normal" do
|
39
|
+
let(:payload) { "#1/8 1399095295 1234 5678 100644 95 `\nFilename" }
|
40
|
+
|
41
|
+
it {
|
42
|
+
subject.should == {
|
43
|
+
:name=>"Filename",
|
44
|
+
:modified=>Time.parse("2014-05-02 22:34:55 -0700"),
|
45
|
+
:owner=>1234,
|
46
|
+
:group=>5678,
|
47
|
+
:mode=>"100644".to_i(8),
|
48
|
+
:start=>68,
|
49
|
+
:size=>95,
|
50
|
+
:magic=>"`\n"
|
51
|
+
}
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
context "long filename" do
|
56
|
+
let(:payload) { "Filename 1399095295 1234 5678 100644 95 `\n" }
|
57
|
+
|
58
|
+
it {
|
59
|
+
subject.should == {
|
60
|
+
:name=>"Filename",
|
61
|
+
:modified=>Time.parse("2014-05-02 22:34:55 -0700"),
|
62
|
+
:owner=>1234,
|
63
|
+
:group=>5678,
|
64
|
+
:mode=>"100644".to_i(8),
|
65
|
+
:start=>60,
|
66
|
+
:size=>95,
|
67
|
+
:magic=>"`\n"
|
68
|
+
}
|
38
69
|
}
|
39
|
-
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "extract_file" do
|
74
|
+
let(:dest_dir) { "tmp/" }
|
75
|
+
let(:header) { { :name => "file", :mode => 0100644 } }
|
76
|
+
let(:data) { "test" }
|
77
|
+
let(:options) { {} }
|
78
|
+
subject { Archive::Ar::Format.extract_file(dest_dir, header, data, options) }
|
79
|
+
|
80
|
+
it { should == true }
|
40
81
|
end
|
41
82
|
end
|
@@ -1,13 +1,42 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Archive::Ar::Reader do
|
4
|
-
let(:
|
5
|
-
let(:
|
4
|
+
let(:options) { {} }
|
5
|
+
let(:source) { io }
|
6
|
+
let(:io) { File.open("spec/fixtures/archive.ar") }
|
7
|
+
let(:reader) { Archive::Ar::Reader.new(source, options) }
|
6
8
|
|
7
|
-
describe "
|
8
|
-
let(:
|
9
|
+
describe "extract" do
|
10
|
+
let(:dest_dir) { "tmp/" }
|
9
11
|
let(:options) { {} }
|
10
|
-
|
12
|
+
subject { reader.extract(dest_dir, options) }
|
13
|
+
|
14
|
+
it { should == ["file"] }
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "each" do
|
18
|
+
context "using IO" do
|
19
|
+
let(:io) { File.open("spec/fixtures/archive.ar") }
|
20
|
+
|
21
|
+
it "yields anything once" do
|
22
|
+
expect {|b|
|
23
|
+
reader.each(&b)
|
24
|
+
}.to yield_successive_args(anything)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "using String" do
|
29
|
+
let(:io) { "spec/fixtures/archive.ar" }
|
30
|
+
|
31
|
+
it "yields anything once" do
|
32
|
+
expect {|b|
|
33
|
+
reader.each(&b)
|
34
|
+
}.to yield_successive_args(anything)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "parse" do
|
11
40
|
subject { reader.parse(io) }
|
12
41
|
|
13
42
|
context "empty" do
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Archive::Ar::Writer do
|
4
|
+
let(:filenames) { [] }
|
5
|
+
let(:dest_file) { "tmp/test.ar" }
|
6
|
+
let(:writer) { Archive::Ar::Writer.new(filenames) }
|
7
|
+
|
8
|
+
describe "write" do
|
9
|
+
context "no files" do
|
10
|
+
it "works" do
|
11
|
+
writer.write(dest_file)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context "one file" do
|
16
|
+
let(:filenames) { ["spec/fixtures/file"] }
|
17
|
+
let(:dest_file) { "tmp/test-one.ar" }
|
18
|
+
|
19
|
+
it "works" do
|
20
|
+
writer.write(dest_file)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/spec/lib/archive/ar_spec.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Archive::Ar do
|
4
|
+
let(:options) { {} }
|
5
|
+
|
6
|
+
describe "create" do
|
7
|
+
let(:dest_file) { "tmp/create.ar" }
|
8
|
+
let(:filenames) { ["spec/fixtures/file"] }
|
9
|
+
subject { Archive::Ar.create(dest_file, filenames, options) }
|
10
|
+
|
11
|
+
it { should == 65 }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "extract" do
|
15
|
+
let(:dest_dir) { "tmp/" }
|
16
|
+
subject { Archive::Ar.extract(source_file, dest_dir, options) }
|
17
|
+
|
18
|
+
context "archive.ar" do
|
19
|
+
let(:source_file) { "spec/fixtures/archive.ar" }
|
20
|
+
|
21
|
+
it { should == ["file"] }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "traverse" do
|
26
|
+
subject { Archive::Ar.traverse(source_file, options) }
|
27
|
+
|
28
|
+
context "archive.ar" do
|
29
|
+
let(:source_file) { "spec/fixtures/archive.ar" }
|
30
|
+
|
31
|
+
it "yields the file" do
|
32
|
+
expect {|b|
|
33
|
+
Archive::Ar.traverse(source_file, options, &b)
|
34
|
+
}.to yield_successive_args(anything)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,85 +1,92 @@
|
|
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.5
|
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-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.5'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description:
|
56
56
|
email:
|
57
57
|
- jbussdieker@gmail.com
|
58
58
|
executables:
|
59
|
-
-
|
59
|
+
- ar.rb
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
-
- .gitignore
|
64
|
-
- .rspec
|
65
|
-
- .travis.yml
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".travis.yml"
|
66
66
|
- Gemfile
|
67
|
+
- Guardfile
|
67
68
|
- LICENSE.txt
|
68
69
|
- README.md
|
69
70
|
- Rakefile
|
70
71
|
- archive-ar.gemspec
|
71
|
-
- bin/
|
72
|
+
- bin/ar.rb
|
73
|
+
- ext/integration.rb
|
74
|
+
- ext/myfile
|
75
|
+
- ext/test.ar
|
72
76
|
- lib/archive/ar.rb
|
73
77
|
- lib/archive/ar/format.rb
|
74
78
|
- lib/archive/ar/reader.rb
|
75
79
|
- lib/archive/ar/version.rb
|
76
80
|
- lib/archive/ar/writer.rb
|
77
|
-
- spec/fixtures/
|
78
|
-
- spec/fixtures/
|
81
|
+
- spec/fixtures/archive.ar
|
82
|
+
- spec/fixtures/emptyfile
|
83
|
+
- spec/fixtures/file
|
79
84
|
- spec/lib/archive/ar/format_spec.rb
|
80
85
|
- spec/lib/archive/ar/reader_spec.rb
|
86
|
+
- spec/lib/archive/ar/writer_spec.rb
|
81
87
|
- spec/lib/archive/ar_spec.rb
|
82
88
|
- spec/spec_helper.rb
|
89
|
+
- tmp/.gitkeep
|
83
90
|
homepage: ''
|
84
91
|
licenses:
|
85
92
|
- MIT
|
@@ -90,24 +97,27 @@ require_paths:
|
|
90
97
|
- lib
|
91
98
|
required_ruby_version: !ruby/object:Gem::Requirement
|
92
99
|
requirements:
|
93
|
-
- -
|
100
|
+
- - ">="
|
94
101
|
- !ruby/object:Gem::Version
|
95
102
|
version: '0'
|
96
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
104
|
requirements:
|
98
|
-
- -
|
105
|
+
- - ">="
|
99
106
|
- !ruby/object:Gem::Version
|
100
107
|
version: '0'
|
101
108
|
requirements: []
|
102
109
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.
|
110
|
+
rubygems_version: 2.2.2
|
104
111
|
signing_key:
|
105
112
|
specification_version: 4
|
106
113
|
summary: Simple AR file functions
|
107
114
|
test_files:
|
108
|
-
- spec/fixtures/
|
109
|
-
- spec/fixtures/
|
115
|
+
- spec/fixtures/archive.ar
|
116
|
+
- spec/fixtures/emptyfile
|
117
|
+
- spec/fixtures/file
|
110
118
|
- spec/lib/archive/ar/format_spec.rb
|
111
119
|
- spec/lib/archive/ar/reader_spec.rb
|
120
|
+
- spec/lib/archive/ar/writer_spec.rb
|
112
121
|
- spec/lib/archive/ar_spec.rb
|
113
122
|
- spec/spec_helper.rb
|
123
|
+
has_rdoc:
|
data/bin/archive-ar
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'archive/ar'
|
3
|
-
require 'optparse'
|
4
|
-
|
5
|
-
options = {}
|
6
|
-
OptionParser.new do |opts|
|
7
|
-
opts.banner = "Usage: archive-ar [options]"
|
8
|
-
|
9
|
-
opts.on("-t", "List the specified files in the order in which they appear in the archive, each on a
|
10
|
-
separate line. If no files are specified, all files in the archive are listed.") do |v|
|
11
|
-
options[:t] = v
|
12
|
-
end
|
13
|
-
|
14
|
-
opts.on("-x", "Extract the specified archive members into the files named by the command line argu-
|
15
|
-
ments. If no members are specified, all the members of the archive are extracted into
|
16
|
-
the current directory.
|
17
|
-
|
18
|
-
If the file does not exist, it is created; if it does exist, the owner and group will
|
19
|
-
be unchanged. The file access and modification times are the time of the extraction
|
20
|
-
(but see the -o option). The file permissions will be set to those of the file when
|
21
|
-
it was entered into the archive; this will fail if the user is not the owner of the
|
22
|
-
extracted file or the super-user.") do |v|
|
23
|
-
options[:x] = v
|
24
|
-
end
|
25
|
-
|
26
|
-
opts.on("-p", "Write the contents of the specified archive files to the standard output. If no files
|
27
|
-
are specified, the contents of all the files in the archive are written in the order
|
28
|
-
they appear in the archive.") do |v|
|
29
|
-
options[:p] = v
|
30
|
-
end
|
31
|
-
|
32
|
-
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
33
|
-
options[:verbose] = v
|
34
|
-
end
|
35
|
-
end.parse!
|
36
|
-
|
37
|
-
if options[:p]
|
38
|
-
raise "illegal option combination for -p" if options[:t]
|
39
|
-
raise "illegal option combination for -p" if options[:x]
|
40
|
-
|
41
|
-
Archive::Ar.traverse(ARGV[0]) do |header, data|
|
42
|
-
if options[:verbose]
|
43
|
-
puts
|
44
|
-
puts "<#{header[:name]}>"
|
45
|
-
puts
|
46
|
-
end
|
47
|
-
puts data
|
48
|
-
end
|
49
|
-
elsif options[:t]
|
50
|
-
raise "illegal option combination for -t" if options[:x]
|
51
|
-
|
52
|
-
Archive::Ar.traverse(ARGV[0]) do |header, data|
|
53
|
-
if options[:verbose]
|
54
|
-
print header[:mode].to_s(8)
|
55
|
-
print "\t"
|
56
|
-
print header[:owner]
|
57
|
-
print "/"
|
58
|
-
print header[:group]
|
59
|
-
print "\t"
|
60
|
-
print header[:size]
|
61
|
-
print "\t"
|
62
|
-
print header[:modified]
|
63
|
-
print "\t"
|
64
|
-
print header[:name]
|
65
|
-
puts
|
66
|
-
else
|
67
|
-
puts header[:name]
|
68
|
-
end
|
69
|
-
end
|
70
|
-
elsif options[:x]
|
71
|
-
if options[:verbose]
|
72
|
-
Archive::Ar.traverse(ARGV[0]) do |header, data|
|
73
|
-
puts "x - #{header[:name]}"
|
74
|
-
Archive::Ar::Format.extract_file(Dir.pwd, header, data)
|
75
|
-
end
|
76
|
-
else
|
77
|
-
Archive::Ar.extract(ARGV[0], Dir.pwd)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
#p options
|
82
|
-
#p ARGV
|
data/spec/fixtures/test-long.ar
DELETED
data/spec/fixtures/test.ar
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
!<arch>
|
2
|
-
Pjjjjjj 1399095295 501 20 100755 95 `
|
3
|
-
source 'https://rubygems.org'
|
4
|
-
|
5
|
-
( Specify your gem's dependencies in archive-ar.gemspec
|
6
|
-
gemspec
|
7
|
-
|
8
|
-
Sjjjjjj 1399095295 502 20 100750 95 `
|
9
|
-
source 'https://rubygems.org'
|
10
|
-
|
11
|
-
# Specify your gem's dependencies in archive-ar.gemspec
|
12
|
-
gemspec
|
13
|
-
|