diff --git a/README.md b/README.md index 7fc16e5..366d19f 100644 --- a/README.md +++ b/README.md @@ -223,7 +223,9 @@ See also [Games Made With Piston](https://github.com/PistonDevelopers/piston/wik * [ozkriff/zemeroth](https://github.com/ozkriff/zemeroth) — A small 2D turn-based hexagonal strategy game [![build badge](https://api.travis-ci.org/ozkriff/zemeroth.svg?branch=master)](https://travis-ci.org/ozkriff/zemeroth) * [rhex](https://github.com/dpc/rhex) — hexagonal ascii roguelike * [rsaarelm/magog](https://github.com/rsaarelm/magog) — A roguelike game in Rust +* [schulke-214/rsnake](https://github.com/schulke-214/rsnake) — Snake written in Rust. * [swatteau/sokoban-rs](https://github.com/swatteau/sokoban-rs) — A Sokoban implementation +* [Thinkofname/rust-quake](https://github.com/Thinkofname/rust-quake) — Quake map renderer in Rust * [Veloren](https://gitlab.com/veloren/veloren) — An open world, open source multiplayer voxel RPG game currently in alpha development [![build badge](https://gitlab.com/veloren/veloren/badges/master/pipeline.svg)](https://gitlab.com/veloren/veloren/-/pipelines) * [Zone of Control](https://github.com/ozkriff/zoc) — A turn-based hexagonal strategy game [![build badge](https://api.travis-ci.org/ozkriff/zoc.svg?branch=master)](https://travis-ci.org/ozkriff/zoc) diff --git a/src/main.rs b/src/main.rs index 7c48950..fa5e24d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,6 +20,17 @@ use diffy::create_patch; const MINIMUM_GITHUB_STARS: u32 = 50; const MINIMUM_CARGO_DOWNLOADS: u32 = 2000; +// Allow overriding the needed stars for a section. "level" is the header level in the markdown, default is MINIMUM_GITHUB_STARS +fn override_stars(level: u32, text: &str) -> Option { + if level == 2 && text.contains("Resources") { + Some(0) + } else if level == 3 && text.contains("Games") { + Some(40) + } else { + None + } +} + lazy_static! { // Overrides for popularity count, each needs a good reason (i.e. downloads/stars we don't support automatic counting of) // Each is a URL that's "enough" for an item to pass the popularity checks @@ -408,12 +419,15 @@ async fn main() -> Result<(), Error> { let mut list_items: Vec = Vec::new(); let mut in_list_item = false; let mut list_item: String = String::new(); - let mut in_resources = false; let mut link_count: u8 = 0; let mut github_stars: u32 = 0; let mut cargo_downloads: u32 = 0; + let mut required_stars: u32 = MINIMUM_GITHUB_STARS; + let mut last_level: u32 = 0; + let mut star_override_level: Option = None; + for (event, range) in parser.into_offset_iter() { match event { Event::Start(tag) => { @@ -474,9 +488,12 @@ async fn main() -> Result<(), Error> { cargo_downloads = 0; } Tag::Heading(level) => { - if level == 2 && in_resources { - // Got to the next item - in_resources = false; + last_level = level; + if let Some(override_level) = star_override_level { + if level == override_level { + star_override_level = None; + required_stars = MINIMUM_GITHUB_STARS; + } } } Tag::Paragraph => {} @@ -488,9 +505,12 @@ async fn main() -> Result<(), Error> { } } Event::Text(text) => { - if text.contains("Resources") { - in_resources = true; + let possible_override = override_stars(last_level, &text); + if let Some(override_value) = possible_override { + star_override_level = Some(last_level); + required_stars = override_value; } + if in_list_item { list_item.push_str(&text); } @@ -498,9 +518,9 @@ async fn main() -> Result<(), Error> { Event::End(tag) => { match tag { Tag::Item => { - if list_item.len() > 0 && !in_resources { + if list_item.len() > 0 { if link_count > 0 { - if github_stars < MINIMUM_GITHUB_STARS && cargo_downloads < MINIMUM_CARGO_DOWNLOADS { + if github_stars < required_stars && cargo_downloads < MINIMUM_CARGO_DOWNLOADS { return Err(format_err!("Not good enough ({} stars < {}, and {} cargo downloads < {}): {}", github_stars, MINIMUM_GITHUB_STARS, cargo_downloads, MINIMUM_CARGO_DOWNLOADS, list_item)); } }