Closed andrew2net closed 1 year ago
@andrew2net how about we add an option to only compare elements which are defined? So we don't need to use list of attributes to ignore?
Something like: pubid_ref.eql?(pubid, only_defined: true)
@mico some undefined elements should be used in comparing. We have various cases across relaton-* gems when some elements should be ignored in comparing. So we need a way to exclude some elements from comparing but not all undefined elements.
@mico some undefined elements should be used in comparing. We have various cases across relaton-* gems when some elements should be ignored in comparing. So we need a way to exclude some elements from comparing but not all undefined elements.
@andrew2net could you provide more details about cases when we need to exclude some elements but not all undefined?
We have many cases in relaton-* gem and the requirements are still changing. So we need some flexibility in IDs' comparing. Some cases are:
edition
in references and we need to select all the document's editions and return the latest.year
in reference and we need to return the latestyear
. The relaton-iso finds all the document's years and gives user a hint message.any_types_stages
option. Types and stages should be ignored if the option is true.all_parts
option. When the option is true, we need to ignore part
and year
.amendment
. Finally it tries to ignore amendment
.part
and year
. It doesn't ignore amendment
but amendment's year
is ignored when omitted in a reference.type
and month
. It also ignores year
if omitted in a reference.edition
and value
if they are omitted.stage
, revision
, and year
if they are omitted.We have many cases in relaton-* gem and the requirements are still changing. So we need some flexibility in IDs' comparing.
Summarizing cases, we need functionality to:
Did I miss something?
What is value
in relaton-ecma?
Looking at that, I agree that excluding list could solve the problem we have. Also, I see here you need to fetch the latest year or edition sometimes, so we can add option for fetching latest version.
We have to scenarios in Relaton, fetching from Relaton repository and fetching from websites.
Relaton repositories have indexes, YAML files with ID => filename
structure. Most indexes have ID as a string, but they are going to be a Hash with Pubid#to_h content (that what we need to_h function). So with IDs as Hash we can create a document Pubid (can we?) and compare it agains a reference Pubid. We need to select a list of document Pubids that match to all the attributes presented in the reference Pubid, ignoring attributes that omitted and listed in an ignore list (attr.nil? && ignore_list.include?(attr)). Next we can find the ID with the biggest attribute number, or create all_parts combined document, or do whatever we need.
Websites search engines return list of document IDs as strings. We need to parse these IDs and compare document Pubids with reference Pubid in same way as described above.
Summarizing cases, we need functionality to:
- return latest year
- return identifiers for all years
- return latest edition
- return identifiers for all edition
- return identifiers for all edition month's (ignore month, but apply year)
- return documents with any types and stages
- return documents with any stages
- return documents with any parts
- return documents with any revisions
- return documents with any amendment's edition (year)
- return documents with any amendments
Did I miss something?
These are parts of Relaton's internal functionality. We don't heed to hardcode each case in the Pubid. Cases can be changed later. So, in Relaton we need:
What is
value
in relaton-ecma?
It's volume
, sorry for mistake. Here is a part of ECMA index:
...
- :id:
:id: ECMA-269
:ed: '2'
:file: data/ECMA-269-2.yaml
- :id:
:id: ECMA-269
:ed: '3'
:vol: '1'
:file: data/ECMA-269-3-1.yaml
- :id:
:id: ECMA-269
:ed: '3'
:vol: '2'
:file: data/ECMA-269-3-2.yaml
...
With ref ECMA-269
all 3 entries selected. With ref ECMA-269-2
only the first entry selected. With ref ECMA-269-3
last 2 entries selected.
Sometimes we need to find last edition, release, or year of publication. Sometimes we need to select all parts collection. For example the method
pubid_ref == pubid
returns false ifpubid_ref
doesn't have edition butpubid
does. We need a way to ignore some attributes if they undefined inpubid_ref
. For example we can pass a list of attributes that should be ignored: