Class: CopyHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/resourcesCopy.rb

Instance Method Summary collapse

Constructor Details

#initializeCopyHelper

desc “Instance”



8
9
# File 'lib/resourcesCopy.rb', line 8

def initialize()  
end

Instance Method Details

#copy(from_dir, to_dir) ⇒ Object

desc “public copy”



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/resourcesCopy.rb', line 18

def copy(from_dir, to_dir)
	# specify files which should not be copied
	dont_copy = ['.xcassets','.bundle']
	Dir[from_dir + "/**/*.{xib,storyboard,xcassets,bundle,jsbundle}"].each do |old_dest| 
		new_dest = old_dest.gsub(from_dir, to_dir)
		should_not_copy = dont_copy.any? { |s| new_dest.end_with?(s) }
		if !should_not_copy
			copy_with_path(old_dest, new_dest);
		else
			FileUtils.mkdir_p(File.dirname(new_dest))
			comd = "cp -R " + old_dest + " " + new_dest
			system(comd)
		end
	end
end

#copy_with_path(src, dest) ⇒ Object

desc “private copy”



12
13
14
15
# File 'lib/resourcesCopy.rb', line 12

def copy_with_path(src, dest)
	FileUtils.mkdir_p(File.dirname(dest))
	FileUtils.cp(src, dest)
end