relaton-ogc 1.20.1 → 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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +1 -1
  4. data/CLAUDE.md +108 -0
  5. data/README.adoc +47 -47
  6. data/docs2.json +30983 -0
  7. data/grammars/basicdoc.rng +1559 -671
  8. data/grammars/biblio-standoc.rng +107 -46
  9. data/grammars/biblio.rng +1010 -375
  10. data/grammars/relaton-ogc.rng +24 -42
  11. data/lib/relaton/ogc/bibdata.rb +7 -0
  12. data/lib/relaton/ogc/bibitem.rb +7 -0
  13. data/lib/relaton/ogc/bibliography.rb +64 -0
  14. data/lib/relaton/ogc/data_fetcher.rb +113 -0
  15. data/lib/relaton/ogc/docidentifier.rb +6 -0
  16. data/lib/relaton/ogc/doctype.rb +12 -0
  17. data/lib/relaton/ogc/ext.rb +18 -0
  18. data/lib/relaton/ogc/hit.rb +18 -0
  19. data/lib/relaton/ogc/hit_collection.rb +36 -0
  20. data/lib/relaton/ogc/item.rb +13 -0
  21. data/lib/relaton/ogc/item_data.rb +6 -0
  22. data/lib/relaton/ogc/processor.rb +58 -0
  23. data/lib/relaton/ogc/scraper.rb +203 -0
  24. data/lib/relaton/ogc/util.rb +8 -0
  25. data/lib/relaton/ogc/version.rb +5 -0
  26. data/lib/relaton/ogc.rb +26 -0
  27. data/relaton_ogc.gemspec +7 -7
  28. metadata +30 -29
  29. data/lib/relaton_ogc/data_fetcher.rb +0 -118
  30. data/lib/relaton_ogc/document_type.rb +0 -22
  31. data/lib/relaton_ogc/editorial_group.rb +0 -82
  32. data/lib/relaton_ogc/hash_converter.rb +0 -25
  33. data/lib/relaton_ogc/hit.rb +0 -20
  34. data/lib/relaton_ogc/hit_collection.rb +0 -32
  35. data/lib/relaton_ogc/ogc_bibliographic_item.rb +0 -69
  36. data/lib/relaton_ogc/ogc_bibliography.rb +0 -80
  37. data/lib/relaton_ogc/processor.rb +0 -58
  38. data/lib/relaton_ogc/scrapper.rb +0 -169
  39. data/lib/relaton_ogc/util.rb +0 -6
  40. data/lib/relaton_ogc/version.rb +0 -3
  41. data/lib/relaton_ogc/xml_parser.rb +0 -45
  42. data/lib/relaton_ogc.rb +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2c5ff2e52f74939f5dd715e54318cc0f7beab1880965868c23b5e43514b62fd4
4
- data.tar.gz: 5a190d493b779ae6d0e7fc1ff2e8529ed210901b5006d90db9470f6d26e87626
3
+ metadata.gz: 63e344f79293ac705bbb72bf724eda7a55394b4f805808dcd897cf4dea55c97d
4
+ data.tar.gz: ca67124e73e4958c7739cee3f007e2ab3c8a85ac87dfb217879995dbabc641e3
5
5
  SHA512:
6
- metadata.gz: '069d2ea46db6d46a067f7949078b7bc1b670f1ab7de046e3ef862c3f17ba60a004a0d60f18266d05ca635f5a34954e415bfa1206e44d7a900d9720279e819580'
7
- data.tar.gz: 74726f295ce90b5590f1fb79173d79aa4ff245fb60e39b61e1582bc2aaf50984e95ea58edcd0424dc09fcb5da7e84272a3c77256094b34778067eadce5077513
6
+ metadata.gz: efc3d0ec325d196285c6b781985b299b049d3a7f47316df903316a4bbf54d6e2423ae43d114c001c985e119cf1df2fe6def0394a4f1de7f37b6aa8c1901074f5
7
+ data.tar.gz: e3621f69f96df3638a4d1f0b924e9c690e3ebd2526b090f9d169d028678fe23ee3ed01e7db0b478609d91b72c8efbe24d1f7b04a9d295c8c8a5e3d633492bdab
data/.gitignore CHANGED
@@ -13,3 +13,4 @@
13
13
  .rspec_status
14
14
  .rubocop-https---raw-githubusercontent-com-riboseinc-oss-guides-master-ci-rubocop-yml
15
15
  Gemfile.lock
16
+ .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,108 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ relaton-ogc is a Ruby gem for retrieving and managing OGC (Open Geospatial Consortium) Standards metadata. It is part of the Relaton ecosystem for bibliographic data management. The gem implements the OGC flavor on top of `relaton-iso`, which itself builds on `relaton-bib`.
8
+
9
+ ## Commands
10
+
11
+ ```bash
12
+ # Install dependencies
13
+ bundle install
14
+
15
+ # Run all tests
16
+ bundle exec rspec
17
+
18
+ # Run a single test file
19
+ bundle exec rspec spec/relaton/ogc/item_spec.rb
20
+
21
+ # Run a single test by line number
22
+ bundle exec rspec spec/relaton/ogc/item_spec.rb:7
23
+
24
+ # Lint
25
+ bundle exec rubocop
26
+
27
+ # Lint with auto-correct
28
+ bundle exec rubocop -A
29
+
30
+ # Interactive console
31
+ bin/console
32
+
33
+ # Build and install gem locally
34
+ bundle exec rake install
35
+ ```
36
+
37
+ ## Architecture
38
+
39
+ ### Class Hierarchy
40
+
41
+ All model classes use `Lutaml::Model::Serializable` for XML/YAML serialization with declarative attribute and mapping definitions.
42
+
43
+ ```
44
+ Iso::Item (from relaton-iso)
45
+ └── Relaton::Ogc::Item # serializer, extends Iso::Item with `ext` and `docidentifier`
46
+ ├── Relaton::Ogc::Bibitem # includes Bib::BibitemShared
47
+ └── Relaton::Ogc::Bibdata # includes Bib::BibdataShared
48
+
49
+ Bib::ItemData (from relaton-bib)
50
+ └── Relaton::Ogc::ItemData # data model returned by Item.from_xml / Item.from_yaml
51
+ ```
52
+
53
+ - **Item** (`lib/relaton/ogc/item.rb`) — serializer; extends `Iso::Item`, declares `model ItemData`, adds `ext` (Ext) and `docidentifier` (Docidentifier) attributes
54
+ - **ItemData** (`lib/relaton/ogc/item_data.rb`) — plain data model extending `Bib::ItemData`
55
+ - **Ext** (`lib/relaton/ogc/ext.rb`) — OGC extension data: doctype, subdoctype (with constrained values)
56
+ - **Doctype** (`lib/relaton/ogc/doctype.rb`) — enumerated OGC document types (standard, engineering-report, best-practice, etc.)
57
+ - **Docidentifier** (`lib/relaton/ogc/docidentifier.rb`) — extends `Bib::Docidentifier`
58
+ - **Bibitem** / **Bibdata** — thin wrappers mixing in shared serialization behavior from `relaton-bib`
59
+
60
+ ### Search & Fetch Pipeline
61
+
62
+ - **Bibliography** (`lib/relaton/ogc/bibliography.rb`) — entry point: `search(text)` and `get(code, year, opts)`
63
+ - **HitCollection** (`lib/relaton/ogc/hit_collection.rb`) — fetches from `relaton-data-ogc` GitHub repo (data-v2 branch), uses `relaton-index` for lookup
64
+ - **Hit** (`lib/relaton/ogc/hit.rb`) — wraps a single search result; lazy-fetches `ItemData` on `#item`
65
+ - **Processor** (`lib/relaton/ogc/processor.rb`) — `Core::Processor` implementation for Relaton registry integration
66
+
67
+ ### Data Fetching
68
+
69
+ - **DataFetcher** (`lib/relaton/ogc/data_fetcher.rb`) — bulk-fetches OGC documents from the NamingAuthority JSON endpoint
70
+ - **Scraper** (`lib/relaton/ogc/scraper.rb`) — parses individual OGC document JSON into `ItemData`
71
+
72
+ ### Key Dependencies
73
+
74
+ - `relaton-iso` — provides `Iso::Item` base class and ISO bibliographic structures
75
+ - `relaton-bib` (transitive via relaton-iso) — core types: `Bib::ItemData`, `Bib::Doctype`, `Bib::Ext`, etc.
76
+ - `lutaml-model` (transitive) — serialization framework for XML/YAML mapping
77
+ - `faraday` — HTTP client for fetching remote data
78
+ - `relaton-index` — index-based document lookup from GitHub-hosted data repos
79
+
80
+ ### Serialization Pattern
81
+
82
+ Models declare attributes and XML mappings in the same class. `Item` is the serializer (handles `from_xml`, `from_yaml`, `to_xml`), `ItemData` is the plain data object returned. Round-trip fidelity (parse → serialize → parse) is the primary correctness criterion tested in specs.
83
+
84
+ ### Test Setup
85
+
86
+ - **RSpec** with `--format documentation`
87
+ - **VCR** + **WebMock** for HTTP interaction recording (`spec/vcr_cassettes/`)
88
+ - **Jing** for RelaxNG schema validation against `grammars/relaton-ogc-compile.rng`
89
+ - **equivalent-xml** for XML comparison in tests
90
+ - Fixtures live in `spec/fixtures/` (YAML, XML)
91
+ - Integration tests in `spec/relaton/ogc/integration_spec.rb` exercise the full search → fetch → serialize pipeline
92
+
93
+ ### Grammars
94
+
95
+ RelaxNG schemas in `grammars/` define the valid XML structure. `relaton-ogc-compile.rng` is the combined schema used for test validation.
96
+
97
+ ### API Notes
98
+
99
+ - `Bib::Docidentifier` uses `.content` (not `.id`) for the identifier string
100
+ - `Bib::Date` uses `.at` returning a `StringDate::Value`; parse with `::Date.parse(d.at.to_s)` to extract year
101
+
102
+ ## Linting
103
+
104
+ RuboCop inherits from the [Ribose OSS style guide](https://github.com/riboseinc/oss-guides). Target Ruby version is 3.1. Rails cops are loaded but disabled.
105
+
106
+ ## CI
107
+
108
+ GitHub Actions workflows in `.github/workflows/` are auto-generated by Cimas — avoid manual edits. `rake.yml` runs tests on push/PR; `release.yml` handles gem publishing.
data/README.adoc CHANGED
@@ -1,4 +1,4 @@
1
- = RelatonOgc
1
+ = Relaton::Ogc
2
2
 
3
3
  image:https://img.shields.io/gem/v/relaton-ogc.svg["Gem Version", link="https://rubygems.org/gems/relaton-ogc"]
4
4
  image:https://github.com/relaton/relaton-ogc/workflows/macos/badge.svg["Build Status (macOS)", link="https://github.com/relaton/relaton-ogc/actions?workflow=macos"]
@@ -8,9 +8,9 @@ image:https://codeclimate.com/github/relaton/relaton-ogc/badges/gpa.svg["Code Cl
8
8
  image:https://img.shields.io/github/issues-pr-raw/relaton/relaton-ogc.svg["Pull Requests", link="https://github.com/relaton/relaton-ogc/pulls"]
9
9
  image:https://img.shields.io/github/commits-since/relaton/relaton-ogc/latest.svg["Commits since latest",link="https://github.com/relaton/relaton-ogc/releases"]
10
10
 
11
- RelatonOgc is a Ruby gem that implements the https://github.com/metanorma/metanorma-model-iso#iso-bibliographic-item[IsoBibliographicItem model].
11
+ Relaton::Ogc is a Ruby gem that implements the https://github.com/metanorma/metanorma-model-iso#iso-bibliographic-item[IsoBibliographicItem model].
12
12
 
13
- You can use it to retrieve metadata of OGC Standards from https://raw.githubusercontent.com/opengeospatial/NamingAuthority/master/incubation/bibliography/bibliography.json, and access such metadata through the `OgcBibliographicItem` object.
13
+ You can use it to retrieve metadata of OGC Standards from the https://github.com/relaton/relaton-data-ogc[relaton-data-ogc] dataset, and access such metadata through the `Relaton::Ogc::ItemData` object.
14
14
 
15
15
  == Installation
16
16
 
@@ -35,14 +35,14 @@ Or install it yourself as:
35
35
 
36
36
  [source,ruby]
37
37
  ----
38
- require 'relaton_ogc'
38
+ require 'relaton/ogc'
39
39
  => true
40
40
 
41
- hits = RelatonOgc::OgcBibliography.search("OGC 19-025r1")
42
- => <RelatonOgc::HitCollection:0x007fcc8e085ba8 @ref=OGC 19-025r1 @fetched=true>
41
+ hits = Relaton::Ogc::Bibliography.search("OGC 19-025r1")
42
+ => <Relaton::Ogc::HitCollection:0x00000000001230 @ref=19-025r1 @fetched=false>
43
43
 
44
- item = hits[0].fetch
45
- => #<RelatonOgc::OgcBibliographicItem:0x007fcab3cb4758
44
+ item = hits[0].item
45
+ => #<Relaton::Ogc::ItemData:0x0000000127b1d870
46
46
  ...
47
47
  ----
48
48
 
@@ -50,11 +50,12 @@ item = hits[0].fetch
50
50
  [source,ruby]
51
51
  ----
52
52
  item.to_xml
53
- => "<bibitem id="19-025r1" type="standard" schema-version="v1.2.1">
54
- <fetched>2022-12-04</fetched>
55
- <title type="title-main" format="text/plain" language="en" script="Latn">Development of Spatial Data Infrastructures for Marine Data Management</title>
56
- <title type="main" format="text/plain" language="en" script="Latn">Development of Spatial Data Infrastructures for Marine Data Management</title>
57
- <uri type="obp">https://portal.ogc.org/files/?artifact_id=88037</uri>
53
+ => "<bibitem id="19025r1" type="standard" schema-version="v1.4.1">
54
+ <fetched>2026-02-27</fetched>
55
+ <title language="en" script="Latn" type="title-main">Development of Spatial Data Infrastructures for Marine Data Management</title>
56
+ <title language="en" script="Latn" type="main">Development of Spatial Data Infrastructures for Marine Data Management</title>
57
+ <uri type="src">http://www.opengis.net/doc/per/marine-sdi</uri>
58
+ <uri type="pdf">https://portal.ogc.org/files/?artifact_id=88037</uri>
58
59
  <docidentifier type="OGC" primary="true">19-025r1</docidentifier>
59
60
  ...
60
61
  </bibitem>"
@@ -63,18 +64,17 @@ With argument `bibdata: true` it outputs XML wrapped by `bibdata` element and ad
63
64
  [source,ruby]
64
65
  ----
65
66
  item.to_xml bibdata: true
66
- => "<bibdata type="standard" schema-version="v1.2.1">
67
- <fetched>2022-12-04</fetched>
68
- <title type="title-main" format="text/plain" language="en" script="Latn">Development of Spatial Data Infrastructures for Marine Data Management</title>
69
- <title type="main" format="text/plain" language="en" script="Latn">Development of Spatial Data Infrastructures for Marine Data Management</title>
70
- <uri type="obp">https://portal.ogc.org/files/?artifact_id=88037</uri>
67
+ => "<bibdata type="standard" schema-version="v1.4.1">
68
+ <fetched>2026-02-27</fetched>
69
+ <title language="en" script="Latn" type="title-main">Development of Spatial Data Infrastructures for Marine Data Management</title>
70
+ <title language="en" script="Latn" type="main">Development of Spatial Data Infrastructures for Marine Data Management</title>
71
+ <uri type="src">http://www.opengis.net/doc/per/marine-sdi</uri>
72
+ <uri type="pdf">https://portal.ogc.org/files/?artifact_id=88037</uri>
71
73
  <docidentifier type="OGC" primary="true">19-025r1</docidentifier>
72
74
  ...
73
75
  <ext schema-version="v1.0.1">
74
76
  <doctype>engineering-report</doctype>
75
- <editorialgroup>
76
- <committee>technical</committee>
77
- </editorialgroup>
77
+ <flavor>ogc</flavor>
78
78
  </ext>
79
79
  </bibdata>"
80
80
  ----
@@ -82,76 +82,76 @@ item.to_xml bibdata: true
82
82
  === Get code, and year
83
83
  [source,ruby]
84
84
  ----
85
- RelatonOgc::OgcBibliography.get "OGC 19-025r1", "2019", {}
86
- [relaton-ogc] (OGC 19-025r1) Fetching from Relaton repository ...
87
- [relaton-ogc] (OGC 19-025r1) Found: `19-025r1`
88
- => #<RelatonOgc::OgcBibliographicItem:0x007fc322e9aba0
85
+ Relaton::Ogc::Bibliography.get "OGC 19-025r1", "2019"
86
+ [relaton-ogc] INFO: (OGC 19-025r1) Fetching from Relaton repository ...
87
+ [relaton-ogc] INFO: (OGC 19-025r1) Found: `19-025r1`
88
+ => #<Relaton::Ogc::ItemData:0x00000001283d6f48
89
89
  ...
90
90
  ----
91
91
 
92
92
  === Create bibliographic item from XML
93
93
  [source,ruby]
94
94
  ----
95
- RelatonOgc::XMLParser.from_xml File.read('spec/fixtures/12_128r14.xml')
96
- => #<RelatonOgc::OgcBibliographicItem:0x00007fd2b1078718
95
+ Relaton::Ogc::Item.from_xml File.read('spec/fixtures/12_128r14.xml')
96
+ => #<Relaton::Ogc::ItemData:0x000000012835e610
97
97
  ...
98
98
  ----
99
99
 
100
100
  === Typed links
101
101
 
102
- Each OGC document has `obp` type link.
102
+ Each OGC document has `scr` type source link.
103
103
 
104
104
  [source,ruby]
105
105
  ----
106
- item.link
107
- => [#<RelatonBib::TypedUri:0x00007fc848994568 @content=#<Addressable::URI:0x8e8 URI:https://portal.ogc.org/files/?artifact_id=88037>, @type="obp">]
106
+ item.source[0].type
107
+ => "obp"
108
+
109
+ item.source[0].content
110
+ => "http://www.opengis.net/doc/per/marine-sdi"
108
111
  ----
109
112
 
110
113
  === Create bibliographic item from YAML
111
114
  [source,ruby]
112
115
  ----
113
- hash = YAML.load_file 'spec/fixtures/ogc_bib_item.yml'
114
- => {"id"=>"19-025r1",
115
- ...
116
-
117
- RelatonOgc::OgcBibliographicItem.from_hash hash
118
- => #<RelatonOgc::OgcBibliographicItem:0x007fc322ef8548
116
+ Relaton::Ogc::Item.from_yaml File.read('spec/fixtures/item.yaml')
117
+ => #<Relaton::Ogc::ItemData:0x0000000124b19d90
119
118
  ...
120
119
  ----
121
120
 
122
121
  === Fetch data
123
122
 
124
- This gem uses the https://raw.githubusercontent.com/opengeospatial/NamingAuthority/master/incubation/bibliography/bibliography.json dataset as a data source.
123
+ This gem uses the https://raw.githubusercontent.com/opengeospatial/NamingAuthority/master/definitions/docs/docs.json[OGC NamingAuthority] dataset as a data source.
125
124
 
126
- The method `RelatonOgc::DataFetcher.fetch(output: "data", format: "yaml")` fetches all the documents from the dataset and saves them to the `./data` folder in YAML format.
125
+ The method `Relaton::Ogc::DataFetcher.fetch(output: "data", format: "yaml")` fetches all the documents from the dataset and saves them to the `./data` folder in YAML format.
127
126
  Arguments:
128
127
 
129
128
  - `output` - folder to save documents (default './data').
130
- - `format` - the format in which the documents are saved. Possible formats are: `yaml`, `xml` (default `yaml`).
129
+ - `format` - the format in which the documents are saved. Possible formats are: `yaml`, `xml`, `bibxml` (default `yaml`).
131
130
 
132
131
  [source,ruby]
133
132
  ----
134
- RelatonOgc::DataFetcher.fetch
135
- Started at: 2021-09-14 11:21:46 +0200
136
- [relaton-ogc] WARNING Duplicated documents: 15-113r5, 08-094r1, 10-025r1, 12-128r14, 16-079, 16-007r3, 13-026r8, 12-128r12, 15-078r6, 12-176r7, 09-102r3, 14-095, 14-115, 07-147r2, 12-000, 12-006, 09-025r1, 07-036, 07-110r4, 03-105r1, 06-042, 07-165r1, 12-066, 06-104r4, 11-122r1, 09-000, 04-094, 07-006r1, 06-035r1, 03-006r3, 05-134, 04-021r3, 02-058, 01-009
137
- Stopped at: 2021-09-14 11:21:48 +0200
133
+ require "relaton/ogc/data_fetcher"
134
+
135
+ Relaton::Ogc::DataFetcher.fetch
136
+ Started at: 2026-02-27 11:21:46 +0200
137
+ Stopped at: 2026-02-27 11:21:48 +0200
138
138
  => nil
139
139
  ----
140
140
 
141
141
  === Logging
142
142
 
143
- RelatonOgc uses the relaton-logger gem for logging. By default, it logs to STDOUT. To change the log levels and add other loggers, read the https://github.com/relaton/relaton-logger#usage[relaton-logger] documentation.
143
+ Relaton::Ogc uses the relaton-logger gem for logging. By default, it logs to STDOUT. To change the log levels and add other loggers, read the https://github.com/relaton/relaton-logger#usage[relaton-logger] documentation.
144
144
 
145
145
  == Development
146
146
 
147
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
147
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
148
148
 
149
149
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
150
150
 
151
151
  == Contributing
152
152
 
153
- Bug reports and pull requests are welcome on GitHub at https://github.com/calconnenct/relaton_ogc.
153
+ Bug reports and pull requests are welcome on GitHub at https://github.com/relaton/relaton-ogc.
154
154
 
155
155
  == License
156
156
 
157
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
157
+ The gem is available as open source under the terms of the https://opensource.org/licenses/MIT[MIT License].