Skip to content

Commit 514b098

Browse files
committed
feat: initial commit
0 parents  commit 514b098

87 files changed

Lines changed: 12061 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/rake.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Auto-generated by Cimas: Do not edit it manually!
2+
# See https://github.com/metanorma/cimas
3+
name: rake
4+
5+
on:
6+
push:
7+
branches: [ master, main ]
8+
tags: [ v* ]
9+
pull_request:
10+
11+
jobs:
12+
rake:
13+
uses: metanorma/ci/.github/workflows/generic-rake.yml@main
14+
secrets:
15+
pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}

.github/workflows/release.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Auto-generated by Cimas: Do not edit it manually!
2+
# See https://github.com/metanorma/cimas
3+
name: release
4+
5+
permissions:
6+
contents: write
7+
packages: write
8+
id-token: write
9+
10+
on:
11+
workflow_dispatch:
12+
inputs:
13+
next_version:
14+
description: |
15+
Next release version. Possible values: x.y.z, major, minor, patch (or pre|rc|etc).
16+
Also, you can pass 'skip' to skip 'git tag' and do 'gem push' for the current version
17+
required: true
18+
default: 'skip'
19+
repository_dispatch:
20+
types: [ do-release ]
21+
22+
jobs:
23+
release:
24+
uses: metanorma/ci/.github/workflows/rubygems-release.yml@main
25+
with:
26+
next_version: ${{ github.event.inputs.next_version }}
27+
secrets:
28+
rubygems-api-key: ${{ secrets.METANORMA_CI_RUBYGEMS_API_KEY }}
29+
pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/.bundle/
2+
/.yardoc
3+
/_yardoc/
4+
/coverage/
5+
/doc/
6+
/pkg/
7+
/spec/reports/
8+
/tmp/
9+
10+
# rspec failure tracking
11+
.rspec_status
12+
13+
Gemfile.lock
14+
.claude
15+
TODO*
16+

.rspec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--format documentation
2+
--color
3+
--require spec_helper

.rubocop.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
inherit_from:
2+
- .rubocop_todo.yml
3+
- https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
4+
5+
# local repo-specific modifications
6+
7+
AllCops:
8+
TargetRubyVersion: 3.2
9+
NewCops: enable
10+
SuggestExtensions: false
11+
12+
Style/Documentation:
13+
Enabled: false
14+
15+
Metrics/BlockLength:
16+
Exclude:
17+
- "spec/**/*"

.rubocop_todo.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# This configuration was generated by
2+
# `rubocop --auto-gen-config`
3+
# on 2026-05-05 13:10:07 UTC using RuboCop version 1.86.1.
4+
# The point is for the user to remove these configuration records
5+
# one by one as the offenses are removed from the code base.
6+
# Note that changes in the inspected code, or installation of new
7+
# versions of RuboCop, may require this file to be generated again.
8+
9+
# Offense count: 7
10+
# This cop supports safe autocorrection (--autocorrect).
11+
# Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
12+
# URISchemes: http, https
13+
Layout/LineLength:
14+
Exclude:
15+
- 'spec/tbx/document_spec.rb'
16+
- 'tbx.gemspec'

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## [Unreleased]
2+
3+
## [0.1.0] - 2026-05-05
4+
5+
- Initial release

CLAUDE.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Build, Test, and Development Commands
6+
7+
```bash
8+
# Install dependencies
9+
bundle install
10+
11+
# Run tests
12+
bundle exec rspec
13+
14+
# Run a single test file
15+
bundle exec rspec spec/tbx/document_spec.rb
16+
17+
# Run linting
18+
bundle exec rubocop
19+
20+
# Run both (default task)
21+
bundle exec rake
22+
```
23+
24+
## Architecture
25+
26+
This is a Ruby gem for parsing and serializing TBX (Termbase Exchange) documents per ISO 30042:2019. It uses `lutaml-model` for XML serialization/deserialization.
27+
28+
### Namespace Structure
29+
30+
```
31+
Tbx
32+
├── Document # Root element (<tbx>)
33+
├── TbxHeader # <tbxHeader>
34+
├── FileDesc # <fileDesc>
35+
├── PublicationStmt # <publicationStmt>
36+
├── TitleStmt # <titleStmt>
37+
├── SourceDesc # <sourceDesc>
38+
├── EncodingDesc # <encodingDesc>
39+
├── RevisionDesc # <revisionDesc>
40+
├── Change # <change>
41+
├── TextElement # <text>
42+
├── Body # <body>
43+
├── Back # <back>
44+
├── ConceptEntry # <conceptEntry>
45+
├── LangSec # <langSec>
46+
├── TermSec # <termSec>
47+
├── Term # <term>
48+
├── TermNote # <termNote>
49+
├── TermNoteGrp # <termNoteGrp>
50+
├── Descrip # <descrip>
51+
├── DescripGrp # <descripGrp>
52+
├── DescripNote # <descripNote>
53+
├── Admin # <admin>
54+
├── AdminGrp # <adminGrp>
55+
├── AdminNote # <adminNote>
56+
├── Note # <note>
57+
├── P # <p>
58+
├── Ref # <ref>
59+
├── Xref # <xref>
60+
├── Transac # <transac>
61+
├── TransacGrp # <transacGrp>
62+
├── TransacNote # <transacNote>
63+
├── DateElement # <date>
64+
├── RefObjectSec # <refObjectSec>
65+
├── RefObject # <refObject>
66+
├── ItemSet # <itemSet>
67+
├── ItemGrp # <itemGrp>
68+
├── Item # <item>
69+
├── Hi # <hi>
70+
├── Foreign # <foreign>
71+
├── Ec # <ec>
72+
├── Sc # <sc>
73+
├── Ph # <ph>
74+
├── Title # <title>
75+
├── Namespaces # XML namespace definitions
76+
└── Ruby # Gem namespace (Tbx::Ruby::VERSION)
77+
```
78+
79+
### Key Implementation Patterns
80+
81+
**Element Classes** (in `lib/tbx/`):
82+
- Inherit from `Lutaml::Model::Serializable`
83+
- Define attributes and XML mapping in `xml do ... end` block
84+
- Use `map_element` to map child elements, `map_content` for text content
85+
- Use `mixed_content` for elements that contain both text and child elements
86+
- Use `w3c_attributes` for `xml:lang` and other W3C attributes
87+
88+
**Example element structure:**
89+
```ruby
90+
module Tbx
91+
class ConceptEntry < Lutaml::Model::Serializable
92+
attribute :id, :string
93+
attribute :lang_sec, ::Tbx::LangSec, collection: true
94+
95+
xml do
96+
root "conceptEntry"
97+
mixed_content
98+
namespace ::Tbx::Namespaces::TbxNamespace
99+
100+
map_attribute "id", to: :id
101+
map_element "langSec", to: :lang_sec
102+
end
103+
end
104+
end
105+
```
106+
107+
**Autoload Pattern**: Elements are autoloaded via `lib/tbx.rb`. When adding new elements, add autoloads in alphabetical order.
108+
109+
### XML Namespace
110+
111+
The TBX namespace is `urn:iso:std:iso:30042:ed-2` defined in `Tbx::Namespaces::TbxNamespace`.
112+
113+
### TBX Styles
114+
115+
- **DCA** (Data Category Archive): Uses standard element names like `<transac type="transactionType">`, `<descrip type="definition">`
116+
- **DCT** (Data Category Tagging): Uses module-namespaced elements like `<basic:transactionType>`, `<basic:definition>`
117+
118+
Currently DCA style is fully supported. DCT support will be added.
119+
120+
### Reference Data
121+
122+
- RNG/XSD schemas: `reference-docs/schemas/`
123+
- TBX-Basic dialect examples: `reference-docs/schemas/TBX-Basic_dialect_v1/`
124+
- Test fixtures: `spec/fixtures/TBX_test_files/` (from https://github.com/LTAC-Global/TBX_test_files)

CODE_OF_CONDUCT.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Code of Conduct
2+
3+
"tbx-ruby" follows [The Ruby Community Conduct Guideline](https://www.ruby-lang.org/en/conduct) in all "collaborative space", which is defined as community communications channels (such as mailing lists, submitted patches, commit comments, etc.):
4+
5+
* Participants will be tolerant of opposing views.
6+
* Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
7+
* When interpreting the words and actions of others, participants should always assume good intentions.
8+
* Behaviour which can be reasonably considered harassment will not be tolerated.
9+
10+
If you have any concerns about behaviour within this project, please contact us at ["ronald.tse@ribose.com"](mailto:"ronald.tse@ribose.com").

Gemfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
gemspec
6+
7+
gem "canon"
8+
gem "lutaml-model", path: "../../lutaml/lutaml-model"
9+
gem "nokogiri"
10+
gem "rake", "~> 13.0"
11+
gem "rspec", "~> 3.0"
12+
gem "rubocop", "~> 1.21"
13+
gem "rubocop-performance"
14+
gem "rubocop-rake"
15+
gem "rubocop-rspec"

0 commit comments

Comments
 (0)