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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a745f1941dd257c8520eb12b595930b5594e7dd61bdc730f74470220010487d
4
- data.tar.gz: b38ebe25300701c3f34e30eb88566b881f905da5b2e8b571ebfc23c505ecce4f
3
+ metadata.gz: a16c6885fa87ba079434ec5e44c073b00addafd0cf1a1269465e097b3cc935f8
4
+ data.tar.gz: 7978c675e94d2666af3ceb93e7eca8572757f6fa68d29821aa272204e8fa0998
5
5
  SHA512:
6
- metadata.gz: ef44e7a91a7dd30e340346f661793e25b91f1ff55e7c3ebc8f6607caca1f1f4eaddf44255a46edbe416dcb0719980ca779089403f6d21d43e0c19289e43e7308
7
- data.tar.gz: 80e58ddecc049e4aecdc827aef4cddaebb550f9c7e0950245007f10aa526d980bec7d8784e41a4ba1e148f6b765c301d10ce5c699f3ae89805a3345bd58ab053
6
+ metadata.gz: 3bc092e1e37e9459323bb97a1888bdf3169b55e0737e31fe98dfa871233e2825df68e7e071e53c5038d77e5c4224ed63db49fb4b523ad85571ea3f9e57739dc3
7
+ data.tar.gz: d761500ec7a99c242e99d534f53fe38efef34c8c99b538e514d0ab356c9704be8415b874a4776c086387b3ab3a3caf4dd992789b90c28bd985ea7126ccdad28e
data/.gitignore CHANGED
@@ -14,3 +14,4 @@
14
14
  .rubocop-https---raw-githubusercontent-com-riboseinc-oss-guides-master-ci-rubocop-yml
15
15
  Gemfile.lock
16
16
  spec/examples.txt
17
+ .claude/
data/.rubocop.yml CHANGED
@@ -7,6 +7,6 @@ require: rubocop-rails
7
7
  inherit_from:
8
8
  - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
9
9
  AllCops:
10
- TargetRubyVersion: 2.7
10
+ TargetRubyVersion: 3.2
11
11
  Rails:
12
12
  Enabled: false
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
- RelatonIho is a Ruby gem that implements the https://github.com/metanorma/metanorma-model-iso#iso-bibliographic-item[IsoBibliographicItem model].
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 'relaton_iho'
46
+ require 'relaton/iho'
47
47
  => true
48
48
 
49
49
  # Search for a standard using a reference without an edition
50
- item = RelatonIho::IhoBibliography.search("IHO B-11")
51
- [relaton-iho] (IHO B-11) Fetching from Relaton repository ...
52
- [relaton-iho] (IHO B-11) Found: `B-11`
53
- => #<RelatonIho::IhoBibliographicItem:0x007fe74fc80800
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 = RelatonIho::IhoBibliography.search("IHO B-11 1.0.0")
58
- [relaton-iho] (IHO B-11 1.0.0) Fetchint from Rlaont repository ...
59
- [relaton-iho] (IHO B-11 1.0.0) Found: `B-11`
60
- => #<RelatonIho::IhoBibliographicItem:0x00007fe79d0ed698
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="B-11" type="standard" schema-version="v1.2.1">
69
- <fetched>2022-12-04</fetched>
70
- <title type="main" format="text/plain" language="en">IHO-IOC GEBCO Cook Book</title>
71
- <title type="main" format="text/plain" language="fr">Livre de recettes GEBCO OHI-COI</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.2.1">
82
- <fetched>2022-12-04</fetched>
83
- <title type="main" format="text/plain" language="en">IHO-IOC GEBCO Cook Book</title>
84
- <title type="main" format="text/plain" language="fr">Livre de recettes GEBCO OHI-COI</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
- RelatonIho::IhoBibliography.get "IHO B-11"
98
- [relaton-iho] (IHO B-11) Fetching from Relaton repository ...
99
- [relaton-iho] (IHO B-11) Found: `B-11`
100
- => #<RelatonIho::IhoBibliographicItem:0x007fe78dbb7c78
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.link
111
- => [#<RelatonBib::TypedUri:0x00007fb5162d1478 @content=#<Addressable::URI:0x8c0 URI:https://www.star.nesdis.noaa.gov/socd/lsa/GEBCO_Cookbook/documents/CookBook_20191031.pdf>, @type="pdf">]
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
- RelatonIho::XMLParser.from_xml File.read('spec/fixtures/iho.xml')
118
- => #<RelatonIho::IhoBibliographicItem:0x007fc322ea82c8
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
- hash = YAML.load_file 'spec/fixtures/iho.yaml'
126
- => {"id"=>"B-11",
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