Skip to content

Commit

Permalink
feat: initial functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
ronaldtse committed Nov 1, 2024
1 parent f716501 commit cd7dada
Show file tree
Hide file tree
Showing 31 changed files with 794 additions and 516 deletions.
24 changes: 24 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-11-01 07:12:25 UTC using RuboCop version 1.68.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# URISchemes: http, https
Layout/LineLength:
Exclude:
- 'spec/oasis/etm/entry_spec.rb'

# Offense count: 6
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 10

# Offense count: 12
RSpec/MultipleExpectations:
Max: 10
7 changes: 5 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ source "https://rubygems.org"
# Specify your gem's dependencies in oasis-etm.gemspec
gemspec

gem "nokogiri"
gem "rake", "~> 13.0"

gem "rspec", "~> 3.0"

gem "rubocop", "~> 1.21"
gem "rubocop-performance"
gem "rubocop-rake"
gem "rubocop-rspec"
gem "xml-c14n"
90 changes: 44 additions & 46 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,42 +1,4 @@
= OASIS Exchange Table Model library

https://github.com/lutaml/oasis-etm[image:https://img.shields.io/github/stars/lutaml/oasis-etm.svg?style=social[GitHub Stars]]
https://github.com/lutaml/oasis-etm[image:https://img.shields.io/github/forks/lutaml/oasis-etm.svg?style=social[GitHub Forks]]
image:https://img.shields.io/github/license/lutaml/oasis-etm.svg[License]
image:https://img.shields.io/github/actions/workflow/status/lutaml/oasis-etm/test.yml?branch=main[Build Status]
image:https://img.shields.io/gem/v/oasis-etm.svg[RubyGems Version]

== Purpose


== Features


== Installation

Add this line to your application's Gemfile:

[source,ruby]
----
gem 'oasis-etm'
----

And then execute:

[source,shell]
----
bundle install
----

Or install it yourself as:

[source,shell]
----
gem install oasis-etm
----

= OASIS Exchange Table Model (ETM) Parser
:source-highlighter: rouge
:toc: macro
:toclevels: 3

Expand All @@ -48,8 +10,26 @@ toc::[]

== Purpose

Ruby library to parse and create OASIS Exchange Table Model (ETM) formatted tables.
This library provides a Ruby implementation of the OASIS Technical Resolution TR 9503:1995.
The OASIS ETM format is a simple XML format for representing tables for
exchange. It is used in the DocBook and NISO JATS standards.

This library provides a Ruby implementation of the
https://www.oasis-open.org/specs/a503.htm[OASIS Technical Resolution TR 9503:1995].

== Features

* Full implementation of the OASIS Exchange Table Model TR 9503:1995
* Intentionally excludes CALS table features not part of the Exchange subset (like `tfoot`)
* XML serialization and deserialization
* Validation of attribute values
* Support for all Exchange Table Model elements:
** `table`
** `tgroup`
** `colspec`
** `thead`
** `tbody`
** `row`
** `entry`

== Installation

Expand All @@ -62,22 +42,22 @@ gem 'oasis-etm'

And then execute:

[source,sh]
[source,shell]
----
$ bundle install
bundle install
----

Or install it yourself as:

[source,sh]
[source,shell]
----
$ gem install oasis-etm
gem install oasis-etm
----


== Usage

=== Basic Example
=== Basic example

[source,ruby]
----
Expand Down Expand Up @@ -119,7 +99,7 @@ table = Oasis::Etm::Table.new(
xml = table.to_xml
----

=== XML Schema
=== XML schema

The OASIS ETM format follows this basic structure:

Expand Down Expand Up @@ -149,6 +129,24 @@ The OASIS ETM format follows this basic structure:
</table>
----

== Development

=== Test files

`spec/fixtures/native/docbook_example.xml`::
https://tdg.docbook.org/tdg/4.5/table

`spec/fixtures/niso-jats/niso-jats-table-wrap.xml`::
https://jats.nlm.nih.gov/options/OASIS/tag-library/19990315/element/oasis-table.html
This is to test the OASIS exchange table model when it is namespaced from
another location.

`spec/fixtures/isosts/isosts_tables.cals.{nn}.xml`::
Tables extracted from https://www.iso.org/schema/isosts/cals/test/isosts_tables.cals.xml.
This is to test the OASIS exchange table model when it is namespaced from
another location.


== Contributing

Bug reports and pull requests are welcome. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
Expand Down
2 changes: 1 addition & 1 deletion lib/oasis/etm/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Entry < Lutaml::Model::Serializable
attribute :valign, :string, values: %w[top middle bottom]

# Content
attribute :content, :string
attribute :content, :string, raw: true

xml do
root "entry"
Expand Down
2 changes: 1 addition & 1 deletion lib/oasis/etm/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Table < Lutaml::Model::Serializable
attribute :tgroups, Tgroup, collection: true

xml do
root "table"
root "table", ordered: true

# Frame mappings
map_attribute "frame", to: :frame
Expand Down
2 changes: 1 addition & 1 deletion lib/oasis/etm/tgroup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Tgroup < Lutaml::Model::Serializable
attribute :tbody, Tbody

xml do
root "tgroup"
root "tgroup", ordered: true

# Attribute mappings
map_attribute "cols", to: :cols
Expand Down
Loading

0 comments on commit cd7dada

Please sign in to comment.