relaton-iho 1.20.4 → 2.0.0.pre.alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -1
- data/CLAUDE.md +66 -0
- data/README.adoc +33 -35
- data/grammars/basicdoc.rng +1559 -671
- data/grammars/biblio-standoc.rng +107 -46
- data/grammars/biblio.rng +1010 -375
- data/grammars/relaton-iho.rng +37 -59
- data/lib/relaton/iho/bibdata.rb +7 -0
- data/lib/relaton/iho/bibitem.rb +7 -0
- data/lib/relaton/iho/bibliography.rb +57 -0
- data/lib/relaton/iho/comment_period.rb +13 -0
- data/lib/relaton/iho/doctype.rb +10 -0
- data/lib/relaton/iho/ext.rb +19 -0
- data/lib/relaton/iho/hash_parser_v1.rb +129 -0
- data/lib/relaton/iho/item.rb +17 -0
- data/lib/relaton/iho/item_base.rb +8 -0
- data/lib/relaton/iho/item_data.rb +6 -0
- data/lib/relaton/iho/processor.rb +54 -0
- data/lib/relaton/iho/relation.rb +9 -0
- data/lib/relaton/iho/util.rb +8 -0
- data/lib/relaton/iho/version.rb +5 -0
- data/lib/relaton/iho.rb +25 -0
- data/relaton_iho.gemspec +7 -6
- metadata +38 -24
- data/lib/relaton_iho/comment_periond.rb +0 -41
- data/lib/relaton_iho/document_type.rb +0 -17
- data/lib/relaton_iho/editorial_group.rb +0 -73
- data/lib/relaton_iho/eg.yml +0 -191
- data/lib/relaton_iho/hash_converter.rb +0 -61
- data/lib/relaton_iho/iho_bibliographic_item.rb +0 -68
- data/lib/relaton_iho/iho_bibliography.rb +0 -59
- data/lib/relaton_iho/iho_group.rb +0 -146
- data/lib/relaton_iho/processor.rb +0 -48
- data/lib/relaton_iho/util.rb +0 -6
- data/lib/relaton_iho/version.rb +0 -3
- data/lib/relaton_iho/xml_parser.rb +0 -62
- data/lib/relaton_iho.rb +0 -27
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a16c6885fa87ba079434ec5e44c073b00addafd0cf1a1269465e097b3cc935f8
|
|
4
|
+
data.tar.gz: 7978c675e94d2666af3ceb93e7eca8572757f6fa68d29821aa272204e8fa0998
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3bc092e1e37e9459323bb97a1888bdf3169b55e0737e31fe98dfa871233e2825df68e7e071e53c5038d77e5c4224ed63db49fb4b523ad85571ea3f9e57739dc3
|
|
7
|
+
data.tar.gz: d761500ec7a99c242e99d534f53fe38efef34c8c99b538e514d0ab356c9704be8415b874a4776c086387b3ab3a3caf4dd992789b90c28bd985ea7126ccdad28e
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/CLAUDE.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## What This Is
|
|
6
|
+
|
|
7
|
+
relaton-iho is a Ruby gem that fetches and serializes IHO (International Hydrographic Organization) standards metadata. It is a "flavor" gem in the Relaton ecosystem, extending relaton-bib with IHO-specific bibliographic data models.
|
|
8
|
+
|
|
9
|
+
## Common Commands
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bundle exec rspec # run all tests
|
|
13
|
+
bundle exec rspec spec/relaton/iho/item_spec.rb # run a single spec file
|
|
14
|
+
bundle exec rspec spec/relaton/iho/item_spec.rb:15 # run a single example by line
|
|
15
|
+
bundle exec rubocop # lint
|
|
16
|
+
bundle exec rubocop -a # lint with auto-fix
|
|
17
|
+
bundle exec rake install # install gem locally
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Architecture
|
|
21
|
+
|
|
22
|
+
### Flavor Pattern
|
|
23
|
+
|
|
24
|
+
This gem follows the Relaton flavor pattern: it subclasses base classes from `relaton-bib` under the `Relaton::Iho` namespace. The key mechanism is `NamespaceHelper` (from relaton-bib), which dynamically resolves the module namespace from the class name. This means `Relaton::Iho::ItemData#to_xml` automatically delegates to `Relaton::Iho::Bibdata.to_xml` (not `Relaton::Bib::Bibdata`).
|
|
25
|
+
|
|
26
|
+
Core model classes and their base classes:
|
|
27
|
+
- `Item < Bib::Item` — main bibliographic item, uses `model ItemData`
|
|
28
|
+
- `ItemData < Bib::ItemData` — data container enabling namespace-aware `to_xml`/`to_yaml`/`to_json`
|
|
29
|
+
- `ItemBase < Item` — stripped-down item for use inside relations (no id, schema_version, fetched, ext)
|
|
30
|
+
- `Bibitem < Item` — XML bibitem serialization (includes `Bib::BibitemShared`)
|
|
31
|
+
- `Bibdata < Item` — XML bibdata serialization (includes `Bib::BibdataShared`)
|
|
32
|
+
- `Relation < Bib::Relation` — overrides `bibitem` attribute to use `Iho::ItemBase`
|
|
33
|
+
- `Doctype < Bib::Doctype` — IHO document type vocabulary
|
|
34
|
+
- `Ext < Bib::Ext` — IHO-specific extension data (doctype, commentperiod)
|
|
35
|
+
- `Processor < Core::Processor` — Relaton processor for registry integration
|
|
36
|
+
- `HashParserV1` — converts v1-format YAML/Hash data to v2 model objects (required on demand, not auto-loaded)
|
|
37
|
+
- `Bibliography` — fetches IHO data from relaton-data-iho GitHub repo
|
|
38
|
+
|
|
39
|
+
All model classes use Lutaml::Model for declarative attribute/serialization definitions.
|
|
40
|
+
|
|
41
|
+
### HashParserV1
|
|
42
|
+
|
|
43
|
+
`HashParserV1` (in `hash_parser_v1.rb`) handles conversion of legacy v1 data to the current model. It overrides the base `Bib::HashParserV1` to handle IHO-specific structures:
|
|
44
|
+
- **editorialgroup**: IHO v1 data has nested committee arrays (`editorialgroup: [[{committee: ...}, ...]]`). Each committee is converted to a `contributor` with `role type="author"` / `description="committee"`, organization "International Hydrographic Organization"/"IHO", and nested `subdivision` elements for sub-committees.
|
|
45
|
+
- **commentperiod**: Moved from top-level into `ext`.
|
|
46
|
+
- Factory methods (`bib_item`, `create_doctype`, `create_relation`) return IHO-specific classes.
|
|
47
|
+
|
|
48
|
+
This module is required on demand (`require "relaton/iho/hash_parser_v1"`) and not auto-loaded by the main `relaton/iho` entry point.
|
|
49
|
+
|
|
50
|
+
### Load Order Constraint
|
|
51
|
+
|
|
52
|
+
In `item.rb`, `require_relative "relation"` is placed **after** the `Item` class definition because `Relation` → `ItemBase` → `Item` creates a circular dependency if loaded before `Item` exists.
|
|
53
|
+
|
|
54
|
+
### Data Retrieval
|
|
55
|
+
|
|
56
|
+
`Bibliography.search`/`.get` fetches YAML from the relaton-data-iho GitHub repo via `Relaton::Index`, then deserializes into model objects.
|
|
57
|
+
|
|
58
|
+
### Test Infrastructure
|
|
59
|
+
|
|
60
|
+
- **VCR cassettes** (`spec/vcr_cassettes/`): recorded HTTP responses for offline testing
|
|
61
|
+
- **RelaxNG validation**: specs validate XML output against `grammars/relaton-iho-compile.rng` using ruby-jing
|
|
62
|
+
- **Fixtures** (`spec/fixtures/`): reference XML/YAML documents for round-trip serialization tests
|
|
63
|
+
|
|
64
|
+
### IHO-Specific Document Types
|
|
65
|
+
|
|
66
|
+
policy-and-procedures, best-practices, supporting-document, report, legal, directives, proposal, standard
|
data/README.adoc
CHANGED
|
@@ -8,7 +8,7 @@ image:https://codeclimate.com/github/relaton/relaton-iho/badges/gpa.svg["Code Cl
|
|
|
8
8
|
image:https://img.shields.io/github/issues-pr-raw/relaton/relaton-iho.svg["Pull Requests", link="https://github.com/relaton/relaton-iho/pulls"]
|
|
9
9
|
image:https://img.shields.io/github/commits-since/relaton/relaton-iho/latest.svg["Commits since latest",link="https://github.com/relaton/relaton-iho/releases"]
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Relaton::Iho is a Ruby gem that implements the https://github.com/metanorma/metanorma-model-iso#iso-bibliographic-item[IsoBibliographicItem model].
|
|
12
12
|
|
|
13
13
|
It currently retrieves metadata of IHO Standards from https://github.com/relaton/relaton-data-iho.
|
|
14
14
|
|
|
@@ -43,21 +43,20 @@ Reference can be specified with or without an edition. References without an edi
|
|
|
43
43
|
|
|
44
44
|
[source,ruby]
|
|
45
45
|
----
|
|
46
|
-
require '
|
|
46
|
+
require 'relaton/iho'
|
|
47
47
|
=> true
|
|
48
48
|
|
|
49
49
|
# Search for a standard using a reference without an edition
|
|
50
|
-
item =
|
|
51
|
-
[relaton-iho] (IHO B-11) Fetching from Relaton repository ...
|
|
52
|
-
[relaton-iho] (IHO B-11) Found: `B-11`
|
|
53
|
-
=> #<
|
|
54
|
-
...
|
|
50
|
+
item = Relaton::Iho::Bibliography.search("IHO B-11")
|
|
51
|
+
[relaton-iho] INFO: (IHO B-11) Fetching from Relaton repository ...
|
|
52
|
+
[relaton-iho] INFO: (IHO B-11) Found: `B-11`
|
|
53
|
+
=> #<Relaton::Iho::ItemData:0x0000000121f85aa8...
|
|
55
54
|
|
|
56
55
|
# Search for a standard using a reference with an edition
|
|
57
|
-
item =
|
|
58
|
-
[relaton-iho] (IHO B-11 1.0.0)
|
|
59
|
-
[relaton-iho] (IHO B-11 1.0.0) Found: `B-11`
|
|
60
|
-
=> #<
|
|
56
|
+
item = Relaton::Iho::Bibliography.search("IHO B-11 1.0.0")
|
|
57
|
+
[relaton-iho] INFO: (IHO B-11 1.0.0) Fetching from Relaton repository ...
|
|
58
|
+
[relaton-iho] INFO: (IHO B-11 1.0.0) Found: `B-11`
|
|
59
|
+
=> #<Relaton::Iho::ItemData:0x0000000125b5bb90
|
|
61
60
|
...
|
|
62
61
|
----
|
|
63
62
|
|
|
@@ -65,10 +64,10 @@ item = RelatonIho::IhoBibliography.search("IHO B-11 1.0.0")
|
|
|
65
64
|
[source,ruby]
|
|
66
65
|
----
|
|
67
66
|
item.to_xml
|
|
68
|
-
=> "<bibitem id="
|
|
69
|
-
<fetched>
|
|
70
|
-
<title
|
|
71
|
-
<title
|
|
67
|
+
=> "<bibitem id="B11" type="standard" schema-version="v1.4.1">
|
|
68
|
+
<fetched>2026-02-20</fetched>
|
|
69
|
+
<title language="en" type="main">IHO-IOC GEBCO Cook Book</title>
|
|
70
|
+
<title language="fr" type="main">Livre de recettes GEBCO OHI-COI</title>
|
|
72
71
|
<uri type="pdf">https://www.star.nesdis.noaa.gov/socd/lsa/GEBCO_Cookbook/documents/CookBook_20191031.pdf</uri>
|
|
73
72
|
<docidentifier type="IHO" primary="true">B-11</docidentifier>
|
|
74
73
|
...
|
|
@@ -78,15 +77,15 @@ With argument `bibdata: true` it outputs XML wrapped by `bibdata` element and ad
|
|
|
78
77
|
[source,ruby]
|
|
79
78
|
----
|
|
80
79
|
item.to_xml bibdata: true
|
|
81
|
-
=> "<bibdata type="standard" schema-version="v1.
|
|
82
|
-
<fetched>
|
|
83
|
-
<title
|
|
84
|
-
<title
|
|
80
|
+
=> "<bibdata type="standard" schema-version="v1.4.1">
|
|
81
|
+
<fetched>2026-02-20</fetched>
|
|
82
|
+
<title language="en" type="main">IHO-IOC GEBCO Cook Book</title>
|
|
83
|
+
<title language="fr" type="main">Livre de recettes GEBCO OHI-COI</title>
|
|
85
84
|
<uri type="pdf">https://www.star.nesdis.noaa.gov/socd/lsa/GEBCO_Cookbook/documents/CookBook_20191031.pdf</uri>
|
|
86
|
-
<docidentifier type="IHO" primary="true">B-11</docidentifier
|
|
85
|
+
<docidentifier type="IHO" primary="true">B-11</docidentifier>
|
|
87
86
|
...
|
|
88
87
|
<ext schema-version="v1.0.0">
|
|
89
|
-
|
|
88
|
+
<flavor>iho</flavor>
|
|
90
89
|
</ext>
|
|
91
90
|
</bibdata>"
|
|
92
91
|
----
|
|
@@ -94,10 +93,10 @@ item.to_xml bibdata: true
|
|
|
94
93
|
=== Get code
|
|
95
94
|
[source,ruby]
|
|
96
95
|
----
|
|
97
|
-
|
|
98
|
-
[relaton-iho] (IHO B-11) Fetching from Relaton repository ...
|
|
99
|
-
[relaton-iho] (IHO B-11) Found: `B-11`
|
|
100
|
-
=> #<
|
|
96
|
+
Relaton::Iho::Bibliography.get "IHO B-11"
|
|
97
|
+
[relaton-iho] INFO: (IHO B-11) Fetching from Relaton repository ...
|
|
98
|
+
[relaton-iho] INFO: (IHO B-11) Found: `B-11`
|
|
99
|
+
=> #<Relaton::Iho::ItemData:0x0000000125f530e0
|
|
101
100
|
...
|
|
102
101
|
----
|
|
103
102
|
|
|
@@ -107,27 +106,26 @@ Each IHO document has `html`, `website`, or `pdf` type link.
|
|
|
107
106
|
|
|
108
107
|
[source,ruby]
|
|
109
108
|
----
|
|
110
|
-
item.
|
|
111
|
-
=>
|
|
109
|
+
item.source.first.type
|
|
110
|
+
=> "pdf"
|
|
111
|
+
|
|
112
|
+
item.source.first.content
|
|
113
|
+
=> "https://www.star.nesdis.noaa.gov/socd/lsa/GEBCO_Cookbook/documents/CookBook_20191031.pdf"
|
|
112
114
|
----
|
|
113
115
|
|
|
114
116
|
=== Create bibliographic item from XML
|
|
115
117
|
[source,ruby]
|
|
116
118
|
----
|
|
117
|
-
|
|
118
|
-
=> #<
|
|
119
|
+
Relaton::Iho::Item.from_xml File.read('spec/fixtures/bibdata.xml')
|
|
120
|
+
=> #<Relaton::Iho::ItemData:0x0000000125f56920
|
|
119
121
|
...
|
|
120
122
|
----
|
|
121
123
|
|
|
122
124
|
=== Create bibliographic item from YAML
|
|
123
125
|
[source,ruby]
|
|
124
126
|
----
|
|
125
|
-
|
|
126
|
-
=>
|
|
127
|
-
...
|
|
128
|
-
|
|
129
|
-
RelatonIho::IhoBibliographicItem.from_hash hash
|
|
130
|
-
=> #<RelatonIho::IhoBibliographicItem:0x007fc322ef8548
|
|
127
|
+
Relaton::Iho::Item.from_yaml File.read('spec/fixtures/item.yaml')
|
|
128
|
+
=> #<Relaton::Iho::ItemData:0x000000012274ac98
|
|
131
129
|
...
|
|
132
130
|
----
|
|
133
131
|
|