Sha256: 1e7154ca9f73c357b6f353d9490edd71049b0e89af0aaa9badfe8949db827085
Contents?: true
Size: 1.32 KB
Versions: 4
Compression:
Stored size: 1.32 KB
Contents
require 'singleton' require 'cocoapods-whitelist/model/allowed_dependency' class WhitelistResolver include Singleton attr_accessor :whitelist attr_accessor :whitelist_loaded attr_accessor :whitelist_url def config @whitelist ||= [] end def initialize() @whitelist_url = DEFAULT_WHITELIST_URL load_whitelist() end def get_whitelist(whitelist_url = DEFAULT_WHITELIST_URL) @whitelist_loaded = @whitelist_url == whitelist_url @whitelist_url = whitelist_url load_whitelist() unless @whitelist_loaded return @whitelist end def load_whitelist begin open(@whitelist_url) { |io| buffer = io.read @whitelist = parse_whitelist(buffer) @whitelist_loaded = true } rescue OpenURI::HTTPError => e status = e.io.status.join(' ') raise "Failed to fetch whitelist from '#{@whitelist_url}'.\n Error: #{status}" end end def parse_whitelist(raw_whitelist) json = JSON.parse(raw_whitelist) return json["whitelist"].map { |dependencyJson| AllowedDependency.new(dependencyJson["name"], dependencyJson["version"], dependencyJson["expire"], dependencyJson["source"], dependencyJson["target"]) } end end
Version data entries
4 entries across 4 versions & 1 rubygems