Commit 1b5367ba authored by Wohlgemuth, Jason's avatar Wohlgemuth, Jason
Browse files

feat: Add spdx download function

parent 291e6400
Loading
Loading
Loading
Loading
Loading
+4 −17
Original line number Diff line number Diff line
use acorn::io::api::{self, Endpoint, RemoteResource, Searchable};
use acorn::io::api;
use acorn::param;
use acorn::prelude::PathBuf;
use clap_verbosity_flag::Verbosity;
@@ -10,9 +10,9 @@ pub async fn run(_path: &Option<PathBuf>, _ignore: &Option<String>, _offline: &b
    println!("CiteAs API is healthy: {}", api::citeas::is_healthy().await);
    println!("ORCiD API is healthy: {}", api::orcid::is_healthy().await);
    println!("ROR API is healthy: {}", api::ror::is_healthy().await);
    // spdx_example(&INCLUDED_ENDPOINTS).await;
    println!("Licenses: {:#?}", api::spdx::Licenses::download().await);
    // orcid_example().await;
    ror_example().await;
    // ror_example().await;
    Ok(())
}
#[allow(dead_code)]
@@ -25,9 +25,7 @@ async fn orcid_example() {
        ),
        param!(FieldList, "fl", "family-name"),
    ];
    // ORCiD API examples
    let text = api::orcid::search(params).await;
    println!("ORCiD Search Response: {text:#?}");
    println!("ORCiD Search Response: {:#?}", api::orcid::search(params).await);
}
#[allow(dead_code)]
async fn ror_example() {
@@ -39,14 +37,3 @@ async fn ror_example() {
    ];
    println!("ROR Search Results: {:#?}", api::ror::search(params).await);
}
#[allow(dead_code)]
async fn spdx_example(endpoints: &Vec<Endpoint>) {
    let text = match endpoints.find_by_name("spdx") {
        | Some(endpoint) => {
            let response = endpoint.invoke("licenses", None).await;
            endpoint.handle::<api::spdx::Licenses>(response)
        }
        | None => Err("No SPDX endpoint found".into()),
    };
    println!("Licenses: {text:#?}");
}
+18 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
//! See `https://github.com/spdx/license-list-data/blob/main/accessingLicenses.md` for more information on the SPDX license list and how to access it.
//!
//! See `https://spdx.org/rdf/terms/` for SPDX RDF terms.
use crate::io::api::{self, RemoteResource, Searchable, INCLUDED_ENDPOINTS};
use serde::{Deserialize, Serialize};

/// Struct for SPDX license data
@@ -44,3 +45,20 @@ impl License {
        self.is_osi_approved
    }
}
impl Licenses {
    /// Download SPDX license data from homepage
    /// ### Example
    /// ```ignore
    ///
    /// let result = spdx::Licenses::download().await;
    /// ```
    pub async fn download() -> Result<Self, String> {
        match INCLUDED_ENDPOINTS.find_by_name("spdx") {
            | Some(endpoint) => {
                let response = endpoint.invoke("licenses", None).await;
                endpoint.handle::<api::spdx::Licenses>(response)
            }
            | None => Err("No SPDX endpoint found".into()),
        }
    }
}
+58 −60
Original line number Diff line number Diff line
@@ -564,43 +564,33 @@ TN:
SF:C:\Users\jason\dev\acorn\acorn-cli\src\commands\gather\mod.rs
FN:7,run
FN:19,orcid_example
FN:33,ror_example
FN:43,spdx_example
FNF:4
FN:31,ror_example
FNF:3
FNDA:0,run
FNDA:0,orcid_example
FNDA:0,ror_example
FNDA:0,spdx_example
DA:7,0
DA:8,0
DA:9,0
DA:10,0
DA:11,0
DA:12,0
DA:15,0
DA:13,0
DA:16,0
DA:19,0
DA:20,0
DA:21,0
DA:24,0
DA:26,0
DA:29,0
DA:30,0
DA:28,0
DA:31,0
DA:32,0
DA:33,0
DA:34,0
DA:35,0
DA:36,0
DA:37,0
DA:38,0
DA:40,0
DA:43,0
DA:44,0
DA:45,0
DA:46,0
DA:47,0
DA:49,0
DA:51,0
LF:29
LF:21
LH:0
end_of_record
TN:
@@ -2413,12 +2403,20 @@ LH:1
end_of_record
TN:
SF:C:\Users\jason\dev\acorn\acorn-lib\src\io\api\spdx.rs
FN:43,License::is_open_source
FNF:1
FN:44,License::is_open_source
FN:55,Licenses::download
FNF:2
FNDA:0,License::is_open_source
DA:43,0
FNDA:0,Licenses::download
DA:44,0
LF:2
DA:45,0
DA:55,0
DA:56,0
DA:57,0
DA:58,0
DA:59,0
DA:61,0
LF:8
LH:0
end_of_record
TN:
@@ -2958,7 +2956,7 @@ FNF:40
FNDA:0,InputOutput::read_markdown
FNDA:0,InputOutput::write_markdown
FNDA:1729382256910270464,<impl FromCommand for SemanticVersion>::from_command
FNDA:1297036692682702848,<impl FromPath for MimeType>::from_path
FNDA:1441151880758558720,<impl FromPath for MimeType>::from_path
FNDA:288230376151711744,<impl ToStrings for Vec<P>>::to_strings
FNDA:0,<impl ToStrings for Vec<P>>::to_absolute_strings
FNDA:5836665117072162816,<impl ToAbsoluteString for PathBuf>::to_absolute_string
@@ -3006,8 +3004,8 @@ DA:165,2017612633061982208
DA:166,4035225266123964416
DA:167,432345564227567616
DA:170,720575940379279360
DA:186,1297036692682702848
DA:190,3891110078048108544
DA:186,1441151880758558720
DA:190,4323455642275676160
DA:194,288230376151711744
DA:195,288230376151711744
DA:196,2233785415175766016
@@ -3249,7 +3247,7 @@ DA:623,432345564227567616
DA:624,432345564227567616
DA:625,864691128455135232
DA:628,432345564227567616
DA:629,5116089176692883456
DA:629,5836665117072162816
DA:631,0
DA:645,0
DA:646,0
@@ -5693,8 +5691,8 @@ FNDA:216172782113783808,Label::fmt_using
FNDA:504403158265495552,<impl From for License>::from
FNDA:144115188075855872,License::from_technology
FNDA:288230376151711744,License::is_open_source
FNDA:1513209474796486656,<impl From for MimeType>::from
FNDA:1080863910568919040,MimeType::file_type
FNDA:1657324662872342528,<impl From for MimeType>::from
FNDA:1224979098644774912,MimeType::file_type
FNDA:0,<impl Default for SemanticVersion>::default
FNDA:1080863910568919040,<impl From for SemanticVersion>::from
FNDA:216172782113783808,<impl StringInterpolation for T>::replace_placeholder_with_string
@@ -5708,7 +5706,7 @@ FNDA:13763000461244235776,crockford_digit
FNDA:72057594037927936,current_date
FNDA:1585267068834414592,detect_json
FNDA:1369094286720630784,detect_xml
FNDA:2377900603251621888,file_extension
FNDA:2522015791327477760,file_extension
FNDA:216172782113783808,find_first
FNDA:0,format_bytes
FNDA:360287970189639680,frontmatter_and_body
@@ -5839,27 +5837,27 @@ DA:557,14411518807585587200
DA:558,288230376151711744
DA:559,432345564227567616
DA:560,72057594037927936
DA:591,1513209474796486656
DA:592,3026418949592973312
DA:593,1513209474796486656
DA:594,2738188573441261568
DA:595,1801439850948198400
DA:596,1873497444986126336
DA:597,1224979098644774912
DA:598,1297036692682702848
DA:599,1297036692682702848
DA:600,720575940379279360
DA:601,576460752303423488
DA:602,1152921504606846976
DA:603,936748722493063168
DA:604,216172782113783808
DA:605,216172782113783808
DA:606,288230376151711744
DA:607,504403158265495552
DA:608,0
DA:591,1657324662872342528
DA:592,3314649325744685056
DA:593,1657324662872342528
DA:594,3026418949592973312
DA:595,1945555039024054272
DA:596,2161727821137838080
DA:597,1369094286720630784
DA:598,1585267068834414592
DA:599,1585267068834414592
DA:600,864691128455135232
DA:601,720575940379279360
DA:602,1441151880758558720
DA:603,1152921504606846976
DA:604,288230376151711744
DA:605,288230376151711744
DA:606,360287970189639680
DA:607,720575940379279360
DA:608,72057594037927936
DA:610,144115188075855872
DA:623,1080863910568919040
DA:624,1080863910568919040
DA:623,1224979098644774912
DA:624,1224979098644774912
DA:625,0
DA:626,432345564227567616
DA:627,0
@@ -5870,13 +5868,13 @@ DA:631,0
DA:632,0
DA:633,0
DA:634,0
DA:635,360287970189639680
DA:635,432345564227567616
DA:636,0
DA:637,0
DA:638,0
DA:639,72057594037927936
DA:640,0
DA:641,144115188075855872
DA:641,216172782113783808
DA:647,0
DA:648,0
DA:661,1080863910568919040
@@ -5958,15 +5956,15 @@ DA:838,720575940379279360
DA:839,216172782113783808
DA:840,5476377146882523136
DA:844,432345564227567616
DA:858,2377900603251621888
DA:862,7133701809754865664
DA:863,1152921504606846976
DA:864,2377900603251621888
DA:865,6701356245527298048
DA:866,6557241057451442176
DA:867,8358680908399640576
DA:868,4107282860161892352
DA:869,1729382256910270464
DA:858,2522015791327477760
DA:862,7566047373982433280
DA:863,2305843009213693952
DA:864,2522015791327477760
DA:865,7133701809754865664
DA:866,6989586621679009792
DA:867,8935141660703064064
DA:868,4395513236313604096
DA:869,1873497444986126336
DA:871,504403158265495552
DA:874,144115188075855872
DA:887,216172782113783808
@@ -6045,7 +6043,7 @@ DA:1091,0
DA:1096,7061644215716937728
DA:1097,288230376151711744
LF:324
LH:199
LH:200
end_of_record
TN:
SF:C:\Users\jason\dev\acorn\acorn-py\target\release\build\glutin_wgl_sys-7bf65d050f60911f\out\wgl_extra_bindings.rs