Skip to content

Commit

Permalink
feat: add ISC license
Browse files Browse the repository at this point in the history
  • Loading branch information
abby-freakazoid committed May 24, 2024
1 parent f9ef0be commit f0e54bd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
15 changes: 15 additions & 0 deletions files/isc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ISC License

Copyright (c) {YEAR} {AUTHOR}

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
12 changes: 12 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ pub fn create_license(license_type: &str) -> Option<Box<dyn license::License>> {
// MIT
"mit" => Some(Box::new(license::Mit {})),
"MIT" => Some(Box::new(license::Mit {})),
// ISC
"isc" => Some(Box::new(license::ISC {})),
"ISC" => Some(Box::new(license::ISC {})),
// GPL
"gpl" => Some(Box::new(license::GPL {})),
"GPL" => Some(Box::new(license::GPL {})),
Expand Down Expand Up @@ -85,6 +88,15 @@ mod test {
assert!(license_text.contains("2018"));
}

#[test]
fn create_isc_license() {
let isc = create_license("isc");
let license_text = isc.unwrap().notice(2018, "TEST_USER", "license-generator");
assert!(license_text.contains("Permission to use, copy, modify, and/or distribute"));
assert!(license_text.contains("TEST_USER"));
assert!(license_text.contains("2018"));
}

#[test]
fn create_gpl_license() {
let gpl = create_license("gpl");
Expand Down
9 changes: 9 additions & 0 deletions src/license.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ impl License for GPL {
}
}

// isc.txt
pub struct ISC {}

impl License for ISC {
fn notice(&self, year: u32, name: &str, _project: &str) -> String {
format!(include_str!("../files/isc.txt"), YEAR = year, AUTHOR = name)
}
}

// lgpl-3.0.txt
pub struct LGPL {}

Expand Down

0 comments on commit f0e54bd

Please sign in to comment.