class XcodeProject::XCBuildConfiguration

Attributes

build_settings[RW]
name[R]

Public Class Methods

new(root, uuid, data) click to toggle source
Calls superclass method XcodeProject::Node::new
# File lib/xcodeproject/xc_build_configuration.rb, line 33
def initialize (root, uuid, data)
        super(root, uuid, data)

        @name = data['name']
        @build_settings = data['buildSettings']
end

Public Instance Methods

change_version(value, type = :major) click to toggle source
# File lib/xcodeproject/xc_build_configuration.rb, line 52
def change_version (value, type = :major)
        case type
                when :major ; write_property('CFBundleShortVersionString', value)
                when :minor ; write_property('CFBundleVersion', value)
                else raise ArgumentError.new('Wrong argument type, expected :major or :minor.')
        end
end
increment_version(type = :major) click to toggle source
# File lib/xcodeproject/xc_build_configuration.rb, line 60
def increment_version (type = :major)
        cv = version(type)
        nv = cv.nil? ? '0' : cv.next

        change_version(nv, type)
end
version(type = :major) click to toggle source
# File lib/xcodeproject/xc_build_configuration.rb, line 40
def version (type = :major)
        major = read_property('CFBundleShortVersionString')
        minor = read_property('CFBundleVersion')

        case type
                when :major ; major
                when :minor ; minor
                when :both  ; major + '.' + minor
                else raise ArgumentError.new('Wrong argument type, expected :major, :minor or :both.')
        end
end

Private Instance Methods

plist_path() click to toggle source
# File lib/xcodeproject/xc_build_configuration.rb, line 69
def plist_path
        root.absolute_path(build_settings['INFOPLIST_FILE'])
end
read_property(key) click to toggle source
# File lib/xcodeproject/xc_build_configuration.rb, line 73
def read_property (key)
        file = File.new(plist_path)
        doc = REXML::Document.new(file)
        
        doc.elements.each("plist/dict/key") do |e| 
                 return e.next_element.text if e.text == key
        end
        nil
end
write_property(key, value) click to toggle source
# File lib/xcodeproject/xc_build_configuration.rb, line 83
def write_property (key, value)
        file = File.new(plist_path)
        doc = REXML::Document.new(file)

        doc.elements.each("plist/dict/key") do |e|
                e.next_element.text = value if e.text == key
        end

        formatter = REXML::Formatters::Default.new
        File.open(plist_path, 'w') do |data|
                formatter.write(doc, data)
        end
        nil
end