excavate 0.3.1 → 0.3.2

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: b66a3e8ff5083bd78711cff8289e18f958578d84fea44be53dcd4f5349508755
4
- data.tar.gz: 1c65ff305ed20893b27470063280f60698d9920db597d42af8e75127c947784a
3
+ metadata.gz: fa5e513f27e2996c18e3b006569540ec1c06c8b178460e2241a891e42fddcfda
4
+ data.tar.gz: 3a0c7b6f1829f2a1d2ff4645d8b40d677a54b693351a883b53b2feb47d29b9b3
5
5
  SHA512:
6
- metadata.gz: feac4007753c19cb52d9f32432f96ab2a2cf6553556cb950ad15f210a0e8f3d0209622b81702e17d4a9fef3e975b42f7f97178d7d55dfc914731245093a159f0
7
- data.tar.gz: 93bed15a89d5f620e45232f9de42afde7efaabc7e79734617c8443f2324858a6a97e6b9e40995ee18ad5bce4d36ea1ac584b238d257accf567e88472ea0fd991
6
+ metadata.gz: 7176e3bb221ef27aa16bb666f278d2081030c28778380fa40b5cdd44737fef9b5a76e9f7b7475dfaceaf33583b7caea80590f39e3a2a5f614f9a957baf082af8
7
+ data.tar.gz: '0359c8ea5ac50e2ad79c8c453b81a5dea7c2a11c1c1e9accf0844aa5f6ea110a3cfe692819c8c786c45a1191cce2d26259135832238fb268a31e913696cac951'
@@ -10,40 +10,22 @@ concurrency:
10
10
  group: '${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.ref_name }}'
11
11
  cancel-in-progress: true
12
12
 
13
- jobs:
14
- prepare:
15
- runs-on: ubuntu-latest
16
- outputs:
17
- head_tag: ${{ steps.check.outputs.head_tag }}
18
- foreign_pr: ${{ steps.check.outputs.foreign_pr }}
19
- steps:
20
- - name: Checkout
21
- uses: actions/checkout@v2.3.4
22
-
23
- - name: Retrieve tags
24
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true
25
- - name: Set output variables
26
- id: check
27
- run: |
28
- fpr="no"
29
- tag=""
30
- if [[ "${{ github.ref }}" == refs/heads/* ]]; then
31
- tag="$(git tag --points-at HEAD)"
32
- elif [[ "${{ github.ref }}" == refs/pull/* ]] && [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.event.pull_request.base.repo.full_name }}" ]; then
33
- fpr="yes"
34
- fi
35
- echo "::set-output name=foreign_pr::${fpr}"
36
- echo "::set-output name=head_tag::${tag}"
13
+ env:
14
+ BUNDLER_VER: 2.3.24
15
+ # Forcing bundler version to ensure that it is consistent everywhere and
16
+ # does not cause bundler gem reinstalls
17
+ # bundler/rubygems 2.3.22 is a minimal requirement to support gnu/musl differentiation
18
+ # https://github.com/rubygems/rubygems/pull/4488
37
19
 
20
+ jobs:
38
21
  test:
39
22
  name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
40
- needs: prepare
41
23
  runs-on: ${{ matrix.os }}
42
24
  continue-on-error: false
43
25
  strategy:
44
26
  fail-fast: false
45
27
  matrix:
46
- ruby: [ '2.6', '2.7', '3.0', '3.1' ]
28
+ ruby: [ '2.7', '3.0', '3.1' ]
47
29
  os: [ ubuntu-latest, windows-latest, macos-latest ]
48
30
 
49
31
  steps:
@@ -52,13 +34,54 @@ jobs:
52
34
  - uses: ruby/setup-ruby@v1
53
35
  with:
54
36
  ruby-version: ${{ matrix.ruby }}
37
+ bundler: ${{ env.BUNDLER_VER }}
55
38
  bundler-cache: true
56
39
 
57
40
  - run: bundle exec rspec
58
41
 
42
+ metanorma:
43
+ name: Test with Metanorma on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
44
+ runs-on: ${{ matrix.os }}
45
+ continue-on-error: false
46
+ strategy:
47
+ fail-fast: false
48
+ matrix:
49
+ ruby: [ '2.7', '3.0', '3.1' ]
50
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
51
+ steps:
52
+ - uses: actions/checkout@v3
53
+ with:
54
+ repository: metanorma/metanorma
55
+
56
+ - uses: metanorma/metanorma-build-scripts/inkscape-setup-action@main
57
+
58
+ - uses: actions/checkout@v3
59
+ with:
60
+ path: "excavate"
61
+
62
+ - run: 'echo ''gem "excavate", path: "./excavate"'' > Gemfile.devel'
63
+
64
+ # https://github.com/rubygems/rubygems/issues/5160
65
+ - if: matrix.ruby == '3.0'
66
+ uses: ruby/setup-ruby@v1
67
+ with:
68
+ ruby-version: ${{ matrix.ruby }}
69
+ bundler-cache: true
70
+ bundler: ${{ env.BUNDLER_VER }}
71
+ rubygems: latest
72
+
73
+ - if: matrix.ruby != '3.0'
74
+ uses: ruby/setup-ruby@v1
75
+ with:
76
+ ruby-version: ${{ matrix.ruby }}
77
+ bundler: ${{ env.BUNDLER_VER }}
78
+ bundler-cache: true
79
+
80
+ - run: bundle exec rake
81
+
59
82
  release:
60
83
  name: Release gem
61
- needs: test
84
+ needs: [ test, metanorma ]
62
85
  runs-on: ubuntu-latest
63
86
  if: contains(github.ref, 'refs/tags/v')
64
87
  steps:
data/.rubocop.yml CHANGED
@@ -1,2 +1,15 @@
1
1
  inherit_from:
2
2
  - 'https://raw.githubusercontent.com/fontist/oss-guides/master/ci/rubocop.yml'
3
+
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 2.7
7
+ SuggestExtensions: false
8
+ Exclude:
9
+ - 'pkg/**/*'
10
+
11
+ Gemspec/RequireMFA:
12
+ Enabled: false
13
+
14
+ Layout/LineLength:
15
+ Max: 160
data/Gemfile CHANGED
@@ -3,10 +3,3 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gemspec
6
-
7
- gem "gem-release"
8
- gem "rake", "~> 13.0"
9
- gem "rspec", "~> 3.2"
10
- gem "rubocop"
11
- gem "rubocop-performance"
12
- gem "rubocop-rails"
data/Rakefile CHANGED
@@ -1,4 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bundler/gem_tasks"
4
- task default: %i[]
4
+ require "rspec/core/rake_task"
5
+ require "rubocop/rake_task"
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+ RuboCop::RakeTask.new
9
+
10
+ task default: %i[spec rubocop]
data/excavate.gemspec CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative "lib/excavate/version"
3
4
 
4
5
  Gem::Specification.new do |spec|
@@ -11,6 +12,7 @@ Gem::Specification.new do |spec|
11
12
  spec.description = "Extract nested archives with a single command."
12
13
  spec.homepage = "https://github.com/fontist/excavate"
13
14
  spec.license = "BSD-3-Clause"
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
14
16
 
15
17
  spec.metadata["homepage_uri"] = spec.homepage
16
18
  spec.metadata["source_code_uri"] = "https://github.com/fontist/excavate"
@@ -19,17 +21,25 @@ Gem::Specification.new do |spec|
19
21
  # Specify which files should be added to the gem when it is released.
20
22
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
23
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features|bin)/}) }
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ f.match(%r{\A(?:test|spec|features|bin)/})
26
+ end
23
27
  end
24
28
  spec.bindir = "exe"
25
29
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
26
30
  spec.require_paths = ["lib"]
27
31
 
28
32
  spec.add_runtime_dependency "arr-pm", "~> 0.0"
29
- spec.add_runtime_dependency "ffi-libarchive-binary", "~> 0.0"
33
+ spec.add_runtime_dependency "bundler", "~> 2.3", ">= 2.3.24"
34
+ spec.add_runtime_dependency "ffi-libarchive-binary", "~> 0.3"
30
35
  spec.add_runtime_dependency "libmspack", "~> 0.1"
31
36
  spec.add_runtime_dependency "ruby-ole", "~> 1.0"
32
37
  spec.add_runtime_dependency "rubyzip", "~> 2.3"
33
- spec.add_runtime_dependency "seven-zip", "~> 1.4"
34
38
  spec.add_runtime_dependency "thor", "~> 1.0"
39
+
40
+ spec.add_development_dependency "rspec", "~> 3.0"
41
+ spec.add_development_dependency "rubocop", "~> 1.7"
42
+ spec.add_development_dependency "rubocop-performance", "~> 1.15"
43
+
44
+ spec.metadata["rubygems_mfa_required"] = "false"
35
45
  end
@@ -17,14 +17,12 @@ module Excavate
17
17
  @archive = archive
18
18
  end
19
19
 
20
- def files(recursive_packages: false, files: [], filter: nil)
20
+ def files(recursive_packages: false, files: [], filter: nil, &block)
21
21
  target = Dir.mktmpdir
22
22
  extract(target, recursive_packages: recursive_packages,
23
23
  files: files, filter: filter)
24
24
 
25
- all_files_in(target).map do |file|
26
- yield file
27
- end
25
+ all_files_in(target).map(&block)
28
26
  ensure
29
27
  FileUtils.rm_rf(target)
30
28
  end
@@ -19,7 +19,7 @@ module Excavate
19
19
 
20
20
  def open_cab(archive)
21
21
  decompressor = LibMsPack::CabDecompressor.new
22
- cab = Utils.silence_stream(STDERR) do
22
+ cab = Utils.silence_stream($stderr) do
23
23
  decompressor.search(archive)
24
24
  end
25
25
 
@@ -14,30 +14,38 @@ module Excavate
14
14
 
15
15
  private
16
16
 
17
+ def extract_cpio_inner_new(entry, file, target)
18
+ path = File.join(target, entry.name)
19
+ if entry.directory?
20
+ FileUtils.mkdir_p(path)
21
+ else
22
+ FileUtils.mkdir_p(File.dirname(path))
23
+ File.write(path, file.read, mode: "wb")
24
+ end
25
+ end
26
+
17
27
  def extract_cpio_new_format(target)
18
28
  File.open(@archive, "rb") do |archive_file|
19
29
  CPIO::ASCIIReader.new(archive_file).each do |entry, file|
20
- path = File.join(target, entry.name)
21
- if entry.directory?
22
- FileUtils.mkdir_p(path)
23
- else
24
- FileUtils.mkdir_p(File.dirname(path))
25
- File.write(path, file.read, mode: "wb")
26
- end
30
+ extract_cpio_inner_new(entry, file, target)
27
31
  end
28
32
  end
29
33
  end
30
34
 
35
+ def extract_cpio_inner_old(entry, target)
36
+ path = File.expand_path(entry.filename, target)
37
+ if entry.directory?
38
+ FileUtils.mkdir_p(path)
39
+ else
40
+ FileUtils.mkdir_p(File.dirname(path))
41
+ File.write(path, entry.data, mode: "wb")
42
+ end
43
+ end
44
+
31
45
  def extract_cpio_old_format(target)
32
46
  File.open(@archive, "rb") do |archive_file|
33
47
  CPIO::ArchiveReader.new(archive_file).each_entry do |entry|
34
- path = File.expand_path(entry.filename, target)
35
- if entry.directory?
36
- FileUtils.mkdir_p(path)
37
- else
38
- FileUtils.mkdir_p(File.dirname(path))
39
- File.write(path, entry.data, mode: "wb")
40
- end
48
+ extract_cpio_inner_old(entry, target)
41
49
  end
42
50
  end
43
51
  end
@@ -1,9 +1,11 @@
1
1
  require "arr-pm"
2
2
 
3
+ H_MAGIC = "\x8e\xad\xe8\x01\x00\x00\x00\x00".force_encoding("BINARY")
4
+
3
5
  # fix for Ruby 3.0
4
- unless RPM::File::Header::HEADER_MAGIC == "\x8e\xad\xe8\x01\x00\x00\x00\x00".force_encoding("BINARY")
6
+ unless RPM::File::Header::HEADER_MAGIC == H_MAGIC
5
7
  RPM::File::Header.send(:remove_const, "HEADER_MAGIC")
6
- RPM::File::Header.const_set("HEADER_MAGIC", "\x8e\xad\xe8\x01\x00\x00\x00\x00".force_encoding("BINARY"))
8
+ RPM::File::Header.const_set(:HEADER_MAGIC, H_MAGIC)
7
9
  end
8
10
 
9
11
  module Excavate
@@ -25,7 +27,7 @@ module Excavate
25
27
  archive_format = tags[:payloadformat]
26
28
  compression_format = tags[:payloadcompressor] == "gzip" ? "gz" : tags[:payloadcompressor]
27
29
  basename = File.basename(archive, ".*")
28
- filename = basename + "." + archive_format + "." + compression_format
30
+ filename = "#{basename}.#{archive_format}.#{compression_format}"
29
31
  File.join(dir, filename)
30
32
  end
31
33
  end
@@ -1,13 +1,24 @@
1
- require "seven_zip_ruby"
1
+ require "ffi-libarchive-binary"
2
2
 
3
3
  module Excavate
4
4
  module Extractors
5
5
  class SevenZipExtractor < Extractor
6
6
  def extract(target)
7
- File.open(@archive, "rb") do |file|
8
- SevenZipRuby::Reader.extract_all(file, target)
7
+ Dir.chdir(target) do
8
+ extract_with_libarchive
9
9
  end
10
10
  end
11
+
12
+ def extract_with_libarchive
13
+ flags = ::Archive::EXTRACT_PERM
14
+ reader = ::Archive::Reader.open_filename(@archive)
15
+
16
+ reader.each_entry do |entry|
17
+ reader.extract(entry, flags.to_i)
18
+ end
19
+
20
+ reader.close
21
+ end
11
22
  end
12
23
  end
13
24
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Excavate
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: excavate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-16 00:00:00.000000000 Z
11
+ date: 2022-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: arr-pm
@@ -24,20 +24,40 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.3'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 2.3.24
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '2.3'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 2.3.24
27
47
  - !ruby/object:Gem::Dependency
28
48
  name: ffi-libarchive-binary
29
49
  requirement: !ruby/object:Gem::Requirement
30
50
  requirements:
31
51
  - - "~>"
32
52
  - !ruby/object:Gem::Version
33
- version: '0.0'
53
+ version: '0.3'
34
54
  type: :runtime
35
55
  prerelease: false
36
56
  version_requirements: !ruby/object:Gem::Requirement
37
57
  requirements:
38
58
  - - "~>"
39
59
  - !ruby/object:Gem::Version
40
- version: '0.0'
60
+ version: '0.3'
41
61
  - !ruby/object:Gem::Dependency
42
62
  name: libmspack
43
63
  requirement: !ruby/object:Gem::Requirement
@@ -81,33 +101,61 @@ dependencies:
81
101
  - !ruby/object:Gem::Version
82
102
  version: '2.3'
83
103
  - !ruby/object:Gem::Dependency
84
- name: seven-zip
104
+ name: thor
85
105
  requirement: !ruby/object:Gem::Requirement
86
106
  requirements:
87
107
  - - "~>"
88
108
  - !ruby/object:Gem::Version
89
- version: '1.4'
109
+ version: '1.0'
90
110
  type: :runtime
91
111
  prerelease: false
92
112
  version_requirements: !ruby/object:Gem::Requirement
93
113
  requirements:
94
114
  - - "~>"
95
115
  - !ruby/object:Gem::Version
96
- version: '1.4'
116
+ version: '1.0'
97
117
  - !ruby/object:Gem::Dependency
98
- name: thor
118
+ name: rspec
99
119
  requirement: !ruby/object:Gem::Requirement
100
120
  requirements:
101
121
  - - "~>"
102
122
  - !ruby/object:Gem::Version
103
- version: '1.0'
104
- type: :runtime
123
+ version: '3.0'
124
+ type: :development
105
125
  prerelease: false
106
126
  version_requirements: !ruby/object:Gem::Requirement
107
127
  requirements:
108
128
  - - "~>"
109
129
  - !ruby/object:Gem::Version
110
- version: '1.0'
130
+ version: '3.0'
131
+ - !ruby/object:Gem::Dependency
132
+ name: rubocop
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: '1.7'
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: '1.7'
145
+ - !ruby/object:Gem::Dependency
146
+ name: rubocop-performance
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: '1.15'
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - "~>"
157
+ - !ruby/object:Gem::Version
158
+ version: '1.15'
111
159
  description: Extract nested archives with a single command.
112
160
  email:
113
161
  - open.source@ribose.com
@@ -116,7 +164,6 @@ executables:
116
164
  extensions: []
117
165
  extra_rdoc_files: []
118
166
  files:
119
- - ".github/workflows/metanorma.yml"
120
167
  - ".github/workflows/test-and-release.yml"
121
168
  - ".gitignore"
122
169
  - ".rspec"
@@ -153,6 +200,7 @@ metadata:
153
200
  homepage_uri: https://github.com/fontist/excavate
154
201
  source_code_uri: https://github.com/fontist/excavate
155
202
  changelog_uri: https://github.com/fontist/excavate
203
+ rubygems_mfa_required: 'false'
156
204
  post_install_message:
157
205
  rdoc_options: []
158
206
  require_paths:
@@ -161,7 +209,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
161
209
  requirements:
162
210
  - - ">="
163
211
  - !ruby/object:Gem::Version
164
- version: '0'
212
+ version: 2.7.0
165
213
  required_rubygems_version: !ruby/object:Gem::Requirement
166
214
  requirements:
167
215
  - - ">="
@@ -1,76 +0,0 @@
1
- name: metanorma
2
-
3
- on:
4
- push:
5
- branches: [ main ]
6
- pull_request:
7
-
8
- concurrency:
9
- group: '${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.ref_name }}'
10
- cancel-in-progress: true
11
-
12
- jobs:
13
- prepare:
14
- runs-on: ubuntu-latest
15
- outputs:
16
- head_tag: ${{ steps.check.outputs.head_tag }}
17
- foreign_pr: ${{ steps.check.outputs.foreign_pr }}
18
- steps:
19
- - name: Checkout
20
- uses: actions/checkout@v2.3.4
21
-
22
- - name: Retrieve tags
23
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true
24
- - name: Set output variables
25
- id: check
26
- run: |
27
- fpr="no"
28
- tag=""
29
- if [[ "${{ github.ref }}" == refs/heads/* ]]; then
30
- tag="$(git tag --points-at HEAD)"
31
- elif [[ "${{ github.ref }}" == refs/pull/* ]] && [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.event.pull_request.base.repo.full_name }}" ]; then
32
- fpr="yes"
33
- fi
34
- echo "::set-output name=foreign_pr::${fpr}"
35
- echo "::set-output name=head_tag::${tag}"
36
-
37
- test:
38
- name: Test with Metanorma on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
39
- needs: prepare
40
- runs-on: ${{ matrix.os }}
41
- continue-on-error: false
42
- strategy:
43
- fail-fast: false
44
- matrix:
45
- ruby: [ '2.7', '3.0', '3.1' ]
46
- os: [ ubuntu-latest, windows-latest, macos-latest ]
47
- steps:
48
- - uses: actions/checkout@v3
49
- with:
50
- repository: metanorma/metanorma
51
-
52
- - uses: metanorma/metanorma-build-scripts/inkscape-setup-action@main
53
-
54
- - uses: actions/checkout@v3
55
- with:
56
- path: "excavate"
57
-
58
- - run: 'echo ''gem "excavate", path: "./excavate"'' > Gemfile.devel'
59
-
60
- - if: matrix.ruby == '3.0'
61
- uses: ruby/setup-ruby@v1
62
- with:
63
- ruby-version: ${{ matrix.ruby }}
64
- bundler-cache: false
65
- rubygems: latest
66
-
67
- - if: matrix.ruby == '3.0'
68
- run: bundle
69
-
70
- - if: matrix.ruby != '3.0'
71
- uses: ruby/setup-ruby@v1
72
- with:
73
- ruby-version: ${{ matrix.ruby }}
74
- bundler-cache: true
75
-
76
- - run: bundle exec rake