Method: TraceableString#encode_with
- Defined in:
- lib/traceable.rb
#encode_with(coder) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/traceable.rb', line 67 def encode_with(coder) coder.tag = nil coder.scalar = self.to_str if debug? # LibYAML, the C YAML library which underlies Ruby's Psych # library, does not handle comments at all. The parser ignores # them and the emitter cannot write them. Thus, to output the # sourcing information in a manner that is at least semi-sane, # we need to put it in the actual value, behind some sort of # separator. # # The separator needs to be representable in Latin-1, otherwise # LibYAML quotes it. It needs to be non-breaking, otherwise # LibYAML will break here to wrap at 80 characters. It cannot # have any special meaning in YAML (including the quote # character), otherwise LibYAML quotes it. It shouldn't appear # in real data, sine we'll need to substitute all instances of # it. # # Also, I like cats, even ASCII ones. coder.scalar += " =^.^= #{@file} (line #{@line}, column #{@column})" end end |