Final crate restructure I hope.

This commit is contained in:
Jordan Petridis 2017-10-05 15:02:19 +03:00
parent 77797ee027
commit 93027e5530
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
16 changed files with 42 additions and 38 deletions

View File

@ -2,5 +2,5 @@
members = [
"hammond-data",
"hammond-cli",
"other"
"hammond-downloader"
]

View File

@ -10,7 +10,7 @@ structopt = "0.1.0"
structopt-derive = "0.1.0"
error-chain = "0.11.0"
hammond-data = {path = "../hammond-data"}
other = {path = "../other"}
hammond-downloader = {path = "../hammond-downloader"}
[dev-dependencies]
assert_cli = "0.5"

View File

@ -1,21 +1,21 @@
extern crate log;
extern crate loggerv;
#[macro_use]
extern crate error_chain;
extern crate structopt;
#[macro_use]
extern crate structopt_derive;
#[macro_use]
extern crate error_chain;
extern crate other;
extern crate hammond_data;
extern crate hammond_downloader;
use structopt::StructOpt;
use hammond_data::dbqueries;
use other::errors::*;
use other::downloader;
use other::index_feed;
use hammond_data::errors::*;
use hammond_data::index_feed;
use hammond_downloader::downloader;
// Should probably had made an Enum instead.
#[derive(StructOpt, Debug)]
#[structopt(name = "example", about = "An example of StructOpt usage.")]
@ -36,7 +36,7 @@ struct Opt {
fn run() -> Result<()> {
let args = Opt::from_args();
loggerv::init_with_verbosity(args.verbosity)?;
loggerv::init_with_verbosity(args.verbosity).unwrap();
hammond_data::init()?;
@ -54,7 +54,7 @@ fn run() -> Result<()> {
if args.dl >= 0 {
let db = hammond_data::establish_connection();
downloader::latest_dl(&db, args.dl as u32)?;
downloader::latest_dl(&db, args.dl as u32).unwrap();
}
if args.latest {

View File

@ -34,4 +34,4 @@ fn test_latest() {
assert_cli::Assert::main_binary()
.with_args(&["--latest"])
.unwrap();
}
}

View File

@ -4,13 +4,19 @@ version = "0.1.0"
authors = ["Jordan Petridis <jordanpetridis@protonmail.com>"]
[dependencies]
rfc822_sanitizer = "0.3.0"
rayon = "0.8.2"
hyper = "0.11.2"
reqwest = "0.7.3"
error-chain = "0.11.0"
log = "0.3.8"
loggerv = "0.3.0"
reqwest = "0.7.3"
diesel = { version = "0.16.0", features = ["sqlite", "deprecated-time", "chrono"] }
diesel_codegen = { version = "0.16.0", features = ["sqlite"] }
xdg = "2.1.0"
lazy_static = "0.2.8"
rss = { version = "1.1.0", features = ["from_url"]}
dotenv = "*"
[dev-dependencies]
tempdir = "0.3.5"

View File

@ -1,7 +1,7 @@
use rss::{Channel, Item};
use rfc822_sanitizer::parse_from_rfc2822_with_fallback;
use hammond_data::models;
use models;
use errors::*;
pub fn parse_podcast(chan: &Channel, source_id: i32) -> Result<models::NewPodcast> {

View File

@ -7,10 +7,9 @@ use reqwest;
use rayon::prelude::*;
use std::sync::{Arc, Mutex};
use hammond_data::schema;
use hammond_data::dbqueries;
use hammond_data::models::*;
use schema;
use dbqueries;
use models::*;
use errors::*;
use feedparser;
@ -211,13 +210,11 @@ fn refresh_source(
#[cfg(test)]
mod tests {
extern crate hammond_data;
extern crate tempdir;
use diesel::prelude::*;
// use diesel::embed_migrations;
use rss;
use std::io::{stdout, BufReader};
use std::io::BufReader;
use std::path::PathBuf;
use std::fs;
@ -239,7 +236,7 @@ mod tests {
let db_path = tmp_dir.path().join("foo_tests.db");
let db = SqliteConnection::establish(db_path.to_str().unwrap()).unwrap();
hammond_data::run_migration_on(&db).unwrap();
::run_migration_on(&db).unwrap();
// TempDB {
// tmp_dir,

View File

@ -17,21 +17,35 @@ extern crate diesel_codegen;
extern crate rayon;
extern crate reqwest;
extern crate hyper;
extern crate xdg;
extern crate rss;
extern crate rfc822_sanitizer;
pub mod dbqueries;
pub mod models;
pub mod schema;
pub mod index_feed;
pub mod feedparser;
pub mod errors {
use diesel::migrations::RunMigrationsError;
use diesel::result;
use rss;
use hyper;
use reqwest;
use std::io;
error_chain! {
foreign_links {
MigrationError(RunMigrationsError);
DieselResultError(result::Error);
RSSError(rss::Error);
HyperError(hyper::error::Error);
ReqError(reqwest::Error);
IoError(io::Error);
}
}
}

View File

@ -1,21 +1,16 @@
[package]
name = "other"
name = "hammond-downloader"
version = "0.1.0"
authors = ["Jordan Petridis <jordanpetridis@protonmail.com>"]
[dependencies]
hammond-data = {path = "../hammond-data"}
rayon = "0.8.2"
error-chain = "0.11.0"
log = "0.3.8"
loggerv = "0.3.0"
rfc822_sanitizer = "0.3.0"
reqwest = "0.7.3"
hyper = "0.11.2"
diesel = { version = "0.16.0", features = ["sqlite"] }
diesel_codegen = { version = "0.16.0", features = ["sqlite"] }
rss = { version = "1.1.0", features = ["from_url"]}
dotenv = "*"
[dev-dependencies]
tempdir = "0.3.5"

View File

@ -8,6 +8,8 @@ use std::path::Path;
use errors::*;
use hammond_data::dbqueries;
use hammond_data::models::Episode;
use hammond_data::DL_DIR;
// Adapted from https://github.com/mattgathu/rget .
// I never wanted to write a custom downloader.
@ -54,9 +56,6 @@ pub fn download_to(target: &str, url: &str) -> Result<()> {
// Initial messy prototype, queries load alot of not needed stuff.
pub fn latest_dl(connection: &SqliteConnection, limit: u32) -> Result<()> {
use hammond_data::models::Episode;
use hammond_data::DL_DIR;
let pds = dbqueries::get_podcasts(connection)?;
pds.iter()

View File

@ -1,6 +1,5 @@
use reqwest;
use rss;
use hyper;
use diesel::result;
use hammond_data;
@ -10,10 +9,8 @@ error_chain! {
foreign_links {
ReqError(reqwest::Error);
IoError(io::Error);
Log(::log::SetLoggerError);
RSSError(rss::Error);
DieselResultError(result::Error);
HyperError(hyper::error::Error);
HamDBError(hammond_data::errors::Error);
}
}

View File

@ -7,12 +7,8 @@ extern crate hammond_data;
extern crate hyper;
#[macro_use]
extern crate log;
extern crate rayon;
extern crate reqwest;
extern crate rfc822_sanitizer;
extern crate rss;
pub mod feedparser;
pub mod downloader;
pub mod index_feed;
pub mod errors;