{"id":19339029,"url":"https://github.com/librariesio/spdx","last_synced_at":"2025-04-23T01:31:32.457Z","repository":{"id":26919039,"uuid":"30381157","full_name":"librariesio/spdx","owner":"librariesio","description":":copyright: A SPDX license normalizer","archived":false,"fork":false,"pushed_at":"2025-03-03T15:52:50.000Z","size":295,"stargazers_count":38,"open_issues_count":2,"forks_count":8,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-15T16:03:13.765Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://libraries.io/rubygems/spdx","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/librariesio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":".github/SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-02-05T22:09:43.000Z","updated_at":"2025-03-03T15:52:55.000Z","dependencies_parsed_at":"2024-03-21T16:31:26.040Z","dependency_job_id":"8cc4d48c-288d-4ff0-b392-0e48ab794164","html_url":"https://github.com/librariesio/spdx","commit_stats":{"total_commits":140,"total_committers":8,"mean_commits":17.5,"dds":0.4285714285714286,"last_synced_commit":"93c6b814d0d7b6e00f3332561a7d808c30b39f02"},"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/librariesio%2Fspdx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/librariesio%2Fspdx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/librariesio%2Fspdx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/librariesio%2Fspdx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/librariesio","download_url":"https://codeload.github.com/librariesio/spdx/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250352320,"owners_count":21416470,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T03:19:33.948Z","updated_at":"2025-04-23T01:31:31.814Z","avatar_url":"https://github.com/librariesio.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [Spdx](http://libraries.io/rubygems/spdx) - A SPDX license parser\n\nThis gem allows you validate and parse spdx expressions. It also contains (relatively) up to date license and license exception lists from https://github.com/spdx/license-list-data/tree/master/json\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'spdx'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install spdx\n\n## Usage\n\n```ruby\nSpdx.valid?(\"(MIT OR AGPL-3.0+)\")\n=\u003e true\n```\n\n```ruby\nSpdx.parse(\"MIT OR AGPL-3.0+\")\n=\u003e LogicalOr+OrExpression4 offset=0, \"MIT OR AGPL-3.0+\":\n  License+LicenseId0 offset=0, \"MIT\" (idstring)\n  LicensePlus+SimpleExpression0 offset=7, \"AGPL-3.0+\" (license_id):\n    License+LicenseId0 offset=7, \"AGPL-3.0\" (idstring)\n```\n\n```ruby\nSpdx.normalize(\"Mit OR agpl-3.0+ AND APACHE-2.0\")\n=\u003e \"MIT OR (AGPL-3.0+ AND Apache-2.0)\"\n\nSpdx.normalize(\"Mit OR agpl-3.0+ AND APACHE-2.0\", top_level_parens: true)\n=\u003e \"(MIT OR (AGPL-3.0+ AND Apache-2.0))\"\n```\n\n### Nodes\n\nParsed SPDX license expressions can be a number of various nodes. Each of these nodes share a few methods, most notably `text_value` which contains the text that spans that node, and `licenses` which contains an array of individual licenses used in that portion of the expression. Below are the nodes in more detail, and their additional methods.\n\n#### `License`\n\nThis node represents a single license, and is the result of the most simple form of expression, e.g. `Spdx.parse(\"MIT\")`. It can also be found as a child node of other nodes.\n\n#### `LicensePlus`\n\nThis node represents the current version of a license or any later version, e.g. `Spdx.parse(\"CDDL-1.0+\")`. The inner license node can be found via the `child` method.\n\n#### `LicenseRef`\n\nThis node represents a reference to a license not defined in the SPDX license list, e.g. `Spdx.parse(\"LicenseRef-23\")`.\n\n#### `DocumentRef`\n\nSimilar to `LicenseRef`, this node also represents a reference to a license not defined in the SPDX license list, e.g. `Spdx.parse(\"DocumentRef-spdx-tool-1.2:LicenseRef-MIT-Style-2\")`.\n\n#### `LicenseException`\n\nThis node represents an exception to a license. See `With`.\n\n#### `With`\n\nThis node represents a license with an SPDX-defined license exception, e.g. `Spdx.parse(\"GPL-2.0-or-later WITH Bison-exception-2.2\")`. This node has two extra methods, `license` and `exception`, which return the nodes for the license portion of the expression and the exception portion of the expression, respectively.\n\n#### `LogicalAnd`\n\nThis node represents an \"AND\" expression, e.g. `Spdx.parse(\"LGPL-2.1-only AND MIT\")`. This node has two extra methods, `left` and `right`, which return the node for the left side of the expression and the node for the right side of the expression, respectively. Any node can be the child of `LogicalAnd`, including `LogicalAnd`/`LogicalOr`.\n\n`Spdx.parse(\"(MIT AND GPL-1.0) OR MPL-2.0 AND Apache-2.0\")` would result in the following tree:\n\n```txt\nLogicalOr\n├── LogicalAnd\n│   ├── License (MIT)\n│   └── License (GPL-1.0)\n└── LogicalAnd\n    ├── License (MPL-2.0)\n    └── License Apache-2.0\n```\n\n#### `LogicalOr`\n\nThe same as `LogicalAnd`, but for \"OR\" expressions.\n\n## Testing\n\nRun the tests with:\n\n```sh\nbundle exec rspec\n```\n\n## Contributing\n\n1. Fork it ( https://github.com/librariesio/spdx/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibrariesio%2Fspdx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibrariesio%2Fspdx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibrariesio%2Fspdx/lists"}