class XcodeProject::Project

Attributes

bundle_path[R]
file_path[R]
name[R]

Public Class Methods

find(pattern = nil) click to toggle source
# File lib/xcodeproject/project.rb, line 36
def self.find(pattern = nil)
  pattern = Pathname.new(pattern.to_s)
  pattern = pattern.join('*.xcodeproj') if pattern.extname != '.xcodeproj'

  Dir[pattern].map { |path| new(path) }
end
new(path) click to toggle source
# File lib/xcodeproject/project.rb, line 43
def initialize(path)
  path = Pathname.new(path)
  raise FilePathError, "No such project file '#{path}'." unless path.exist?

  @bundle_path = path
  @file_path = bundle_path.join('project.pbxproj')
  @name = bundle_path.basename('.*').to_s
end

Public Instance Methods

change() { |data| ... } click to toggle source
# File lib/xcodeproject/project.rb, line 52
def change
  data = read
  yield data
  write data
end
doctor() click to toggle source
# File lib/xcodeproject/project.rb, line 68
def doctor
  change(&:doctor)
end
read() click to toggle source
# File lib/xcodeproject/project.rb, line 58
def read
  Data.new(JSON.parse(`plutil -convert json -o - "#{file_path}"`), bundle_path.dirname)
end
write(data) click to toggle source
# File lib/xcodeproject/project.rb, line 62
def write(data)
  File.open(file_path, 'w') do |file|
    file.write(data.to_plist)
  end
end