Class: MotionProvisioning::MobileProvision
- Inherits:
-
Object
- Object
- MotionProvisioning::MobileProvision
- Defined in:
- lib/motion-provisioning/mobileprovision.rb
Overview
Represents a .mobileprovision file on disk
Instance Attribute Summary collapse
-
#certificates ⇒ Object
Returns the value of attribute certificates.
-
#enabled_services ⇒ Object
Returns the value of attribute enabled_services.
-
#hash ⇒ Object
Returns the value of attribute hash.
Instance Method Summary collapse
- #devices ⇒ Object
-
#initialize(path) ⇒ MobileProvision
constructor
A new instance of MobileProvision.
- #name ⇒ Object
-
#valid?(certificate, app_entitlements) ⇒ Boolean
Checks wether the .mobileprovision file is valid by checking its expiration date, entitlements and certificates.
Constructor Details
#initialize(path) ⇒ MobileProvision
Returns a new instance of MobileProvision.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/motion-provisioning/mobileprovision.rb', line 7 def initialize(path) file = File.read(path) start_index = file.index("<?xml") end_index = file.index("</plist>") + 8 length = end_index - start_index self.hash = Plist::parse_xml(file.slice(start_index, length)) self.certificates = [] self.enabled_services = [] hash['DeveloperCertificates'].each do |certificate| self.certificates << certificate.read end end |
Instance Attribute Details
#certificates ⇒ Object
Returns the value of attribute certificates.
4 5 6 |
# File 'lib/motion-provisioning/mobileprovision.rb', line 4 def certificates @certificates end |
#enabled_services ⇒ Object
Returns the value of attribute enabled_services.
4 5 6 |
# File 'lib/motion-provisioning/mobileprovision.rb', line 4 def enabled_services @enabled_services end |
#hash ⇒ Object
Returns the value of attribute hash.
4 5 6 |
# File 'lib/motion-provisioning/mobileprovision.rb', line 4 def hash @hash end |
Instance Method Details
#devices ⇒ Object
25 26 27 |
# File 'lib/motion-provisioning/mobileprovision.rb', line 25 def devices hash['ProvisionedDevices'].map(&:downcase) end |
#name ⇒ Object
21 22 23 |
# File 'lib/motion-provisioning/mobileprovision.rb', line 21 def name hash['Name'] end |
#valid?(certificate, app_entitlements) ⇒ Boolean
Checks wether the .mobileprovision file is valid by checking its expiration date, entitlements and certificates
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/motion-provisioning/mobileprovision.rb', line 34 def valid?(certificate, app_entitlements) return false if hash['ExpirationDate'] < DateTime.now if !certificates.include?(File.read(certificate)) Utils.log("Warning", "Your provisioning profile does not include your certificate. Repairing...") return false end true end |