Skip to content

Conversation

meatball133
Copy link
Member

The fix for the exercise name was only applied for the generator not the bin script. The underscore method in the generator will now clear all characters which is not numbers or letters. Noticed this would conflict when a description on problem spec had for example "," in it. Further, are there some formatting changes to make so it formats the files correctly.

Copy link
Member

@kotp kotp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving with comment/questions.

bin/generate Outdated
@@ -9,6 +9,10 @@ def exercises
.select { |file| File.directory? File.join('./exercises/practice', file) }
end

def underscore(str)
str.gsub(/[^a-zA-Z0-9_-]/, '').gsub(/[-\s]/, '_').downcase
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this use the character class instead of listing these, or is this limited to only the mentioned characters?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I don't write regex that often, so I am not that good at it. Likely something I should work on.

end

def underscore(str)
str.gsub(/[-\s]/, '_').downcase
str.gsub(/[^a-zA-Z0-9_\- ]/, '').gsub(/[-\s]/, '_').downcase
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use a character class here as well?

@kotp kotp merged commit 5424cdd into main Aug 31, 2025
5 checks passed
@kotp kotp deleted the fix-naming branch August 31, 2025 19:12
meatball133 added a commit that referenced this pull request Aug 31, 2025
* Enhance underscore method to filter invalid characters and update test file naming convention
* Add test case which test underscore for special characters
* Use character classes in regex. Also expose description for nested test cases.
* Underscore must not create multiple underscores around special characters
meatball133 added a commit that referenced this pull request Aug 31, 2025
* Enhance underscore method to filter invalid characters and update test file naming convention
* Add test case which test underscore for special characters
* Use character classes in regex. Also expose description for nested test cases.
* Underscore must not create multiple underscores around special characters
meatball133 added a commit that referenced this pull request Aug 31, 2025
* Enhance underscore method to filter invalid characters and update test file naming convention
* Add test case which test underscore for special characters
* Use character classes in regex. Also expose description for nested test cases.
* Underscore must not create multiple underscores around special characters
kotp added a commit that referenced this pull request Aug 31, 2025
* Make test name unique in allergies
* Changed exercises to use single quotes. Changed template for allergies so it should match the old version.
* Update acronym solution to work on the new test
* Fix import and class in atbash test
* Fix exercise naming in generator (#1770) (#1774)
* Enhance underscore method to filter invalid characters and update test file naming convention
* Add test case which test underscore for special characters
* Use character classes in regex. Also expose description for nested test cases.
* Underscore must not create multiple underscores around special characters

---------

Co-authored-by: Victor Goff <[email protected]>
meatball133 added a commit that referenced this pull request Aug 31, 2025
* Fix exercise naming in generator (#1770)

* Enhance underscore method to filter invalid characters and update test file naming convention
* Add test case which test underscore for special characters
* Use character classes in regex. Also expose description for nested test cases.
* Underscore must not create multiple underscores around special characters

* Add templates to exercises batch 1 (#1771)

* Make test name unique in allergies
* Changed exercises to use single quotes. Changed template for allergies so it should match the old version.
* Update acronym solution to work on the new test
* Fix import and class in atbash test
* Fix exercise naming in generator (#1770) (#1774)
* Enhance underscore method to filter invalid characters and update test file naming convention
* Add test case which test underscore for special characters
* Use character classes in regex. Also expose description for nested test cases.
* Underscore must not create multiple underscores around special characters

---------

Co-authored-by: Victor Goff <[email protected]>

---------

Co-authored-by: Victor Goff <[email protected]>
meatball133 added a commit that referenced this pull request Sep 3, 2025
* Update bob and change and book store

* Add templates for bottlesong, bowling,clock and collatz conjecture

* Fix exercise naming in generator (#1770) (#1776)

* Enhance underscore method to filter invalid characters and update test file naming convention
* Add test case which test underscore for special characters
* Use character classes in regex. Also expose description for nested test cases.
* Underscore must not create multiple underscores around special characters

* Fix formatting

* Add EOL
kotp pushed a commit that referenced this pull request Sep 7, 2025
* Add templates for exercises batch 3
* Fix exercise naming in generator (#1770) (#1777)
* Enhance underscore method to filter invalid characters and update test file naming convention
* Add test case which test underscore for special characters
* Use character classes in regex. Also expose description for nested test cases.
* Underscore must not create multiple underscores around special characters
* Change to single quotes, change conditional statement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants