ffi-libarchive 0.2.0 → 0.4.1
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 +5 -5
- data/Gemfile +3 -3
- data/LICENSE +201 -674
- data/README.md +69 -4
- data/Rakefile +26 -9
- data/VERSION +1 -0
- data/ffi-libarchive.gemspec +13 -13
- data/lib/ffi-libarchive.rb +10 -11
- data/lib/ffi-libarchive/archive.rb +94 -43
- data/lib/ffi-libarchive/entry.rb +148 -156
- data/lib/ffi-libarchive/reader.rb +31 -34
- data/lib/ffi-libarchive/stat.rb +14 -14
- data/lib/ffi-libarchive/version.rb +1 -1
- data/lib/ffi-libarchive/writer.rb +27 -34
- data/test/sets/ts_read.rb +91 -93
- data/test/sets/ts_write.rb +93 -93
- data/test/test_ffi-libarchive.rb +4 -4
- metadata +22 -18
- data/.gitattributes +0 -6
- data/.gitignore +0 -55
- data/.rubocop.yml +0 -41
- data/.yardopts +0 -5
data/test/sets/ts_write.rb
CHANGED
@@ -1,123 +1,123 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "ffi-libarchive"
|
2
|
+
require "tmpdir"
|
3
|
+
require "test/unit"
|
4
4
|
|
5
5
|
class TS_WriteArchive < Test::Unit::TestCase
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
7
|
+
CONTENT_SPEC =
|
8
|
+
[
|
9
|
+
["test/", "directory", 0755, nil ],
|
10
|
+
["test/b/", "directory", 0755, nil ],
|
11
|
+
["test/b/c/", "directory", 0755, nil ],
|
12
|
+
["test/b/c/c.dat", "file", 0600, "\266\262\v_\266\243\305\3601\204\277\351\354\265\003\036\036\365f\377\210\205\032\222\346\370b\360u\032Y\301".b ],
|
13
|
+
["test/b/c/d/", "directory", 0711, nil ],
|
14
|
+
["test/b/c/d/d.dat", "symbolic_link", 0777, "../c.dat" ],
|
15
|
+
["test/b/b.dat", "file", 0640, "s&\245\354(M\331=\270\000!s\355\240\252\355'N\304\343\bY\317\t\274\210\3128\321\347\234!".b ],
|
16
|
+
["test/a.dat", "file", 0777, "\021\216\231Y\354\236\271\372\336\213\224R\211{D{\277\262\304\211xu\330\\\275@~\035\vSRM".b ]
|
17
|
+
]
|
18
|
+
|
19
|
+
def test_end_to_end_write_read_tar_gz
|
20
|
+
Dir.mktmpdir do |dir|
|
21
|
+
Archive.write_open_filename(dir + "/test.tar.gz", :gzip, :tar) do |ar|
|
22
|
+
write_content(ar)
|
23
|
+
end
|
24
|
+
|
25
|
+
verify_content(dir + "/test.tar.gz")
|
27
26
|
end
|
27
|
+
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
verify_content_memory(memory)
|
29
|
+
def test_end_to_end_write_read_memory
|
30
|
+
memory = ""
|
31
|
+
Archive.write_open_memory(memory, Archive::COMPRESSION_GZIP, Archive::FORMAT_TAR) do |ar|
|
32
|
+
write_content ar
|
35
33
|
end
|
34
|
+
verify_content_memory(memory)
|
35
|
+
end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
def test_end_to_end_write_read_tar_gz_with_external_gzip
|
38
|
+
Dir.mktmpdir do |dir|
|
39
|
+
Archive.write_open_filename(dir + "/test.tar.gz", "gzip", :tar) do |ar|
|
40
|
+
write_content(ar)
|
41
|
+
end
|
42
42
|
|
43
|
-
|
44
|
-
end
|
43
|
+
verify_content(dir + "/test.tar.gz")
|
45
44
|
end
|
45
|
+
end
|
46
46
|
|
47
|
-
|
47
|
+
private
|
48
48
|
|
49
|
-
|
50
|
-
|
49
|
+
def write_content(ar)
|
50
|
+
content_spec_idx = 0
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
while content_spec_idx < CONTENT_SPEC.size()
|
53
|
+
entry_path, entry_type, entry_mode, entry_content = \
|
54
|
+
CONTENT_SPEC[content_spec_idx]
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
56
|
+
ar.new_entry do |entry|
|
57
|
+
entry.pathname = entry_path
|
58
|
+
entry.mode = entry_mode
|
59
|
+
entry.filetype = eval "Archive::Entry::#{entry_type.upcase}" # rubocop:disable Security/Eval
|
60
|
+
entry.size = entry_content.size if entry_content
|
61
|
+
entry.symlink = entry_content if entry_type == "symbolic_link"
|
62
|
+
entry.atime = Time.now.to_i
|
63
|
+
entry.mtime = Time.now.to_i
|
64
|
+
ar.write_header(entry)
|
65
65
|
|
66
|
-
|
67
|
-
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
content_spec_idx += 1
|
66
|
+
if entry_type == "file"
|
67
|
+
ar.write_data(entry_content)
|
72
68
|
end
|
73
|
-
|
69
|
+
end
|
74
70
|
|
75
|
-
|
76
|
-
|
77
|
-
|
71
|
+
content_spec_idx += 1
|
72
|
+
end
|
73
|
+
end
|
78
74
|
|
79
|
-
|
80
|
-
|
81
|
-
|
75
|
+
def verify_content_memory(memory)
|
76
|
+
Archive.read_open_memory(memory) do |ar|
|
77
|
+
content_spec_idx = 0
|
82
78
|
|
83
|
-
|
84
|
-
|
85
|
-
|
79
|
+
while (entry = ar.next_header)
|
80
|
+
expect_pathname, expect_type, expect_mode, expect_content = \
|
81
|
+
CONTENT_SPEC[content_spec_idx]
|
86
82
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
content = ar.read_data(1024)
|
91
|
-
assert_equal expect_content, content
|
92
|
-
end
|
83
|
+
assert_equal expect_pathname, entry.pathname
|
84
|
+
assert_equal entry.send("#{expect_type}?"), true
|
85
|
+
assert_equal expect_mode, (entry.mode & 07777)
|
93
86
|
|
94
|
-
|
95
|
-
|
87
|
+
if entry.symbolic_link?
|
88
|
+
assert_equal expect_content, entry.symlink
|
89
|
+
elsif entry.file?
|
90
|
+
content = ar.read_data(1024)
|
91
|
+
assert_equal expect_content, content
|
96
92
|
end
|
97
|
-
end
|
98
93
|
|
99
|
-
|
100
|
-
|
101
|
-
|
94
|
+
content_spec_idx += 1
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
102
98
|
|
103
|
-
|
104
|
-
|
105
|
-
|
99
|
+
def verify_content(filename)
|
100
|
+
Archive.read_open_filename(filename) do |ar|
|
101
|
+
content_spec_idx = 0
|
106
102
|
|
107
|
-
|
108
|
-
|
109
|
-
|
103
|
+
while (entry = ar.next_header)
|
104
|
+
expect_pathname, expect_type, expect_mode, expect_content = \
|
105
|
+
CONTENT_SPEC[content_spec_idx]
|
110
106
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
content = ar.read_data(1024)
|
115
|
-
assert_equal expect_content, content
|
116
|
-
end
|
107
|
+
assert_equal expect_pathname, entry.pathname
|
108
|
+
assert_equal entry.send("#{expect_type}?"), true
|
109
|
+
assert_equal expect_mode, (entry.mode & 07777)
|
117
110
|
|
118
|
-
|
119
|
-
|
111
|
+
if entry.symbolic_link?
|
112
|
+
assert_equal expect_content, entry.symlink
|
113
|
+
elsif entry.file?
|
114
|
+
content = ar.read_data(1024)
|
115
|
+
assert_equal expect_content, content
|
120
116
|
end
|
117
|
+
|
118
|
+
content_spec_idx += 1
|
119
|
+
end
|
121
120
|
end
|
121
|
+
end
|
122
122
|
|
123
123
|
end
|
data/test/test_ffi-libarchive.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-libarchive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Bellone
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2018-06-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: ffi
|
@@ -54,6 +54,20 @@ dependencies:
|
|
54
54
|
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: '0'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: test-unit
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
57
71
|
description: A Ruby FFI binding to libarchive.
|
58
72
|
email:
|
59
73
|
- jbellone@bloomberg.net
|
@@ -63,16 +77,11 @@ executables: []
|
|
63
77
|
extensions: []
|
64
78
|
extra_rdoc_files: []
|
65
79
|
files:
|
66
|
-
- ".gitattributes"
|
67
|
-
- ".gitignore"
|
68
|
-
- ".rubocop.yml"
|
69
|
-
- ".yardopts"
|
70
80
|
- Gemfile
|
71
81
|
- LICENSE
|
72
82
|
- README.md
|
73
83
|
- Rakefile
|
74
|
-
-
|
75
|
-
- bin/rubocop
|
84
|
+
- VERSION
|
76
85
|
- ffi-libarchive.gemspec
|
77
86
|
- lib/ffi-libarchive.rb
|
78
87
|
- lib/ffi-libarchive/archive.rb
|
@@ -85,9 +94,9 @@ files:
|
|
85
94
|
- test/sets/ts_read.rb
|
86
95
|
- test/sets/ts_write.rb
|
87
96
|
- test/test_ffi-libarchive.rb
|
88
|
-
homepage: https://github.com/
|
97
|
+
homepage: https://github.com/chef/ffi-libarchive
|
89
98
|
licenses:
|
90
|
-
-
|
99
|
+
- Apache-2.0
|
91
100
|
metadata: {}
|
92
101
|
post_install_message:
|
93
102
|
rdoc_options: []
|
@@ -97,7 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
97
106
|
requirements:
|
98
107
|
- - ">="
|
99
108
|
- !ruby/object:Gem::Version
|
100
|
-
version:
|
109
|
+
version: 2.4.0
|
101
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
111
|
requirements:
|
103
112
|
- - ">="
|
@@ -105,13 +114,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
114
|
version: '0'
|
106
115
|
requirements: []
|
107
116
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
117
|
+
rubygems_version: 2.7.6
|
109
118
|
signing_key:
|
110
119
|
specification_version: 4
|
111
120
|
summary: A Ruby FFI binding to libarchive.
|
112
|
-
test_files:
|
113
|
-
- test/data/test.tar.gz
|
114
|
-
- test/sets/ts_read.rb
|
115
|
-
- test/sets/ts_write.rb
|
116
|
-
- test/test_ffi-libarchive.rb
|
117
|
-
has_rdoc:
|
121
|
+
test_files: []
|
data/.gitattributes
DELETED
data/.gitignore
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
# Ignore docs files
|
2
|
-
_gh_pages
|
3
|
-
_site
|
4
|
-
.ruby-version
|
5
|
-
.node-version
|
6
|
-
Gemfile.lock
|
7
|
-
pkg/
|
8
|
-
|
9
|
-
# Numerous always-ignore extensions
|
10
|
-
*.diff
|
11
|
-
*.err
|
12
|
-
*.orig
|
13
|
-
*.log
|
14
|
-
*.rej
|
15
|
-
*.swo
|
16
|
-
*.swp
|
17
|
-
*.zip
|
18
|
-
*.vi
|
19
|
-
*~
|
20
|
-
|
21
|
-
# OS or Editor folders
|
22
|
-
.DS_Store
|
23
|
-
._*
|
24
|
-
Thumbs.db
|
25
|
-
.cache
|
26
|
-
.project
|
27
|
-
.settings
|
28
|
-
.tmproj
|
29
|
-
*.esproj
|
30
|
-
nbproject
|
31
|
-
*.sublime-project
|
32
|
-
*.sublime-workspace
|
33
|
-
.idea
|
34
|
-
|
35
|
-
# Komodo
|
36
|
-
*.komodoproject
|
37
|
-
.komodotools
|
38
|
-
|
39
|
-
# grunt-html-validation
|
40
|
-
validation-status.json
|
41
|
-
validation-report.json
|
42
|
-
|
43
|
-
# Folders to ignore
|
44
|
-
bin
|
45
|
-
node_modules
|
46
|
-
tmp
|
47
|
-
vendor
|
48
|
-
.bundle
|
49
|
-
|
50
|
-
# Chef specifics to ignore
|
51
|
-
.chef
|
52
|
-
.chefdk
|
53
|
-
.kitchen
|
54
|
-
.vagrant
|
55
|
-
Berksfile.lock
|
data/.rubocop.yml
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
---
|
2
|
-
AlignParameters:
|
3
|
-
Enabled: false
|
4
|
-
|
5
|
-
Encoding:
|
6
|
-
Enabled: false
|
7
|
-
|
8
|
-
ClassLength:
|
9
|
-
Enabled: false
|
10
|
-
|
11
|
-
MethodLength:
|
12
|
-
Enabled: false
|
13
|
-
|
14
|
-
LineLength:
|
15
|
-
Enabled: false
|
16
|
-
|
17
|
-
Documentation:
|
18
|
-
Enabled: false
|
19
|
-
|
20
|
-
PerceivedComplexity:
|
21
|
-
Enabled: false
|
22
|
-
|
23
|
-
CyclomaticComplexity:
|
24
|
-
Enabled: false
|
25
|
-
|
26
|
-
Style/FileName:
|
27
|
-
Enabled: false
|
28
|
-
|
29
|
-
Style/ClassAndModuleChildren:
|
30
|
-
Enabled: false
|
31
|
-
|
32
|
-
Metrics/AbcSize:
|
33
|
-
Enabled: false
|
34
|
-
|
35
|
-
AllCops:
|
36
|
-
Exclude:
|
37
|
-
- 'Guardfile'
|
38
|
-
- 'test/**/*_spec.rb'
|
39
|
-
|
40
|
-
Style/GuardClause:
|
41
|
-
Enabled: false
|