Skip to content

Instantly share code, notes, and snippets.

@ren
Created May 18, 2014 01:10
Show Gist options
  • Save ren/6af84e4302f0fb558f33 to your computer and use it in GitHub Desktop.
Save ren/6af84e4302f0fb558f33 to your computer and use it in GitHub Desktop.
iOS .imageset generator
#!/usr/bin/env ruby
contents_json = Dir["**/Contents.json"]
contents_json.each do |file|
newline = "\"filename\" : \"#{(file.split('/')[1]).gsub('.imageset', '.jpg')}\""
new_contents = "{
\"images\" : [
{
\"idiom\" : \"universal\",
\"scale\" : \"1x\"
},
{
\"idiom\" : \"universal\",
\"scale\" : \"2x\",
#{newline}
}
],
\"info\" : {
\"version\" : 1,
\"author\" : \"xcode\"
}
}"
f = File.new(file, "w")
f.write new_contents
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment