Module: JSONSchemer::Format::URITemplate

Included in:
JSONSchemer::Format
Defined in:
lib/json_schemer/format/uri_template.rb

Constant Summary collapse

PCT_ENCODED =
'%\h{2}'
EXPLODE =

pct-encoded = “%” HEXDIG HEXDIG

'\*'
MAX_LENGTH =

explode = “*”

'[1-9]\d{0,3}'
PREFIX =

max-length = %x31-39 0*3DIGIT ; positive integer < 10000

":#{MAX_LENGTH}"
MODIFIER_LEVEL4 =

modifier-level4 = prefix / explode

"#{PREFIX}|#{EXPLODE}"
VARCHAR =

varchar = ALPHA / DIGIT / “_” / pct-encoded

"(\\w|#{PCT_ENCODED})"
VARNAME =

varname = varchar *( [“.”] varchar )

"#{VARCHAR}(\\.?#{VARCHAR})*"
VARSPEC =

varspec = varname [ modifier-level4 ]

"#{VARNAME}(#{MODIFIER_LEVEL4})?"
VARIABLE_LIST =

variable-list = varspec *( “,” varspec )

"#{VARSPEC}(,#{VARSPEC})*"
OPERATOR =
'[+#./;?&=,!@|]'
EXPRESSION =

operator = op-level2 / op-level3 / op-reserve op-level2 = “+” / “#” op-level3 = “.” / “/” / “;” / “?” / “&” op-reserve = “=” / “,” / “!” / “@” / “|”

"{#{OPERATOR}?#{VARIABLE_LIST}}"
LITERALS =
"[^\\x00-\\x20\\x7F\"%'<>\\\\^`{|}]|#{PCT_ENCODED}"
URI_TEMPLATE =

literals = %x21 / %x23-24 / %x26 / %x28-3B / %x3D / %x3F-5B

/  %x5D / %x5F / %x61-7A / %x7E / ucschar / iprivate
/  pct-encoded
     ; any Unicode character except: CTL, SP,
     ;  DQUOTE, "'", "%" (aside from pct-encoded),
     ;  "<", ">", "\", "^", "`", "{", "|", "}"
"(#{LITERALS}|#{EXPRESSION})*"
URI_TEMPLATE_REGEX =
/\A#{URI_TEMPLATE}\z/

Instance Method Summary collapse

Instance Method Details

#valid_uri_template?(data) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/json_schemer/format/uri_template.rb', line 29

def valid_uri_template?(data)
  URI_TEMPLATE_REGEX.match?(data)
end