Created
December 18, 2015 02:38
-
-
Save daveshah/10f0eee932da3e63f793 to your computer and use it in GitHub Desktop.
Ugh, because this is one of those things I've done way too much
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fileutils' | |
class Tuple | |
attr_accessor :first, :last | |
def initialize(first,last) | |
@first = first | |
@last = last | |
end | |
end | |
ios_directory = "../ios-images/" | |
android_base_dir = "../app/src/main/res" | |
hdpi_dir = "#{android_base_dir}/drawable-hdpi/" | |
mdpi_dir = "#{android_base_dir}/drawable-mdpi/" | |
xhdpi_dir = "#{android_base_dir}/drawable-xhdpi/" | |
cleaned_file_names = Dir.entries("../ios-images/") | |
.reject{|file_name| !file_name.include?(".png") } | |
.map { |file_name| Tuple.new(file_name, file_name.downcase.gsub("-","_")) } | |
cleaned_file_names.each { |tuple| | |
if tuple.last.include?("@2x") | |
file = tuple.last.gsub("@2x","") | |
FileUtils.cp(ios_directory + tuple.first,hdpi_dir + file) | |
elsif tuple.last.include?("@3x") | |
file = tuple.last.gsub("@3x","") | |
FileUtils.cp(ios_directory + tuple.first,xhdpi_dir + file) | |
else | |
FileUtils.cp(ios_directory + tuple.first, mdpi_dir + tuple.last) | |
end | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment