Class: OSX::ProvisioningProfile
- Inherits:
-
Object
- Object
- OSX::ProvisioningProfile
- Defined in:
- lib/keychain_osx/provisioningprofile.rb
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
- #find_profile_uuid(path) ⇒ Object
-
#initialize(path) ⇒ ProvisioningProfile
constructor
A new instance of ProvisioningProfile.
- #install ⇒ Object
- #install_path ⇒ Object
- #uninstall ⇒ Object
Constructor Details
#initialize(path) ⇒ ProvisioningProfile
Returns a new instance of ProvisioningProfile.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/keychain_osx/provisioningprofile.rb', line 8 def initialize(path) raise "Provisioning profile '#{path}' does not exist" unless File.exists? path @path = path @identifiers = [] @devices = [] @appstore = true @enterprise = false uuid = nil find_profile_uuid(path) end |
Instance Attribute Details
#appstore ⇒ Object (readonly)
Returns the value of attribute appstore.
6 7 8 |
# File 'lib/keychain_osx/provisioningprofile.rb', line 6 def appstore @appstore end |
#devices ⇒ Object (readonly)
Returns the value of attribute devices.
6 7 8 |
# File 'lib/keychain_osx/provisioningprofile.rb', line 6 def devices @devices end |
#identifiers ⇒ Object (readonly)
Returns the value of attribute identifiers.
6 7 8 |
# File 'lib/keychain_osx/provisioningprofile.rb', line 6 def identifiers @identifiers end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/keychain_osx/provisioningprofile.rb', line 6 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/keychain_osx/provisioningprofile.rb', line 6 def path @path end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
6 7 8 |
# File 'lib/keychain_osx/provisioningprofile.rb', line 6 def uuid @uuid end |
Class Method Details
.find_installed_by_uuid(uuid) ⇒ Object
96 97 98 99 100 |
# File 'lib/keychain_osx/provisioningprofile.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/keychain_osx/provisioningprofile.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/keychain_osx/provisioningprofile.rb', line 90 def self.installed_profiles Dir["#{self.profiles_path}/*.mobileprovision"].map do |file| ProvisioningProfile.new(file) end end |
.profiles_path ⇒ Object
63 64 65 |
# File 'lib/keychain_osx/provisioningprofile.rb', line 63 def self.profiles_path File. "~/Library/MobileDevice/Provisioning\ Profiles/" end |
Instance Method Details
#appstore? ⇒ Boolean
55 56 57 |
# File 'lib/keychain_osx/provisioningprofile.rb', line 55 def appstore? @appstore end |
#enterprise? ⇒ Boolean
59 60 61 |
# File 'lib/keychain_osx/provisioningprofile.rb', line 59 def enterprise? @enterprise end |
#find_profile_uuid(path) ⇒ Object
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 49 50 51 52 53 |
# File 'lib/keychain_osx/provisioningprofile.rb', line 22 def find_profile_uuid(path) 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 |
#install ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/keychain_osx/provisioningprofile.rb', line 71 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 FileUtils.mkdir_p(File.dirname(self.install_path)) FileUtils.cp(self.path, self.install_path) end |
#install_path ⇒ Object
67 68 69 |
# File 'lib/keychain_osx/provisioningprofile.rb', line 67 def install_path "#{ProvisioningProfile.profiles_path}/#{self.uuid}.mobileprovision" end |