ali 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87c6eabd67795103f67548a9d919c6d32f18f33cff4031732af54d5d476793e6
4
- data.tar.gz: '0813d3011868515c36890d1ff33252b7f085b67556865ca83d91da4dddab19b5'
3
+ metadata.gz: eeb297b558c72b7706c4c675da5fe39006dc820e6f0cb8df9d86d736acd64f6e
4
+ data.tar.gz: 136e95f155e967005e362312bf3b595634e045c8a7463a6367e194bb7e0e01ff
5
5
  SHA512:
6
- metadata.gz: 5e2a51ca271a68b902b7271b136112d5044f54a1b4b94ad7880818c7587aedc4d9745a88d61b991c38a5748acf40f1c227f0c725c175e2bf0b8afefd46f4eb63
7
- data.tar.gz: 4b3d02847bd0d2afab3a9d44af3c25f02a6a63a43493f7c722db9ca6304990923efb0ec8e1a6afce38a8d0e020078d743827ae04442aa747724c4748dcde5e30
6
+ metadata.gz: 635a1fb88345c73d0f6da4f1d678e165b238ba521d7b176c87eb5165f3d8ba74a68ebc32247dd18d5a7059010ee5549c4dfea04aed774377450be3babc592f04
7
+ data.tar.gz: eb532ef7c414c0bc6685fb250edc0dafc3d124703233168e69a8ad8d561854423d648c409a33685dd3e5b1d1a18b305d128d07f525b414644ba5ee90f837eb98
@@ -9,4 +9,8 @@ on:
9
9
 
10
10
  jobs:
11
11
  rake:
12
- uses: metanorma/ci/.github/workflows/graphviz-rake.yml@main
12
+ uses: metanorma/ci/.github/workflows/generic-rake.yml@main
13
+ with:
14
+ setup-tools: graphviz
15
+ submodules: true
16
+ choco-cache: true
@@ -11,6 +11,11 @@ on:
11
11
  push:
12
12
  tags: [ v* ]
13
13
 
14
+ permissions:
15
+ contents: write
16
+ id-token: write
17
+ pull-requests: write
18
+
14
19
  jobs:
15
20
  release:
16
21
  uses: metanorma/ci/.github/workflows/rubygems-release.yml@main
data/.gitignore CHANGED
@@ -9,3 +9,5 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+
13
+ Gemfile.lock
data/.rubocop_todo.yml CHANGED
@@ -1,14 +1,12 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2024-10-30 08:03:48 UTC using RuboCop version 1.67.0.
3
+ # on 2026-04-20 07:55:01 UTC using RuboCop version 1.86.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
9
  # Offense count: 1
10
- # Configuration parameters: Severity, Include.
11
- # Include: **/*.gemspec
12
10
  Gemspec/RequiredRubyVersion:
13
11
  Exclude:
14
12
  - 'ali.gemspec'
data/CLAUDE.md ADDED
@@ -0,0 +1,34 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ This is the `ali` Ruby gem — an implementation of the [NISO Access and License Indicators (ALI) Schemas](https://www.niso.org/schemas/ali/1.0) (NISO RP 22-2021). It parses and generates ALI data in both XML and JSON-LD formats. The gem is used by the `niso-jats` gem.
8
+
9
+ ## Commands
10
+
11
+ - **Run all tests and lint:** `bundle exec rake` (default task runs `spec` then `rubocop`)
12
+ - **Run tests only:** `bundle exec rspec`
13
+ - **Run a single test file:** `bundle exec rspec spec/ali/free_to_read_spec.rb`
14
+ - **Run a single test by line:** `bundle exec rspec spec/ali/free_to_read_spec.rb:15`
15
+ - **Lint only:** `bundle exec rubocop`
16
+
17
+ ## Architecture
18
+
19
+ All model classes inherit from `Lutaml::Model::Serializable` (from the `lutaml-model` gem) and declare attributes + XML/JSON mappings using its DSL.
20
+
21
+ - **`Ali::FreeToRead`** — `free_to_read` element. Attributes: `start_date` (date), `end_date` (date).
22
+ - **`Ali::LicenseRef`** — `license_ref` element. Attributes: `start_date` (date), `applies_to` (string), `uri` (string, mapped from XML text content).
23
+ - **`Ali::Container`** — Root container for JSON-LD usage only (not part of the NISO ALI spec). Contains collections of `FreeToRead` and `LicenseRef`.
24
+
25
+ XML namespace for all elements: `http://www.niso.org/schemas/ali/1.0/`
26
+
27
+ The adapter configuration (Nokogiri for XML, standard library for JSON/YAML) is set up in `spec/spec_helper.rb`.
28
+
29
+ ## Key Details
30
+
31
+ - `LicenseRef#uri` is mapped from XML element *content* (`map_content`), not an attribute.
32
+ - XML tests use `be_xml_equivalent_to` (from `lutaml-model`) for XML comparison; JSON tests use `eq` on strings.
33
+ - Ruby >= 3.0.0 required.
34
+ - CI uses reusable workflows from `metanorma/ci` (generic-rake, rubygems-release).
data/Gemfile CHANGED
@@ -5,9 +5,10 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in reqif.gemspec
6
6
  gemspec
7
7
 
8
+ gem "canon"
9
+ gem "lutaml-model", github: "lutaml/lutaml-model", branch: "main"
8
10
  gem "nokogiri"
9
11
  gem "rake", "~> 13.0"
10
12
  gem "rspec", "~> 3.0"
11
13
  gem "rubocop", "~> 1.21"
12
14
  gem "rubocop-performance"
13
- gem "xml-c14n"
data/ali.gemspec CHANGED
@@ -31,5 +31,5 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  spec.required_ruby_version = ">= 3.0.0"
33
33
 
34
- spec.add_dependency "lutaml-model"
34
+ spec.add_dependency "lutaml-model", "~> 0.8.0"
35
35
  end
data/lib/ali/container.rb CHANGED
@@ -9,14 +9,14 @@ module Ali
9
9
  attribute :license_ref, LicenseRef, collection: true
10
10
 
11
11
  xml do
12
- root "ali-container"
13
- namespace "http://www.niso.org/schemas/ali/1.0/"
12
+ element "ali-container"
13
+ namespace Namespace
14
14
 
15
15
  map_element "free_to_read", to: :free_to_read
16
16
  map_element "license_ref", to: :license_ref
17
17
  end
18
18
 
19
- json do
19
+ key_value do
20
20
  map "free_to_read", to: :free_to_read
21
21
  map "license_ref", to: :license_ref
22
22
  end
@@ -6,14 +6,14 @@ module Ali
6
6
  attribute :end_date, :date
7
7
 
8
8
  xml do
9
- root "free_to_read"
10
- namespace "http://www.niso.org/schemas/ali/1.0/"
9
+ element "free_to_read"
10
+ namespace Namespace
11
11
 
12
12
  map_attribute "start_date", to: :start_date
13
13
  map_attribute "end_date", to: :end_date
14
14
  end
15
15
 
16
- json do
16
+ key_value do
17
17
  map "start_date", to: :start_date
18
18
  map "end_date", to: :end_date
19
19
  end
@@ -7,15 +7,15 @@ module Ali
7
7
  attribute :uri, :string
8
8
 
9
9
  xml do
10
- root "license_ref"
11
- namespace "http://www.niso.org/schemas/ali/1.0/"
10
+ element "license_ref"
11
+ namespace Namespace
12
12
 
13
13
  map_attribute "start_date", to: :start_date
14
14
  map_attribute "applies_to", to: :applies_to
15
15
  map_content to: :uri
16
16
  end
17
17
 
18
- json do
18
+ key_value do
19
19
  map "start_date", to: :start_date
20
20
  map "applies_to", to: :applies_to
21
21
  map "uri", to: :uri
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ali
4
+ class Namespace < Lutaml::Xml::Namespace
5
+ uri "http://www.niso.org/schemas/ali/1.0/"
6
+ prefix_default "ali"
7
+ end
8
+ end
data/lib/ali/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ali
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/ali.rb CHANGED
@@ -1,14 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "ali/version"
4
3
  require "lutaml/model"
5
4
 
6
5
  module Ali
7
6
  class Error < StandardError; end
8
7
 
9
- # Your code goes here...
8
+ autoload :FreeToRead, "ali/free_to_read"
9
+ autoload :LicenseRef, "ali/license_ref"
10
+ autoload :Container, "ali/container"
11
+ autoload :Namespace, "ali/namespace"
12
+ autoload :Version, "ali/version"
10
13
  end
11
-
12
- require_relative "ali/free_to_read"
13
- require_relative "ali/license_ref"
14
- require_relative "ali/container"
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ali
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.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: 2024-10-30 00:00:00.000000000 Z
11
+ date: 2026-04-20 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: '0'
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: '0'
26
+ version: 0.8.0
27
27
  description: A Ruby library for parsing and generating NISO Access and License Indicators
28
28
  (ALI) Schemas data
29
29
  email:
@@ -38,6 +38,7 @@ files:
38
38
  - ".rspec"
39
39
  - ".rubocop.yml"
40
40
  - ".rubocop_todo.yml"
41
+ - CLAUDE.md
41
42
  - Gemfile
42
43
  - README.adoc
43
44
  - Rakefile
@@ -48,6 +49,7 @@ files:
48
49
  - lib/ali/container.rb
49
50
  - lib/ali/free_to_read.rb
50
51
  - lib/ali/license_ref.rb
52
+ - lib/ali/namespace.rb
51
53
  - lib/ali/version.rb
52
54
  - sig/ali.rbs
53
55
  homepage: https://github.com/lutaml/ali