Class: Bosh::Cli::YamlHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/cli/yaml_helper.rb

Class Method Summary collapse

Class Method Details

.check_duplicate_keys(path) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/cli/yaml_helper.rb', line 39

def check_duplicate_keys(path)
  # Some Ruby builds on Ubuntu seem to expose a bug
  # with the opposite order of Syck check, so we first
  # check for Syck and then for YAML::Syck
  if defined?(Syck)
    @syck_class = Syck
  elsif defined?(YAML::Syck)
    @syck_class = YAML::Syck
  else
    raise "Cannot find Syck parser for YAML, " +
              "please check your Ruby installation"
  end

  File.open(path) do |f|
    begin
      process_map(YAML.parse(f))
    rescue => e
      raise "Bad yaml file #{path}, " + e.message
    end
  end
end