deploy config
This commit is contained in:
parent
da40e48b19
commit
d0a7e7ec88
10 changed files with 231 additions and 39 deletions
|
@ -6,7 +6,7 @@ pub trait Source {
|
|||
/// Return the URL to query
|
||||
fn url(&self) -> String;
|
||||
/// Given the content of the url figure out the date of the latest leak
|
||||
fn latest_leak(&self, html: String) -> Result<time::Date>;
|
||||
fn latest_leak(&self, html: &str) -> Result<time::Date>;
|
||||
}
|
||||
|
||||
pub fn sources() -> Vec<Box<dyn Source + Send>> {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::{str::FromStr, time::Instant};
|
||||
use std::{str::FromStr};
|
||||
|
||||
use super::Source;
|
||||
use anyhow::{bail, Context, Result};
|
||||
|
@ -12,8 +12,8 @@ impl Source for Wikipedia {
|
|||
"https://en.wikipedia.org/wiki/War_Thunder".to_string()
|
||||
}
|
||||
|
||||
fn latest_leak(&self, html: String) -> Result<time::Date> {
|
||||
let soup = soup::Soup::new(&html);
|
||||
fn latest_leak(&self, html: &str) -> Result<time::Date> {
|
||||
let soup = soup::Soup::new(html);
|
||||
|
||||
let tables = soup.tag("table").find_all();
|
||||
|
||||
|
@ -82,7 +82,7 @@ fn parse_wikipedia_date(text: &str) -> Result<time::Date> {
|
|||
fn test_wikipedia_html_parse() {
|
||||
let html = std::fs::read_to_string("./data/wikipedia.html").unwrap();
|
||||
|
||||
let real = Wikipedia.latest_leak(html).unwrap();
|
||||
let real = Wikipedia.latest_leak(&html).unwrap();
|
||||
let expected = time::Date::from_calendar_date(2023, time::Month::December, 12).unwrap();
|
||||
|
||||
assert_eq!(expected, real);
|
||||
|
@ -108,8 +108,4 @@ fn test_wikipedia_date_parse() {
|
|||
parse_wikipedia_date("October 2021").unwrap(),
|
||||
time::Date::from_calendar_date(2021, time::Month::October, 1).unwrap()
|
||||
);
|
||||
assert_eq!(
|
||||
parse_wikipedia_date("october 2021").unwrap(),
|
||||
time::Date::from_calendar_date(2021, time::Month::October, 1).unwrap()
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue