Over a million developers have joined DZone.

Inject A Version Number Before A File Extension In Ruby (2 One Liners)

·
Quick way to add a version to a file name in ruby.  I use it for when I'm bulk renaming javascript/stylesheets to force updates...


path = path.split('.').insert(-2,@the_version).join('.')

# or
path.insert(-(File.extname(path).length+1),@the_version)
Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}