class MobileProvision::Representation
Constants
- ADHOC_PROFILE_KEY
- APP_ID_KEY
- CERTIFICATE_FOOTER
- CERTIFICATE_HEADER
- CERTIFICATE_KEY
- EMPTY_STRING
- ENTITLEMENTS_KEY
- EXPIRATION_DATE_KEY
- HAS_ASSOCIATED_DOMAINS
- INHOUSE_PROFILE_KEY
- LINE_BREAK
- PLIST_START
- PLIST_STOP
- STRING_FORMAT
- TABULATION
- TEAM_ID_KEY
- UTF8_ENCODING
Attributes
app_id[R]
bundle_id[R]
certificate[R]
expiration_date[R]
has_associated_domains[R]
profile_type[R]
registered_udids[R]
team_id[R]
Public Class Methods
new(file)
click to toggle source
# File lib/mobile_provision/representation.rb, line 17 def initialize(file) read!(file) @expiration_date = build_expiration_date @certificate = build_certificate @app_id = build_app_id @profile_type = build_profile_type @registered_udids = build_registered_udids @team_id = build_team_id @bundle_id = build_bundle_id @has_associated_domains = has_associated_domains? end
Private Instance Methods
build_app_id()
click to toggle source
# File lib/mobile_provision/representation.rb, line 76 def build_app_id entitlements = read_plist_value(ENTITLEMENTS_KEY) read_plist_value(APP_ID_KEY, entitlements) end
build_bundle_id()
click to toggle source
# File lib/mobile_provision/representation.rb, line 107 def build_bundle_id build_app_id[/(?<=\.).*/] end
build_certificate()
click to toggle source
# File lib/mobile_provision/representation.rb, line 81 def build_certificate certificate = read_plist_value(CERTIFICATE_KEY).first key = certificate.scan(/.{1,64}/).join(LINE_BREAK) CERTIFICATE_HEADER + key.gsub(TABULATION, EMPTY_STRING) + CERTIFICATE_FOOTER end
build_expiration_date()
click to toggle source
# File lib/mobile_provision/representation.rb, line 71 def build_expiration_date expiration_date = read_plist_value(EXPIRATION_DATE_KEY) Time.parse(expiration_date.to_s).utc end
build_profile_type()
click to toggle source
# File lib/mobile_provision/representation.rb, line 87 def build_profile_type if read_plist_value(INHOUSE_PROFILE_KEY) IN_HOUSE_TYPE elsif read_plist_value(ADHOC_PROFILE_KEY) AD_HOC_TYPE else PROFILE_ERROR_TYPE end end
build_registered_udids()
click to toggle source
# File lib/mobile_provision/representation.rb, line 97 def build_registered_udids return nil unless @profile_type == AD_HOC_TYPE read_plist_value(ADHOC_PROFILE_KEY) end
build_team_id()
click to toggle source
# File lib/mobile_provision/representation.rb, line 102 def build_team_id entitlements = read_plist_value(ENTITLEMENTS_KEY) read_plist_value(TEAM_ID_KEY, entitlements) end
has_associated_domains?()
click to toggle source
# File lib/mobile_provision/representation.rb, line 111 def has_associated_domains? entitlements = read_plist_value(ENTITLEMENTS_KEY) read_plist_value(HAS_ASSOCIATED_DOMAINS, entitlements).kind_of? String end
read!(file)
click to toggle source
# File lib/mobile_provision/representation.rb, line 44 def read!(file) buffer = String.new inside_plist = false file.each do |line| inside_plist = true if line.include? PLIST_START if inside_plist buffer << line break if line.include? PLIST_STOP end end encoded_plist = buffer.encode(UTF8_ENCODING, STRING_FORMAT, invalid: :replace, undef: :replace, replace: EMPTY_STRING) encoded_plist = encoded_plist.sub(/#{PLIST_STOP}.+/, PLIST_STOP) @plist = read_plist(encoded_plist) end
read_plist(data)
click to toggle source
# File lib/mobile_provision/representation.rb, line 60 def read_plist(data) CFPropertyList::List.new(data: data).value.value end
read_plist_value(var, plist = @plist)
click to toggle source
# File lib/mobile_provision/representation.rb, line 64 def read_plist_value(var, plist = @plist) res = plist[var].value res.is_a?(Array) ? res.collect(&:value) : res rescue NoMethodError nil end