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


61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/zerg_xcode/objects/pbx_project.rb', line 61

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


38
39
40
41
42
43
44
45
# File 'lib/zerg_xcode/objects/pbx_project.rb', line 38

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


55
56
57
58
59
# File 'lib/zerg_xcode/objects/pbx_project.rb', line 55

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


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

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