Method: Pod::YAMLHelper.load_string

Defined in:
lib/cocoapods-core/yaml_helper.rb

.load_string(yaml_string, file_path = nil) ⇒ Hash, Array

Loads a YAML string and provide more informative error messages in special cases like merge conflict.

Parameters:

  • yaml_string (String)

    The YAML String to be loaded

  • file_path (Pathname) (defaults to: nil)

    The (optional) file path to be used for read for the YAML file

Returns:

  • (Hash, Array)

    the Ruby YAML representaton



56
57
58
59
60
61
62
63
64
# File 'lib/cocoapods-core/yaml_helper.rb', line 56

def load_string(yaml_string, file_path = nil)
  YAML.safe_load(yaml_string, :permitted_classes => [Date, Time, Symbol])
rescue
  if yaml_has_merge_error?(yaml_string)
    raise Informative, yaml_merge_conflict_msg(yaml_string, file_path)
  else
    raise Informative, yaml_parsing_error_msg(yaml_string, file_path)
  end
end