Class: InfluxDB::LineProtocol::Unescapes
- Inherits:
-
Object
- Object
- InfluxDB::LineProtocol::Unescapes
- Defined in:
- lib/influxdb/lineprotocol/parser.rb
Instance Method Summary collapse
Instance Method Details
#unescape(field, str) ⇒ Object
686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 |
# File 'lib/influxdb/lineprotocol/parser.rb', line 686 def unescape(field, str) case field when :measurement # 1. escaped hash, null, or tab at the beginning # 2. escaped comma, space, or newline anywhere # 3. escaped backslash at the end str .sub(/^\\([#\0\t])/, '\\1') .gsub(/\\([, \n])/, '\\1') .sub(/\\\\$/, '\\') when :tag_key, :tag_value # 1. escaped comma, equals, newline, or space anywhere # 2. escaped backslash at the end str .gsub(/\\([,=\n ])/, '\\1') .sub(/\\\\$/, '\\') when :field_key # 1. escaped null or tab at beginning # 2. escaped comma, equals, newline, or space anywhere # 3. escaped backslash at the end str .sub(/^\\([\0\t])/, '\\1') .gsub(/\\([,=\n ])/, '\\1') .sub(/\\\\$/, '\\') when :string # escaped quote anywhere str.gsub(/\\"/, '"') end end |