Class: Pod::Installer
- Inherits:
-
Object
- Object
- Pod::Installer
- Defined in:
- lib/podfileDep/thin/installer.rb
Instance Attribute Summary collapse
-
#thin_pods ⇒ Hash{String, Pod:Target}
所有的pod库被使用的次数.
-
#thin_unused_pods ⇒ String
未被使用的pod库列表.
Instance Method Summary collapse
- #download_dependencies ⇒ Object
-
#thin_all_deps_local_yaml ⇒ Object
获取在local_yaml里使用的依赖库.
-
#thin_all_deps_pods_targets ⇒ Object
获取在pods_targets使用的依赖库.
-
#thin_all_deps_shell_targets ⇒ Object
获取在壳工程里使用的依赖库.
-
#thin_delete_pod(unused_pod) ⇒ Object
删除某个依赖库.
-
#thin_delete_pods_unused ⇒ Object
删除某些依赖库.
-
#thin_pod_unused ⇒ Object
删除未被使用的依赖.
-
#thin_unused_deps ⇒ Object
获取未被使用到的依赖库.
-
#thin_update_reference_count(pod_target) ⇒ Object
递归更新引用计数.
Instance Attribute Details
#thin_pods ⇒ Hash{String, Pod:Target}
Returns 所有的pod库被使用的次数.
11 12 13 |
# File 'lib/podfileDep/thin/installer.rb', line 11 def thin_pods @thin_pods end |
#thin_unused_pods ⇒ String
Returns 未被使用的pod库列表.
14 15 16 |
# File 'lib/podfileDep/thin/installer.rb', line 14 def thin_unused_pods @thin_unused_pods end |
Instance Method Details
#download_dependencies ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/podfileDep/thin/installer.rb', line 17 def download_dependencies UI.section '下载依赖...' do thin_pod_unused #自定义 thin_delete_pods_unused #自定义 install_pod_sources run_podfile_pre_install_hooks clean_pod_sources end end |
#thin_all_deps_local_yaml ⇒ Object
获取在local_yaml里使用的依赖库
100 101 102 103 104 105 106 107 108 109 |
# File 'lib/podfileDep/thin/installer.rb', line 100 def thin_all_deps_local_yaml local = Local.new local.deps_yaml.each do |yaml_pod| if thin_pods.has_key?(yaml_pod) thin_pods[yaml_pod].max_reference_count end end thin_pods end |
#thin_all_deps_pods_targets ⇒ Object
获取在pods_targets使用的依赖库
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/podfileDep/thin/installer.rb', line 58 def thin_all_deps_pods_targets pod_targets = analysis_result.pod_targets pod_targets.each do |pod_target| thin_pods[pod_target.to_s] = pod_target end pod_targets.each do |pod_target| pod_target.dependent_targets.each do|sub_pod_target| thin_update_reference_count(sub_pod_target) end end thin_pods end |
#thin_all_deps_shell_targets ⇒ Object
获取在壳工程里使用的依赖库
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/podfileDep/thin/installer.rb', line 87 def thin_all_deps_shell_targets shell = Shell.new shell.deps_shell.each { |shell_pod| if thin_pods.has_key?(shell_pod) thin_pods[shell_pod].max_reference_count end } thin_pods end |
#thin_delete_pod(unused_pod) ⇒ Object
删除某个依赖库
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/podfileDep/thin/installer.rb', line 130 def thin_delete_pod(unused_pod) sandbox_state.added.delete(unused_pod) sandbox_state.changed.delete(unused_pod) sandbox_state.unchanged.delete(unused_pod) pod_targets.delete_if { |pod_target| pod_target.to_s == unused_pod } aggregate_targets.each { |aggregate_target| aggregate_target.pod_targets.delete_if { |pod_target| pod_target.to_s == unused_pod } } aggregate_targets.each do |aggregate_target| aggregate_target.user_build_configurations.each_key do |config| pod_targets = aggregate_target.pod_targets_for_build_configuration(config) pod_targets.delete_if { |pod_target| pod_target.to_s == unused_pod } end end analysis_result.specifications.delete_if { |specification| real_specification = specification.to_s.split(" (")[0] real_pod = real_specification.split("/")[0] real_pod == unused_pod } end |
#thin_delete_pods_unused ⇒ Object
删除某些依赖库
113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/podfileDep/thin/installer.rb', line 113 def thin_delete_pods_unused if thin_unused_pods.empty? return end thin_unused_pods.each do |unused_pod| = { :verbose_prefix => '-> '.red } UI.titled_section("忽略安装 #{unused_pod}".red, ) do thin_delete_pod(unused_pod) end end end |
#thin_pod_unused ⇒ Object
删除未被使用的依赖
31 32 33 34 35 36 37 |
# File 'lib/podfileDep/thin/installer.rb', line 31 def thin_pod_unused @thin_pods = Hash.new thin_all_deps_pods_targets thin_all_deps_shell_targets thin_all_deps_local_yaml thin_unused_deps end |
#thin_unused_deps ⇒ Object
获取未被使用到的依赖库
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/podfileDep/thin/installer.rb', line 41 def thin_unused_deps thin_unused_pods = [] thin_pods.each do |name, pod_target| pod_target.reduce_reference_count end thin_pods.each do |name, pod_target| if pod_target.reference_count <= 0 thin_unused_pods << name end end @thin_unused_pods = thin_unused_pods end |
#thin_update_reference_count(pod_target) ⇒ Object
递归更新引用计数
77 78 79 80 81 82 83 |
# File 'lib/podfileDep/thin/installer.rb', line 77 def thin_update_reference_count(pod_target) pod = thin_pods[pod_target.to_s] pod.reference_count += 1 pod.dependent_targets.each do|sub_pod_target| thin_update_reference_count(sub_pod_target) end end |