inspec/lib/inspec/runtime_profile.rb
Dominik Richter 5d1765c9bb add inspec.profile.file(...) for profile files
Fixes https://github.com/chef/inspec/issues/1396

Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
2017-05-03 20:39:27 +02:00

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