INNER CODE UNIT · Ruby
string
Shopify/krane · lib/krane/bindings_parser.rb:35
return unless string =~ /\A@/
begin
file_path = string.gsub(/\A@/, '')
case File.extname(file_path)
when '.json'
bindings = parse_json(File.read(file_path))
when '.yaml', '.yml'
bindings = YAML.safe_load(File.read(file_path), permitted_classes: [], permitted_symbols: [],
aliases: true, filename: file_path)
else
raise ArgumentError, "Supplied file does not appear to be JSON or YAML"
end
bindings
rescue Errno::ENOENT
raise ArgumentError, "Supplied file does not exist: #{string}"