Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion generatorv2/lib/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def initialize(exercise = nil)
@exercise = exercise
end

def generate(result_path = "./exercises/practice/#{@exercise}/#{@exercise}_test.rb")
def generate(result_path = "./exercises/practice/#{@exercise}/#{to_snake(@exercise)}_test.rb")
json = remote_files
uuid = toml("./exercises/practice/#{@exercise}/.meta/tests.toml")
additional_json(json)
Expand All @@ -38,6 +38,10 @@ def camel_case(str)
str.split(/[-_]/).map(&:capitalize).join
end

def to_snake(str)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see camel_case right above here, should this be snake_case instead?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also I see underscore is very similar. And the tests file has not been update to reflect testing of this new public method.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Didn't think about that method. Was quite tired when I made this commit, but good suggestion.

str.gsub(/([a-z\d])([A-Z])/, '\1_\2').tr("-", "_").downcase

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not...

Suggested change
str.gsub(/([a-z\d])([A-Z])/, '\1_\2').tr("-", "_").downcase
str.tr("-", "_").downcase

Are there tests for this file?

end

def skip?
if @first
@first = false
Expand Down
Loading