Skip to content

Commit

Permalink
feat(psa): psa json serialize support.
Browse files Browse the repository at this point in the history
  • Loading branch information
ynfeng committed Feb 26, 2021
1 parent 00e0a25 commit ab668e7
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 1 deletion.
3 changes: 3 additions & 0 deletions psa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ pub use psa_library::Library;
pub use psa_library::LibraryScope;
pub use psa_module::Module;
pub use psa_project::Project;
#[macro_use]
extern crate serde_derive;
extern crate serde;

pub mod files;
pub mod jvm;
Expand Down
1 change: 1 addition & 0 deletions psa/src/pas_content_root.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[derive(Serialize)]
pub struct ContentRoot {
pub source_root: Vec<String>,
pub resource_root: Vec<String>,
Expand Down
24 changes: 24 additions & 0 deletions psa/src/project_structure_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,28 @@ mod tests {

assert_eq!(project.is_none(), true);
}

#[test]
fn should_serialize() {
let project_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.parent()
.unwrap()
.to_path_buf()
.join("_fixtures")
.join("projects")
.join("java")
.join("multi_mod_maven_project")
.clone();

let analyzer = ProjectAnalyzer::default();

let project = analyzer
.run(project_dir.display().to_string().as_str())
.unwrap();

let project_json = serde_json::to_string_pretty(&project).unwrap();

println!("{}", project_json);
assert_ne!(project_json, "");
}
}
1 change: 1 addition & 0 deletions psa/src/psa_facet.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[derive(Serialize)]
pub struct Facet {
pub name: String,
}
Expand Down
3 changes: 2 additions & 1 deletion psa/src/psa_library.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#[derive(Serialize)]
pub struct Library {
pub name: String,
pub group: String,
pub version: String,
pub scope: LibraryScope,
}

#[derive(PartialEq, Debug)]
#[derive(Serialize, PartialEq, Debug)]
pub enum LibraryScope {
Test,
Compile,
Expand Down
1 change: 1 addition & 0 deletions psa/src/psa_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::pas_content_root::ContentRoot;
use crate::psa_facet::Facet;
use crate::psa_library::Library;

#[derive(Serialize)]
pub struct Module {
pub name: String,
pub path: String,
Expand Down
1 change: 1 addition & 0 deletions psa/src/psa_project.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::psa_module::Module;

#[derive(Serialize)]
pub struct Project {
pub name: String,
pub path: String,
Expand Down

0 comments on commit ab668e7

Please sign in to comment.