-
-
Notifications
You must be signed in to change notification settings - Fork 528
Fix exercise naming in generator #1770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…t file naming convention
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
generatorv2/lib/generator.rb
Outdated
end | ||
|
||
def underscore(str) | ||
str.gsub(/[-\s]/, '_').downcase | ||
str.gsub(/[^a-zA-Z0-9_\- ]/, '').gsub(/[-\s]/, '_').downcase |
There was a problem hiding this comment.
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?
* 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
* 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
* 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
* 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]>
* 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]>
* 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
* 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
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.