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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -1
- data/CLAUDE.md +108 -0
- data/README.adoc +47 -47
- data/docs2.json +30983 -0
- data/grammars/basicdoc.rng +1559 -671
- data/grammars/biblio-standoc.rng +107 -46
- data/grammars/biblio.rng +1010 -375
- data/grammars/relaton-ogc.rng +24 -42
- data/lib/relaton/ogc/bibdata.rb +7 -0
- data/lib/relaton/ogc/bibitem.rb +7 -0
- data/lib/relaton/ogc/bibliography.rb +64 -0
- data/lib/relaton/ogc/data_fetcher.rb +113 -0
- data/lib/relaton/ogc/docidentifier.rb +6 -0
- data/lib/relaton/ogc/doctype.rb +12 -0
- data/lib/relaton/ogc/ext.rb +18 -0
- data/lib/relaton/ogc/hit.rb +18 -0
- data/lib/relaton/ogc/hit_collection.rb +36 -0
- data/lib/relaton/ogc/item.rb +13 -0
- data/lib/relaton/ogc/item_data.rb +6 -0
- data/lib/relaton/ogc/processor.rb +58 -0
- data/lib/relaton/ogc/scraper.rb +203 -0
- data/lib/relaton/ogc/util.rb +8 -0
- data/lib/relaton/ogc/version.rb +5 -0
- data/lib/relaton/ogc.rb +26 -0
- data/relaton_ogc.gemspec +7 -7
- metadata +30 -29
- data/lib/relaton_ogc/data_fetcher.rb +0 -118
- data/lib/relaton_ogc/document_type.rb +0 -22
- data/lib/relaton_ogc/editorial_group.rb +0 -82
- data/lib/relaton_ogc/hash_converter.rb +0 -25
- data/lib/relaton_ogc/hit.rb +0 -20
- data/lib/relaton_ogc/hit_collection.rb +0 -32
- data/lib/relaton_ogc/ogc_bibliographic_item.rb +0 -69
- data/lib/relaton_ogc/ogc_bibliography.rb +0 -80
- data/lib/relaton_ogc/processor.rb +0 -58
- data/lib/relaton_ogc/scrapper.rb +0 -169
- data/lib/relaton_ogc/util.rb +0 -6
- data/lib/relaton_ogc/version.rb +0 -3
- data/lib/relaton_ogc/xml_parser.rb +0 -45
- data/lib/relaton_ogc.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: 63e344f79293ac705bbb72bf724eda7a55394b4f805808dcd897cf4dea55c97d
|
|
4
|
+
data.tar.gz: ca67124e73e4958c7739cee3f007e2ab3c8a85ac87dfb217879995dbabc641e3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: efc3d0ec325d196285c6b781985b299b049d3a7f47316df903316a4bbf54d6e2423ae43d114c001c985e119cf1df2fe6def0394a4f1de7f37b6aa8c1901074f5
|
|
7
|
+
data.tar.gz: e3621f69f96df3638a4d1f0b924e9c690e3ebd2526b090f9d169d028678fe23ee3ed01e7db0b478609d91b72c8efbe24d1f7b04a9d295c8c8a5e3d633492bdab
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
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
|
-
=
|
|
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
|
-
|
|
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://
|
|
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 '
|
|
38
|
+
require 'relaton/ogc'
|
|
39
39
|
=> true
|
|
40
40
|
|
|
41
|
-
hits =
|
|
42
|
-
=> <
|
|
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].
|
|
45
|
-
=> #<
|
|
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="
|
|
54
|
-
<fetched>
|
|
55
|
-
<title
|
|
56
|
-
<title
|
|
57
|
-
<uri type="
|
|
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.
|
|
67
|
-
<fetched>
|
|
68
|
-
<title
|
|
69
|
-
<title
|
|
70
|
-
<uri type="
|
|
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
|
-
<
|
|
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
|
-
|
|
86
|
-
[relaton-ogc] (OGC 19-025r1) Fetching from Relaton repository ...
|
|
87
|
-
[relaton-ogc] (OGC 19-025r1) Found: `19-025r1`
|
|
88
|
-
=> #<
|
|
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
|
-
|
|
96
|
-
=> #<
|
|
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 `
|
|
102
|
+
Each OGC document has `scr` type source link.
|
|
103
103
|
|
|
104
104
|
[source,ruby]
|
|
105
105
|
----
|
|
106
|
-
item.
|
|
107
|
-
=>
|
|
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
|
-
|
|
114
|
-
=>
|
|
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/
|
|
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 `
|
|
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
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
|
|
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 `
|
|
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/
|
|
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
|
|
157
|
+
The gem is available as open source under the terms of the https://opensource.org/licenses/MIT[MIT License].
|