Module: Ya2YAML::Constants

Included in:
Ya2YAML
Defined in:
lib/ya2yaml.rb

Constant Summary collapse

UCS_0X85 =

c285@UTF8 Unicode next line

[0x85].pack('U')
UCS_0XA0 =

c2a0@UTF8 Unicode non-breaking space

[0xa0].pack('U')
UCS_0X2028 =

e280a8@UTF8 Unicode line separator

[0x2028].pack('U')
UCS_0X2029 =

e280a9@UTF8 Unicode paragraph separator

[0x2029].pack('U')
ESCAPE_SEQ =

non-break characters

{
  "\x00" => '\\0',
  "\x07" => '\\a',
  "\x08" => '\\b',
  "\x0b" => '\\v',
  "\x0c" => '\\f',
  "\x1b" => '\\e',
  "\""   => '\\"',
  "\\"   => '\\\\',
}
ESCAPE_SEQ_NS =

non-breaking space

{
  UCS_0XA0 => '\\_',
}
ESCAPE_SEQ_WS =

white spaces

{
  "\x09" => '\\t',
  " "    => '\\x20',
}
ESCAPE_SEQ_LB =

line breaks

{
  "\x0a"     => '\\n',
  "\x0d"     => '\\r',
  UCS_0X85   => '\\N',
  UCS_0X2028 => '\\L',
  UCS_0X2029 => '\\P',
}
REX_LF =

regexps for line breaks

Regexp.escape("\x0a")
REX_CR =
Regexp.escape("\x0d")
REX_CRLF =
Regexp.escape("\x0d\x0a")
REX_NEL =
Regexp.escape(UCS_0X85)
REX_LS =
Regexp.escape(UCS_0X2028)
REX_PS =
Regexp.escape(UCS_0X2029)
REX_ANY_LB =
/(#{REX_LF}|#{REX_CR}|#{REX_NEL}|#{REX_LS}|#{REX_PS})/
REX_NORMAL_LB =
/(#{REX_LF}|#{REX_LS}|#{REX_PS})/
REX_BOOL =

regexps for language-Independent types for YAML1.1

/
   y|Y|yes|Yes|YES|n|N|no|No|NO
  |true|True|TRUE|false|False|FALSE
  |on|On|ON|off|Off|OFF
/x
REX_FLOAT =
/
   [-+]?([0-9][0-9_]*)?\.[0-9.]*([eE][-+][0-9]+)? # (base 10)
  |[-+]?[0-9][0-9_]*(:[0-5]?[0-9])+\.[0-9_]*      # (base 60)
  |[-+]?\.(inf|Inf|INF)                           # (infinity)
  |\.(nan|NaN|NAN)                                # (not a number)
/x
REX_INT =
/
   [-+]?0b[0-1_]+                   # (base 2)
  |[-+]?0[0-7_]+                    # (base 8)
  |[-+]?(0|[1-9][0-9_]*)            # (base 10)
  |[-+]?0x[0-9a-fA-F_]+             # (base 16)
  |[-+]?[1-9][0-9_]*(:[0-5]?[0-9])+ # (base 60)
/x
REX_MERGE =
/
  <<
/x
REX_NULL =
/
   ~              # (canonical)
  |null|Null|NULL # (English)
  |               # (Empty)
/x
REX_TIMESTAMP =
/
   [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] # (ymd)
  |[0-9][0-9][0-9][0-9]                       # (year)
   -[0-9][0-9]?                               # (month)
   -[0-9][0-9]?                               # (day)
   ([Tt]|[ \t]+)[0-9][0-9]?                   # (hour)
   :[0-9][0-9]                                # (minute)
   :[0-9][0-9]                                # (second)
   (\.[0-9]*)?                                # (fraction)
   (([ \t]*)Z|[-+][0-9][0-9]?(:[0-9][0-9])?)? # (time zone)
/x
REX_VALUE =
/
  =
/x