Skip to content

Commit

Permalink
Removing Archive::Tar::Minitar
Browse files Browse the repository at this point in the history
  • Loading branch information
malikparvez committed Aug 30, 2024
1 parent 297c16e commit d03bd75
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions lib/puppet_forge/tar/mini.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'zlib'
require 'archive/tar/minitar'
require 'minitar'

module PuppetForge
class Tar
Expand All @@ -15,7 +15,7 @@ def unpack(sourcefile, destdir)
file_lists = {}
Zlib::GzipReader.open(sourcefile) do |reader|
file_lists = validate_files(reader)
Archive::Tar::Minitar.unpack(reader, destdir, file_lists[:valid]) do |action, name, stats|
Minitar.unpack(reader, destdir, file_lists[:valid]) do |action, name, stats|
case action
when :file_done
FileUtils.chmod('u+rw,g+r,a-st', "#{destdir}/#{name}")
Expand All @@ -33,7 +33,7 @@ def unpack(sourcefile, destdir)

def pack(sourcedir, destfile)
Zlib::GzipWriter.open(destfile) do |writer|
Archive::Tar::Minitar.pack(sourcedir, writer)
Minitar.pack(sourcedir, writer)
end
end

Expand All @@ -50,7 +50,7 @@ def pack(sourcedir, destfile)
# @return [Hash{:symbol => Array<String>}] a hash with file-category keys pointing to lists of filenames.
def validate_files(tarfile)
file_lists = {:valid => [], :invalid => [], :symlinks => []}
Archive::Tar::Minitar.open(tarfile).each do |entry|
Minitar.open(tarfile).each do |entry|
flag = entry.typeflag
if flag.nil? || flag =~ /[[:digit:]]/ && SYMLINK_FLAGS.include?(flag.to_i)
file_lists[:symlinks] << entry.full_name
Expand Down
2 changes: 1 addition & 1 deletion puppet_forge.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "faraday", "~> 2.0"
spec.add_runtime_dependency "faraday-follow_redirects", "~> 0.3.0"
spec.add_dependency "semantic_puppet", "~> 1.0"
spec.add_dependency "minitar", "< 1.0.0 "
spec.add_dependency "minitar", "~> 1.0.0 "

spec.add_development_dependency "rake"
spec.add_development_dependency "rspec", "~> 3.0"
Expand Down
8 changes: 4 additions & 4 deletions spec/unit/forge/tar/mini_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def initialize(name, full_name, typeflag)
writer = double('GzipWriter')

expect(Zlib::GzipWriter).to receive(:open).with(destfile).and_yield(writer)
expect(Archive::Tar::Minitar).to receive(:pack).with(sourcedir, writer)
expect(Minitar).to receive(:pack).with(sourcedir, writer)

minitar.pack(sourcedir, destfile)
end
Expand All @@ -66,8 +66,8 @@ def initialize(name, full_name, typeflag)
reader = double('GzipReader')

expect(Zlib::GzipReader).to receive(:open).with(sourcefile).and_yield(reader)
expect(Archive::Tar::Minitar).to receive(:open).with(reader).and_return(tarfile_contents)
expect(Archive::Tar::Minitar).to receive(:unpack).with(reader, destdir, ['full_file']).and_yield(:file_start, 'thefile', nil)
expect(Minitar).to receive(:open).with(reader).and_return(tarfile_contents)
expect(Minitar).to receive(:unpack).with(reader, destdir, ['full_file']).and_yield(:file_start, 'thefile', nil)

file_lists = minitar.unpack(sourcefile, destdir)

Expand All @@ -81,6 +81,6 @@ def unpacks_the_entry(type, name)

expect(Zlib::GzipReader).to receive(:open).with(sourcefile).and_yield(reader)
expect(minitar).to receive(:validate_files).with(reader).and_return({:valid => [name]})
expect(Archive::Tar::Minitar).to receive(:unpack).with(reader, destdir, [name]).and_yield(type, name, nil)
expect(Minitar).to receive(:unpack).with(reader, destdir, [name]).and_yield(type, name, nil)
end
end

0 comments on commit d03bd75

Please sign in to comment.