1
0
mirror of https://github.com/ThrowTheSwitch/Unity.git synced 2026-01-29 11:14:27 +01:00

Fixed issue #486

This commit is contained in:
mvandervoord
2020-03-17 20:38:11 -04:00
parent 371e062555
commit 2c3e75e859

View File

@@ -164,23 +164,25 @@ class UnityModuleGenerator
end end
############################ ############################
def create_filename(part1, part2 = '') def neutralize_filename(name, start_cap=true)
if part2.empty? return name if name.empty?
case (@options[:naming]) name = name.split(/(?:\s+|_|(?=[A-Z][a-z]))|(?<=[a-z])(?=[A-Z])/).map{|v|v.capitalize}.join('_')
when 'bumpy' then part1 if start_cap
when 'camel' then part1 return name
when 'snake' then part1.downcase
when 'caps' then part1.upcase
else part1
end
else else
case (@options[:naming]) return name[0].downcase + name[1..-1]
when 'bumpy' then part1 + part2 end
when 'camel' then part1 + part2 end
when 'snake' then part1.downcase + '_' + part2.downcase
when 'caps' then part1.upcase + '_' + part2.upcase ############################
else part1 + '_' + part2 def create_filename(part1, part2 = '')
end name = part2.empty? ? part1 : part1 + '_' + part2
case (@options[:naming])
when 'bumpy' then neutralize_filename(name,false).gsub('_','')
when 'camel' then neutralize_filename(name).gsub('_','')
when 'snake' then neutralize_filename(name).downcase
when 'caps' then neutralize_filename(name).upcase
else name
end end
end end