Class: LgPodPlugin::Main
- Inherits:
-
Object
- Object
- LgPodPlugin::Main
- Defined in:
- lib/lg_pod_plugin/runner.rb
Class Method Summary collapse
- .install_external_pod(work_space, podfile, install_hash_map) ⇒ Object
- .run(command, options = {}) ⇒ Object
-
.run_pod_install(update, libs, options = {}) ⇒ Object
执行pod install/update命令.
Class Method Details
.install_external_pod(work_space, podfile, install_hash_map) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/lg_pod_plugin/runner.rb', line 67 def self.install_external_pod(work_space, podfile, install_hash_map) #下载 External pods LRequest.shared.libs = Hash.new.merge!(install_hash_map) LgPodPlugin.log_green "Pre-downloading External Pods" unless install_hash_map.empty? install_hash_map.each do |key, val| git = val[:git] tag = val[:tag] commit = val[:commit] if git && tag LRequest.shared. = { :git => git, :tag => tag, :spec => nil, :release_pod => false } unless LCache.new(work_space).find_pod_cache(key, { :git => git, :tag => tag }) LRequest.shared.libs.delete(key) next end elsif git && commit LRequest.shared. = { :git => git, :commit => commit, :spec => nil, :release_pod => false } unless LCache.new(work_space).find_pod_cache(key, { :git => git, :commit => commit }) LRequest.shared.libs.delete(key) next end end LgPodPlugin::Installer.new(podfile, key, val) end end |
.run(command, options = {}) ⇒ Object
14 15 16 17 18 19 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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/lg_pod_plugin/runner.rb', line 14 def self.run(command, = {}) is_update = (command == "update") work_space = Pathname(Dir.pwd) LgPodPlugin.log_green "当前工作目录 #{work_space}" podfile_path = work_space.join("Podfile") unless podfile_path.exist? LgPodPlugin.log_red "no such file `Podfile`" return end LRequest.shared.is_update = is_update podfile = Pod::Podfile.from_file(podfile_path) target = podfile.send(:current_target_definition) local_pods = Hash.new release_pods = Hash.new install_hash_map = {} children = target.children children.each do |s| internal_hash = s.send(:internal_hash) next unless internal_hash.is_a?(Hash) dependencies = internal_hash["dependencies"] next unless dependencies.is_a?(Array) dependencies.each { |e| next unless e.is_a?(Hash) next if (key = e.keys.first) == nil pod_name = key val = e[key].last pod_name = key.split("/").first if key.include?("/") next unless val.is_a?(Hash) next unless val[:podspec] == nil if path = val[:path] local_pods[pod_name] = val else install_hash_map[pod_name] = val end } end # 安装开发版本pod self.install_external_pod(work_space, podfile, Hash.new.merge!(install_hash_map)) # 下载 release_pod repo_update = [:repo_update] ||= false external_pods = install_hash_map.merge!(local_pods) ReleasePod.install_release_pod(work_space, podfile,repo_update, is_update, Hash.new.merge!(external_pods), local_pods) # LgPodPlugin.log_green "开始安装Pod" # #切换工作目录到当前工程下, 开始执行pod install # FileUtils.chdir(work_space) # libs = Set[] # libs += Array(local_pods) # libs += LRequest.shared.libs.keys # 执行pod install/ update 方法入口 # update_pod = (command == "update") # run_pod_install(update_pod, libs, options) end |
.run_pod_install(update, libs, options = {}) ⇒ Object
执行pod install/update命令
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/lg_pod_plugin/runner.rb', line 94 def self.run_pod_install(update, libs, = {}) verbose = [:verbose] repo_update = [:repo_update] if update if libs.empty? LgPodPlugin.log_red "no external pod update, you can use `pod update` to update --all pods" system("bundle exec arch -x86_64 pod update #{repo_update ? "--repo-update" : "--no-repo-update"} #{verbose ? "--verbose" : ""} ") else pod_names = Array(libs).join(" ") LgPodPlugin.log_green Array(libs).join("\n") LgPodPlugin.log_green "bundle exec arch -x86_64 pod update #{repo_update ? "--repo-update" : "--no-repo-update"} #{verbose ? "--verbose" : ""} " system("bundle exec arch -x86_64 pod update #{pod_names} #{repo_update ? "--repo-update" : "--no-repo-update"} #{verbose ? "--verbose" : ""} ") end else LgPodPlugin.log_green "bundle exec arch -x86_64 pod install #{repo_update ? "--repo-update" : "--no-repo-update"} #{verbose ? "--verbose" : ""}" system("bundle exec arch -x86_64 pod install #{repo_update ? "--repo-update" : "--no-repo-update"} #{verbose ? "--verbose" : ""}") end end |