Class: Chef::Resource::File::Verification::Yaml

Inherits:
Chef::Resource::File::Verification show all
Defined in:
lib/chef/resource/file/verification/yaml.rb

Overview

Extends File verification to provide a Yaml verification

Example: file 'foo.yaml' do content "--- foo: 'foo-" verify :yaml end

Instance Attribute Summary

Attributes inherited from Chef::Resource::File::Verification

#output

Instance Method Summary collapse

Methods inherited from Chef::Resource::File::Verification

#initialize, #logger, lookup, provides, provides?, #to_s, #verify_block, #verify_command, #verify_registered_verification

Methods included from Mixin::DescendantsTracker

#descendants, descendants, direct_descendants, #direct_descendants, find_descendants_by_name, #find_descendants_by_name, #inherited, store_inherited

Constructor Details

This class inherits a constructor from Chef::Resource::File::Verification

Instance Method Details

#verify(path, opts = {}) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/chef/resource/file/verification/yaml.rb', line 41

def verify(path, opts = {})
  Psych.parse_file(path)
  true
rescue Psych::SyntaxError => e
  Chef::Log.error("Yaml syntax verify failed with : #{e.message}")
  false
end