spdx.cr

A Crystal implementation of the SPDX (Software Package Data Exchange) specification. Parse, validate, and manipulate SPDX license expressions and documents with type-safe Crystal code.

Implements SPDX 2.3 with full license expression parsing, document model, Tag-Value and JSON format support.

Overview

spdx.cr provides a Crystal library and CLI tool for working with SPDX -- the open standard for communicating software bill of materials (SBOM) information. It supports parsing license expressions, querying the official SPDX license list, and reading/writing SPDX documents in both Tag-Value and JSON formats.

Features

Installation

Add spdx.cr to your shard.yml:

dependencies:
  spdx:
    github: hahwul/spdx.cr

Then run:

shards install

Quick Example

require "spdx"

# Parse a license expression
ast = Spdx.parse("MIT AND Apache-2.0")
puts ast  # => MIT AND Apache-2.0

# Check if an expression is valid
Spdx.valid_expression?("MIT OR GPL-2.0-only")  # => true

# Look up a license
lic = Spdx.find_license("MIT")
puts lic.name          # => "MIT License"
puts lic.osi_approved? # => true