metanorma / pubid-iso

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

Creating an identifier should not require creating Amendment/Corrigendum classes #101

Closed ronaldtse closed 2 years ago

ronaldtse commented 2 years ago

We need a simple way of adding an Amendment / Corrigendum.

I'm surprised that this doesn't work:

Pubid::Iso::Identifier.new(number: 17301, part: 1, publisher: "ISO", language: "en", year: 2016, amendments: [{number: 1, stage: "NP"}]).to_s
lib/pubid/iso/renderer/base.rb:58:in `block in render_amendments': undefined method `render_pubid' for {:number=>1, :stage=>"NP"}:Hash (NoMethodError)

      amendments.sort.map { |amendment| amendment.render_pubid(opts[:stage_format_long], opts[:with_date]) }.join("+")
                                                 ^^^^^^^^^^^^^
    from lib/pubid/iso/renderer/base.rb:58:in `map'
    from lib/pubid/iso/renderer/base.rb:58:in `render_amendments

If the amendment: is given a hash (or hashes), convert those to classes internally.