module XcodeMove
Constants
- VERSION
Public Class Methods
mv(src, dst, options)
click to toggle source
Moves from one `Pathname` to another
# File lib/xcmv.rb, line 11 def self.mv(src, dst, options) src_file = src.directory? ? Group.new(src) : File.new(src) dst_file = dst.directory? ? src_file.with_dirname(dst) : File.new(dst) puts("#{src_file.path} => #{dst_file.path}") project_mv(src_file, dst_file, options) disk_mv(src_file, dst_file, options) save(src_file, dst_file) end
Private Class Methods
disk_mv(src_file, dst_file, options)
click to toggle source
Move the src_file to the dst_file on disk
# File lib/xcmv.rb, line 53 def self.disk_mv(src_file, dst_file, options) mover = options[:git] ? "git mv" : "mv" command = "#{mover} '#{src_file.path}' '#{dst_file.path}'" system(command) || abort end
project_mv(src_file, dst_file, options)
click to toggle source
Prepare the project file(s) for the move
# File lib/xcmv.rb, line 25 def self.project_mv(src_file, dst_file, options) if src_file.path.directory? # Process all children first children = src_file.path.children.map { |c| c.directory? ? Group.new(c) : File.new(c) } children.each do | src_child | dst_child = src_child.with_dirname(dst_file.path) project_mv(src_child, dst_child, options) end else # Remove old destination file reference if it exists if dst_file.pbx_file dst_file.remove_from_project end # Add new destination file reference to the new xcodeproj dst_file.create_file_reference dst_file.add_to_targets(options[:targets], options[:headers]) end # Remove original directory/file from xcodeproj if src_file.pbx_file src_file.remove_from_project else warn("⚠️ Warning: #{src_file.path.basename} not found in #{src_file.project.path.basename}, moving anyway...") end end
save(src_file, dst_file)
click to toggle source
Save the src_file and dst_file project files to disk
# File lib/xcmv.rb, line 60 def self.save(src_file, dst_file) src_file.save_and_close dst_file.save_and_close end