Class: Inspec::IafProvider

Inherits:
TarProvider show all
Defined in:
lib/inspec/file_provider.rb

Overview

class TarProvider

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from TarProvider

#extract, #read

Methods inherited from FileProvider

#binread, for_path, #read, #relative_provider

Constructor Details

#initialize(path) ⇒ IafProvider

Returns a new instance of IafProvider.



230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/inspec/file_provider.rb', line 230

def initialize(path)
  f = File.open(path, "rb")
  version = f.readline.strip!
  if version == "INSPEC-PROFILE-1"
    while f.readline != "\n" do end
    content = f.read
    f.close
  elsif version == "INSPEC-PROFILE-2"
    f.readline.strip!
    content = f.read
    f.close
    content = content.slice(490, content.length).lstrip
  else
    raise Inspec::InvalidProfileSignature, "Unrecognized IAF version."
  end

  tmpfile = nil
  Dir.mktmpdir do |workdir|
    tmpfile = Pathname.new(workdir).join("temp_profile.tar.gz")
    File.open(tmpfile, "wb") { |fl| fl.write(content) }
    super(tmpfile)
  end
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



228
229
230
# File 'lib/inspec/file_provider.rb', line 228

def files
  @files
end