Giter Club home page Giter Club logo

spdx's Introduction

๐Ÿ†” spdx

Embark Embark Crates.io Docs Minimum Stable Rust Version SPDX Version dependency status Build Status

Helper crate for SPDX license expressions.

Usage

use spdx::Expression;

fn main() {
    let this_is_fine = Expression::parse("MIT OR Apache-2.0").unwrap();

    assert!(this_is_fine.evaluate(|req| {
        if let spdx::LicenseItem::SPDX { id, .. } = req.license {
            // Both MIT and Apache-2.0 are OSI approved, so this expression
            // evaluates to true
            return id.is_osi_approved();
        }

        false
    }));

    assert!(!this_is_fine.evaluate(|req| {
        if let spdx::LicenseItem::SPDX { id, .. } = req.license {
            // This is saying we don't accept any licenses that are OSI approved
            // so the expression will evaluate to false as both sides of the OR
            // are now rejected
            return !id.is_osi_approved();
        }

        false
    }));

    // `NOPE` is not a valid SPDX license identifier, so this expression
    // will fail to parse
    let _this_is_not = Expression::parse("MIT OR NOPE").unwrap_err();
}

Updating SPDX list

You can update the list of SPDX identifiers for licenses and exceptions by running the update program cargo run --manifest-path=update/Cargo.toml -- v3.6 where v3.6 is the tag in the SPDX data repo.

Contributing

Contributor Covenant

We welcome community contributions to this project.

Please read our Contributor Guide for more information on how to get started.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

spdx's People

Contributors

bossmc avatar deanbdean avatar jake-shadle avatar kain88-de avatar kornelski avatar lpil avatar maikklein avatar repi avatar soniasingla avatar swagadon avatar xampprocky avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.