Compare commits

..

No commits in common. "0f0b0449930bb7a98a231f549fb81dbce38cec28" and "08bf7ed29e10ba6012afcd57cea263e9f0a707e9" have entirely different histories.

6 changed files with 10 additions and 35 deletions

View File

@ -1,11 +1,6 @@
//! Parsing for `/~<group>`.
use std::str::FromStr;
use {
color_eyre::{eyre::Error, Result},
scraper::Html,
};
use {color_eyre::Result, scraper::Html};
use crate::{
regexes::GROUP_SUBSCRIBERS_RE,
@ -47,15 +42,6 @@ pub struct GroupWikiLink {
pub url: String,
}
impl FromStr for Group {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let html = Html::parse_document(s);
Self::from_html(&html)
}
}
impl Group {
/// Parses a [`Group`] from a [`scraper::Html`] tree.
pub fn from_html(html: &Html) -> Result<Self> {

View File

@ -1,11 +1,6 @@
//! Parsing for [`/groups`](https://tildes.net/groups).
use std::str::FromStr;
use {
color_eyre::{eyre::Error, Result},
scraper::Html,
};
use {color_eyre::Result, scraper::Html};
use crate::{
regexes::{DUPLICATE_WHITESPACE_RE, GROUP_LIST_ACTIVITY_RE},
@ -37,15 +32,6 @@ pub struct GroupListSummary {
pub topic_activity: Option<i32>,
}
impl FromStr for GroupList {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let html = Html::parse_document(s);
Self::from_html(&html)
}
}
impl GroupList {
/// Parses a [`GroupList`] from a [`scraper::Html`] tree.
pub fn from_html(html: &Html) -> Result<Self> {

View File

@ -30,4 +30,5 @@ pub(crate) mod group_list;
pub use {
group::{Group, GroupWikiLink},
group_list::{GroupList, GroupListSummary},
scraper::Html,
};

View File

@ -23,7 +23,7 @@ lazy_static! {
/// Selector for the group subscriber count.
pub static ref GROUP_SUBSCRIBERS: Selector = selector(".group-subscription-count");
/// Selector for sub groups.
/// Selector for group wiki links.
pub static ref GROUP_SUB_GROUP_LINKS: Selector = selector(r#"#sidebar .link-group"#);
/// Selector for group wiki links.

View File

@ -1,10 +1,11 @@
use std::fs::read_to_string;
use {insta::assert_debug_snapshot, tildes_parser::Group};
use {insta::assert_debug_snapshot, scraper::Html, tildes_parser::Group};
#[test]
fn test_group_parsing() {
let html = read_to_string("tests/samples/group.html").unwrap();
let group = &html.parse::<Group>().unwrap();
let html = Html::parse_document(&html);
let group = Group::from_html(&html).unwrap();
assert_debug_snapshot!(group);
}

View File

@ -1,10 +1,11 @@
use std::fs::read_to_string;
use {insta::assert_debug_snapshot, tildes_parser::GroupList};
use {insta::assert_debug_snapshot, scraper::Html, tildes_parser::GroupList};
#[test]
fn test_group_list_parsing() {
let html = read_to_string("tests/samples/group_list.html").unwrap();
let group_list = html.parse::<GroupList>().unwrap();
let html = Html::parse_document(&html);
let group_list = GroupList::from_html(&html).unwrap();
assert_debug_snapshot!(group_list);
}