-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
91 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod pas_content_root; | ||
pub mod psa_facet; | ||
pub mod psa_library; | ||
pub mod psa_module; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
pub struct ContentRoot { | ||
pub source_root: Vec<String>, | ||
pub resource_root: Vec<String>, | ||
pub test_source_root: Vec<String>, | ||
pub test_resource_root: Vec<String>, | ||
} | ||
|
||
impl ContentRoot { | ||
pub fn add_source_root(&mut self, root_path: &str) { | ||
self.source_root.push(root_path.to_string()); | ||
} | ||
|
||
pub fn add_resource_root(&mut self, root_path: &str) { | ||
self.resource_root.push(root_path.to_string()); | ||
} | ||
|
||
pub fn add_test_source_root(&mut self, root_path: &str) { | ||
self.test_source_root.push(root_path.to_string()); | ||
} | ||
|
||
pub fn add_test_resource_root(&mut self, root_path: &str) { | ||
self.test_resource_root.push(root_path.to_string()); | ||
} | ||
} | ||
|
||
impl Default for ContentRoot { | ||
fn default() -> Self { | ||
ContentRoot { | ||
source_root: vec![], | ||
resource_root: vec![], | ||
test_source_root: vec![], | ||
test_resource_root: vec![], | ||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use crate::pas_content_root::ContentRoot; | ||
|
||
#[test] | ||
fn should_add_various_roots() { | ||
let mut content_root = ContentRoot::default(); | ||
|
||
content_root.add_source_root("src/main/java"); | ||
content_root.add_resource_root("src/main/resources"); | ||
content_root.add_test_source_root("src/test/java"); | ||
content_root.add_test_resource_root("src/test/resources"); | ||
|
||
assert_eq!(content_root.source_root, vec!["src/main/java".to_string()]); | ||
assert_eq!( | ||
content_root.resource_root, | ||
vec!["src/main/resources".to_string()] | ||
); | ||
assert_eq!( | ||
content_root.test_source_root, | ||
vec!["src/test/java".to_string()] | ||
); | ||
assert_eq!( | ||
content_root.test_resource_root, | ||
vec!["src/test/resources".to_string()] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters