sts 0.6.5 → 0.6.6
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/TODO.sts-refactor/00-overview.md +3 -3
- data/TODO.sts-refactor/03-namespace-coupling.md +15 -4
- data/TODO.sts-refactor/09-autoload-cleanup.md +48 -83
- data/TODO.sts-refactor/11-duplicate-models.md +32 -2
- data/lib/sts/iso_sts/array.rb +1 -1
- data/lib/sts/iso_sts/attrib.rb +72 -0
- data/lib/sts/iso_sts/boxed_text.rb +2 -0
- data/lib/sts/iso_sts/disp_quote.rb +2 -0
- data/lib/sts/iso_sts/table_wrap_foot.rb +1 -1
- data/lib/sts/iso_sts.rb +1 -3
- data/lib/sts/version.rb +1 -1
- metadata +3 -4
- data/lib/sts/iso_sts/mathml2/math.rb +0 -68
- data/lib/sts/iso_sts/mathml2.rb +0 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 201840881c86c036233c5bb1305bf176bbe6bf4ca0f43a22e370105cac0ed54f
|
|
4
|
+
data.tar.gz: 5845dd5fb849611a4a11bf173af68b3c226cf5c807d09bb721cf09cecdc8544b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 20d4010381ed9daf225ecf13afc922b5cf338ec62318b24ee22554163885c815aa5db22257be600262fe8be9f7f8668a0569805e5a201db35b98a84e1fbfa982
|
|
7
|
+
data.tar.gz: c4078992f02ab4a9e6640e750d2f54b29136b187a58b9e42cc21e9a2cc76b7049c6e25f9b823e0827f2851468e3f0dcc618271526880ae3121be3f2fc5512d69
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|---|------|----------|----------|--------------|
|
|
20
20
|
| 01 | `01-mathml-delegation.md` | Anti-Pattern Fix | DONE | — |
|
|
21
21
|
| 02 | `02-type-resolution.md` | Anti-Pattern Fix | DONE | — |
|
|
22
|
-
| 03 | `03-namespace-coupling.md` | Architecture | IN PROGRESS (63→
|
|
22
|
+
| 03 | `03-namespace-coupling.md` | Architecture | IN PROGRESS (63→11 refs) | 01, 02 |
|
|
23
23
|
| 04 | `04-register-versioning.md` | Architecture | HIGH | 01, 02 |
|
|
24
24
|
| 05 | `05-missing-elements.md` | Feature Gap | MOSTLY DONE | 04 |
|
|
25
25
|
| 06 | `06-missing-attributes.md` | Feature Gap | DONE | 04 |
|
|
@@ -166,7 +166,7 @@ grep -r "method_missing|respond_to_missing|Object.const_get|\.send" lib/
|
|
|
166
166
|
- ~~Expand StringName usage (in contrib, element-citation, related-article — NISO STS 1.2)~~ → DONE: added to name-alternatives; already in person-group and mixed-citation
|
|
167
167
|
|
|
168
168
|
### Architectural Items (High Effort)
|
|
169
|
-
- `03-namespace-coupling.md` — IN PROGRESS: 63→
|
|
169
|
+
- `03-namespace-coupling.md` — IN PROGRESS: 63→11 IsoSts→NisoSts references
|
|
170
170
|
remaining (issue #40). ISOSTS.xsd governs content models and all non-`@id`
|
|
171
171
|
attributes; the `@id` follows the 86948b9 convention.
|
|
172
172
|
- `04-register-versioning.md` — Version the models via lutaml-model Registers
|
|
@@ -193,7 +193,7 @@ the **NISO** XSD and applied the result to IsoSts.
|
|
|
193
193
|
|
|
194
194
|
## Next Action
|
|
195
195
|
Two independent tracks:
|
|
196
|
-
1. Finish `03` — the
|
|
196
|
+
1. Finish `03` — the 11 remaining refs split across five recursive roots
|
|
197
197
|
(`ElementCitation`, `PersonGroup`, `Collab`, `Source`, `TermDisplay`) and
|
|
198
198
|
five child-bearing roots. `DispQuote` and `BoxedText` themselves are now
|
|
199
199
|
IsoSts classes. The first 15 high-reuse dependency leaves are modelled,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
**Priority**: HIGH
|
|
4
4
|
**Category**: Architecture
|
|
5
5
|
**Estimated Effort**: High
|
|
6
|
-
**Status**: Partially done — 63 →
|
|
6
|
+
**Status**: Partially done — 63 → 11 references (GitHub issue #40)
|
|
7
7
|
|
|
8
8
|
## Problem
|
|
9
9
|
|
|
@@ -14,6 +14,9 @@ evolves, so coupling them violates OCP.
|
|
|
14
14
|
PR #31 reduced this from 157 to 63 references. Issue #40 reduced it further,
|
|
15
15
|
from 63 to 16. The `IsoSts::DispQuote` / `IsoSts::BoxedText` addition then
|
|
16
16
|
reduced it from 16 to 13 (Body#disp_quote, Sec#disp_quote, Sec#boxed_text).
|
|
17
|
+
The `IsoSts::Attrib` addition then reduced it from 13 to 11
|
|
18
|
+
(Array#attrib, TableWrapFoot#attrib) and filled the omission in DispQuote /
|
|
19
|
+
BoxedText from PR #48.
|
|
17
20
|
|
|
18
21
|
## Content models from ISOSTS.xsd; `@id` from the 86948b9 convention
|
|
19
22
|
|
|
@@ -74,12 +77,20 @@ Non-`@id` attribute lists must be **generated** from the XSD, never hand-read:
|
|
|
74
77
|
from NisoSts, which disagrees: `NisoSts::DispQuote` lacks `xml_lang` and
|
|
75
78
|
`title`; `NisoSts::BoxedText` carries `form_type`/`is_form` that ISOSTS does
|
|
76
79
|
not define). Children limited to existing IsoSts types; omitted children
|
|
77
|
-
(`
|
|
80
|
+
(`speech`, `statement`, `verse-group`, `address`, `alternatives`,
|
|
78
81
|
`array`, `chem-struct-wrap`, `fig-group`, `media`, `supplementary-material`,
|
|
79
82
|
`table-wrap`, `table-wrap-group`, `disp-formula-group`, `mml:math`,
|
|
80
83
|
`related-article`, `related-object`, `glossary`) are tracked below.
|
|
81
84
|
`BoxedText#sts_object_id` (not `:object_id`) follows the `NisoSts::Graphic`
|
|
82
85
|
convention to avoid clashing with `Object#object_id`. 3 refs.
|
|
86
|
+
- **`Attrib` added** — mixed-content class modelled from ISOSTS.xsd with the
|
|
87
|
+
25 inline-element children that have IsoSts types today. Fills the
|
|
88
|
+
`attrib` gap left in `DispQuote` and `BoxedText` from the prior bullet.
|
|
89
|
+
2 refs (`Array#attrib`, `TableWrapFoot#attrib`). Omitted inline children
|
|
90
|
+
(`inline-supplementary-material`, `related-article`, `related-object`,
|
|
91
|
+
`element-citation`, `overline`, `roman`, `sans-serif`, `alternatives`,
|
|
92
|
+
`private-char`, `chem-struct`, `mml:math`, `target`, `tbx:entailedTerm`)
|
|
93
|
+
tracked below.
|
|
83
94
|
|
|
84
95
|
### Why classes and not plain `:string`
|
|
85
96
|
|
|
@@ -90,12 +101,12 @@ round-trip. For a scalar, `render_empty: :empty` recovers it; for a collection
|
|
|
90
101
|
to `[]`, destroying the information at parse time before any render option
|
|
91
102
|
applies. Content-only classes round-trip every case.
|
|
92
103
|
|
|
93
|
-
## Remaining —
|
|
104
|
+
## Remaining — 11 refs
|
|
94
105
|
|
|
95
106
|
**5 refs to 5 recursive roots**: `ElementCitation`, `PersonGroup`, `Collab`,
|
|
96
107
|
`Source`, `TermDisplay`. Each reaches the same 78–79-element
|
|
97
108
|
mutually-recursive core before existing IsoSts boundaries (`sec` → `p` →
|
|
98
|
-
`disp-quote` → `p`). `DispQuote` and `
|
|
109
|
+
`disp-quote` → `p`). `DispQuote`, `BoxedText`, and `Attrib` are now IsoSts
|
|
99
110
|
classes and no longer in this list.
|
|
100
111
|
|
|
101
112
|
**8 refs to 5 child-bearing roots**, now measured after the first dependency
|
|
@@ -1,88 +1,53 @@
|
|
|
1
1
|
# 09: Autoload and Require Cleanup
|
|
2
2
|
|
|
3
|
+
**Status**: Refreshed 2026-07-26. Most items done; remaining items noted below.
|
|
3
4
|
**Priority**: LOW
|
|
4
5
|
**Category**: Cleanup
|
|
5
|
-
**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
6
|
+
**Files Affected**: `lib/sts.rb`, `lib/sts/iso_sts.rb`, `lib/sts/niso_sts.rb`
|
|
7
|
+
|
|
8
|
+
## Done
|
|
9
|
+
|
|
10
|
+
- **Moxml monkey-patch removed entirely** — upstream fix in moxml aa58888.
|
|
11
|
+
No code lives in `lib/sts.rb` patching `Moxml::Adapter::Nokogiri`.
|
|
12
|
+
- **`lib/sts/mathml.rb` deleted** (commit 9e977a5) — Presentation MathML
|
|
13
|
+
unified on the mml gem (`Mml::V3::Math` for NisoSts, `Mml::V2::Math` for
|
|
14
|
+
IsoSts/TbxIsoTml per the host-binding fix in PR #45).
|
|
15
|
+
- **`lib/sts/iso_sts/mathml2/` deleted** (this change) — dead-code hack file
|
|
16
|
+
that violated multiple anti-pattern rules. `IsoSts::Mathml2::Math` is gone.
|
|
17
|
+
- **`lib/sts/content_groups/` deleted** — was dead code (the only caller,
|
|
18
|
+
`IsoSts::ContentGroups::HighlightElements`, was itself dead).
|
|
19
|
+
- **`lib/sts/tbx_iso_tml/fn.rb` and `fn_group.rb` deleted** (PR #47) —
|
|
20
|
+
duplicates of `NisoSts::Fn` / `NisoSts::FnGroup` with conflicting Ruby
|
|
21
|
+
attribute names.
|
|
22
|
+
- **Autoload registry is 1:1 with the directory tree** for both `iso_sts/`
|
|
23
|
+
and `niso_sts/`.
|
|
24
|
+
- **`require_relative` is forbidden in `lib/`** — enforced by the
|
|
25
|
+
strengthened `spec/anti_patterns_spec.rb` (this change).
|
|
26
|
+
|
|
27
|
+
## Current autoload conventions
|
|
28
|
+
|
|
29
|
+
- Top-level: `lib/sts.rb` declares `autoload` for each top-level namespace
|
|
30
|
+
(`IsoSts`, `NisoSts`, `TbxIsoTml`, `Namespaces`, `Profiles`, `VERSION`).
|
|
31
|
+
- Each namespace's `lib/sts/<namespace>.rb` file declares `autoload` for
|
|
32
|
+
every class in that namespace, organised by category with leading
|
|
33
|
+
comments. Alphabetical order within each category block.
|
|
34
|
+
- External gems are eagerly required at the top of `lib/sts.rb`
|
|
35
|
+
(`require "lutaml/model"`, `require "mml"`). Internal code never uses
|
|
36
|
+
`require` or `require_relative`.
|
|
37
|
+
|
|
38
|
+
## Remaining items
|
|
39
|
+
|
|
40
|
+
- **`lib/sts/iso_sts.rb:3` has `require "mml"`** — redundant with the
|
|
41
|
+
top-level require in `lib/sts.rb:4`. Can be removed once verified no
|
|
42
|
+
load-order issue exists. Low priority.
|
|
43
|
+
- **Verify no implicit load-order deps remain** — the autoload system
|
|
44
|
+
should resolve all references lazily. If a circular dependency emerges,
|
|
45
|
+
it usually indicates a misnamed constant or a missing autoload entry.
|
|
46
|
+
|
|
47
|
+
## Verification
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
bundle exec rspec spec/anti_patterns_spec.rb # catches require_relative,
|
|
51
|
+
# internal require, etc.
|
|
52
|
+
bundle exec rake # full suite
|
|
44
53
|
```
|
|
45
|
-
lib/
|
|
46
|
-
├── sts.rb # Top-level: requires, Moxml patch (documented)
|
|
47
|
-
├── sts/
|
|
48
|
-
│ ├── namespaces.rb # Namespace constants
|
|
49
|
-
│ ├── mathml.rb # MathML wrapper (after TODO 01 fix)
|
|
50
|
-
│ ├── mathml/ # MathML-specific types (if needed)
|
|
51
|
-
│ ├── base/ # Shared base types (after TODO 03)
|
|
52
|
-
│ │ ├── text/ # Bold, Italic, Sub, Sup
|
|
53
|
-
│ │ ├── struct/ # Section, Paragraph, List
|
|
54
|
-
│ │ ├── meta/ # Title, Label, Caption
|
|
55
|
-
│ │ └── refs/ # Xref, BiblioRef
|
|
56
|
-
│ ├── iso_sts/ # ISOSTS namespace
|
|
57
|
-
│ │ ├── iso_sts.rb # Autoload declarations
|
|
58
|
-
│ │ ├── v1_1/ # ISOSTS v1.1 classes
|
|
59
|
-
│ │ └── content_groups/ # Content group helpers
|
|
60
|
-
│ ├── niso_sts/ # NISO STS namespace
|
|
61
|
-
│ │ ├── niso_sts.rb # Autoload declarations
|
|
62
|
-
│ │ ├── v1_0/ # NISO STS 1.0 classes
|
|
63
|
-
│ │ ├── v1_2/ # NISO STS 1.2 classes
|
|
64
|
-
│ │ ├── content_groups/ # Content group helpers
|
|
65
|
-
│ │ ├── mml_content/ # MathML content elements
|
|
66
|
-
│ │ └── xi.rb, ali.rb # Namespace modules
|
|
67
|
-
│ ├── tbx_iso_tml/ # TBX namespace
|
|
68
|
-
│ │ ├── tbx_iso_tml.rb # Autoload declarations
|
|
69
|
-
│ │ └── ...
|
|
70
|
-
│ ├── content_groups/ # Shared content group helpers
|
|
71
|
-
│ │ └── helpers.rb # After TODO 02 fix
|
|
72
|
-
│ └── profiles/ # ISO/IEC validation layer (after TODO 08)
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## Dependencies
|
|
76
|
-
|
|
77
|
-
- `01-mathml-delegation.md` — MathML wrapper location
|
|
78
|
-
- `03-namespace-coupling.md` — base types directory structure
|
|
79
|
-
- `04-register-versioning.md` — versioned subdirectories
|
|
80
|
-
|
|
81
|
-
## TODO Checklist
|
|
82
|
-
|
|
83
|
-
- [x] Document Moxml monkey-patch with rationale (removed entirely — upstream fix in moxml aa58888)
|
|
84
|
-
- [x] Audit autoload entries for alphabetical order
|
|
85
|
-
- [x] After refactoring: remove orphaned files (deleted content_groups dead code)
|
|
86
|
-
- [ ] After refactoring: verify no implicit load-order deps
|
|
87
|
-
- [x] After refactoring: clean up unused requires
|
|
88
|
-
- [x] Verify `bundle exec rake` passes cleanly
|
|
@@ -1,10 +1,40 @@
|
|
|
1
1
|
# 11: Duplicate Model Resolution
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**Status**: REJECTED (2026-07-26) — kept for historical context.
|
|
4
|
+
**Priority**: N/A
|
|
4
5
|
**Category**: Architecture
|
|
5
|
-
**Estimated Effort**:
|
|
6
|
+
**Estimated Effort**: N/A
|
|
6
7
|
**Files Affected**: `lib/sts/iso_sts/`, `lib/sts/niso_sts/`
|
|
7
8
|
|
|
9
|
+
## Why rejected
|
|
10
|
+
|
|
11
|
+
The "Resolution Strategy" below proposes a `Sts::Base::*` three-tier class
|
|
12
|
+
hierarchy that both `IsoSts` and `NisoSts` inherit from. This contradicts:
|
|
13
|
+
|
|
14
|
+
- The 2026-05-07 ADR on namespace independence.
|
|
15
|
+
- `TODO.sts-refactor/03-namespace-coupling.md` "Rejected" section.
|
|
16
|
+
- The project-global memory `architecture-namespace-independence`:
|
|
17
|
+
"NEVER create shared `Sts::Base` classes that both namespaces inherit from".
|
|
18
|
+
|
|
19
|
+
The schemas genuinely diverge — `IsoSts::Fig` has `title`/`alternatives` that
|
|
20
|
+
`NisoSts::Figure` lacks; `IsoSts::Ref` has `nlm-citation`/`citation-alternatives`
|
|
21
|
+
that `NisoSts::Reference` lacks. A shared base would fight the schemas and
|
|
22
|
+
violate the Open/Closed Principle.
|
|
23
|
+
|
|
24
|
+
The "duplicate" classes between IsoSts and NisoSts are intentional: each
|
|
25
|
+
namespace must have its own complete, independent set of model classes
|
|
26
|
+
modelled from its own schema (ISOSTS.xsd vs NISO-STS-extended-1.xsd). The
|
|
27
|
+
correct way to reduce the duplication appearance is to finish TODO 03
|
|
28
|
+
(model IsoSts classes from ISOSTS.xsd, replacing NisoSts references),
|
|
29
|
+
not to share base types.
|
|
30
|
+
|
|
31
|
+
The rest of this document is preserved for reference only. **Do not implement
|
|
32
|
+
the proposals below.**
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Original problem statement (rejected)
|
|
37
|
+
|
|
8
38
|
## Problem
|
|
9
39
|
|
|
10
40
|
Many model classes exist in both `Sts::IsoSts` and `Sts::NisoSts` with the same XML element name but potentially different attributes. This creates:
|
data/lib/sts/iso_sts/array.rb
CHANGED
|
@@ -11,7 +11,7 @@ module Sts
|
|
|
11
11
|
attribute :originator, :string
|
|
12
12
|
attribute :label, ::Sts::IsoSts::Label
|
|
13
13
|
attribute :table, ::Sts::IsoSts::Table
|
|
14
|
-
attribute :attrib, ::Sts::
|
|
14
|
+
attribute :attrib, ::Sts::IsoSts::Attrib, collection: true
|
|
15
15
|
attribute :permissions, ::Sts::IsoSts::Permissions, collection: true
|
|
16
16
|
|
|
17
17
|
xml do
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Sts
|
|
4
|
+
module IsoSts
|
|
5
|
+
class Attrib < Lutaml::Model::Serializable
|
|
6
|
+
attribute :id, :string
|
|
7
|
+
attribute :specific_use, :string
|
|
8
|
+
attribute :xml_lang, :string
|
|
9
|
+
attribute :content, :string, collection: true
|
|
10
|
+
attribute :email, ::Sts::IsoSts::Email, collection: true
|
|
11
|
+
attribute :ext_link, ::Sts::IsoSts::ExtLink, collection: true
|
|
12
|
+
attribute :uri, ::Sts::IsoSts::Uri, collection: true
|
|
13
|
+
attribute :mixed_citation, ::Sts::IsoSts::MixedCitation, collection: true
|
|
14
|
+
attribute :std, ::Sts::IsoSts::Std, collection: true
|
|
15
|
+
attribute :bold, ::Sts::IsoSts::Bold, collection: true
|
|
16
|
+
attribute :italic, ::Sts::IsoSts::Italic, collection: true
|
|
17
|
+
attribute :monospace, ::Sts::IsoSts::Monospace, collection: true
|
|
18
|
+
attribute :num, ::Sts::IsoSts::Num, collection: true
|
|
19
|
+
attribute :sc, ::Sts::IsoSts::Sc, collection: true
|
|
20
|
+
attribute :strike, ::Sts::IsoSts::Strike, collection: true
|
|
21
|
+
attribute :underline, ::Sts::IsoSts::Underline, collection: true
|
|
22
|
+
attribute :inline_graphic, ::Sts::IsoSts::InlineGraphic, collection: true
|
|
23
|
+
attribute :inline_formula, ::Sts::IsoSts::InlineFormula, collection: true
|
|
24
|
+
attribute :abbrev, ::Sts::IsoSts::Abbrev, collection: true
|
|
25
|
+
attribute :milestone_end, ::Sts::IsoSts::MilestoneEnd, collection: true
|
|
26
|
+
attribute :milestone_start, ::Sts::IsoSts::MilestoneStart,
|
|
27
|
+
collection: true
|
|
28
|
+
attribute :named_content, ::Sts::IsoSts::NamedContent, collection: true
|
|
29
|
+
attribute :styled_content, ::Sts::IsoSts::StyledContent, collection: true
|
|
30
|
+
attribute :fn, ::Sts::IsoSts::Fn, collection: true
|
|
31
|
+
attribute :xref, ::Sts::IsoSts::Xref, collection: true
|
|
32
|
+
attribute :std_ref, ::Sts::IsoSts::StdRef, collection: true
|
|
33
|
+
attribute :sub, ::Sts::IsoSts::Sub, collection: true
|
|
34
|
+
attribute :sup, ::Sts::IsoSts::Sup, collection: true
|
|
35
|
+
|
|
36
|
+
xml do # rubocop:disable Metrics/BlockLength
|
|
37
|
+
element "attrib"
|
|
38
|
+
mixed_content
|
|
39
|
+
|
|
40
|
+
map_attribute "id", to: :id
|
|
41
|
+
map_attribute "specific-use", to: :specific_use
|
|
42
|
+
map_attribute "xml:lang", to: :xml_lang
|
|
43
|
+
|
|
44
|
+
map_content to: :content
|
|
45
|
+
map_element "email", to: :email
|
|
46
|
+
map_element "ext-link", to: :ext_link
|
|
47
|
+
map_element "uri", to: :uri
|
|
48
|
+
map_element "mixed-citation", to: :mixed_citation
|
|
49
|
+
map_element "std", to: :std
|
|
50
|
+
map_element "bold", to: :bold
|
|
51
|
+
map_element "italic", to: :italic
|
|
52
|
+
map_element "monospace", to: :monospace
|
|
53
|
+
map_element "num", to: :num
|
|
54
|
+
map_element "sc", to: :sc
|
|
55
|
+
map_element "strike", to: :strike
|
|
56
|
+
map_element "underline", to: :underline
|
|
57
|
+
map_element "inline-graphic", to: :inline_graphic
|
|
58
|
+
map_element "inline-formula", to: :inline_formula
|
|
59
|
+
map_element "abbrev", to: :abbrev
|
|
60
|
+
map_element "milestone-end", to: :milestone_end
|
|
61
|
+
map_element "milestone-start", to: :milestone_start
|
|
62
|
+
map_element "named-content", to: :named_content
|
|
63
|
+
map_element "styled-content", to: :styled_content
|
|
64
|
+
map_element "fn", to: :fn
|
|
65
|
+
map_element "xref", to: :xref
|
|
66
|
+
map_element "std-ref", to: :std_ref
|
|
67
|
+
map_element "sub", to: :sub
|
|
68
|
+
map_element "sup", to: :sup
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -30,6 +30,7 @@ module Sts
|
|
|
30
30
|
attribute :term_sec, ::Sts::IsoSts::TermSec, collection: true
|
|
31
31
|
attribute :fn_group, ::Sts::IsoSts::FnGroup, collection: true
|
|
32
32
|
attribute :ref_list, ::Sts::IsoSts::RefList, collection: true
|
|
33
|
+
attribute :attrib, ::Sts::IsoSts::Attrib, collection: true
|
|
33
34
|
attribute :permissions, ::Sts::IsoSts::Permissions, collection: true
|
|
34
35
|
|
|
35
36
|
xml do # rubocop:disable Metrics/BlockLength
|
|
@@ -62,6 +63,7 @@ module Sts
|
|
|
62
63
|
map_element "term-sec", to: :term_sec
|
|
63
64
|
map_element "fn-group", to: :fn_group
|
|
64
65
|
map_element "ref-list", to: :ref_list
|
|
66
|
+
map_element "attrib", to: :attrib
|
|
65
67
|
map_element "permissions", to: :permissions
|
|
66
68
|
end
|
|
67
69
|
end
|
|
@@ -22,6 +22,7 @@ module Sts
|
|
|
22
22
|
attribute :graphic, ::Sts::IsoSts::Graphic, collection: true
|
|
23
23
|
attribute :disp_formula, ::Sts::IsoSts::DispFormula, collection: true
|
|
24
24
|
attribute :disp_quote, ::Sts::IsoSts::DispQuote, collection: true
|
|
25
|
+
attribute :attrib, ::Sts::IsoSts::Attrib, collection: true
|
|
25
26
|
attribute :permissions, ::Sts::IsoSts::Permissions, collection: true
|
|
26
27
|
|
|
27
28
|
xml do
|
|
@@ -46,6 +47,7 @@ module Sts
|
|
|
46
47
|
map_element "graphic", to: :graphic
|
|
47
48
|
map_element "disp-formula", to: :disp_formula
|
|
48
49
|
map_element "disp-quote", to: :disp_quote
|
|
50
|
+
map_element "attrib", to: :attrib
|
|
49
51
|
map_element "permissions", to: :permissions
|
|
50
52
|
end
|
|
51
53
|
end
|
|
@@ -10,7 +10,7 @@ module Sts
|
|
|
10
10
|
attribute :non_normative_example, ::Sts::IsoSts::NonNormativeExample
|
|
11
11
|
attribute :fn_group, ::Sts::IsoSts::FnGroup
|
|
12
12
|
attribute :fn, ::Sts::IsoSts::Fn
|
|
13
|
-
attribute :attrib, ::Sts::
|
|
13
|
+
attribute :attrib, ::Sts::IsoSts::Attrib
|
|
14
14
|
attribute :permissions, ::Sts::IsoSts::Permissions
|
|
15
15
|
|
|
16
16
|
xml do
|
data/lib/sts/iso_sts.rb
CHANGED
|
@@ -101,6 +101,7 @@ module Sts
|
|
|
101
101
|
# Shared model foundations
|
|
102
102
|
autoload :Abbrev, "#{__dir__}/iso_sts/abbrev"
|
|
103
103
|
autoload :Annotation, "#{__dir__}/iso_sts/annotation"
|
|
104
|
+
autoload :Attrib, "#{__dir__}/iso_sts/attrib"
|
|
104
105
|
autoload :Country, "#{__dir__}/iso_sts/country"
|
|
105
106
|
autoload :Day, "#{__dir__}/iso_sts/day"
|
|
106
107
|
autoload :Etal, "#{__dir__}/iso_sts/etal"
|
|
@@ -157,8 +158,5 @@ module Sts
|
|
|
157
158
|
autoload :AnnexType, "#{__dir__}/iso_sts/annex_type"
|
|
158
159
|
autoload :FnGroup, "#{__dir__}/iso_sts/fn_group"
|
|
159
160
|
autoload :Fn, "#{__dir__}/iso_sts/fn"
|
|
160
|
-
|
|
161
|
-
# MathML2 wrapper
|
|
162
|
-
autoload :Mathml2, "#{__dir__}/iso_sts/mathml2"
|
|
163
161
|
end
|
|
164
162
|
end
|
data/lib/sts/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sts
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-07-
|
|
11
|
+
date: 2026-07-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bigdecimal
|
|
@@ -127,6 +127,7 @@ files:
|
|
|
127
127
|
- lib/sts/iso_sts/app.rb
|
|
128
128
|
- lib/sts/iso_sts/app_group.rb
|
|
129
129
|
- lib/sts/iso_sts/array.rb
|
|
130
|
+
- lib/sts/iso_sts/attrib.rb
|
|
130
131
|
- lib/sts/iso_sts/back.rb
|
|
131
132
|
- lib/sts/iso_sts/body.rb
|
|
132
133
|
- lib/sts/iso_sts/bold.rb
|
|
@@ -176,8 +177,6 @@ files:
|
|
|
176
177
|
- lib/sts/iso_sts/list_item.rb
|
|
177
178
|
- lib/sts/iso_sts/long_desc.rb
|
|
178
179
|
- lib/sts/iso_sts/lpage.rb
|
|
179
|
-
- lib/sts/iso_sts/mathml2.rb
|
|
180
|
-
- lib/sts/iso_sts/mathml2/math.rb
|
|
181
180
|
- lib/sts/iso_sts/meta_date.rb
|
|
182
181
|
- lib/sts/iso_sts/milestone_end.rb
|
|
183
182
|
- lib/sts/iso_sts/milestone_start.rb
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "nokogiri"
|
|
4
|
-
|
|
5
|
-
module Sts
|
|
6
|
-
module IsoSts
|
|
7
|
-
module Mathml2
|
|
8
|
-
class Math < Lutaml::Model::Serializable
|
|
9
|
-
attribute :id, :string
|
|
10
|
-
attribute :display, :string
|
|
11
|
-
attribute :content, :string, collection: true
|
|
12
|
-
xml do
|
|
13
|
-
namespace ::Sts::Namespaces::MathmlNamespace
|
|
14
|
-
element "math"
|
|
15
|
-
mixed_content
|
|
16
|
-
map_attribute :id, to: :id
|
|
17
|
-
map_attribute :display, to: :display
|
|
18
|
-
map_content to: :content
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
MATH_NS = "http://www.w3.org/1998/Math/MathML"
|
|
22
|
-
|
|
23
|
-
def to_xml(*)
|
|
24
|
-
@original_xml || %{<math xmlns="#{MATH_NS}"/>}
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def self.from_xml(input)
|
|
28
|
-
input_str = input.respond_to?(:read) ? input.read : input.to_s
|
|
29
|
-
|
|
30
|
-
doc = parse_with_namespace(input_str)
|
|
31
|
-
math_element = find_math_element(doc)
|
|
32
|
-
return new if math_element.nil?
|
|
33
|
-
|
|
34
|
-
math = new
|
|
35
|
-
math.id = math_element["id"]
|
|
36
|
-
math.display = math_element["display"]
|
|
37
|
-
math.content = extract_inner_content(math_element)
|
|
38
|
-
math.instance_variable_set(:@original_xml, math_element.to_xml)
|
|
39
|
-
math
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def self.parse_with_namespace(xml_str)
|
|
43
|
-
# Detect namespace-prefixed math elements and wrap to resolve prefixes
|
|
44
|
-
if xml_str.include?("<mml:") || xml_str.match?(/<\w+:math[\s>]/)
|
|
45
|
-
wrapped = "<wrapper xmlns:mml=\"#{MATH_NS}\">#{xml_str}</wrapper>"
|
|
46
|
-
Nokogiri::XML(wrapped)
|
|
47
|
-
else
|
|
48
|
-
Nokogiri::XML(xml_str)
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
private_class_method :parse_with_namespace
|
|
52
|
-
|
|
53
|
-
def self.find_math_element(doc)
|
|
54
|
-
doc.at_xpath("//math[@xmlns='#{MATH_NS}']") ||
|
|
55
|
-
doc.at_xpath(".//mml:math", "mml" => MATH_NS) ||
|
|
56
|
-
doc.at_xpath(".//*[local-name()='math']")
|
|
57
|
-
end
|
|
58
|
-
private_class_method :find_math_element
|
|
59
|
-
|
|
60
|
-
def self.extract_inner_content(math_element)
|
|
61
|
-
content = math_element.children.to_xml
|
|
62
|
-
content.empty? ? nil : content
|
|
63
|
-
end
|
|
64
|
-
private_class_method :extract_inner_content
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
end
|