class AssetsMapper::AssetsMapper
Public Class Methods
add_prefix(input)
click to toggle source
# File lib/assets_mapper_ext.rb, line 36 def add_prefix(input) "k#{input}" end
check_string(input, allow_modification)
click to toggle source
# File lib/assets_mapper_ext.rb, line 6 def check_string(input, allow_modification) if allow_modification remove_spacing( add_prefix( titleize( remove_non_alphanumeric input ) ) ) elsif input.match('([0-9]+.+|[ \W]*)') error_msg = "Asset name: ".red + input.yellow + " violates Swift variable naming rules!!\n".red + \ "Please consider to change it".red suggestion_msg = "If your want to allow #{"asset_mapper".green} to perform modification\n" \ "You can set option --allow-modification" puts error_msg puts suggestion_msg abort else input end end
new(ignore_folder, allow_modification)
click to toggle source
# File lib/assets-mapper.rb, line 6 def initialize(ignore_folder, allow_modification) @ignore_folder = ignore_folder @allow_modification = allow_modification end
remove_non_alphanumeric(input)
click to toggle source
# File lib/assets_mapper_ext.rb, line 28 def remove_non_alphanumeric(input) input.downcase.gsub(/[^a-z0-9\s]/, '') end
remove_spacing(input)
click to toggle source
# File lib/assets_mapper_ext.rb, line 40 def remove_spacing(input) input.gsub(' ','') end
titleize(input)
click to toggle source
# File lib/assets_mapper_ext.rb, line 32 def titleize(input) input.split.each{|x| x.capitalize!}.join('') end
Public Instance Methods
create_assets_map(path_to_read, path_to_write)
click to toggle source
# File lib/assets-mapper.rb, line 10 def create_assets_map(path_to_read, path_to_write) if @ignore_folder xcasset = IgnoreFolderXcassets.new(path_to_read, @allow_modification) Xcassets.write(xcasset.enum.to_s, path_to_write) else puts "No" end end
Private Instance Methods
read_assets(name)
click to toggle source
# File lib/assets-mapper.rb, line 19 def read_assets(name) puts "Read assets with name : #{name}" end