diff --git a/crates/core/src/models/language.rs b/crates/core/src/models/language.rs index d5ff22b7a..99cea8f48 100644 --- a/crates/core/src/models/language.rs +++ b/crates/core/src/models/language.rs @@ -278,7 +278,7 @@ impl std::str::FromStr for PiranhaLanguage { let ruby_rules: Rules = parse_toml(include_str!("../cleanup_rules/ruby/rules.toml")); let ruby_edges: Edges = parse_toml(include_str!("../cleanup_rules/ruby/edges.toml")); Ok(PiranhaLanguage { - extension: "rs".to_string(), + extension: "rb".to_string(), supported_language: SupportedLanguage::Ruby, language: tree_sitter_ruby::language(), scopes: parse_toml::(include_str!( @@ -286,7 +286,7 @@ impl std::str::FromStr for PiranhaLanguage { )) .scopes() .to_vec(), - comment_nodes: vec![], + comment_nodes: vec!["comment".to_string()], rules: Some(ruby_rules), edges: Some(ruby_edges), }) diff --git a/crates/core/src/tests/mod.rs b/crates/core/src/tests/mod.rs index 29dfd4ede..90774de75 100644 --- a/crates/core/src/tests/mod.rs +++ b/crates/core/src/tests/mod.rs @@ -37,6 +37,7 @@ mod test_piranha_scala; mod test_piranha_thrift; +mod test_piranha_ruby; mod test_piranha_scm; mod test_piranha_strings; mod test_piranha_yaml; diff --git a/crates/core/src/tests/test_piranha_ruby.rs b/crates/core/src/tests/test_piranha_ruby.rs new file mode 100644 index 000000000..b3391ef9f --- /dev/null +++ b/crates/core/src/tests/test_piranha_ruby.rs @@ -0,0 +1,32 @@ +/* + Copyright (c) 2023 Uber Technologies, Inc. + +

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file + except in compliance with the License. You may obtain a copy of the License at +

http://www.apache.org/licenses/LICENSE-2.0 + +

Unless required by applicable law or agreed to in writing, software distributed under the + License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + express or implied. See the License for the specific language governing permissions and + limitations under the License. +*/ + +use crate::models::default_configs::RUBY; + +use super::create_rewrite_tests; + +create_rewrite_tests! { + RUBY, + test_replace_empty_if_unless_statement: "replace_empty_if_or_unless_statement", 1; + test_replace_ternary_operator: "replace_ternary_operator", 1; + test_replace_if_statement: "replace_if_statement", 3; + test_replace_unless_statement: "replace_unless_statement", 3; + test_boolean_cleanup: "simplify_boolean_expressions", 1; + test_simplify_rspec_block_expressions: "simplify_rspec_block_expressions", 1; + test_simplify_if_lambda_conditional_statements: "simplify_if_lambda_conditional_statements", 1; + test_simplify_unless_lambda_conditional_statements: "simplify_unless_lambda_conditional_statements", 1; + test_simplify_if_proc_conditional_statements: "simplify_if_proc_conditional_statements", 1; + test_simplify_unless_proc_conditional_statements: "simplify_unless_proc_conditional_statements", 1; + test_delete_lines_after_return: "delete_lines_after_return", 1; + simplify_variable_assigned_flag_check: "simplify_variable_assigned_flag_check", 1; +} \ No newline at end of file