Run rustfmt.
This commit is contained in:
parent
5b19274e6a
commit
b528c48e3b
@ -40,6 +40,8 @@ nightly:test:
|
||||
rustfmt:
|
||||
image: "rustlang/rust:nightly"
|
||||
stage: lint
|
||||
variables:
|
||||
CFG_RELEASE_CHANNEL: "nightly"
|
||||
script:
|
||||
- rustc --version && cargo --version
|
||||
- cargo install rustfmt-nightly
|
||||
|
||||
@ -198,9 +198,10 @@ pub fn update_none_to_played_now(parent: &Podcast) -> Result<usize> {
|
||||
|
||||
let epoch_now = Utc::now().timestamp() as i32;
|
||||
con.transaction(|| -> Result<usize> {
|
||||
Ok(diesel::update(
|
||||
Episode::belonging_to(parent).filter(played.is_null()),
|
||||
).set(played.eq(Some(epoch_now)))
|
||||
.execute(&*con)?)
|
||||
Ok(
|
||||
diesel::update(Episode::belonging_to(parent).filter(played.is_null()))
|
||||
.set(played.eq(Some(epoch_now)))
|
||||
.execute(&*con)?,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
@ -276,13 +276,12 @@ mod tests {
|
||||
f2.get_episodes().unwrap()
|
||||
};
|
||||
|
||||
eps1.into_par_iter()
|
||||
.zip(eps2)
|
||||
.into_par_iter()
|
||||
.for_each(|(ep1, ep2): (Episode, Episode)| {
|
||||
eps1.into_par_iter().zip(eps2).into_par_iter().for_each(
|
||||
|(ep1, ep2): (Episode, Episode)| {
|
||||
assert_eq!(ep1, ep2);
|
||||
assert_eq!(ep1.id(), ep2.id());
|
||||
assert_eq!(ep1.podcast_id(), ep2.podcast_id());
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,6 +37,7 @@ extern crate diesel_migrations;
|
||||
#[macro_use]
|
||||
extern crate derive_builder;
|
||||
|
||||
extern crate ammonia;
|
||||
extern crate chrono;
|
||||
extern crate r2d2;
|
||||
extern crate r2d2_diesel;
|
||||
@ -46,7 +47,6 @@ extern crate rfc822_sanitizer;
|
||||
extern crate rss;
|
||||
extern crate url;
|
||||
extern crate xdg;
|
||||
extern crate ammonia;
|
||||
|
||||
#[allow(missing_docs)]
|
||||
pub mod dbqueries;
|
||||
|
||||
@ -342,9 +342,9 @@ impl<'a> Source {
|
||||
let lmod = headers.get::<LastModified>();
|
||||
|
||||
// FIXME: This dsnt work most of the time apparently
|
||||
if self.http_etag() != etag.map(|x| x.tag())
|
||||
|| self.last_modified != lmod.map(|x| format!("{}", x))
|
||||
{
|
||||
if self.http_etag() != etag.map(|x| x.tag()) || self.last_modified != lmod.map(|x| {
|
||||
format!("{}", x)
|
||||
}) {
|
||||
self.http_etag = etag.map(|x| x.tag().to_string().to_owned());
|
||||
self.last_modified = lmod.map(|x| format!("{}", x));
|
||||
self.save()?;
|
||||
|
||||
@ -62,19 +62,17 @@ pub(crate) fn new_episode(item: &Item, parent_id: i32) -> Result<NewEpisode> {
|
||||
|
||||
let length = item.enclosure().map(|x| x.length().parse().unwrap_or(0));
|
||||
|
||||
Ok(
|
||||
NewEpisodeBuilder::default()
|
||||
.title(title)
|
||||
.uri(uri)
|
||||
.description(description)
|
||||
.length(length)
|
||||
.published_date(pub_date)
|
||||
.epoch(epoch)
|
||||
.guid(guid)
|
||||
.podcast_id(parent_id)
|
||||
.build()
|
||||
.unwrap()
|
||||
)
|
||||
Ok(NewEpisodeBuilder::default()
|
||||
.title(title)
|
||||
.uri(uri)
|
||||
.description(description)
|
||||
.length(length)
|
||||
.published_date(pub_date)
|
||||
.epoch(epoch)
|
||||
.guid(guid)
|
||||
.podcast_id(parent_id)
|
||||
.build()
|
||||
.unwrap())
|
||||
}
|
||||
|
||||
|
||||
@ -278,9 +276,9 @@ mod tests {
|
||||
|
||||
let firstitem = channel.items().first().unwrap();
|
||||
let descr = "Audit your network with a couple of easy commands on Kali Linux. Chris \
|
||||
decides to blow off a little steam by attacking his IoT devices, Wes has \
|
||||
the scope on Equifax blaming open source & the Beard just saved the \
|
||||
show. It’s a really packed episode!";
|
||||
decides to blow off a little steam by attacking his IoT devices, Wes has the \
|
||||
scope on Equifax blaming open source & the Beard just saved the show. \
|
||||
It’s a really packed episode!";
|
||||
let i = new_episode(&firstitem, 0).unwrap();
|
||||
|
||||
assert_eq!(i.title(), Some("Hacking Devices with Kali Linux | LUP 214"));
|
||||
@ -321,9 +319,8 @@ mod tests {
|
||||
let channel = Channel::read_from(BufReader::new(file)).unwrap();
|
||||
|
||||
let firstitem = channel.items().iter().nth(9).unwrap();
|
||||
let descr = "This week we look at <a \
|
||||
href=\"https://github.com/rust-lang/rfcs/pull/2094\" rel=\"noopener \
|
||||
noreferrer\">RFC 2094</a> \"Non-lexical lifetimes\"";
|
||||
let descr = "This week we look at <a href=\"https://github.com/rust-lang/rfcs/pull/2094\" \
|
||||
rel=\"noopener noreferrer\">RFC 2094</a> \"Non-lexical lifetimes\"";
|
||||
let i = new_episode(&firstitem, 0).unwrap();
|
||||
|
||||
assert_eq!(i.title(), Some("Episode #9 - A Once in a Lifetime RFC"));
|
||||
@ -344,9 +341,10 @@ mod tests {
|
||||
let second = channel.items().iter().nth(8).unwrap();
|
||||
let i2 = new_episode(&second, 0).unwrap();
|
||||
|
||||
let descr2 = "This week we look at <a href=\"https://github.com/rust-lang/rfcs/pull/2071\" \
|
||||
rel=\"noopener noreferrer\">RFC 2071</a> \"Add impl Trait type alias and \
|
||||
variable declarations\"";
|
||||
let descr2 = "This week we look at <a \
|
||||
href=\"https://github.com/rust-lang/rfcs/pull/2071\" rel=\"noopener \
|
||||
noreferrer\">RFC 2071</a> \"Add impl Trait type alias and variable \
|
||||
declarations\"";
|
||||
assert_eq!(i2.title(), Some("Episode #8 - An Existential Crisis"));
|
||||
assert_eq!(
|
||||
i2.uri(),
|
||||
|
||||
@ -109,9 +109,10 @@ pub fn url_cleaner(s: &str) -> String {
|
||||
// TODO: Docs
|
||||
pub fn replace_extra_spaces(s: &str) -> String {
|
||||
s.lines()
|
||||
.map(|x| x.split_whitespace().collect::<Vec<_>>().join(" "))
|
||||
.filter(|x| !x.is_empty())
|
||||
.collect::<Vec<_>>().join("\n")
|
||||
.map(|x| x.split_whitespace().collect::<Vec<_>>().join(" "))
|
||||
.filter(|x| !x.is_empty())
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@ -60,14 +60,15 @@ fn download_into(dir: &str, file_title: &str, url: &str) -> Result<String> {
|
||||
// Determine the file extension from the http content-type header.
|
||||
fn get_ext(content: Option<ContentType>) -> Option<String> {
|
||||
let cont = content.clone()?;
|
||||
content.and_then(|c| mime_guess::get_extensions(c.type_().as_ref(), c.subtype().as_ref()))
|
||||
.and_then(|c| {
|
||||
if c.contains(&cont.subtype().as_ref()) {
|
||||
Some(cont.subtype().as_ref().to_string())
|
||||
} else {
|
||||
Some(c.first().unwrap().to_string())
|
||||
}
|
||||
})
|
||||
content
|
||||
.and_then(|c| mime_guess::get_extensions(c.type_().as_ref(), c.subtype().as_ref()))
|
||||
.and_then(|c| {
|
||||
if c.contains(&cont.subtype().as_ref()) {
|
||||
Some(cont.subtype().as_ref().to_string())
|
||||
} else {
|
||||
Some(c.first().unwrap().to_string())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// TODO: Write unit-tests.
|
||||
|
||||
@ -46,7 +46,7 @@ impl Content {
|
||||
self.podcasts.init(&self.stack);
|
||||
if self.podcasts.flowbox.get_children().is_empty() {
|
||||
self.stack.set_visible_child_name("empty");
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
self.stack.set_visible_child_name("podcasts");
|
||||
@ -100,9 +100,9 @@ impl Into<ContentState<PodcastsView>> for ContentState<Empty> {
|
||||
fn into(self) -> ContentState<PodcastsView> {
|
||||
self.content.stack.set_visible_child_name("podcasts");
|
||||
|
||||
ContentState{
|
||||
ContentState {
|
||||
content: self.content,
|
||||
state: PodcastsView{},
|
||||
state: PodcastsView {},
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -114,9 +114,9 @@ impl UpdateView for ContentState<Empty> {
|
||||
impl Into<ContentState<Empty>> for ContentState<PodcastsView> {
|
||||
fn into(self) -> ContentState<Empty> {
|
||||
self.content.stack.set_visible_child_name("empty");
|
||||
ContentState{
|
||||
ContentState {
|
||||
content: self.content,
|
||||
state: Empty{},
|
||||
state: Empty {},
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -125,9 +125,9 @@ impl Into<ContentState<WidgetsView>> for ContentState<PodcastsView> {
|
||||
fn into(self) -> ContentState<WidgetsView> {
|
||||
self.content.stack.set_visible_child_name("widget");
|
||||
|
||||
ContentState{
|
||||
ContentState {
|
||||
content: self.content,
|
||||
state: WidgetsView{},
|
||||
state: WidgetsView {},
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -142,9 +142,9 @@ impl UpdateView for ContentState<PodcastsView> {
|
||||
impl Into<ContentState<PodcastsView>> for ContentState<WidgetsView> {
|
||||
fn into(self) -> ContentState<PodcastsView> {
|
||||
self.content.stack.set_visible_child_name("podcasts");
|
||||
ContentState{
|
||||
ContentState {
|
||||
content: self.content,
|
||||
state: PodcastsView{},
|
||||
state: PodcastsView {},
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -152,9 +152,9 @@ impl Into<ContentState<PodcastsView>> for ContentState<WidgetsView> {
|
||||
impl Into<ContentState<Empty>> for ContentState<WidgetsView> {
|
||||
fn into(self) -> ContentState<Empty> {
|
||||
self.content.stack.set_visible_child_name("empty");
|
||||
ContentState{
|
||||
ContentState {
|
||||
content: self.content,
|
||||
state: Empty{},
|
||||
state: Empty {},
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -165,7 +165,7 @@ impl UpdateView for ContentState<WidgetsView> {
|
||||
let id = WidgetExt::get_name(&old).unwrap();
|
||||
let pd = dbqueries::get_podcast_from_id(id.parse::<i32>().unwrap()).unwrap();
|
||||
|
||||
let pdw = PodcastWidget::new_initialized(&self.content.stack, &pd);;
|
||||
let pdw = PodcastWidget::new_initialized(&self.content.stack, &pd);
|
||||
self.content.replace_widget(pdw);
|
||||
}
|
||||
}
|
||||
@ -178,17 +178,16 @@ impl ContentState<PodcastsView> {
|
||||
content.podcasts.init(&content.stack);
|
||||
if content.podcasts.flowbox.get_children().is_empty() {
|
||||
content.stack.set_visible_child_name("empty");
|
||||
return Err(
|
||||
ContentState{
|
||||
content,
|
||||
state: Empty{},
|
||||
});
|
||||
return Err(ContentState {
|
||||
content,
|
||||
state: Empty {},
|
||||
});
|
||||
}
|
||||
|
||||
content.stack.set_visible_child_name("podcasts");
|
||||
Ok(ContentState {
|
||||
content,
|
||||
state: PodcastsView{},
|
||||
state: PodcastsView {},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user