mirror of
https://github.com/inspec/inspec
synced 2024-11-27 15:10:44 +00:00
5d1765c9bb
Fixes https://github.com/chef/inspec/issues/1396 Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
26 lines
648 B
Ruby
26 lines
648 B
Ruby
# encoding: utf-8
|
|
# Copyright 2017 Chef Software
|
|
# author: Dominik Richter
|
|
# author: Christoph Hartmann
|
|
|
|
module Inspec
|
|
class RuntimeProfile
|
|
attr_reader :files
|
|
|
|
def initialize(profile)
|
|
@src = profile.source_reader
|
|
@files = @src.data_files.keys.map do |k|
|
|
k.sub('files' + File::SEPARATOR, '')
|
|
end
|
|
end
|
|
|
|
# Retrieve a profile file's contents
|
|
#
|
|
# @param name [String] the name of the file
|
|
# @return [String] contents of the file of RuntimeError if missing
|
|
def file(name)
|
|
@src.data_files[File.join('files', name)] ||
|
|
raise("Cannot find file #{name} in profile.")
|
|
end
|
|
end
|
|
end
|