Class: CocoapodsSubmit::ProvisioningProfile

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ ProvisioningProfile

Returns a new instance of ProvisioningProfile.



5
6
7
# File 'lib/provisioning_profile.rb', line 5

def initialize(hash)
  @hash = hash
end

Class Method Details

.from_file(path) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/provisioning_profile.rb', line 23

def self.from_file(path)
  return nil unless File.exists? path

  start_string = "<?"
  end_string = "</plist>"

  profile = File.read(path)
  profile = profile.slice(profile.index(start_string), profile.length)
  profile = profile.slice(0, profile.index(end_string) + end_string.length)
  profile = Plist::parse_xml(profile)

  new(profile)
end

.from_uuid(uuid) ⇒ Object



9
10
11
# File 'lib/provisioning_profile.rb', line 9

def self.from_uuid(uuid)
  from_file File.expand_path File.join "~/Library/MobileDevice/Provisioning Profiles", "#{uuid}.mobileprovision"
end

Instance Method Details

#rankObject



13
14
15
16
17
18
19
20
21
# File 'lib/provisioning_profile.rb', line 13

def rank
  return 0.0 unless @hash

  rank = 1.0
  rank *= 0.0 if @hash["Entitlements"]["get-task-allow"]
  rank *= 1.0 / @hash["ProvisionedDevices"].count if @hash["ProvisionedDevices"]

  return rank
end