relaton-cli 1.20.5 → 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 +96 -0
- data/Gemfile +1 -0
- data/docs/README.adoc +175 -257
- data/lib/relaton/bibdata.rb +10 -10
- data/lib/relaton/cli/command.rb +39 -4
- data/lib/relaton/cli/relaton_file.rb +6 -6
- data/lib/relaton/cli/subcommand_collection.rb +37 -5
- data/lib/relaton/cli/subcommand_db.rb +6 -0
- data/lib/relaton/cli/util.rb +1 -1
- data/lib/relaton/cli/version.rb +1 -1
- data/lib/relaton/cli/xml_to_html_renderer.rb +7 -6
- data/lib/relaton/cli/yaml_convertor.rb +9 -7
- data/lib/relaton/cli.rb +9 -11
- data/relaton-cli.gemspec +2 -2
- data/templates/_document.liquid +11 -12
- metadata +8 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 78896ea0b02f8711ab4eea67a5d74909137f45a42a7d0785c68ae8db0756dcbb
|
|
4
|
+
data.tar.gz: e8db97ab8e36651275173de95ce88d59979931b8fc44d6d563a23736201c86c6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f4c4f1ea97e4ce93484b2923529645c828cc9d5c0b9bf0e4563b554a962bb7e11e58491ed589155366257410f33868df6e56db83bebb5d4ebef082e35c78c895
|
|
7
|
+
data.tar.gz: b89d0b397640e7fe3bd7a4866559723ee1aebf85390be44ad09b756e2f51722972b29b8c0382a74e605d464afe15daa7c8e9f016063cc16a9e8e95f5babe0b0b
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/CLAUDE.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
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-cli is a Ruby CLI tool for managing bibliographic references to standards (ISO, IEC, IETF, NIST, etc.). It provides commands to fetch, convert, and organize standards metadata in XML, YAML, BibTeX, and HTML formats. Part of the broader Relaton/Metanorma ecosystem.
|
|
8
|
+
|
|
9
|
+
## Common 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/cli/command_spec.rb
|
|
20
|
+
|
|
21
|
+
# Run a specific test by line number
|
|
22
|
+
bundle exec rspec spec/relaton/cli/command_spec.rb:42
|
|
23
|
+
|
|
24
|
+
# Build the gem
|
|
25
|
+
bundle exec rake build
|
|
26
|
+
|
|
27
|
+
# Lint (RuboCop, inherits from Ribose OSS guide)
|
|
28
|
+
bundle exec rubocop
|
|
29
|
+
bundle exec rubocop -a # auto-fix
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Architecture
|
|
33
|
+
|
|
34
|
+
### Entry Point & CLI Framework
|
|
35
|
+
|
|
36
|
+
The executable `exe/relaton` calls `Relaton::Cli.start(ARGV)` which routes to `Relaton::Cli::Command`, a Thor-based command class. Thor handles argument parsing, option definitions, and subcommand routing.
|
|
37
|
+
|
|
38
|
+
### Command Structure
|
|
39
|
+
|
|
40
|
+
- `lib/relaton/cli/command.rb` — Main Thor command class with top-level commands (fetch, extract, concatenate, split, yaml2xml, xml2yaml, xml2html, yaml2html, convert, fetch-data)
|
|
41
|
+
- `lib/relaton/cli/subcommand_collection.rb` — `relaton collection` subcommands (create, info, list, get, find, fetch, import, export)
|
|
42
|
+
- `lib/relaton/cli/subcommand_db.rb` — `relaton db` subcommands (create, mv, clear, fetch, fetch_all, doctype)
|
|
43
|
+
|
|
44
|
+
### Option Forwarding Pattern
|
|
45
|
+
|
|
46
|
+
`Command#fetch` and `SubcommandDb#fetch` use the shared `fetch_document` helper (in `Relaton::Cli` private methods at the bottom of `command.rb`). This helper transforms Thor's kebab-case option keys to snake_case symbols via `gsub("-", "_").to_sym` and splats them as `**dup_opts` to `Relaton.db.fetch` / `Relaton.db.fetch_std`. Adding a new Thor option to these commands automatically forwards it to the underlying library with no method changes needed.
|
|
47
|
+
|
|
48
|
+
`SubcommandCollection#fetch` calls `Relaton.db.fetch` directly (not through `fetch_document`), so new options must be explicitly forwarded there.
|
|
49
|
+
|
|
50
|
+
Current fetch options that use this pattern: `--no-cache`, `--all-parts`, `--keep-year`, `--publication-date-before`, `--publication-date-after`.
|
|
51
|
+
|
|
52
|
+
### Core Data Classes
|
|
53
|
+
|
|
54
|
+
- `lib/relaton/bibdata.rb` — `Relaton::Bibdata` wraps `RelatonBib::BibliographicItem`, adding URL type handling and serialization to XML/YAML/Hash. Uses `method_missing` to delegate to the underlying bibitem.
|
|
55
|
+
- `lib/relaton/bibcollection.rb` — `Relaton::Bibcollection` represents a collection of bibliographic items with title/author/doctype metadata. Handles XML/YAML round-tripping.
|
|
56
|
+
- `lib/relaton/element_finder.rb` — Mixin providing XPath utilities with namespace handling.
|
|
57
|
+
|
|
58
|
+
### Converters (Template Method Pattern)
|
|
59
|
+
|
|
60
|
+
- `lib/relaton/cli/base_convertor.rb` — Abstract base defining the conversion flow (convert_and_write, write_to_file_collection)
|
|
61
|
+
- `lib/relaton/cli/xml_convertor.rb` — XML → YAML conversion
|
|
62
|
+
- `lib/relaton/cli/yaml_convertor.rb` — YAML → XML conversion (includes processor detection via doctype)
|
|
63
|
+
- `lib/relaton/cli/xml_to_html_renderer.rb` — Renders XML/YAML to HTML using Liquid templates from `templates/`
|
|
64
|
+
|
|
65
|
+
### File Operations
|
|
66
|
+
|
|
67
|
+
`lib/relaton/cli/relaton_file.rb` — Static methods for extract (pull bibdata from Metanorma XML), concatenate (combine files into a collection), and split (break a collection into individual files).
|
|
68
|
+
|
|
69
|
+
### Database (Singleton)
|
|
70
|
+
|
|
71
|
+
`Relaton::Cli::RelatonDb` (in `lib/relaton/cli.rb`) is a Singleton managing a `Relaton::Db` instance. DB path is persisted in `~/.relaton/dbpath`. The `relaton` gem's registry auto-discovers 30+ standard-body processors.
|
|
72
|
+
|
|
73
|
+
### Processor Detection
|
|
74
|
+
|
|
75
|
+
`Relaton::Cli.processor(doc)` and `.parse_xml(doc)` detect the correct processor (ISO, IEC, IETF, etc.) from a document's `docidentifier` element type attribute, falling back to prefix matching.
|
|
76
|
+
|
|
77
|
+
## Test Structure
|
|
78
|
+
|
|
79
|
+
- `spec/acceptance/` — End-to-end CLI integration tests using `rspec-command`
|
|
80
|
+
- `spec/relaton/cli/` — Unit tests for command, converters, subcommands, DB
|
|
81
|
+
- `spec/relaton/` — Unit tests for Bibcollection and Bibdata
|
|
82
|
+
- `spec/support/` — Test setup: SimpleCov, WebMock, VCR, equivalent-xml matchers
|
|
83
|
+
- `spec/fixtures/` and `spec/vcr_cassettes/` — Test data and recorded HTTP responses
|
|
84
|
+
|
|
85
|
+
Tests use VCR cassettes to replay HTTP interactions with standards registries. WebMock blocks real HTTP requests in tests.
|
|
86
|
+
|
|
87
|
+
## Key Dependencies
|
|
88
|
+
|
|
89
|
+
- `relaton ~> 1.20.0` — Core library providing DB, registry, and all standard-body processors
|
|
90
|
+
- `thor` / `thor-hollaback` — CLI framework
|
|
91
|
+
- `liquid ~> 5` — HTML template rendering
|
|
92
|
+
- `nokogiri` (transitive via relaton) — XML parsing
|
|
93
|
+
|
|
94
|
+
## Ruby Version
|
|
95
|
+
|
|
96
|
+
Requires Ruby >= 3.0.0 (set in gemspec and `.rubocop.yml`).
|
data/Gemfile
CHANGED