Class: Pod::Podfile::TargetDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-cache-proxy/native/podfile_dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cache_proxy_sourceObject (readonly)

Returns the value of attribute cache_proxy_source.



32
33
34
# File 'lib/cocoapods-cache-proxy/native/podfile_dsl.rb', line 32

def cache_proxy_source
  @cache_proxy_source
end

#ignore_cache_proxyObject (readonly)

Returns the value of attribute ignore_cache_proxy.



31
32
33
# File 'lib/cocoapods-cache-proxy/native/podfile_dsl.rb', line 31

def ignore_cache_proxy
  @ignore_cache_proxy
end

Instance Method Details

#check_ignore_cache_proxy_pod(pod) ⇒ TrueClass, FalseClass

Parameters:

  • pod (String)

Returns:

  • (TrueClass, FalseClass)


119
120
121
122
123
124
125
126
# File 'lib/cocoapods-cache-proxy/native/podfile_dsl.rb', line 119

def check_ignore_cache_proxy_pod(pod)
    return false if pod.blank?
    ignores = []
    ignores.concat(get_ignore_cache_proxy_pods)
    ignores.concat(root.get_ignore_cache_proxy_pods) unless root.nil?
    ignores.concat(parent.get_ignore_cache_proxy_pods) unless parent.nil?
    ignores.uniq.include?(pod)
end

#get_ignore_cache_proxy_podsArray<String>

Returns:

  • (Array<String>)


113
114
115
# File 'lib/cocoapods-cache-proxy/native/podfile_dsl.rb', line 113

def get_ignore_cache_proxy_pods
    @ignore_cache_proxy.nil? ? [] : @ignore_cache_proxy.uniq
end

#orig_parse_inhibit_warningsObject

—- patch method —- We want modify ‘store_pod` method, but it’s hard to insert a line in the implementation. So we patch a method called in ‘store_pod`.



51
# File 'lib/cocoapods-cache-proxy/native/podfile_dsl.rb', line 51

alias_method :orig_parse_inhibit_warnings, :parse_inhibit_warnings

#parse_inhibit_warnings(name, requirements) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/cocoapods-cache-proxy/native/podfile_dsl.rb', line 52

def parse_inhibit_warnings(name, requirements)
    options = requirements.last

    if options.is_a?(Hash)
        if options.has_key?(Pod::Podfile::IgnorePodProxy.keyword)
            ignore = options[Pod::Podfile::IgnorePodProxy.keyword]
            options.delete(Pod::Podfile::IgnorePodProxy.keyword)
            set_ignore_cache_proxy_pods([name]) if ignore
        end

        if options.has_key?(Pod::Podfile::UsedPodProxySource.keyword)
            source_name = options[Pod::Podfile::UsedPodProxySource.keyword]
            options.delete(Pod::Podfile::UsedPodProxySource.keyword)
            unless source_name.blank?
                raise Pod::Informative.exception "cache proxy source: `#{source_name}` source does not exist." unless (source = CPSH.get_cache_proxy_source_conf(source_name))
                @cache_proxy_source = Hash.new if @cache_proxy_source.nil?
                @cache_proxy_source[name] = source
            end
        end
        requirements.pop if options.empty?
    end
    orig_parse_inhibit_warnings(name, requirements)
end

#proxy_source_for_pod(pod) ⇒ CacheProxySource

Parameters:

  • pod (String)

Returns:



130
131
132
133
# File 'lib/cocoapods-cache-proxy/native/podfile_dsl.rb', line 130

def proxy_source_for_pod(pod)
    return nil if @cache_proxy_source.blank?
    @cache_proxy_source[pod]
end

#set_ignore_cache_proxy_pods(pods) ⇒ Object

Parameters:

  • pods (Array<String>)


104
105
106
107
108
109
110
# File 'lib/cocoapods-cache-proxy/native/podfile_dsl.rb', line 104

def set_ignore_cache_proxy_pods(pods)
    return if pods.blank?
    @ignore_cache_proxy = [] if @ignore_cache_proxy.nil?
    pods.uniq.each do |pod|
        @ignore_cache_proxy << pod unless @ignore_cache_proxy.include?(pod)
    end
end