Class: RXCode::Project

Inherits:
Model
  • Object
show all
Defined in:
lib/rxcode/models/project.rb

Constant Summary collapse

XCODE_PROJECT_EXTENSION =
PROJECT DISCOVERY & LOOKUP =================================================================================
'.xcodeproj'.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

class_for_archived_object_type, map_archived_object, object_at_path, #root

Constructor Details

#initialize(path, options = nil) ⇒ Project

Returns a new instance of Project.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/rxcode/models/project.rb', line 5

def initialize(path, options = nil)
  raise "#{path.inspect} is not a valid XCode project path" unless self.class.is_project_at_path?(path)
  
  super nil
  
  @path = path
  
  if options && options[:workspace]
    @workspace = options[:workspace]
  end
end

Instance Attribute Details

#pathObject (readonly)

PROJECT PATH ===============================================================================================


34
35
36
# File 'lib/rxcode/models/project.rb', line 34

def path
  @path
end

#workspaceObject (readonly)

WORKSPACE ==================================================================================================


19
20
21
# File 'lib/rxcode/models/project.rb', line 19

def workspace
  @workspace
end

Class Method Details

.is_project_at_path?(project_path) ⇒ Boolean

Determines if the provided file path is an XCode project

Returns:

  • (Boolean)


28
29
30
# File 'lib/rxcode/models/project.rb', line 28

def self.is_project_at_path?(project_path)
  File.directory?(project_path) && File.extname(project_path) == XCODE_PROJECT_EXTENSION
end

Instance Method Details

#archiveObject



40
41
42
43
44
45
46
47
# File 'lib/rxcode/models/project.rb', line 40

def archive
  @archive ||=
    begin
      a = Archive.new(project_archive_path) { |archived_object| Model.map_archived_object(archived_object) }
      a.root_object.model_object = self
      a
    end
end

#archive_objectObject



49
50
51
# File 'lib/rxcode/models/project.rb', line 49

def archive_object
  archive.root_object
end

#build_configuration_listObject

BUILD CONFIGURATIONS =======================================================================================


65
66
67
# File 'lib/rxcode/models/project.rb', line 65

def build_configuration_list
  archive_object.model_object_for_key('buildConfigurationList')
end

#project_archive_pathObject



36
37
38
# File 'lib/rxcode/models/project.rb', line 36

def project_archive_path
  File.join(self.path, 'project.pbxproj')
end

#target_namesObject



59
60
61
# File 'lib/rxcode/models/project.rb', line 59

def target_names
  targets.map(&:name)
end

#targetsObject

TARGETS ====================================================================================================


55
56
57
# File 'lib/rxcode/models/project.rb', line 55

def targets
  archive_object.array_of_model_objects_for_key('targets')
end