metanorma / pubid-iso

Implementation of ISO pubid
BSD 2-Clause "Simplified" License
1 stars 0 forks source link

URGENT! Convert hash values to String #246

Closed andrew2net closed 7 months ago

andrew2net commented 7 months ago

The #to_h method returns Hash with Parslet::Slice values:

> hash = Pubid::Iso::Identifier.parse('ISO/CD 16659-2').to_h
 => {:publisher=>"ISO", :number=>"16659"@7, :stage=>"CD", :part=>"2"@13, :edition=>nil, :type=>:is}

> hash[:number].class
 => Parslet::Slice

when the hash is stored in YAML it becomes:

...
- :id:
    :publisher: ISO
    :number: !ruby/object:Parslet::Slice
      position: !ruby/object:Parslet::Position
        string: ISO/CD 16659-2
        bytepos: 7
      str: '16659'
      line_cache: &8 !ruby/object:Parslet::Source::LineCache
        line_ends: []
        last_line_end:
    :stage: CD
    :part: !ruby/object:Parslet::Slice
      position: !ruby/object:Parslet::Position
        string: ISO/CD 16659-2
        bytepos: 13
      str: '2'
      line_cache: *8
    :type: :is
...

it should be:

...
- :id:
    :publisher: ISO
    :number: '16659'
    :stage: CD
    :part: '2'
    :type: :is
...