Method: Inspec::TarProvider#initialize
- Defined in:
- lib/inspec/file_provider.rb
#initialize(path) ⇒ TarProvider
Returns a new instance of TarProvider.
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/inspec/file_provider.rb', line 154 def initialize(path) @path = path @contents = {} @files = [] walk_tar(@path) do |tar| @files = tar.find_all(&:file?) # delete all entries with no name @files = @files.find_all { |x| !x.full_name.empty? && x.full_name.squeeze("/") !~ %r{\.{2}(?:/|\z)} } # delete all entries that have a PaxHeader @files = @files.delete_if { |x| x.full_name.include?("PaxHeader/") } # replace all items of the array simply with the relative filename of the file @files.map! { |x| Pathname.new(x.full_name).relative_path_from(Pathname.new(".")).to_s } end end |