Class: Secrets::YAML
- Inherits:
-
Object
- Object
- Secrets::YAML
- Defined in:
- lib/inspec/secrets/yaml.rb
Instance Attribute Summary collapse
-
#inputs ⇒ Object
readonly
Returns the value of attribute inputs.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(target) ⇒ YAML
constructor
array of yaml file paths.
Constructor Details
#initialize(target) ⇒ YAML
array of yaml file paths
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/inspec/secrets/yaml.rb', line 18 def initialize(target) @inputs = ::YAML.load_file(target) if @inputs == false || !@inputs.is_a?(Hash) Inspec::Log.warn("#{self.class} unable to parse #{target}: invalid YAML or contents is not a Hash") @inputs = nil end rescue => e raise "Error reading InSpec inputs: #{e}" end |
Instance Attribute Details
#inputs ⇒ Object (readonly)
Returns the value of attribute inputs.
7 8 9 |
# File 'lib/inspec/secrets/yaml.rb', line 7 def inputs @inputs end |
Class Method Details
.resolve(target) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/inspec/secrets/yaml.rb', line 9 def self.resolve(target) unless target.is_a?(String) && File.file?(target) && [".yml", ".yaml"].include?(File.extname(target).downcase) return nil end new(target) end |