-
Notifications
You must be signed in to change notification settings - Fork 0
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
6 changed files
with
102 additions
and
14 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
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,34 @@ | ||
use crate::args::ignore_facts::parse_facts; | ||
use std::collections::HashMap; | ||
use std::fs::File; | ||
use std::io::{BufRead, BufReader}; | ||
use std::path::Path; | ||
|
||
/// Ignore file. | ||
/// `name` Ignore file name | ||
#[derive(Clone)] | ||
pub struct IgnoreFile { | ||
name: String, | ||
} | ||
|
||
impl IgnoreFile { | ||
/// New ignore file. | ||
pub fn new(name: String) -> IgnoreFile { | ||
IgnoreFile { name } | ||
} | ||
|
||
/// Is file exists? | ||
pub fn exists(self) -> bool { | ||
Path::new(&self.name).exists() | ||
} | ||
|
||
/// Facts. | ||
pub fn facts(self) -> HashMap<String, Vec<String>> { | ||
let file = File::open(self.name); | ||
let reader = BufReader::new(file); | ||
let facts: Vec<String> = reader.lines() | ||
.filter_map(Result::ok) | ||
.collect(); | ||
parse_facts(facts) | ||
} | ||
} |
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,27 @@ | ||
use crate::args::ignore_facts::{ignores_dim, ignores_title}; | ||
use crate::args::ignore_file::IgnoreFile; | ||
use crate::github::github_issue::GithubIssue; | ||
|
||
/// Ignore issue? | ||
/// * `issue`: Issue | ||
/// * `file`: File with facts | ||
pub fn ignore_issue(issue: GithubIssue, file: IgnoreFile) -> bool { | ||
let facts = file.facts(); | ||
let mut result = false; | ||
if ignores_title(issue.clone().title(), facts.clone()) { | ||
result = true | ||
} else if ignores_dim( | ||
issue.author(), | ||
String::from("author"), | ||
facts.clone(), | ||
) { | ||
result = true | ||
} else if ignores_dim( | ||
issue.labels(), | ||
String::from("label"), | ||
facts, | ||
) { | ||
result = true | ||
} | ||
result | ||
} |
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
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