Skip to content

Instantly share code, notes, and snippets.

@kyubuns
Created March 2, 2018 04:43
Show Gist options
  • Save kyubuns/1d38e73c711806105d07023621f940b7 to your computer and use it in GitHub Desktop.
Save kyubuns/1d38e73c711806105d07023621f940b7 to your computer and use it in GitHub Desktop.
class String
def snakecase
#gsub(/::/, '/').
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
gsub(/([a-z\d])([A-Z])/,'\1_\2').
tr('-', '_').
gsub(/\s/, '_').
gsub(/__+/, '_').
downcase
end
alias_method :underscore, :snakecase
end
Dir.glob('Asset Bundles/*.meta').each do |file_path|
file = File.read(file_path)
name = File.basename(file_path).gsub(/.meta/, "").snakecase
file = file.gsub(/assetBundleName: \n/, "assetBundleName: #{name}\n")
File.write(file_path, file)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment