Class: PDK::Config::YAML
Instance Attribute Summary
Attributes inherited from Namespace
Instance Method Summary collapse
Methods inherited from Namespace
#[], #[]=, #child_namespace?, #fetch, #include_in_parent?, #initialize, #mount, #namespace, #resolve, #to_h, #value
Constructor Details
This class inherits a constructor from PDK::Config::Namespace
Instance Method Details
#parse_data(data, filename) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/pdk/config/yaml.rb', line 6 def parse_data(data, filename) return {} if data.nil? || data.empty? require 'yaml' ::YAML.safe_load(data, [Symbol], [], true) rescue Psych::SyntaxError => e raise PDK::Config::LoadError, _('Syntax error when loading %{file}: %{error}') % { file: filename, error: "#{e.problem} #{e.context}", } rescue Psych::DisallowedClass => e raise PDK::Config::LoadError, _('Unsupported class in %{file}: %{error}') % { file: filename, error: e., } end |
#serialize_data(data) ⇒ Object
24 25 26 27 28 |
# File 'lib/pdk/config/yaml.rb', line 24 def serialize_data(data) require 'yaml' ::YAML.dump(data) end |