Class: Pod::Tdfire::BinaryCacheCleaner

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-tdfire-binary/binary_cache_cleaner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(analysis_result) ⇒ BinaryCacheCleaner

Returns a new instance of BinaryCacheCleaner.



40
41
42
43
# File 'lib/cocoapods-tdfire-binary/binary_cache_cleaner.rb', line 40

def initialize(analysis_result)
  @analysis_result = analysis_result
  @use_binary_specs = analysis_result.specifications.uniq { |s| s.root.name }.reject(&:tdfire_use_source?)
end

Instance Attribute Details

#use_binary_specsObject (readonly)

Returns the value of attribute use_binary_specs.



38
39
40
# File 'lib/cocoapods-tdfire-binary/binary_cache_cleaner.rb', line 38

def use_binary_specs
  @use_binary_specs
end

Instance Method Details

#clean!Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/cocoapods-tdfire-binary/binary_cache_cleaner.rb', line 45

def clean!
  # 判断有效组件的 cache 中是否有二进制,没有的话,删除组件缓存
  specs = use_binary_specs - no_binary_specs

  return if specs.empty?

  UI.section 'Tdfire: 处理没有二进制版本的组件' do
    specs.each do |s|
      # 处理 cache
      clean_pod_cache(s)
      
      # 处理 Pods 
      clean_local_cache(s)
    end
  end
end

#no_binary_specsObject



62
63
64
65
66
67
68
69
70
71
# File 'lib/cocoapods-tdfire-binary/binary_cache_cleaner.rb', line 62

def no_binary_specs
  @invalid_specs ||= begin 
    use_binary_specs.reject do |s|
      json_string = Pod::Tdfire::BinaryUrlManager.search_binary(s.root.name)
      pod = JSON.parse(json_string, object_class: OpenStruct)
      versions = pod.versions || []
      versions.include?(s.version.to_s)
    end
  end
end