Class: Xcode::ProvisioningProfile

Inherits:
Object
  • Object
show all
Defined in:
lib/xcode/provisioning_profile.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ ProvisioningProfile

Returns a new instance of ProvisioningProfile.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/xcode/provisioning_profile.rb', line 4

def initialize(path)
  
  raise "Provisioning profile '#{path}' does not exist" unless File.exists? path
  
  @path = path
  @identifiers = []
  @devices = []
  @appstore = true
  
  # TODO: im sure this could be done in a nicer way.  maybe read out the XML-like stuff and use the plist -> json converter
  uuid = nil
  File.open(path, "rb") do |f|
    input = f.read
    
    if input=~/ProvisionedDevices/
      @appstore = false
    end
    
    if input=~/<key>ProvisionedDevices<\/key>.*?<array>(.*?)<\/array>/im
      $1.split(/<string>/).each do |id|
        next if id.nil? or id.strip==""
        @devices << id.gsub(/<\/string>/,'').strip
      end
    end
    
    input=~/<key>UUID<\/key>.*?<string>(.*?)<\/string>/im
    @uuid = $1.strip
            
    input=~/<key>Name<\/key>.*?<string>(.*?)<\/string>/im
    @name = $1.strip
    
    input=~/<key>ApplicationIdentifierPrefix<\/key>.*?<array>(.*?)<\/array>/im
    $1.split(/<string>/).each do |id|
      next if id.nil? or id.strip==""
      @identifiers << id.gsub(/<\/string>/,'').strip
    end
  end

end

Instance Attribute Details

#appstoreObject (readonly)

Returns the value of attribute appstore.



3
4
5
# File 'lib/xcode/provisioning_profile.rb', line 3

def appstore
  @appstore
end

#devicesObject (readonly)

Returns the value of attribute devices.



3
4
5
# File 'lib/xcode/provisioning_profile.rb', line 3

def devices
  @devices
end

#identifiersObject (readonly)

Returns the value of attribute identifiers.



3
4
5
# File 'lib/xcode/provisioning_profile.rb', line 3

def identifiers
  @identifiers
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/xcode/provisioning_profile.rb', line 3

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/xcode/provisioning_profile.rb', line 3

def path
  @path
end

#uuidObject (readonly)

Returns the value of attribute uuid.



3
4
5
# File 'lib/xcode/provisioning_profile.rb', line 3

def uuid
  @uuid
end

Class Method Details

.installed_profilesObject



64
65
66
67
68
# File 'lib/xcode/provisioning_profile.rb', line 64

def self.installed_profiles
  Dir["#{self.profiles_path}/*.mobileprovision"].map do |file|
    ProvisioningProfile.new(file)
  end
end

.profiles_pathObject



48
49
50
# File 'lib/xcode/provisioning_profile.rb', line 48

def self.profiles_path
  File.expand_path "~/Library/MobileDevice/Provisioning\\ Profiles/"  
end

Instance Method Details

#appstore?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/xcode/provisioning_profile.rb', line 44

def appstore?
  @appstore
end

#installObject



56
57
58
# File 'lib/xcode/provisioning_profile.rb', line 56

def install
  Xcode::Shell.execute("cp #{self.path} #{self.install_path}")   
end

#install_pathObject



52
53
54
# File 'lib/xcode/provisioning_profile.rb', line 52

def install_path
  "#{ProvisioningProfile.profiles_path}/#{self.uuid}.mobileprovision"
end

#uninstallObject



60
61
62
# File 'lib/xcode/provisioning_profile.rb', line 60

def uninstall
  Xcode::Shell.execute("rm -f #{self.install_path}")
end