-
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.
feat(ruby): add support for rufo (#100)
- Loading branch information
Showing
7 changed files
with
97 additions
and
18 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use super::execute_command; | ||
|
||
#[inline] | ||
pub fn format_using_rufo( | ||
snippet_path: &std::path::Path, | ||
) -> std::io::Result<(bool, Option<String>)> { | ||
let mut cmd = std::process::Command::new("rufo"); | ||
|
||
cmd.arg("--simple-exit").arg(snippet_path); | ||
|
||
execute_command(&mut cmd, snippet_path) | ||
} | ||
|
||
#[cfg(test)] | ||
mod test_rufo { | ||
use crate::{ | ||
formatters::{rufo::format_using_rufo, setup_snippet}, | ||
languages::Language, | ||
}; | ||
|
||
#[test_with::executable(rufo)] | ||
#[test] | ||
fn it_should_format_ruby() { | ||
let input = "def add( a , b ) | ||
return a + b | ||
end"; | ||
|
||
let expected_output = "def add(a, b) | ||
return a + b | ||
end | ||
"; | ||
|
||
let snippet = setup_snippet(input, Language::Ruby.to_file_ext()) | ||
.expect("it to create a snippet file"); | ||
|
||
let output = format_using_rufo(snippet.path()) | ||
.expect("it to be successful") | ||
.1 | ||
.expect("it to be some"); | ||
|
||
assert_eq!(expected_output, output); | ||
} | ||
} |
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