self.download_latest_xcrc_release

in cocoapods-plugin/lib/cocoapods-xcremotecache/command/hooks.rb [282:303]


      def self.download_latest_xcrc_release(local_package_location)
        release_url = 'https://api.github.com/repos/spotify/XCRemoteCache/releases/latest'
        asset_url = nil

        URI.open(release_url) do |f|
          assets_array = JSON.parse(f.read)['assets']
          
          asset_array = assets_array.detect{|arr| arr['name'].include?(FAT_ARCHIVE_NAME_INFIX)}
          asset_url = asset_array['url']
        end

        if asset_url.nil?
          throw "Downloading XCRemoteCache failed"
        end

        URI.open(asset_url, "accept" => 'application/octet-stream') do |f|
          File.open(local_package_location, "wb") do |file|
            file.puts f.read
          end
        end
      end