Class: Inspec::IafProvider
- Inherits:
-
TarProvider
- Object
- FileProvider
- TarProvider
- Inspec::IafProvider
- Defined in:
- lib/inspec/file_provider.rb
Overview
class TarProvider
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Instance Method Summary collapse
-
#initialize(path) ⇒ IafProvider
constructor
A new instance of IafProvider.
Methods inherited from TarProvider
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
#files ⇒ Object (readonly)
Returns the value of attribute files.
228 229 230 |
# File 'lib/inspec/file_provider.rb', line 228 def files @files end |