archive-ar 0.0.1 → 0.0.2
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 +8 -8
- data/bin/archive-ar +82 -0
- data/lib/archive/ar/format.rb +12 -1
- data/lib/archive/ar/reader.rb +3 -0
- data/lib/archive/ar/version.rb +1 -1
- data/spec/fixtures/test.ar +2 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NmEwMzBjZGVmZTJmOTJlN2VmMjc5ZDI5ZDA1ODQ4MTE2YTA5MzdmYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
M2VhYmEzNWRhYTFjMWEyNTFhMzQyZjljNzEzOTljNTE1MDQwZmVjNg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
N2YyNTk2NTU3OTlhMzliMWRhNjYxMGU3NTJiYjYwZmIxNmE5ZTg4OTUxN2Zj
|
10
|
+
ZWFkMTBmZmJlYzBhNzlhZjg4NjRhMjE4NWVlNWY3Y2FhODhmYTdlOGQ4MmMz
|
11
|
+
MDgwNGMyNjkyM2M5MTAyZjg3NTNlYTkzZGJiODQ1NDBiMDA4ZWU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MTVhMmU2YTQ5ZmIxNTBhM2MxYWViZjI3MjNjMDU1ZTIyNDY4MjBmZDk5YWMy
|
14
|
+
OTQ4MTc1YjI5ODRkZjA3ZDM2OTQ1ZDJmYmY4NDFkYmQ4MzMyMDZkNTc1MTQ2
|
15
|
+
NjYzY2FkZDY2ZTc2NDRiNDNhMjVkNjQxMjg1ZjE0MTM4YjUxYTc=
|
data/bin/archive-ar
ADDED
@@ -0,0 +1,82 @@
|
|
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/lib/archive/ar/format.rb
CHANGED
@@ -16,12 +16,23 @@ module Archive
|
|
16
16
|
:modified => Time.at(h.shift.to_i),
|
17
17
|
:owner => h.shift.to_i,
|
18
18
|
:group => h.shift.to_i,
|
19
|
-
:mode => h.shift,
|
19
|
+
:mode => h.shift.to_i(8),
|
20
20
|
:start => io.tell,
|
21
21
|
:size => h.shift.to_i,
|
22
22
|
:magic => h.shift,
|
23
23
|
}
|
24
24
|
end
|
25
|
+
|
26
|
+
def extract_file(dest_dir, header, data, options = {})
|
27
|
+
file = File.join(dest_dir, header[:name])
|
28
|
+
|
29
|
+
File.open(file, "w") do |f|
|
30
|
+
f.write(data)
|
31
|
+
end
|
32
|
+
|
33
|
+
File.chmod(header[:mode], file)
|
34
|
+
#FileUtils.chown(header[:owner], header[:group], file)
|
35
|
+
end
|
25
36
|
end
|
26
37
|
end
|
27
38
|
end
|
data/lib/archive/ar/reader.rb
CHANGED
data/lib/archive/ar/version.rb
CHANGED
data/spec/fixtures/test.ar
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
!<arch>
|
2
|
-
|
2
|
+
Pjjjjjj 1399095295 501 20 100755 95 `
|
3
3
|
source 'https://rubygems.org'
|
4
4
|
|
5
5
|
( Specify your gem's dependencies in archive-ar.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
|
8
|
+
Sjjjjjj 1399095295 502 20 100750 95 `
|
9
9
|
source 'https://rubygems.org'
|
10
10
|
|
11
11
|
# Specify your gem's dependencies in archive-ar.gemspec
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua B. Bussdieker
|
@@ -55,7 +55,8 @@ dependencies:
|
|
55
55
|
description:
|
56
56
|
email:
|
57
57
|
- jbussdieker@gmail.com
|
58
|
-
executables:
|
58
|
+
executables:
|
59
|
+
- archive-ar
|
59
60
|
extensions: []
|
60
61
|
extra_rdoc_files: []
|
61
62
|
files:
|
@@ -66,6 +67,7 @@ files:
|
|
66
67
|
- README.md
|
67
68
|
- Rakefile
|
68
69
|
- archive-ar.gemspec
|
70
|
+
- bin/archive-ar
|
69
71
|
- lib/archive/ar.rb
|
70
72
|
- lib/archive/ar/format.rb
|
71
73
|
- lib/archive/ar/reader.rb
|