Sha256: 18542ccf11cdd7003e4a427a89997f79e88a5816c431bb1ef91537b484947304
Contents?: true
Size: 716 Bytes
Versions: 7
Compression:
Stored size: 716 Bytes
Contents
# frozen_string_literal: true module JSONSchemer module Location JSON_POINTER_TOKEN_ESCAPE_CHARS = { '~' => '~0', '/' => '~1' } JSON_POINTER_TOKEN_ESCAPE_REGEX = Regexp.union(JSON_POINTER_TOKEN_ESCAPE_CHARS.keys) class << self def root {} end def join(location, name) location[name] ||= { :name => name, :parent => location } end def resolve(location) location[:resolve] ||= location[:parent] ? "#{resolve(location[:parent])}/#{escape_json_pointer_token(location[:name])}" : '' end def escape_json_pointer_token(token) token.gsub(JSON_POINTER_TOKEN_ESCAPE_REGEX, JSON_POINTER_TOKEN_ESCAPE_CHARS) end end end end
Version data entries
7 entries across 7 versions & 1 rubygems