Class: Pod::Specification

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-privacy/privacy/privacy_specification_hook.rb

Overview

The Specification provides a DSL to describe a Pod. A pod is defined as a library originating from a source. A specification can support detailed attributes for modules of code through subspecs.

Usually it is stored in files with ‘podspec` extension.

Instance Method Summary collapse

Instance Method Details

#bb_resource_bundlesObject

返回resource_bundles



49
50
51
# File 'lib/cocoapods-privacy/privacy/privacy_specification_hook.rb', line 49

def bb_resource_bundles
  hash_value['resource_bundles']
end

#has_privacyObject

是否含有隐私协议文件



14
15
16
17
# File 'lib/cocoapods-privacy/privacy/privacy_specification_hook.rb', line 14

def has_privacy
    resource_bundle = attributes_hash['resource_bundles']
    resource_bundle && resource_bundle.to_s.include?('PrivacyInfo.xcprivacy')
end

#is_need_search_moduleObject

是否为需要检索组件



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/cocoapods-privacy/privacy/privacy_specification_hook.rb', line 20

def is_need_search_module
    unless File.exist?(PrivacyUtils.cache_config_file)
        raise Informative, "无配置文件,run `pod privacy config config_file` 进行配置"
    end

    #查找source(可能是subspec)
    git_source = recursive_git_source(self)
    unless git_source
        return false
    end

    # 如果指定了--all 参数,那么忽略黑名单白名单,全部检索
    return true if Pod::Config.instance.is_all

    # 判断域名白名单 和 黑名单,确保该组件是自己的组件,第三方sdk不做检索
    config = Privacy::Config.instance          

    ## 规则:
    ## 1、白名单/黑名单是通过组件podspec 中 source 字段的值来匹配,包含关键词即为命中,所有可以是git关键的域名,也可以是完整的git链接
    ## 2、白名单:当白名单为空数组时:默认为全部组件都为白名单!!!; 当白名单不为空时,仅检索白名单数组内的组件
    git_source_whitelisted = config.source_white_list.empty? ? true : config.source_white_list.any? { |item| git_source.include?(item) }

    ## 3、黑名单:在白名单基础上,需要排除的组件
    git_source_blacklisted = config.source_black_list.any? { |item| git_source.include?(item) }
    ## 4、最终检索的范围:白名单 - 黑名单
    git_source_whitelisted && !git_source_blacklisted
end