Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ISC license #25

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading