oasis-etm 0.1.0 → 0.2.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/.github/workflows/release.yml +5 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +13 -8
- data/.rubocop_todo.yml +27 -5
- data/CLAUDE.md +35 -0
- data/Gemfile +2 -1
- data/README.adoc +126 -14
- data/lib/oasis/etm/colspec.rb +8 -3
- data/lib/oasis/etm/entry.rb +9 -4
- data/lib/oasis/etm/namespace.rb +10 -0
- data/lib/oasis/etm/row.rb +6 -4
- data/lib/oasis/etm/table.rb +9 -6
- data/lib/oasis/etm/tbody.rb +2 -3
- data/lib/oasis/etm/tcol.rb +7 -3
- data/lib/oasis/etm/tgroup.rb +8 -7
- data/lib/oasis/etm/thead.rb +2 -3
- data/lib/oasis/etm/version.rb +1 -1
- data/lib/oasis/etm.rb +10 -3
- data/lib/oasis-etm.rb +3 -1
- data/oasis-etm.gemspec +1 -1
- data/spec/fixtures/native/docbook_example.xml +3 -2
- data/spec/oasis/etm/colspec_spec.rb +4 -4
- data/spec/oasis/etm/entry_spec.rb +9 -9
- data/spec/oasis/etm/row_spec.rb +5 -4
- data/spec/oasis/etm/table_spec.rb +5 -5
- data/spec/oasis/etm/tbody_spec.rb +3 -3
- data/spec/oasis/etm/tgroup_spec.rb +4 -4
- data/spec/oasis/etm/thead_spec.rb +3 -3
- data/spec/oasis/etm_spec.rb +42 -14
- data/spec/spec_helper.rb +12 -12
- metadata +8 -7
- data/oasis-etm_wrapped.txt +0 -1910
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
RSpec.describe Oasis::Etm::Entry do
|
|
3
3
|
let(:xml) do
|
|
4
4
|
<<~XML
|
|
5
|
-
<entry
|
|
5
|
+
<entry xmlns="http://docs.oasis-open.org/ns/oasis-exchange/table"
|
|
6
6
|
colname="col1"
|
|
7
7
|
namest="col1"
|
|
8
8
|
nameend="col2"
|
|
@@ -24,8 +24,8 @@ RSpec.describe Oasis::Etm::Entry do
|
|
|
24
24
|
expect(entry.namest).to eq("col1")
|
|
25
25
|
expect(entry.nameend).to eq("col2")
|
|
26
26
|
expect(entry.morerows).to eq(1)
|
|
27
|
-
expect(entry.colsep).to eq(1)
|
|
28
|
-
expect(entry.rowsep).to eq(1)
|
|
27
|
+
expect(entry.colsep).to eq("1")
|
|
28
|
+
expect(entry.rowsep).to eq("1")
|
|
29
29
|
expect(entry.align).to eq("center")
|
|
30
30
|
expect(entry.char).to eq(".")
|
|
31
31
|
expect(entry.charoff).to eq("50")
|
|
@@ -33,7 +33,7 @@ RSpec.describe Oasis::Etm::Entry do
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
it "parses content" do
|
|
36
|
-
expect(entry.content).to eq("Cell content")
|
|
36
|
+
expect(entry.content).to eq(["Cell content"])
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
|
@@ -55,7 +55,7 @@ RSpec.describe Oasis::Etm::Entry do
|
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
it "generates valid XML" do
|
|
58
|
-
expect(entry.to_xml).to
|
|
58
|
+
expect(entry.to_xml).to be_xml_equivalent_to(xml)
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
|
|
@@ -81,21 +81,21 @@ RSpec.describe Oasis::Etm::Entry do
|
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
it "validates colsep values" do
|
|
84
|
-
entry = described_class.new(colsep: 2)
|
|
84
|
+
entry = described_class.new(colsep: "2")
|
|
85
85
|
errors = entry.validate
|
|
86
86
|
expect(errors).to match_array(
|
|
87
87
|
have_attributes(
|
|
88
|
-
message: /colsep is `2`, must be one of the following \[0, 1\]/,
|
|
88
|
+
message: /colsep is `2`, must be one of the following \[0, 1, yes, no\]/,
|
|
89
89
|
),
|
|
90
90
|
)
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
it "validates rowsep values" do
|
|
94
|
-
entry = described_class.new(rowsep: 2)
|
|
94
|
+
entry = described_class.new(rowsep: "2")
|
|
95
95
|
errors = entry.validate
|
|
96
96
|
expect(errors).to match_array(
|
|
97
97
|
have_attributes(
|
|
98
|
-
message: /rowsep is `2`, must be one of the following \[0, 1\]/,
|
|
98
|
+
message: /rowsep is `2`, must be one of the following \[0, 1, yes, no\]/,
|
|
99
99
|
),
|
|
100
100
|
)
|
|
101
101
|
end
|
data/spec/oasis/etm/row_spec.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
RSpec.describe Oasis::Etm::Row do
|
|
2
2
|
let(:xml) do
|
|
3
3
|
<<~XML
|
|
4
|
-
<row rowsep="1" valign="middle">
|
|
4
|
+
<row xmlns="http://docs.oasis-open.org/ns/oasis-exchange/table" rowsep="1" valign="middle">
|
|
5
5
|
<entry>Cell 1</entry>
|
|
6
6
|
<entry>Cell 2</entry>
|
|
7
7
|
<entry>Cell 3</entry>
|
|
@@ -13,13 +13,14 @@ RSpec.describe Oasis::Etm::Row do
|
|
|
13
13
|
subject(:row) { described_class.from_xml(xml) }
|
|
14
14
|
|
|
15
15
|
it "parses attributes" do
|
|
16
|
-
expect(row.rowsep).to eq(1)
|
|
16
|
+
expect(row.rowsep).to eq("1")
|
|
17
17
|
expect(row.valign).to eq("middle")
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
it "parses entries" do
|
|
21
21
|
expect(row.entries.size).to eq(3)
|
|
22
|
-
expect(row.entries.map(&:content)).to eq(["Cell 1", "Cell 2",
|
|
22
|
+
expect(row.entries.map(&:content)).to eq([["Cell 1"], ["Cell 2"],
|
|
23
|
+
["Cell 3"]])
|
|
23
24
|
end
|
|
24
25
|
end
|
|
25
26
|
|
|
@@ -37,7 +38,7 @@ RSpec.describe Oasis::Etm::Row do
|
|
|
37
38
|
end
|
|
38
39
|
|
|
39
40
|
it "generates valid XML" do
|
|
40
|
-
expect(row.to_xml).to
|
|
41
|
+
expect(row.to_xml).to be_xml_equivalent_to(xml)
|
|
41
42
|
end
|
|
42
43
|
end
|
|
43
44
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
RSpec.describe Oasis::Etm::Table do
|
|
2
2
|
let(:xml) do
|
|
3
3
|
<<~XML
|
|
4
|
-
<table frame="all" colsep="1" rowsep="1">
|
|
5
|
-
<title>Sample Table</title>
|
|
4
|
+
<table xmlns="http://docs.oasis-open.org/ns/oasis-exchange/table" frame="all" colsep="1" rowsep="1">
|
|
5
|
+
<title xmlns="">Sample Table</title>
|
|
6
6
|
<tgroup cols="3">
|
|
7
7
|
<colspec colnum="1" colwidth="1*"/>
|
|
8
8
|
<colspec colnum="2" colwidth="2*"/>
|
|
@@ -31,8 +31,8 @@ RSpec.describe Oasis::Etm::Table do
|
|
|
31
31
|
|
|
32
32
|
it "parses table attributes" do
|
|
33
33
|
expect(table.frame).to eq("all")
|
|
34
|
-
expect(table.colsep).to eq(1)
|
|
35
|
-
expect(table.rowsep).to eq(1)
|
|
34
|
+
expect(table.colsep).to eq("1")
|
|
35
|
+
expect(table.rowsep).to eq("1")
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
it "parses title" do
|
|
@@ -88,7 +88,7 @@ RSpec.describe Oasis::Etm::Table do
|
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
it "generates valid XML" do
|
|
91
|
-
expect(table.to_xml).to
|
|
91
|
+
expect(table.to_xml).to be_xml_equivalent_to(xml)
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
94
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
RSpec.describe Oasis::Etm::Tbody do
|
|
2
2
|
let(:xml) do
|
|
3
3
|
<<~XML
|
|
4
|
-
<tbody valign="top">
|
|
4
|
+
<tbody xmlns="http://docs.oasis-open.org/ns/oasis-exchange/table" valign="top">
|
|
5
5
|
<row>
|
|
6
6
|
<entry>Cell 1</entry>
|
|
7
7
|
<entry>Cell 2</entry>
|
|
@@ -21,7 +21,7 @@ RSpec.describe Oasis::Etm::Tbody do
|
|
|
21
21
|
it "parses rows" do
|
|
22
22
|
expect(tbody.rows.size).to eq(1)
|
|
23
23
|
expect(tbody.rows.first.entries.size).to eq(3)
|
|
24
|
-
expect(tbody.rows.first.entries.first.content).to eq("Cell 1")
|
|
24
|
+
expect(tbody.rows.first.entries.first.content).to eq(["Cell 1"])
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
@@ -42,7 +42,7 @@ RSpec.describe Oasis::Etm::Tbody do
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
it "generates valid XML" do
|
|
45
|
-
expect(tbody.to_xml).to
|
|
45
|
+
expect(tbody.to_xml).to be_xml_equivalent_to(xml)
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
RSpec.describe Oasis::Etm::Tgroup do
|
|
2
2
|
let(:xml) do
|
|
3
3
|
<<~XML
|
|
4
|
-
<tgroup cols="3" colsep="1" rowsep="1" align="center">
|
|
4
|
+
<tgroup xmlns="http://docs.oasis-open.org/ns/oasis-exchange/table" cols="3" colsep="1" rowsep="1" align="center">
|
|
5
5
|
<colspec colnum="1" colwidth="1*"/>
|
|
6
6
|
<colspec colnum="2" colwidth="2*"/>
|
|
7
7
|
<colspec colnum="3" colwidth="1*"/>
|
|
@@ -31,8 +31,8 @@ RSpec.describe Oasis::Etm::Tgroup do
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
it "parses optional attributes" do
|
|
34
|
-
expect(tgroup.colsep).to eq(1)
|
|
35
|
-
expect(tgroup.rowsep).to eq(1)
|
|
34
|
+
expect(tgroup.colsep).to eq("1")
|
|
35
|
+
expect(tgroup.rowsep).to eq("1")
|
|
36
36
|
expect(tgroup.align).to eq("center")
|
|
37
37
|
end
|
|
38
38
|
|
|
@@ -91,7 +91,7 @@ RSpec.describe Oasis::Etm::Tgroup do
|
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
it "generates valid XML" do
|
|
94
|
-
expect(tgroup.to_xml).to
|
|
94
|
+
expect(tgroup.to_xml).to be_xml_equivalent_to(xml)
|
|
95
95
|
end
|
|
96
96
|
end
|
|
97
97
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
RSpec.describe Oasis::Etm::Thead do
|
|
2
2
|
let(:xml) do
|
|
3
3
|
<<~XML
|
|
4
|
-
<thead valign="middle">
|
|
4
|
+
<thead xmlns="http://docs.oasis-open.org/ns/oasis-exchange/table" valign="middle">
|
|
5
5
|
<row>
|
|
6
6
|
<entry>Header 1</entry>
|
|
7
7
|
<entry>Header 2</entry>
|
|
@@ -21,7 +21,7 @@ RSpec.describe Oasis::Etm::Thead do
|
|
|
21
21
|
it "parses rows" do
|
|
22
22
|
expect(thead.rows.size).to eq(1)
|
|
23
23
|
expect(thead.rows.first.entries.size).to eq(3)
|
|
24
|
-
expect(thead.rows.first.entries.first.content).to eq("Header 1")
|
|
24
|
+
expect(thead.rows.first.entries.first.content).to eq(["Header 1"])
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
@@ -42,7 +42,7 @@ RSpec.describe Oasis::Etm::Thead do
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
it "generates valid XML" do
|
|
45
|
-
expect(thead.to_xml).to
|
|
45
|
+
expect(thead.to_xml).to be_xml_equivalent_to(xml)
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
end
|
data/spec/oasis/etm_spec.rb
CHANGED
|
@@ -14,17 +14,27 @@ RSpec.describe Oasis::Etm do
|
|
|
14
14
|
let(:xml_string) { File.read(file_path) }
|
|
15
15
|
|
|
16
16
|
it "performs lossless round-trip conversion" do
|
|
17
|
-
|
|
17
|
+
xml_content = xml_string.dup
|
|
18
|
+
|
|
19
|
+
# Remove <para> elements which are foreign elements not supported by the model
|
|
20
|
+
doc = Nokogiri::XML(xml_content)
|
|
21
|
+
doc.xpath("//para").remove
|
|
22
|
+
xml_content = doc.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
|
|
23
|
+
|
|
24
|
+
parsed = Oasis::Etm::Table.from_xml(xml_content)
|
|
18
25
|
generated = parsed.to_xml(
|
|
19
26
|
pretty: true,
|
|
20
27
|
declaration: true,
|
|
21
28
|
encoding: "utf-8",
|
|
22
29
|
)
|
|
23
30
|
|
|
24
|
-
|
|
25
|
-
|
|
31
|
+
# Model always adds xmlns to elements, so we need to add it to input for comparison
|
|
32
|
+
# Add xmlns="" to title since model outputs title with empty namespace
|
|
33
|
+
normalized_xml = xml_content
|
|
34
|
+
.gsub("<table", '<table xmlns="http://docs.oasis-open.org/ns/oasis-exchange/table"')
|
|
35
|
+
.gsub("<title>", '<title xmlns="">')
|
|
26
36
|
|
|
27
|
-
expect(generated).to be_analogous_with(
|
|
37
|
+
expect(generated).to be_analogous_with(normalized_xml)
|
|
28
38
|
end
|
|
29
39
|
end
|
|
30
40
|
end
|
|
@@ -38,17 +48,28 @@ RSpec.describe Oasis::Etm do
|
|
|
38
48
|
let(:xml_string) { File.read(file_path) }
|
|
39
49
|
|
|
40
50
|
it "performs lossless round-trip conversion" do
|
|
41
|
-
|
|
51
|
+
xml_content = xml_string.dup
|
|
52
|
+
|
|
53
|
+
# Normalize FPI namespace URI to URN for Canon compatibility
|
|
54
|
+
xml_content = xml_content.gsub(
|
|
55
|
+
'xmlns:oasis="-//OASIS//DTD XML Exchange Table Model 19990315//EN"',
|
|
56
|
+
'xmlns:oasis="urn:oasis:names:tc:xml:table"',
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
# Remove <bold> elements which are foreign elements not supported by the model
|
|
60
|
+
doc = Nokogiri::XML(xml_content)
|
|
61
|
+
doc.xpath("//bold").remove
|
|
62
|
+
xml_content = doc.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
|
|
63
|
+
|
|
64
|
+
parsed = Oasis::Etm::Table.from_xml(xml_content)
|
|
42
65
|
generated = parsed.to_xml(
|
|
66
|
+
prefix: true,
|
|
43
67
|
pretty: true,
|
|
44
68
|
declaration: true,
|
|
45
69
|
encoding: "utf-8",
|
|
46
70
|
)
|
|
47
71
|
|
|
48
|
-
|
|
49
|
-
.gsub(/^<\?xml.*\n/, "")
|
|
50
|
-
|
|
51
|
-
expect(generated).to be_analogous_with(cleaned_xml_string)
|
|
72
|
+
expect(generated).to be_analogous_with(xml_content)
|
|
52
73
|
end
|
|
53
74
|
end
|
|
54
75
|
end
|
|
@@ -62,17 +83,24 @@ RSpec.describe Oasis::Etm do
|
|
|
62
83
|
let(:xml_string) { File.read(file_path) }
|
|
63
84
|
|
|
64
85
|
it "performs lossless round-trip conversion" do
|
|
65
|
-
|
|
86
|
+
xml_content = xml_string.dup
|
|
87
|
+
|
|
88
|
+
if file_path.include?("niso-jats-table-wrap.xml")
|
|
89
|
+
# Remove <xref> elements which are foreign elements not supported by the model
|
|
90
|
+
doc = Nokogiri::XML(xml_content)
|
|
91
|
+
doc.xpath("//xref").remove
|
|
92
|
+
xml_content = doc.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
parsed = Oasis::Etm::Table.from_xml(xml_content)
|
|
66
96
|
generated = parsed.to_xml(
|
|
97
|
+
prefix: true,
|
|
67
98
|
pretty: true,
|
|
68
99
|
declaration: true,
|
|
69
100
|
encoding: "utf-8",
|
|
70
101
|
)
|
|
71
102
|
|
|
72
|
-
|
|
73
|
-
.gsub(/^<\?xml.*\n/, "")
|
|
74
|
-
|
|
75
|
-
expect(generated).to be_analogous_with(cleaned_xml_string)
|
|
103
|
+
expect(generated).to be_analogous_with(xml_content)
|
|
76
104
|
end
|
|
77
105
|
end
|
|
78
106
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
require "nokogiri"
|
|
5
|
-
require "xml-c14n"
|
|
3
|
+
require_relative "../lib/oasis-etm"
|
|
6
4
|
|
|
7
5
|
# Require all support files
|
|
8
|
-
Dir[File.join(__dir__, "support", "**", "*.rb")].each
|
|
6
|
+
Dir[File.join(__dir__, "support", "**", "*.rb")].each do |f|
|
|
7
|
+
require f
|
|
8
|
+
end
|
|
9
9
|
|
|
10
10
|
RSpec.configure do |config|
|
|
11
11
|
# Enable flags like --only-failures and --next-failure
|
|
@@ -19,13 +19,13 @@ RSpec.configure do |config|
|
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
require "
|
|
23
|
-
require "lutaml/model/xml_adapter/nokogiri_adapter"
|
|
24
|
-
require "lutaml/model/json_adapter/standard_json_adapter"
|
|
25
|
-
require "lutaml/model/yaml_adapter/standard_yaml_adapter"
|
|
26
|
-
|
|
22
|
+
require "nokogiri"
|
|
27
23
|
Lutaml::Model::Config.configure do |config|
|
|
28
|
-
config.
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
config.xml_adapter_type = :nokogiri
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
require "canon"
|
|
28
|
+
Canon::Config.configure do |config|
|
|
29
|
+
config.xml.match.profile = :spec_friendly
|
|
30
|
+
config.xml.diff.use_color = true
|
|
31
31
|
end
|
metadata
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: oasis-etm
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-04-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: lutaml-model
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 0.8.0
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - "
|
|
24
|
+
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
26
|
+
version: 0.8.0
|
|
27
27
|
description: 'Library for manipulation of OASIS Exchange Table Model XML.
|
|
28
28
|
|
|
29
29
|
'
|
|
@@ -39,6 +39,7 @@ files:
|
|
|
39
39
|
- ".rspec"
|
|
40
40
|
- ".rubocop.yml"
|
|
41
41
|
- ".rubocop_todo.yml"
|
|
42
|
+
- CLAUDE.md
|
|
42
43
|
- CODE_OF_CONDUCT.md
|
|
43
44
|
- Gemfile
|
|
44
45
|
- README.adoc
|
|
@@ -49,6 +50,7 @@ files:
|
|
|
49
50
|
- lib/oasis/etm.rb
|
|
50
51
|
- lib/oasis/etm/colspec.rb
|
|
51
52
|
- lib/oasis/etm/entry.rb
|
|
53
|
+
- lib/oasis/etm/namespace.rb
|
|
52
54
|
- lib/oasis/etm/row.rb
|
|
53
55
|
- lib/oasis/etm/table.rb
|
|
54
56
|
- lib/oasis/etm/tbody.rb
|
|
@@ -57,7 +59,6 @@ files:
|
|
|
57
59
|
- lib/oasis/etm/thead.rb
|
|
58
60
|
- lib/oasis/etm/version.rb
|
|
59
61
|
- oasis-etm.gemspec
|
|
60
|
-
- oasis-etm_wrapped.txt
|
|
61
62
|
- sig/oasis/etm.rbs
|
|
62
63
|
- spec/fixtures/isosts/isosts_tables.cals.01.xml
|
|
63
64
|
- spec/fixtures/isosts/isosts_tables.cals.02.xml
|