lutaml / expressir

Ruby parser for the ISO EXPRESS language
3 stars 3 forks source link

= Expressir: EXPRESS in Ruby

image:https://img.shields.io/gem/v/expressir.svg["Gem Version", link="https://rubygems.org/gems/expressir"] // image:https://codeclimate.com/github/lutaml/expressir/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/lutaml/expressir"] image:https://github.com/lutaml/expressir/workflows/rake/badge.svg["Build Status", link="https://github.com/lutaml/expressir/actions?workflow=rake"]

== Purpose

Expressir ("EXPRESS in Ruby") is a Ruby parser for EXPRESS and a set of Ruby tools for accessing ISO EXPRESS data models.

== Architecture

Expressir consists of 3 parts:

. Parsers. A parser allows Expressir to read EXPRESS files, including:

EXPRESS data modelling language (ISO 10303-11:2007) EXPRESS data modelling language in XML (STEPmod) ** EXPRESS XML (ISO 10303-28:2007) "Industrial automation systems and integration — Product data representation and exchange — Part 28: Implementation methods: XML representations of EXPRESS schemas and data, using XML schemas")

. Data model. The data model (lib/expressir/express) is the Ruby data model that fully represents an EXPRESS data model.

. Converters. A converter transforms the EXPRESS Ruby data model into an interoperable export format, including: EXPRESS data modelling language (ISO 10303-11:2007) W3C OWL OMG SysML (XMI 2.1, XMI 2.5) OMG UML 2 (XMI 2.1) ** OMG UML 2 for Eclipse (XMI 2.1)

== Usage

This gem ships with a CLI tool. To check what's available you can simply run the script directly from exe/expressir, by default it will display some usage instructions.

[source, sh]

$ expressir

Commands: expressir format PATH # pretty print EXPRESS schema located at PATH expressir help [COMMAND] # Describe available commands or one specific command expressir version # The Expressir Version

=== Pretty print

[source, sh]

expressir format schemas/resources/action_schema/action_schema.exp

== Development

We are following Sandi Metz's Rules for this gem, you can read the http://robots.thoughtbot.com/post/50655960596/sandi-metz-rules-for-developers[description of the rules here] All new code should follow these rules. If you make changes in a pre-existing file that violates these rules you should fix the violations as part of your contribution.

=== Setup

Clone the repository.

[source, sh]

git clone https://github.com/metanorma/expressir

Setup your environment.

[source, sh]

bin/setup git submodule update --init bundle exec rake generate bundle exec rake compile

Run the test suite

[source, sh]

bundle exec rake

=== Grammar updates

THe EXPRESS grammar is lined as Git submodule at ext/express-grammar.

Should you update it, please run rake generate. This command will generate source code for updated native extension using the antlr4-native gem. Please note that we create several classes on top of antlr4-native output so using embedded rake task is a real requirement.

When a new extension is generated and tested, please check in updated C++ files to git (rake generate is NOT a CI step, extension source files are pulled from the repo).

== Installation

Add this line to your application's Gemfile:

[source, sh]

gem "expressir"

And then execute:

[source, sh]

$ bundle install

Or install it yourself as:

[source, sh]

$ gem install expressir

== Usage

=== Filtering out schemas

Use the select_proc argument of to_hash.

Example:

[source,ruby]

schema_yaml = YAML.load_file('documents/iso-10303-41/schemas.yaml') schema_paths = schema_yaml['schemas'].map {|x,y| y['path'].gsub("../../", "")}

repo = Expressir::Express::Parser.from_files(schema_paths)

filtered_schemas = ["action_schema", "date_time_schema"] select_proc = Proc.new do |value| if value.is_a?(Expressir::Model::Declarations::Schema) filtered_schemas.include?(value.id) else true end end

repo_hash = repo.to_hash(select_proc: select_proc) schemas = repo_hash['schemas'] schemas.map {|s| s["id"] }

== Contributing

First, thank you for contributing! We love pull requests from everyone. By participating in this project, you hereby grant https://www.ribose.com[Ribose Inc.] the right to grant or transfer an unlimited number of non exclusive licenses or sub-licenses to third parties, under the copyright covering the contribution to use the contribution by all means.

Here are a few technical guidelines to follow:

== License

Expressir is distributed under the BSD 2-clause license.

Expressir originally contained some code from the NIST Reeper project but has been completely rewritten.

The https://www.nist.gov/services-resources/software/reeper[NIST Reeper license] is reproduced below:

[quote]


This software was funded by NIST and developed by EuroSTEP. Pursuant to title 17 Section 105 of the United States Code this software is not subject to copyright protection and is in the public domain.

We would appreciate acknowledgment if the software is used. Links to non-Federal Government Web sites do not imply NIST endorsement of any particular product, service, organization, company, information provider, or content.


== Credits

Copyright Ribose Inc.