Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
# See https://github.com/metanorma/cimas
name: release

permissions:
contents: write
packages: write
id-token: write

on:
workflow_dispatch:
inputs:
Expand All @@ -16,10 +21,8 @@ on:

jobs:
release:
uses: metanorma/ci/.github/workflows/rubygems-release.yml@main
uses: relaton/support/.github/workflows/release.yml@main
with:
next_version: ${{ github.event.inputs.next_version }}
secrets:
rubygems-api-key: ${{ secrets.METANORMA_CI_RUBYGEMS_API_KEY }}
pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}

rubygems-api-key: ${{ secrets.LUTAML_CI_RUBYGEMS_API_KEY }}
23 changes: 17 additions & 6 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
AllCops:
TargetRubyVersion: 3.0
# Auto-generated by Cimas: Do not edit it manually!
# See https://github.com/metanorma/cimas
inherit_from:
- https://raw.githubusercontent.com/riboseinc/oss-guides/main/ci/rubocop.yml
- .rubocop_todo.yml

inherit_mode:
merge:
- Exclude

Style/StringLiterals:
EnforcedStyle: double_quotes
# local repo-specific modifications
# ...
plugins:
- rubocop-rspec
- rubocop-performance
- rubocop-rake

Style/StringLiteralsInInterpolation:
EnforcedStyle: double_quotes
AllCops:
TargetRubyVersion: 3.0
241 changes: 241 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2026-04-01 07:11:02 UTC using RuboCop version 1.86.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: 17
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation.
Bundler/OrderedGems:
Exclude:
- 'Gemfile'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation.
Gemspec/OrderedDependencies:
Exclude:
- 'reqif.gemspec'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Gemspec/RequireMFA:
Exclude:
- 'reqif.gemspec'

# Offense count: 63
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: with_first_argument, with_fixed_indentation
Layout/ArgumentAlignment:
Exclude:
- 'lib/reqif.rb'
- 'lib/reqif/datatypes.rb'
- 'lib/reqif/default_value.rb'
- 'lib/reqif/definition.rb'
- 'lib/reqif/doors/readonly_attributes.rb'
- 'lib/reqif/editable_atts.rb'
- 'lib/reqif/reqif_float.rb'
- 'lib/reqif/spec_attributes.rb'
- 'lib/reqif/type.rb'
- 'lib/reqif/values.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
Layout/ClosingParenthesisIndentation:
Exclude:
- 'spec/reqif/polarion_export_spec.rb'
- 'spec/spec_helper.rb'

# Offense count: 22
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowForAlignment.
Layout/CommentIndentation:
Exclude:
- 'lib/reqif/doors/module_definition.rb'
- 'lib/reqif/doors/readonly_attributes.rb'
- 'lib/reqif/doors/rif_definition.rb'
- 'lib/reqif/req_if_tool_extension.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Layout/ElseAlignment:
Exclude:
- 'spec/spec_helper.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only
Layout/EmptyLinesAroundClassBody:
Exclude:
- 'lib/reqif/req_if_tool_extension.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
Layout/FirstArgumentIndentation:
Exclude:
- 'spec/reqif/polarion_export_spec.rb'
- 'spec/spec_helper.rb'

# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: normal, indented_internal_methods
Layout/IndentationConsistency:
Exclude:
- 'lib/reqif/doors/readonly_attributes.rb'
- 'reqif.gemspec'

# Offense count: 10
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Width, EnforcedStyleAlignWith, AllowedPatterns.
# SupportedStylesAlignWith: start_of_line, relative_to_receiver
Layout/IndentationWidth:
Exclude:
- 'lib/reqif/doors/readonly_attributes.rb'
- 'spec/spec_helper.rb'

# Offense count: 78
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
# URISchemes: http, https
Layout/LineLength:
Enabled: false

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: symmetrical, new_line, same_line
Layout/MultilineMethodCallBraceLayout:
Exclude:
- 'spec/reqif/polarion_export_spec.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: aligned, indented
Layout/MultilineOperationIndentation:
Exclude:
- 'spec/reqif_spec.rb'

# Offense count: 8
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: final_newline, final_blank_line
Layout/TrailingEmptyLines:
Exclude:
- 'lib/reqif/doors/identifier.rb'
- 'lib/reqif/doors/module_definition.rb'
- 'lib/reqif/doors/namespace.rb'
- 'lib/reqif/doors/readonly_attributes.rb'
- 'lib/reqif/doors/rif_definition.rb'
- 'lib/reqif/doors/string_type.rb'
- 'lib/reqif/string_type.rb'
- 'lib/reqif/xhtml/namespace.rb'

# Offense count: 63
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowInHeredoc.
Layout/TrailingWhitespace:
Exclude:
- 'lib/reqif.rb'
- 'lib/reqif/datatypes.rb'
- 'lib/reqif/default_value.rb'
- 'lib/reqif/definition.rb'
- 'lib/reqif/doors/readonly_attributes.rb'
- 'lib/reqif/editable_atts.rb'
- 'lib/reqif/reqif_float.rb'
- 'lib/reqif/spec_attributes.rb'
- 'lib/reqif/type.rb'
- 'lib/reqif/values.rb'

# Offense count: 1
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
# AllowedMethods: refine
Metrics/BlockLength:
Max: 90

# Offense count: 1
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
Metrics/CyclomaticComplexity:
Exclude:
- 'lib/reqif/reqif_float.rb'

# Offense count: 3
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 12

# Offense count: 1
# Configuration parameters: IgnoredMetadata.
RSpec/DescribeClass:
Exclude:
- 'spec/reqif/polarion_export_spec.rb'

# Offense count: 4
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 11

# Offense count: 11
RSpec/MultipleExpectations:
Max: 8

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: not_to, to_not
RSpec/NotToNot:
Exclude:
- 'spec/reqif/polarion_export_spec.rb'

# Offense count: 2
# Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata, InflectorPath, EnforcedInflector.
# SupportedInflectors: default, active_support
RSpec/SpecFilePathFormat:
Exclude:
- 'spec/reqif/data_types_spec.rb'
- 'spec/reqif/tool_extension_spec.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: separated, grouped
Style/AccessorGrouping:
Exclude:
- 'lib/reqif/high_precision_date_time.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowIfModifier.
Style/IfInsideElse:
Exclude:
- 'spec/spec_helper.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/MultilineIfModifier:
Exclude:
- 'lib/reqif/reqif_float.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Exclude:
- 'reqif.gemspec'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
Style/TrailingCommaInArguments:
Exclude:
- 'spec/reqif/req_if_spec.rb'
73 changes: 73 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Overview

This is a Ruby gem (`reqif`) that parses and generates ReqIF (Requirements Interchange Format) XML documents. ReqIF is an OMG standard (v1.2) for exchanging requirements between different tools. The gem is part of the `lutaml` family.

## Commands

```bash
bundle install # Install dependencies
bundle exec rake # Run specs + rubocop (default)
bundle exec rake spec # Run specs only
bundle exec rake rubocop # Run linter only
bundle exec rspec spec/reqif_spec.rb # Run a single spec file
bundle exec bin/console # Start an IRB console with the gem loaded
```

## Architecture

### Framework: lutaml/model

All model classes inherit from `Lutaml::Model::Serializable` and use an `xml` DSL block to define XML serialization. The gem uses `Lutaml::Model::XmlAdapter::NokogiriAdapter` for XML parsing/generation.

### Class-per-file pattern

Each ReqIF concept is a separate class in `lib/reqif/`. Classes follow a consistent structure:

```ruby
module Reqif
class Foo < Lutaml::Model::Serializable
attribute :bar, :string
attribute :baz, SomeOtherClass

xml do
element "FOO"
namespace "http://www.omg.org/spec/ReqIF/20110401/reqif.xsd"
map_attribute "BAR", to: :bar
map_element "BAZ", to: :baz
end
end
end
```

### Key model classes

- `ReqIf` — Root element, contains `THE-HEADER`, `CORE-CONTENT`, `TOOL-EXTENSIONS`
- `ReqIfContent` — Contains `DATATYPES`, `SPEC-TYPES`, `SPEC-OBJECTS`, `SPEC-RELATIONS`, `SPECIFICATIONS`, `SPEC-RELATION-GROUPS`
- `SpecObject` — A single requirement with attributes (identifier, long_name, desc, etc.) and `VALUES`
- `Specification` — A container/hierarchy that has `CHILDREN` referencing other specs
- `SpecRelation` — A relation between two specs with `SOURCE` and `TARGET` references
- `Values` — Container for `AttributeValue` elements (boolean, date, enumeration, integer, real, string, xhtml)
- `Type` / `SpecObjectType` / `SpecificationType` — Type definitions for spec objects/specifications
- `Datatypes` — Container for datatype definitions (boolean, date, enumeration, integer, real, string, xhtml)

### Attribute naming conventions

XML element names use uppercase-kebab-case (e.g., `SPEC-OBJECT`, `LAST-CHANGE`) while Ruby attributes use snake_case (e.g., `spec_object`, `last_change`). The `map_element` and `map_attribute` DSL methods handle the translation.

### Autoloading

Zeitwerk is used for autoloading. `lib/reqif.rb` sets up the loader and eager loads all classes.

### XML round-trip testing

Round-trip tests in `spec/reqif_spec.rb` parse fixture XML files, regenerate XML via `to_xml`, and compare canonicalization using `xml-c14n`. All fixture files under `spec/fixtures/` (`.xml`, `.reqif`) are automatically included.

### Style

- String literals: double quotes enforced by RuboCop
- Ruby version: 3.0+
- Frozen string literals: required at the top of every file
7 changes: 5 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ source "https://rubygems.org"
# Specify your gem's dependencies in reqif.gemspec
gemspec

gem "canon"
gem "lutaml-model", github: "lutaml/lutaml-model", branch: "main"
gem "nokogiri"
gem "rake", "~> 13.0"
gem "rspec", "~> 3.0"
gem "rubocop", "~> 1.21"
gem "nokogiri"
gem "rubocop-performance"
gem "xml-c14n"
gem "rubocop-rake"
gem "rubocop-rspec"
Loading
Loading