Class: Match::Portal::Cache

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(platform:, profile_type:, additional_cert_types:, bundle_id_identifiers:, needs_profiles_devices:, needs_profiles_certificate_content:, include_mac_in_profiles:) ⇒ Cache

Returns a new instance of Cache.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'match/lib/match/portal_cache.rb', line 31

def initialize(platform:, profile_type:, additional_cert_types:, bundle_id_identifiers:, needs_profiles_devices:, needs_profiles_certificate_content:, include_mac_in_profiles:)
  @platform = platform
  @profile_type = profile_type

  # Bundle Ids
  @bundle_id_identifiers = bundle_id_identifiers

  # Certs
  @additional_cert_types = additional_cert_types

  # Profiles
  @needs_profiles_devices = needs_profiles_devices
  @needs_profiles_certificate_content = needs_profiles_certificate_content

  # Devices
  @include_mac_in_profiles = include_mac_in_profiles
end

Instance Attribute Details

#additional_cert_typesObject (readonly)

Returns the value of attribute additional_cert_types.



29
30
31
# File 'match/lib/match/portal_cache.rb', line 29

def additional_cert_types
  @additional_cert_types
end

#bundle_id_identifiersObject (readonly)

Returns the value of attribute bundle_id_identifiers.



29
30
31
# File 'match/lib/match/portal_cache.rb', line 29

def bundle_id_identifiers
  @bundle_id_identifiers
end

#include_mac_in_profilesObject (readonly)

Returns the value of attribute include_mac_in_profiles.



29
30
31
# File 'match/lib/match/portal_cache.rb', line 29

def include_mac_in_profiles
  @include_mac_in_profiles
end

#needs_profiles_certificate_contentObject (readonly)

Returns the value of attribute needs_profiles_certificate_content.



29
30
31
# File 'match/lib/match/portal_cache.rb', line 29

def needs_profiles_certificate_content
  @needs_profiles_certificate_content
end

#needs_profiles_devicesObject (readonly)

Returns the value of attribute needs_profiles_devices.



29
30
31
# File 'match/lib/match/portal_cache.rb', line 29

def needs_profiles_devices
  @needs_profiles_devices
end

#platformObject (readonly)

Returns the value of attribute platform.



29
30
31
# File 'match/lib/match/portal_cache.rb', line 29

def platform
  @platform
end

#profile_typeObject (readonly)

Returns the value of attribute profile_type.



29
30
31
# File 'match/lib/match/portal_cache.rb', line 29

def profile_type
  @profile_type
end

Class Method Details

.build(params:, bundle_id_identifiers:) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'match/lib/match/portal_cache.rb', line 7

def self.build(params:, bundle_id_identifiers:)
  require_relative 'profile_includes'
  require 'sigh'

  profile_type = Sigh.profile_type_for_distribution_type(
    platform: params[:platform],
    distribution_type: params[:type]
  )

  cache = Portal::Cache.new(
    platform: params[:platform],
    profile_type: profile_type,
    additional_cert_types: params[:additional_cert_types],
    bundle_id_identifiers: bundle_id_identifiers,
    needs_profiles_devices: ProfileIncludes.can_force_include_all_devices?(params: params, notify: true),
    needs_profiles_certificate_content: !ProfileIncludes.can_force_include_all_certificates?(params: params, notify: true),
    include_mac_in_profiles: params[:include_mac_in_profiles]
  )

  return cache
end

Instance Method Details

#bundle_idsObject



68
69
70
71
72
73
74
# File 'match/lib/match/portal_cache.rb', line 68

def bundle_ids
  @bundle_ids ||= Match::Portal::Fetcher.bundle_ids(
    bundle_id_identifiers: @bundle_id_identifiers
  )

  return @bundle_ids.dup
end

#certificatesObject



76
77
78
79
80
81
82
83
84
# File 'match/lib/match/portal_cache.rb', line 76

def certificates
  @certificates ||= Match::Portal::Fetcher.certificates(
    platform: @platform,
    profile_type: @profile_type,
    additional_cert_types: @additional_cert_types
  )

  return @certificates.dup
end

#devicesObject



96
97
98
99
100
101
102
103
# File 'match/lib/match/portal_cache.rb', line 96

def devices
  @devices ||= Match::Portal::Fetcher.devices(
    platform: @platform,
    include_mac_in_profiles: @include_mac_in_profiles
  )

  return @devices.dup
end

#forget_portal_profile(portal_profile) ⇒ Object



62
63
64
65
66
# File 'match/lib/match/portal_cache.rb', line 62

def forget_portal_profile(portal_profile)
  return unless @profiles && portal_profile

  @profiles -= [portal_profile]
end

#portal_profile(stored_profile_path:, keychain_path:) ⇒ Object



49
50
51
52
53
54
55
56
# File 'match/lib/match/portal_cache.rb', line 49

def portal_profile(stored_profile_path:, keychain_path:)
  parsed = FastlaneCore::ProvisioningProfile.parse(stored_profile_path, keychain_path)
  uuid = parsed["UUID"]

  portal_profile = self.profiles.detect { |i| i.uuid == uuid }

  portal_profile
end

#profilesObject



86
87
88
89
90
91
92
93
94
# File 'match/lib/match/portal_cache.rb', line 86

def profiles
  @profiles ||= Match::Portal::Fetcher.profiles(
    profile_type: @profile_type,
    needs_profiles_devices: @needs_profiles_devices,
    needs_profiles_certificate_content: @needs_profiles_certificate_content
  )

  return @profiles.dup
end

#reset_certificatesObject



58
59
60
# File 'match/lib/match/portal_cache.rb', line 58

def reset_certificates
  @certificates = nil
end