Class: WhitelistResolver
- Inherits:
-
Object
- Object
- WhitelistResolver
- Includes:
- Singleton
- Defined in:
- lib/cocoapods-whitelist/client/whitelist_resolver.rb
Instance Attribute Summary collapse
-
#whitelist ⇒ Object
Returns the value of attribute whitelist.
-
#whitelist_loaded ⇒ Object
Returns the value of attribute whitelist_loaded.
-
#whitelist_url ⇒ Object
Returns the value of attribute whitelist_url.
Instance Method Summary collapse
- #config ⇒ Object
- #get_whitelist(whitelist_url = DEFAULT_WHITELIST_URL) ⇒ Object
-
#initialize ⇒ WhitelistResolver
constructor
A new instance of WhitelistResolver.
- #load_whitelist ⇒ Object
- #parse_whitelist(raw_whitelist) ⇒ Object
Constructor Details
#initialize ⇒ WhitelistResolver
Returns a new instance of WhitelistResolver.
15 16 17 18 |
# File 'lib/cocoapods-whitelist/client/whitelist_resolver.rb', line 15 def initialize() @whitelist_url = DEFAULT_WHITELIST_URL load_whitelist() end |
Instance Attribute Details
#whitelist ⇒ Object
Returns the value of attribute whitelist.
7 8 9 |
# File 'lib/cocoapods-whitelist/client/whitelist_resolver.rb', line 7 def whitelist @whitelist end |
#whitelist_loaded ⇒ Object
Returns the value of attribute whitelist_loaded.
8 9 10 |
# File 'lib/cocoapods-whitelist/client/whitelist_resolver.rb', line 8 def whitelist_loaded @whitelist_loaded end |
#whitelist_url ⇒ Object
Returns the value of attribute whitelist_url.
9 10 11 |
# File 'lib/cocoapods-whitelist/client/whitelist_resolver.rb', line 9 def whitelist_url @whitelist_url end |
Instance Method Details
#config ⇒ Object
11 12 13 |
# File 'lib/cocoapods-whitelist/client/whitelist_resolver.rb', line 11 def config @whitelist ||= [] end |
#get_whitelist(whitelist_url = DEFAULT_WHITELIST_URL) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/cocoapods-whitelist/client/whitelist_resolver.rb', line 20 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 |
#load_whitelist ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/cocoapods-whitelist/client/whitelist_resolver.rb', line 28 def load_whitelist begin URI.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 |
#parse_whitelist(raw_whitelist) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/cocoapods-whitelist/client/whitelist_resolver.rb', line 41 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"], dependencyJson["allows_granular_projects"] ) } end |