Sha256: 3b6539fb846c55bd2d576fa21989a96ac33b0cd6be8505cbbbdb43175e407797

Contents?: true

Size: 919 Bytes

Versions: 258

Compression:

Stored size: 919 Bytes

Contents

require 'yaml'

module Puppet::Util::Yaml
  if defined?(::Psych::SyntaxError)
    YamlLoadExceptions = [::StandardError, ::Psych::SyntaxError]
  else
    YamlLoadExceptions = [::StandardError]
  end

  class YamlLoadError < Puppet::Error; end

  def self.load_file(filename, default_value = false, strip_classes = false)
    if(strip_classes) then
      data = YAML::parse_file(filename)
      data.root.each do |o|
        if o.respond_to?(:tag=) and
           o.tag != nil and
           o.tag.start_with?("!ruby")
          o.tag = nil
        end
      end
      data.to_ruby || default_value
    else
      yaml = YAML.load_file(filename)
      yaml || default_value
    end
  rescue *YamlLoadExceptions => detail
    raise YamlLoadError.new(detail.message, detail)
  end

  def self.dump(structure, filename)
    Puppet::Util.replace_file(filename, 0660) do |fh|
      YAML.dump(structure, fh)
    end
  end
end

Version data entries

258 entries across 258 versions & 3 rubygems

Version Path
puppet-5.5.17-x86-mingw32 lib/puppet/util/yaml.rb
puppet-5.5.17 lib/puppet/util/yaml.rb
puppet-5.5.17-x64-mingw32 lib/puppet/util/yaml.rb
puppet-5.5.17-universal-darwin lib/puppet/util/yaml.rb
puppet-5.5.16 lib/puppet/util/yaml.rb
puppet-5.5.16-x86-mingw32 lib/puppet/util/yaml.rb
puppet-5.5.16-x64-mingw32 lib/puppet/util/yaml.rb
puppet-5.5.16-universal-darwin lib/puppet/util/yaml.rb
puppet-retrospec-1.8.0 vendor/pup410/lib/puppet/util/yaml.rb
puppet-retrospec-1.7.0 vendor/pup410/lib/puppet/util/yaml.rb
puppet-5.5.14 lib/puppet/util/yaml.rb
puppet-5.5.14-x86-mingw32 lib/puppet/util/yaml.rb
puppet-5.5.14-x64-mingw32 lib/puppet/util/yaml.rb
puppet-5.5.14-universal-darwin lib/puppet/util/yaml.rb
puppet-5.5.13 lib/puppet/util/yaml.rb
puppet-5.5.13-x86-mingw32 lib/puppet/util/yaml.rb
puppet-5.5.13-x64-mingw32 lib/puppet/util/yaml.rb
puppet-5.5.13-universal-darwin lib/puppet/util/yaml.rb
puppet-5.5.12 lib/puppet/util/yaml.rb
puppet-5.5.12-x86-mingw32 lib/puppet/util/yaml.rb