Class: Xcode::ProvisioningProfile
- Inherits:
-
Object
- Object
- Xcode::ProvisioningProfile
- Includes:
- TerminalOutput
- Defined in:
- lib/xcode/provisioning_profile.rb
Constant Summary
Constants included from TerminalOutput
Instance Attribute Summary collapse
-
#appstore ⇒ Object
readonly
Returns the value of attribute appstore.
-
#devices ⇒ Object
readonly
Returns the value of attribute devices.
-
#identifiers ⇒ Object
readonly
Returns the value of attribute identifiers.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
Class Method Summary collapse
- .find_installed_by_uuid(uuid) ⇒ Object
- .installed_profile(name) ⇒ Object
- .installed_profiles ⇒ Object
- .profiles_path ⇒ Object
Instance Method Summary collapse
- #appstore? ⇒ Boolean
- #enterprise? ⇒ Boolean
-
#initialize(path) ⇒ ProvisioningProfile
constructor
A new instance of ProvisioningProfile.
- #install ⇒ Object
- #install_path ⇒ Object
- #uninstall ⇒ Object
Methods included from TerminalOutput
#color_output=, #color_output?, #format_lhs, included, #log_level, log_level=, #print, #print_input, #print_output, #print_system, #print_task, #puts, terminal_supports_colors?
Constructor Details
#initialize(path) ⇒ ProvisioningProfile
Returns a new instance of ProvisioningProfile.
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 43 44 45 46 47 48 |
# File 'lib/xcode/provisioning_profile.rb', line 5 def initialize(path) raise "Provisioning profile '#{path}' does not exist" unless File.exists? path @path = path @identifiers = [] @devices = [] @appstore = true @enterprise = false # 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>ProvisionsAllDevices<\/key>/ @enterprise = true 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
#appstore ⇒ Object (readonly)
Returns the value of attribute appstore.
4 5 6 |
# File 'lib/xcode/provisioning_profile.rb', line 4 def appstore @appstore end |
#devices ⇒ Object (readonly)
Returns the value of attribute devices.
4 5 6 |
# File 'lib/xcode/provisioning_profile.rb', line 4 def devices @devices end |
#identifiers ⇒ Object (readonly)
Returns the value of attribute identifiers.
4 5 6 |
# File 'lib/xcode/provisioning_profile.rb', line 4 def identifiers @identifiers end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/xcode/provisioning_profile.rb', line 4 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
4 5 6 |
# File 'lib/xcode/provisioning_profile.rb', line 4 def path @path end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
4 5 6 |
# File 'lib/xcode/provisioning_profile.rb', line 4 def uuid @uuid end |
Class Method Details
.find_installed_by_uuid(uuid) ⇒ Object
96 97 98 99 100 |
# File 'lib/xcode/provisioning_profile.rb', line 96 def self.find_installed_by_uuid uuid ProvisioningProfile.installed_profiles.each do |p| return p if p.uuid == uuid end end |
.installed_profile(name) ⇒ Object
102 103 104 |
# File 'lib/xcode/provisioning_profile.rb', line 102 def self.installed_profile(name) self.installed_profiles.select {|p| p.name == name.to_s}.first; end |
.installed_profiles ⇒ Object
90 91 92 93 94 |
# File 'lib/xcode/provisioning_profile.rb', line 90 def self.installed_profiles Dir["#{self.profiles_path}/*.mobileprovision"].map do |file| ProvisioningProfile.new(file) end end |
.profiles_path ⇒ Object
58 59 60 |
# File 'lib/xcode/provisioning_profile.rb', line 58 def self.profiles_path File. "~/Library/MobileDevice/Provisioning\\ Profiles/" end |
Instance Method Details
#appstore? ⇒ Boolean
50 51 52 |
# File 'lib/xcode/provisioning_profile.rb', line 50 def appstore? @appstore end |
#enterprise? ⇒ Boolean
54 55 56 |
# File 'lib/xcode/provisioning_profile.rb', line 54 def enterprise? @enterprise end |
#install ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/xcode/provisioning_profile.rb', line 66 def install # Do not reinstall if profile is same and is already installed return if (self.path == self.install_path.gsub(/\\ /, ' ')) ProvisioningProfile.installed_profiles.each do |installed| if installed.identifiers==self.identifiers and installed.uuid==self.uuid installed.uninstall end end # print_task "profile", "installing #{self.path} with uuid #{self.uuid}", :info cmd = Xcode::Shell::Command.new 'cp' cmd << self.path cmd << self.install_path cmd.execute end |
#install_path ⇒ Object
62 63 64 |
# File 'lib/xcode/provisioning_profile.rb', line 62 def install_path "#{ProvisioningProfile.profiles_path}/#{self.uuid}.mobileprovision" end |