Class: AllowlistResolver
- Inherits:
-
Object
- Object
- AllowlistResolver
- Includes:
- Singleton
- Defined in:
- lib/cocoapods-allowlist/client/allowlist_resolver.rb
Instance Attribute Summary collapse
-
#allowlist ⇒ Object
Returns the value of attribute allowlist.
-
#allowlist_branch ⇒ Object
Returns the value of attribute allowlist_branch.
-
#allowlist_directory ⇒ Object
Returns the value of attribute allowlist_directory.
-
#allowlist_loaded ⇒ Object
Returns the value of attribute allowlist_loaded.
-
#allowlist_url ⇒ Object
Returns the value of attribute allowlist_url.
Instance Method Summary collapse
- #config ⇒ Object
- #get_allowlist(allowlist_url = ConfigURL::ALLOWLIST_SSH) ⇒ Object
-
#initialize ⇒ AllowlistResolver
constructor
A new instance of AllowlistResolver.
- #load_allowlist ⇒ Object
- #parse_allowlist(raw_allowlist) ⇒ Object
Constructor Details
#initialize ⇒ AllowlistResolver
Returns a new instance of AllowlistResolver.
22 23 24 25 26 27 |
# File 'lib/cocoapods-allowlist/client/allowlist_resolver.rb', line 22 def initialize() @allowlist_url = ConfigURL::ALLOWLIST_SSH @allowlist_directory = nil @allowlist_branch = "master" load_allowlist() end |
Instance Attribute Details
#allowlist ⇒ Object
Returns the value of attribute allowlist.
12 13 14 |
# File 'lib/cocoapods-allowlist/client/allowlist_resolver.rb', line 12 def allowlist @allowlist end |
#allowlist_branch ⇒ Object
Returns the value of attribute allowlist_branch.
16 17 18 |
# File 'lib/cocoapods-allowlist/client/allowlist_resolver.rb', line 16 def allowlist_branch @allowlist_branch end |
#allowlist_directory ⇒ Object
Returns the value of attribute allowlist_directory.
15 16 17 |
# File 'lib/cocoapods-allowlist/client/allowlist_resolver.rb', line 15 def allowlist_directory @allowlist_directory end |
#allowlist_loaded ⇒ Object
Returns the value of attribute allowlist_loaded.
13 14 15 |
# File 'lib/cocoapods-allowlist/client/allowlist_resolver.rb', line 13 def allowlist_loaded @allowlist_loaded end |
#allowlist_url ⇒ Object
Returns the value of attribute allowlist_url.
14 15 16 |
# File 'lib/cocoapods-allowlist/client/allowlist_resolver.rb', line 14 def allowlist_url @allowlist_url end |
Instance Method Details
#config ⇒ Object
18 19 20 |
# File 'lib/cocoapods-allowlist/client/allowlist_resolver.rb', line 18 def config @allowlist ||= [] end |
#get_allowlist(allowlist_url = ConfigURL::ALLOWLIST_SSH) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/cocoapods-allowlist/client/allowlist_resolver.rb', line 29 def get_allowlist(allowlist_url = ConfigURL::ALLOWLIST_SSH) @allowlist_loaded = @allowlist_url == allowlist_url @allowlist_url = allowlist_url load_allowlist() unless @allowlist_loaded return @allowlist end |
#load_allowlist ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/cocoapods-allowlist/client/allowlist_resolver.rb', line 37 def load_allowlist begin create_temp_directory GitHelper.clone_from_branch(@allowlist_url, @allowlist_directory, @allowlist_branch) file_path = File.join(@allowlist_directory, "ios-allowlist.json") if File.exist?(file_path) file = File.read(file_path) @allowlist = parse_allowlist(file) @allowlist_loaded = true else raise "File not found: #{file_path}" end rescue OpenURI::HTTPError => e status = e.io.status.join(' ') raise "Failed to fetch allowlist from '#{@allowlist_url}'.\n Error: #{status}" rescue => e raise "Failed to load allowlist: #{e.}" ensure cleanup end end |
#parse_allowlist(raw_allowlist) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/cocoapods-allowlist/client/allowlist_resolver.rb', line 60 def parse_allowlist(raw_allowlist) json = JSON.parse(raw_allowlist) return json["allowlist"].map { |dependencyJson| AllowedDependency.new( dependencyJson["name"], dependencyJson["version"], dependencyJson["expires"], dependencyJson["source"], dependencyJson["target"], dependencyJson["allows_granular_projects"] ) } end |