Skip to content

Commit 4d35e5a

Browse files
committed
Replace license crate with askalono
1 parent 493a07f commit 4d35e5a

File tree

6 files changed

+124
-12
lines changed

6 files changed

+124
-12
lines changed

Diff for: Cargo.lock

+105-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ exclude = ["assets/*.png"]
1212
colored= "1.8.0"
1313
git2 = {version = "0.7.5", default-features = false}
1414
tokei = "10.0"
15-
license = "0.8.1"
15+
askalono = "0.3.0"
1616
bytecount = "0.5.1"
1717
clap = "2.33.0"
1818
strum = "0.16.0"

Diff for: resources/license-cache.bin.gz

1.45 MB
Binary file not shown.

Diff for: src/info.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -596,9 +596,8 @@ impl Info {
596596
}, // TODO: multiple prefixes, like COPYING?
597597
)
598598
.filter_map(|entry| {
599-
license::from_text_ext(&fs::read_to_string(entry).unwrap_or_else(|_| "".into()))
599+
license::from_text(&fs::read_to_string(entry).unwrap_or_else(|_| "".into()))
600600
})
601-
.map(|license| license.name().to_string())
602601
.collect::<Vec<_>>()
603602
.join(", ");
604603

Diff for: src/license.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use askalono::{Store, TextData};
2+
3+
static CACHE_DATA: &[u8] = include_bytes!("../resources/license-cache.bin.gz");
4+
5+
pub fn from_text(text: &str) -> Option<String> {
6+
match Store::from_cache(CACHE_DATA) {
7+
Ok(store) => match store.analyze(&TextData::from(text)) {
8+
Ok(license) => Some(license.name),
9+
Err(_) => None,
10+
},
11+
Err(_) => None,
12+
}
13+
}

Diff for: src/main.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
extern crate bytecount;
22

3+
extern crate askalono;
34
extern crate colored;
45
extern crate git2;
5-
extern crate license;
66
extern crate tokei;
77
#[macro_use]
88
extern crate clap;
@@ -33,6 +33,7 @@ mod error;
3333
mod image_backends;
3434
mod info;
3535
mod language;
36+
mod license;
3637

3738
use ascii_art::AsciiArt;
3839
use commit_info::CommitInfo;
@@ -179,7 +180,8 @@ Possible values: [{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}]",
179180
.long("image")
180181
.takes_value(true)
181182
.help("Sets a custom image to use instead of the ascii logo"),
182-
).arg(
183+
)
184+
.arg(
183185
Arg::with_name("no-merges")
184186
.short("m")
185187
.long("no-merges")

0 commit comments

Comments
 (0)