diff --git a/Cargo.lock b/Cargo.lock index 935b825..312acb6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2201,10 +2201,13 @@ dependencies = [ "db-core", "db-sqlx-sqlite", "derive_more", + "federate-core", "forge-core", "gitea", "lazy_static", "log", + "mktemp", + "publiccodeyml", "rand", "reqwest", "serde", diff --git a/Cargo.toml b/Cargo.toml index 90cf77a..8671309 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,6 +65,15 @@ path = "./forge/gitea" [dependencies.forge-core] path = "./forge/forge-core" +[dependencies.federate-core] +path = "./federate/federate-core" + +[dependencies.publiccodeyml] +path = "./federate/publiccodeyml" + [dependencies.sqlx] features = ["runtime-actix-rustls", "uuid", "postgres", "time", "offline", "sqlite"] version = "0.5.11" + +[dev-dependencies] +mktemp = "0.4.1" diff --git a/src/federate.rs b/src/federate.rs new file mode 100644 index 0000000..7a68cc0 --- /dev/null +++ b/src/federate.rs @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2022 Aravinth Manivannan + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +use crate::settings::Settings; +use federate_core::Federate; + +use publiccodeyml::{errors::FederateErorr, PccFederate}; + +pub type BoxFederate = Box>; + +pub async fn get_federate(settings: Option) -> BoxFederate { + let settings = settings.unwrap_or_else(|| Settings::new().unwrap()); + Box::new(PccFederate::new(settings.repository.root).await.unwrap()) +} diff --git a/src/main.rs b/src/main.rs index af443d8..d4694fb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,6 +17,7 @@ */ pub mod ctx; pub mod db; +pub mod federate; pub mod forge; pub mod settings; pub mod spider;