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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9532812554990a4cc11d27d32a940db3ae908343c7154de1268deec1cefa55fb
4
- data.tar.gz: 4bcfe71b907f013cee3e4f07751083016b23321cad540b1340f323051927946c
3
+ metadata.gz: 78896ea0b02f8711ab4eea67a5d74909137f45a42a7d0785c68ae8db0756dcbb
4
+ data.tar.gz: e8db97ab8e36651275173de95ce88d59979931b8fc44d6d563a23736201c86c6
5
5
  SHA512:
6
- metadata.gz: f1679a4108b0bdb582b3ce78dd5eb8b13ee5e08194d9906e529e15ed394cc6d0d8a0f82ca53c6700d7cbe2e5137a6d86bb9c0356ee5b5ed004acd04c2f751d32
7
- data.tar.gz: 6e5051f654b4c48a8c9d08ca5a4e95e0960bfb893711dae1d124463f1dd5da251d7ffe70acf51bd9895cd5c986a74e6d122d4fb518670c47ad57a84f8ea40e6f
6
+ metadata.gz: f4c4f1ea97e4ce93484b2923529645c828cc9d5c0b9bf0e4563b554a962bb7e11e58491ed589155366257410f33868df6e56db83bebb5d4ebef082e35c78c895
7
+ data.tar.gz: b89d0b397640e7fe3bd7a4866559723ee1aebf85390be44ad09b756e2f51722972b29b8c0382a74e605d464afe15daa7c8e9f016063cc16a9e8e95f5babe0b0b
data/.gitignore CHANGED
@@ -15,3 +15,4 @@
15
15
  .byebug_history
16
16
  Gemfile.lock
17
17
  .DS_Store
18
+ .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: 3.0
10
+ TargetRubyVersion: 3.2
11
11
  Rails:
12
12
  Enabled: true
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
@@ -15,3 +15,4 @@ gem "simplecov"
15
15
  gem "vcr"
16
16
  gem "webmock"
17
17
  gem "debug"
18
+ gem "fiddle"