Skip to content

Commit

Permalink
feat: add language for plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Feb 24, 2021
1 parent f96e7ad commit b278560
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
41 changes: 41 additions & 0 deletions core_model/src/coco_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,45 @@ impl Default for CocoConfig {
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
pub struct RepoConfig {
pub url: String,
pub language: Option<Vec<String>>,
}

impl Default for RepoConfig {
fn default() -> Self {
RepoConfig {
url: "".to_string(),
language: None,
}
}
}

impl RepoConfig {
pub fn new(url: &str) -> RepoConfig {
RepoConfig {
url: url.to_string(),
language: None,
}
}
}

#[cfg(test)]
mod test {
use crate::CocoConfig;

#[test]
fn should_parse_language() {
let data = r#"
repo:
- url: https://github.com/projectfluent/fluent-rs
language: [Rust, JavaScript]
plugins:
- swagger
"#;
let config: CocoConfig = serde_yaml::from_str(&data).expect("parse config file error");
let repos = config.repo;
let languages = repos[0].language.as_ref().unwrap();
assert_eq!(2, languages.len());
assert_eq!("Rust", languages[0]);
}
}
1 change: 1 addition & 0 deletions plugins/coco_struct_analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ mod tests {
let mut repos = vec![];
repos.push(RepoConfig {
url: format!("{}", ctags_fixtures_dir().display()),
language: None,
});
let config = CocoConfig {
repo: repos,
Expand Down
3 changes: 2 additions & 1 deletion src/bin/coco.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ fn create_config(config_file: &str) -> CocoConfig {
let current = env::current_dir().unwrap();
repo.push(RepoConfig {
url: current.into_os_string().to_str().unwrap().to_string(),
language: None,
});
CocoConfig {
repo,
repo: repo,
plugins: vec![],
}
}
Expand Down

0 comments on commit b278560

Please sign in to comment.