Sha256: 5583b906cb2848bfd27d152266728bb41c997d81fc5374f2af2c5b686950b1b9

Contents?: true

Size: 827 Bytes

Versions: 14

Compression:

Stored size: 827 Bytes

Contents

# A Backend implementation capable of reading YAML syntax
class Puppet::Pops::Binder::Hiera2::YamlBackend < Puppetx::Puppet::Hiera2Backend
  def read_data(module_dir, source)
    begin
      source_file = File.join(module_dir, "#{source}.yaml")
      # if file is present but empty or has only "---", YAML.load_file returns false,
      # in which case fall back to returning an empty hash
      YAML.load_file(source_file) || {}
    rescue TypeError => e
      # SafeYaml chokes when trying to load using utf-8 and the file is empty
      raise e if File.size?(source_file)
      {}
    rescue Errno::ENOTDIR
      # This is OK, the file doesn't need to be present. Return an empty hash
      {}
    rescue Errno::ENOENT
      # This is OK, the file doesn't need to be present. Return an empty hash
      {}
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
puppet-3.4.3 lib/puppet/pops/binder/hiera2/yaml_backend.rb
puppet-3.4.2 lib/puppet/pops/binder/hiera2/yaml_backend.rb
puppet-3.4.1 lib/puppet/pops/binder/hiera2/yaml_backend.rb
puppet-3.4.0 lib/puppet/pops/binder/hiera2/yaml_backend.rb
puppet-3.4.0.rc2 lib/puppet/pops/binder/hiera2/yaml_backend.rb
puppet-3.4.0.rc1 lib/puppet/pops/binder/hiera2/yaml_backend.rb
puppet-3.3.2 lib/puppet/pops/binder/hiera2/yaml_backend.rb
puppet-3.3.1 lib/puppet/pops/binder/hiera2/yaml_backend.rb
puppet-3.3.1.rc3 lib/puppet/pops/binder/hiera2/yaml_backend.rb
puppet-3.3.1.rc2 lib/puppet/pops/binder/hiera2/yaml_backend.rb
puppet-3.3.1.rc1 lib/puppet/pops/binder/hiera2/yaml_backend.rb
puppet-3.3.0 lib/puppet/pops/binder/hiera2/yaml_backend.rb
puppet-3.3.0.rc3 lib/puppet/pops/binder/hiera2/yaml_backend.rb
puppet-3.3.0.rc2 lib/puppet/pops/binder/hiera2/yaml_backend.rb