DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

cory has posted 2 posts at DZone. View Full User Profile

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

02.23.2009
| 1648 views |
  • submit to reddit
        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)