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



75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/zerg_xcode/objects/pbx_project.rb', line 75

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



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

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



69
70
71
72
73
# File 'lib/zerg_xcode/objects/pbx_project.rb', line 69

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



61
62
63
64
65
66
67
# File 'lib/zerg_xcode/objects/pbx_project.rb', line 61

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