excavate 0.3.1 → 0.3.3

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: ae1e2f6707705a5247f26db5c29f7ffb3618ccdf890277ca664cc91361e9ab7c
4
+ data.tar.gz: 5ea58834d2bcbb1005a36c9f239d32f34a7e61a2bff4a4a0548cdc5e4ae38688
5
5
  SHA512:
6
- metadata.gz: feac4007753c19cb52d9f32432f96ab2a2cf6553556cb950ad15f210a0e8f3d0209622b81702e17d4a9fef3e975b42f7f97178d7d55dfc914731245093a159f0
7
- data.tar.gz: 93bed15a89d5f620e45232f9de42afde7efaabc7e79734617c8443f2324858a6a97e6b9e40995ee18ad5bce4d36ea1ac584b238d257accf567e88472ea0fd991
6
+ metadata.gz: 38d73443fa50e9d4af01d9adcde21e45cee4c201f7bb586ce9097d37e092153d18acd5109183ba3bec3c9ecbd4a017d4f4882a44f3f1caf9e83ad98b769b8997
7
+ data.tar.gz: 0c6b9f6673b571ca5f582b4b0080180b89d091cfbaa85932b642f3c9ee690433e9e0afbac4b7ad1536307c09f54f2d614dc9df1a1690cdde0e0f736ac9f3151b
@@ -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/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
+ /.vscode
3
4
  /_yardoc/
4
5
  /coverage/
5
6
  /doc/
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,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative "lib/excavate/version"
3
4
 
5
+ # rubocop:disable Metrics/BlockLength
6
+
4
7
  Gem::Specification.new do |spec|
5
8
  spec.name = "excavate"
6
9
  spec.version = Excavate::VERSION
@@ -11,6 +14,7 @@ Gem::Specification.new do |spec|
11
14
  spec.description = "Extract nested archives with a single command."
12
15
  spec.homepage = "https://github.com/fontist/excavate"
13
16
  spec.license = "BSD-3-Clause"
17
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
14
18
 
15
19
  spec.metadata["homepage_uri"] = spec.homepage
16
20
  spec.metadata["source_code_uri"] = "https://github.com/fontist/excavate"
@@ -19,17 +23,27 @@ Gem::Specification.new do |spec|
19
23
  # Specify which files should be added to the gem when it is released.
20
24
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
25
  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)/}) }
26
+ `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{\A(?:test|spec|features|bin)/})
28
+ end
23
29
  end
24
30
  spec.bindir = "exe"
25
31
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
26
32
  spec.require_paths = ["lib"]
27
33
 
28
34
  spec.add_runtime_dependency "arr-pm", "~> 0.0"
29
- spec.add_runtime_dependency "ffi-libarchive-binary", "~> 0.0"
35
+ spec.add_runtime_dependency "bundler", "~> 2.3", ">= 2.3.24"
36
+ spec.add_runtime_dependency "ffi-libarchive-binary", "~> 0.3"
30
37
  spec.add_runtime_dependency "libmspack", "~> 0.1"
31
38
  spec.add_runtime_dependency "ruby-ole", "~> 1.0"
32
39
  spec.add_runtime_dependency "rubyzip", "~> 2.3"
33
40
  spec.add_runtime_dependency "seven-zip", "~> 1.4"
34
41
  spec.add_runtime_dependency "thor", "~> 1.0"
42
+
43
+ spec.add_development_dependency "rspec", "~> 3.0"
44
+ spec.add_development_dependency "rubocop", "~> 1.7"
45
+ spec.add_development_dependency "rubocop-performance", "~> 1.15"
46
+ spec.metadata["rubygems_mfa_required"] = "false"
35
47
  end
48
+
49
+ # rubocop:enable Metrics/BlockLength
@@ -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
@@ -186,6 +184,12 @@ module Excavate
186
184
  FileUtils.cp(archive, target)
187
185
  end
188
186
 
187
+ def may_be_nested_cab?(extension, message)
188
+ extension == "exe" &&
189
+ message.start_with?("Invalid file format",
190
+ "Unrecognized archive format")
191
+ end
192
+
189
193
  def extract_once(archive, target)
190
194
  extension = normalized_extension(archive)
191
195
  extractor_class = TYPES[extension]
@@ -195,8 +199,7 @@ module Excavate
195
199
 
196
200
  extractor_class.new(archive).extract(target)
197
201
  rescue StandardError => e
198
- raise unless extension == "exe" &&
199
- e.message.start_with?("Invalid file format")
202
+ raise unless may_be_nested_cab?(extension, e.message)
200
203
 
201
204
  Extractors::CabExtractor.new(archive).extract(target)
202
205
  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
@@ -4,8 +4,10 @@ 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
+ File.open(@archive, "rb") do |file|
9
+ SevenZipRuby::Reader.extract_all(file, target)
10
+ end
9
11
  end
10
12
  end
11
13
  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.3"
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.3
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-27 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
@@ -108,6 +128,48 @@ dependencies:
108
128
  - - "~>"
109
129
  - !ruby/object:Gem::Version
110
130
  version: '1.0'
131
+ - !ruby/object:Gem::Dependency
132
+ name: rspec
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: '3.0'
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: '3.0'
145
+ - !ruby/object:Gem::Dependency
146
+ name: rubocop
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: '1.7'
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - "~>"
157
+ - !ruby/object:Gem::Version
158
+ version: '1.7'
159
+ - !ruby/object:Gem::Dependency
160
+ name: rubocop-performance
161
+ requirement: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - "~>"
164
+ - !ruby/object:Gem::Version
165
+ version: '1.15'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - "~>"
171
+ - !ruby/object:Gem::Version
172
+ version: '1.15'
111
173
  description: Extract nested archives with a single command.
112
174
  email:
113
175
  - open.source@ribose.com
@@ -116,7 +178,6 @@ executables:
116
178
  extensions: []
117
179
  extra_rdoc_files: []
118
180
  files:
119
- - ".github/workflows/metanorma.yml"
120
181
  - ".github/workflows/test-and-release.yml"
121
182
  - ".gitignore"
122
183
  - ".rspec"
@@ -153,6 +214,7 @@ metadata:
153
214
  homepage_uri: https://github.com/fontist/excavate
154
215
  source_code_uri: https://github.com/fontist/excavate
155
216
  changelog_uri: https://github.com/fontist/excavate
217
+ rubygems_mfa_required: 'false'
156
218
  post_install_message:
157
219
  rdoc_options: []
158
220
  require_paths:
@@ -161,7 +223,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
161
223
  requirements:
162
224
  - - ">="
163
225
  - !ruby/object:Gem::Version
164
- version: '0'
226
+ version: 2.7.0
165
227
  required_rubygems_version: !ruby/object:Gem::Requirement
166
228
  requirements:
167
229
  - - ">="
@@ -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