metanorma / pubid-iso

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

URGENT! Exclude year doesn't work #258

Closed andrew2net closed 6 months ago

andrew2net commented 7 months ago
ref = Pubid::Iso::Identifier.parse('ISO/IEC 23008-1/WD Amd 1')
=> #<Pubid::Iso::Identifier::Amendment:0x000000012d6bf020 @base=#<Pubid::Iso::Identifier::InternationalStandard:0x000000012d6bf160 @copublisher="IEC", @edition=nil, @month=nil, @number...

id = Pubid::Iso::Identifier.parse('ISO/IEC 23008-1:2023/WD Amd 1')
=> #<Pubid::Iso::Identifier::Amendment:0x000000012d6b7320 @base=#<Pubid::Iso::Identifier::InternationalStandard:0x000000012d6b7460 @copublisher="IEC", @edition=nil, @month=nil, @number...

id.exclude(:year) == ref
=> false
mico commented 7 months ago

@andrew2net

0> Identifier.parse('ISO/IEC 23008-1:2023/WD Amd 1').year
=> nil

0> Identifier.parse('ISO/IEC 23008-1:2023/WD Amd 1').base.year
=> 2023

0> Identifier.parse('ISO/IEC 23008-1:2023/WD Amd 1').base.exclude(:year).to_s
=> "ISO/IEC 23008-1"

I had no idea about cases like this, so for now only the way to deal with that:

0> id = Identifier.parse('ISO/IEC 23008-1:2023/WD Amd 1')
0> id.base = id.base.exclude(:year)
0> id.to_s
=> "ISO/IEC 23008-1/WD Amd 1"
ronaldtse commented 7 months ago

This is indeed tricky, but the most tricky part is that IDs like 'ISO/IEC 23008-1/WD Amd 1' that do not contain a base year shouldn't be used...

mico commented 7 months ago

This is indeed tricky, but the most tricky part is that IDs like 'ISO/IEC 23008-1/WD Amd 1' that do not contain a base year shouldn't be used...

@ronaldtse Do you mean we should raise an error?

ronaldtse commented 7 months ago

@mico no, we know that these references exist, so we must support them.

andrew2net commented 7 months ago

@mico maybe we need another name for amendment year? For example use pubid.exclude(:year, :amd_year) to exclude both years.

ronaldtse commented 7 months ago

The thing is a supplement is not only "amendment" but also "corrigenda" and "supplement". Unless we pass on options to the base?

Also... why do we want to explicitly exclude year in the rendering?

ronaldtse commented 7 months ago

I understand the need to compare after exclude... I guess there is a need.

How about something like:

pubid.exclude(:year, base: [:year])
mico commented 7 months ago

I understand the need to compare after exclude... I guess there is a need.

How about something like:

pubid.exclude(:year, base: [:year])

@ronaldtse What about something like:

pubid.exclude(:year, apply_to_base: true)

So it will exclude year for supplement and base as well.

ronaldtse commented 7 months ago

I’m not sure what you can “exclude” though, so I don’t know if everything you can exclude at the Supplement level can also apply to the base?

andrew2net commented 7 months ago
pubid.exclude(:year, base: [:year])
pubid.exclude(:year, apply_to_base: true)

@ronaldtse @mico for me both approaches look ok if we don't need to check whether pubid has base document or not. But, I'm not sure that we won't need to control base document year and amd document year separately later.