Module: ZergXcode::Objects::PBXProject::FileVisitor

Defined in:
lib/zerg_xcode/objects/pbx_project.rb

Overview

Container for the visitor that lists all files in a project.

Class Method Summary collapse

Class Method Details

.merge_path(old_path, source_tree, object) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/zerg_xcode/objects/pbx_project.rb', line 71

def self.merge_path(old_path, source_tree, object)
  case source_tree
  when '<group>'
    base_path = old_path
  else
    base_path = source_tree
  end
  if object['path']
    path = File.join(base_path, object['path'])
  else
    path = old_path
  end
  return path
end

.visit(object, root_path, files) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/zerg_xcode/objects/pbx_project.rb', line 48

def self.visit(object, root_path, files)
  case object.isa
  when :PBXGroup
    visit_group(object, root_path, files)
  when :PBXFileReference
    visit_file(object, root_path, files)
  end
end

.visit_file(file, root_path, files) ⇒ Object



65
66
67
68
69
# File 'lib/zerg_xcode/objects/pbx_project.rb', line 65

def self.visit_file(file, root_path, files)
  path = merge_path(root_path, file['sourceTree'], file)
  
  files << { :path => path, :object => file } 
end

.visit_group(group, root_path, files) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/zerg_xcode/objects/pbx_project.rb', line 57

def self.visit_group(group, root_path, files)
  path = merge_path(root_path, group['sourceTree'], group)
  
  group['children'].each do |child|
    visit child, path, files
  end
end