ffi-libarchive 0.4.4 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee3adc120723c76032310ce14cb7f3baa719e4652611b1970dd0a6abfcba52c9
4
- data.tar.gz: 90dcedb260ba9ec0747f34618d112e2118f10441e64cd11dad51ffdd084bdb62
3
+ metadata.gz: c72d2c946ebbe1abc58adcc317403ec80da09dc6f1279da0a6ac4ba9b97f69b0
4
+ data.tar.gz: 28b4880ea52ac6818b2c8278aece3cbb1733c6df31a7832bf0d7b079f6bb2e8b
5
5
  SHA512:
6
- metadata.gz: c87837659aa48f7fae76486623e11ada02709d20ce550e48a95a64562a2184ec2607f5bbfc1518c4f8f0adc0a3ccce9ad3f2fc49246d5a9d603c40afeaa23c96
7
- data.tar.gz: 9a760bec0f9bfd48e55fc8a06743e1cef832999f2a345e738a264ea2bcd9e1bbf2deb3f98c0fb98a141c3dab29862dd031a82527905104f45eea13b31bc949b2
6
+ metadata.gz: bc3da073141178fb7c7a92d86a345cfb1767218a1b30251b7ad610e8f3e21372e1937e63a4f5bc2375ebd032d3cb8401ac834c80bac35fb1821d081b779b850a
7
+ data.tar.gz: fa05aa479a2909b02e5e74f8ec361e9cae5a6092cbe42a3db1b6443c02eee740d0eee9fb91ec2a485904641eb8de98e6675f386e17b22217c086cf56de0f717c
@@ -1,3 +1,3 @@
1
1
  module Archive
2
- VERSION = "0.4.4".freeze
2
+ VERSION = "0.4.6".freeze
3
3
  end
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.4
4
+ version: 0.4.6
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: 2018-11-05 00:00:00.000000000 Z
13
+ date: 2018-12-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ffi
@@ -40,34 +40,6 @@ dependencies:
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
42
  version: '0'
43
- - !ruby/object:Gem::Dependency
44
- name: rake
45
- requirement: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: '0'
50
- type: :development
51
- prerelease: false
52
- version_requirements: !ruby/object:Gem::Requirement
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
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'
71
43
  description: A Ruby FFI binding to libarchive.
72
44
  email:
73
45
  - jbellone@bloomberg.net
@@ -77,12 +49,7 @@ executables: []
77
49
  extensions: []
78
50
  extra_rdoc_files: []
79
51
  files:
80
- - Gemfile
81
52
  - LICENSE
82
- - README.md
83
- - Rakefile
84
- - VERSION
85
- - ffi-libarchive.gemspec
86
53
  - lib/ffi-libarchive.rb
87
54
  - lib/ffi-libarchive/archive.rb
88
55
  - lib/ffi-libarchive/entry.rb
@@ -90,10 +57,6 @@ files:
90
57
  - lib/ffi-libarchive/stat.rb
91
58
  - lib/ffi-libarchive/version.rb
92
59
  - lib/ffi-libarchive/writer.rb
93
- - test/data/test.tar.gz
94
- - test/sets/ts_read.rb
95
- - test/sets/ts_write.rb
96
- - test/test_ffi-libarchive.rb
97
60
  homepage: https://github.com/chef/ffi-libarchive
98
61
  licenses:
99
62
  - Apache-2.0
@@ -114,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
77
  version: '0'
115
78
  requirements: []
116
79
  rubyforge_project:
117
- rubygems_version: 2.7.7
80
+ rubygems_version: 2.7.6
118
81
  signing_key:
119
82
  specification_version: 4
120
83
  summary: A Ruby FFI binding to libarchive.
data/Gemfile DELETED
@@ -1,10 +0,0 @@
1
- source "https://rubygems.org"
2
- gemspec
3
-
4
- group :lint do
5
- gem "chefstyle"
6
- end
7
-
8
- group :doc do
9
- gem "yard"
10
- end
data/README.md DELETED
@@ -1,77 +0,0 @@
1
- ffi-libarchive
2
- ==============
3
- A Ruby FFI binding to [libarchive][0].
4
-
5
- This library provides Ruby FFI bindings to the well-known
6
- [libarchive library][0].
7
-
8
- ## Installation
9
-
10
- Ensure that you have libarchive installed. On Debian/Ubuntu:
11
-
12
- ```sh
13
- apt install libarchive13
14
- ```
15
-
16
- On macOS with Homebrew:
17
- ```sh
18
- brew install libarchive
19
- ```
20
-
21
- Add this line to your application's Gemfile:
22
-
23
- ```ruby
24
- gem 'ffi-libarchive'
25
- ```
26
-
27
- And then execute:
28
-
29
- ```shell
30
- $ bundle
31
- ```
32
-
33
- Or install it yourself as:
34
-
35
- ```shell
36
- $ gem install ffi-libarchive
37
- ```
38
-
39
- ## Usage
40
-
41
- To extract an archive into the current directory:
42
-
43
- ```ruby
44
- flags = Archive::EXTRACT_PERM
45
- reader = Archive::Reader.open_filename('/path/to/archive.tgz')
46
-
47
- reader.each_entry do |entry|
48
- reader.extract(entry, flags.to_i)
49
- end
50
- reader.close
51
- ```
52
-
53
- To create a gzipped tar archive:
54
-
55
- ```ruby
56
- Archive.write_open_filename('my.tgz', Archive::COMPRESSION_GZIP, Archive::FORMAT_TAR_PAX_RESTRICTED) do |tar|
57
- content = File.read 'some_path'
58
- size = content.size
59
- tar.new_entry do |e|
60
- e.pathname = 'some_path'
61
- e.size = size
62
- e.filetype = Archive::Entry::FILE
63
- tar.write_header e
64
- tar.write_data content
65
- end
66
- end
67
- ```
68
-
69
- ## Contributing
70
-
71
- Bug reports and pull requests are welcome on GitHub at <https://github.com/chef/ffi-libarchive>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Community Guidelines](https://docs.chef.io/community_guidelines.html) code of conduct.
72
-
73
- ## License
74
-
75
- The gem is available as open source under the terms of the Apache License, v2
76
-
77
- [0]: https://github.com/libarchive/libarchive
data/Rakefile DELETED
@@ -1,28 +0,0 @@
1
- #!/usr/bin/env rake
2
-
3
- require "bundler/setup"
4
- require "bundler/gem_tasks"
5
- require "chefstyle"
6
- require "rubocop/rake_task"
7
- require "rake/testtask"
8
-
9
- namespace :style do
10
- desc "Run Ruby style checks"
11
- RuboCop::RakeTask.new(:ruby)
12
- end
13
-
14
- Rake::TestTask.new(:test) do |t|
15
- t.libs << "test"
16
- t.libs << "lib"
17
- t.test_files = FileList["test/test_ffi-libarchive.rb"]
18
- end
19
-
20
- desc "Run all style checks"
21
- task style: ["style:ruby"]
22
-
23
- desc "Run style & unit tests on Travis"
24
- task travis: %w{style test}
25
-
26
- # Default
27
- desc "Run style, unit"
28
- task default: %w{style test}
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.4.4
@@ -1,25 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "ffi-libarchive/version"
5
-
6
- Gem::Specification.new do |s|
7
- s.name = "ffi-libarchive"
8
- s.version = Archive::VERSION
9
- s.authors = ["John Bellone", "Jamie Winsor", "Frank Fischer"]
10
- s.email = %w{jbellone@bloomberg.net jamie@vialstudios.com frank-fischer@shadow-soft.de}
11
- s.description = "A Ruby FFI binding to libarchive."
12
- s.summary = s.description
13
- s.homepage = "https://github.com/chef/ffi-libarchive"
14
- s.license = "Apache-2.0"
15
-
16
- s.files = %w{ Gemfile Rakefile README.md LICENSE VERSION } + Dir.glob("{lib,test}/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) } + Dir.glob("*.gemspec")
17
- s.require_paths = %w{lib}
18
- s.required_ruby_version = ">= 2.4.0"
19
-
20
- s.add_dependency "ffi", "~> 1.0"
21
-
22
- s.add_development_dependency "bundler"
23
- s.add_development_dependency "rake"
24
- s.add_development_dependency "test-unit"
25
- end
Binary file
@@ -1,143 +0,0 @@
1
- require "ffi-libarchive"
2
- require "tmpdir"
3
- require "test/unit"
4
-
5
- class TS_ReadArchive < Test::Unit::TestCase
6
-
7
- CONTENT_SPEC = [
8
- ["test/", "directory", 0755, nil ],
9
- ["test/b/", "directory", 0755, nil ],
10
- ["test/b/c/", "directory", 0755, nil ],
11
- ["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 ],
12
- ["test/b/c/d/", "directory", 0711, nil ],
13
- ["test/b/c/d/d.dat", "symbolic_link", 0777, "../c.dat" ],
14
- ["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 ],
15
- ["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 ]
16
- ].freeze
17
-
18
- def setup
19
- File.open("data/test.tar.gz", "rb") do |f|
20
- @archive_content = f.read
21
- end
22
- end
23
-
24
- def test_read_tar_gz_from_file
25
- Archive.read_open_filename("data/test.tar.gz") do |ar|
26
- verify_content(ar)
27
- end
28
- end
29
-
30
- def test_read_tar_gz_from_file_with_external_gunzip
31
- Archive.read_open_filename("data/test.tar.gz", "gunzip") do |ar|
32
- verify_content(ar)
33
- end
34
- end
35
-
36
- def test_read_tar_gz_from_memory
37
- Archive.read_open_memory(@archive_content) do |ar|
38
- verify_content(ar)
39
- end
40
- end
41
-
42
- def test_read_tar_gz_from_memory_with_external_gunzip
43
- Archive.read_open_memory(@archive_content, "gunzip") do |ar|
44
- verify_content(ar)
45
- end
46
- end
47
-
48
- def test_read_entry_bigger_than_internal_buffer
49
- alphabet = "abcdefghijklmnopqrstuvwxyz"
50
- entry_size = 1024 * 4 - 3
51
-
52
- srand
53
- content = ""
54
- 1.upto(entry_size) do |i|
55
- index = rand(alphabet.size)
56
- content += alphabet[index, 1]
57
- end
58
-
59
- Dir.mktmpdir do |dir|
60
- Archive.write_open_filename(dir + "/test.tar.gz",
61
- Archive::COMPRESSION_BZIP2, Archive::FORMAT_TAR) do |ar|
62
- ar.new_entry do |entry|
63
- entry.pathname = "chubby.dat"
64
- entry.mode = 0666
65
- entry.filetype = Archive::Entry::FILE
66
- entry.atime = Time.now.to_i
67
- entry.mtime = Time.now.to_i
68
- entry.size = entry_size
69
- ar.write_header(entry)
70
- ar.write_data(content)
71
- end
72
- end
73
-
74
- Archive.read_open_filename(dir + "/test.tar.gz") do |ar|
75
- ar.next_header
76
- data = ar.read_data
77
-
78
- assert_equal entry_size, data.size
79
- assert_equal content.size, data.size
80
- assert_equal content, data
81
- end
82
-
83
- Archive.read_open_filename(dir + "/test.tar.gz") do |ar|
84
- ar.next_header
85
- data = ""
86
- ar.read_data(128) { |chunk| data += chunk }
87
-
88
- assert_equal content, data
89
- end
90
- end
91
- end
92
-
93
- def test_extract_no_additional_flags
94
- Dir.mktmpdir do |dir|
95
- Archive.read_open_filename("data/test.tar.gz") do |ar|
96
- Dir.chdir(dir) do
97
- ar.each_entry do |e|
98
- ar.extract(e)
99
- assert_not_equal File.mtime(e.pathname), e.mtime
100
- end
101
- end
102
- end
103
- end
104
- end
105
-
106
- def test_extract_extract_time
107
- Dir.mktmpdir do |dir|
108
- Archive.read_open_filename("data/test.tar.gz") do |ar|
109
- Dir.chdir(dir) do
110
- ar.each_entry do |e|
111
- ar.extract(e, Archive::EXTRACT_TIME.to_i)
112
- next if e.directory? || e.symbolic_link?
113
- assert_equal File.mtime(e.pathname), e.mtime
114
- end
115
- end
116
- end
117
- end
118
- end
119
-
120
- private
121
-
122
- def verify_content(ar)
123
- content_spec_idx = 0
124
-
125
- while (entry = ar.next_header)
126
- expect_pathname, expect_type, expect_mode, expect_content = CONTENT_SPEC[content_spec_idx]
127
-
128
- assert_equal expect_pathname, entry.pathname
129
- assert_equal entry.send("#{expect_type}?"), true
130
- assert_equal expect_mode, (entry.mode & 07777)
131
-
132
- if entry.symbolic_link?
133
- assert_equal expect_content, entry.symlink
134
- elsif entry.file?
135
- content = ar.read_data(1024)
136
- assert_equal expect_content, content
137
- end
138
-
139
- content_spec_idx += 1
140
- end
141
- end
142
-
143
- end
@@ -1,122 +0,0 @@
1
- require "ffi-libarchive"
2
- require "tmpdir"
3
- require "test/unit"
4
-
5
- class TS_WriteArchive < Test::Unit::TestCase
6
-
7
- CONTENT_SPEC = [
8
- ["test/", "directory", 0755, nil ],
9
- ["test/b/", "directory", 0755, nil ],
10
- ["test/b/c/", "directory", 0755, nil ],
11
- ["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 ],
12
- ["test/b/c/d/", "directory", 0711, nil ],
13
- ["test/b/c/d/d.dat", "symbolic_link", 0777, "../c.dat" ],
14
- ["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 ],
15
- ["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 ]
16
- ].freeze
17
-
18
- def test_end_to_end_write_read_tar_gz
19
- Dir.mktmpdir do |dir|
20
- Archive.write_open_filename(dir + "/test.tar.gz", :gzip, :tar) do |ar|
21
- write_content(ar)
22
- end
23
-
24
- verify_content(dir + "/test.tar.gz")
25
- end
26
- end
27
-
28
- def test_end_to_end_write_read_memory
29
- memory = ""
30
- Archive.write_open_memory(memory, Archive::COMPRESSION_GZIP, Archive::FORMAT_TAR) do |ar|
31
- write_content ar
32
- end
33
- verify_content_memory(memory)
34
- end
35
-
36
- def test_end_to_end_write_read_tar_gz_with_external_gzip
37
- Dir.mktmpdir do |dir|
38
- Archive.write_open_filename(dir + "/test.tar.gz", "gzip", :tar) do |ar|
39
- write_content(ar)
40
- end
41
-
42
- verify_content(dir + "/test.tar.gz")
43
- end
44
- end
45
-
46
- private
47
-
48
- def write_content(ar)
49
- content_spec_idx = 0
50
-
51
- while content_spec_idx < CONTENT_SPEC.size()
52
- entry_path, entry_type, entry_mode, entry_content = \
53
- CONTENT_SPEC[content_spec_idx]
54
-
55
- ar.new_entry do |entry|
56
- entry.pathname = entry_path
57
- entry.mode = entry_mode
58
- entry.filetype = eval "Archive::Entry::#{entry_type.upcase}" # rubocop:disable Security/Eval
59
- entry.size = entry_content.size if entry_content
60
- entry.symlink = entry_content if entry_type == "symbolic_link"
61
- entry.atime = Time.now.to_i
62
- entry.mtime = Time.now.to_i
63
- ar.write_header(entry)
64
-
65
- if entry_type == "file"
66
- ar.write_data(entry_content)
67
- end
68
- end
69
-
70
- content_spec_idx += 1
71
- end
72
- end
73
-
74
- def verify_content_memory(memory)
75
- Archive.read_open_memory(memory) do |ar|
76
- content_spec_idx = 0
77
-
78
- while (entry = ar.next_header)
79
- expect_pathname, expect_type, expect_mode, expect_content = \
80
- CONTENT_SPEC[content_spec_idx]
81
-
82
- assert_equal expect_pathname, entry.pathname
83
- assert_equal entry.send("#{expect_type}?"), true
84
- assert_equal expect_mode, (entry.mode & 07777)
85
-
86
- if entry.symbolic_link?
87
- assert_equal expect_content, entry.symlink
88
- elsif entry.file?
89
- content = ar.read_data(1024)
90
- assert_equal expect_content, content
91
- end
92
-
93
- content_spec_idx += 1
94
- end
95
- end
96
- end
97
-
98
- def verify_content(filename)
99
- Archive.read_open_filename(filename) do |ar|
100
- content_spec_idx = 0
101
-
102
- while (entry = ar.next_header)
103
- expect_pathname, expect_type, expect_mode, expect_content = \
104
- CONTENT_SPEC[content_spec_idx]
105
-
106
- assert_equal expect_pathname, entry.pathname
107
- assert_equal entry.send("#{expect_type}?"), true
108
- assert_equal expect_mode, (entry.mode & 07777)
109
-
110
- if entry.symbolic_link?
111
- assert_equal expect_content, entry.symlink
112
- elsif entry.file?
113
- content = ar.read_data(1024)
114
- assert_equal expect_content, content
115
- end
116
-
117
- content_spec_idx += 1
118
- end
119
- end
120
- end
121
-
122
- end
@@ -1,8 +0,0 @@
1
-
2
- Dir.chdir File.dirname(__FILE__)
3
-
4
- $LOAD_PATH.unshift "../lib/", "."
5
-
6
- require "test/unit"
7
- require "sets/ts_read"
8
- require "sets/ts_write"