Module: Pod::ExternalSources
- Defined in:
- lib/cocoapods-xzdevelop/xz_external_sources.rb
Class Method Summary collapse
- .clone_binary(params, podfile_path, podname) ⇒ Object
- .clone_dev(params, podfile_path, podname) ⇒ Object
- .concrete_class_from_params(params, podfile_path, podname) ⇒ Object
- .findposepec(podpath, podname) ⇒ Object
- .process_custome_parameters(params, podfile_path, podname) ⇒ Object
Class Method Details
.clone_binary(params, podfile_path, podname) ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/cocoapods-xzdevelop/xz_external_sources.rb', line 160 def self.clone_binary(params,podfile_path,podname) devpod_path = File.dirname(podfile_path) if Dir.exist?("#{devpod_path}/DevPods") itselfpath = findposepec("#{devpod_path}/DevPods",podname) if !itselfpath.empty? `rm -rf #{itselfpath}` end end if params[:binary] == true gitv = params[:tag] binary_url = "http://10.0.2.77/staticpods/#{podname}/#{podname}-#{gitv}.zip" #生成二进制url下载 params.clear() params[:http] = binary_url return params else params.delete(:dev) params.delete(:binary) return params end end |
.clone_dev(params, podfile_path, podname) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 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 |
# File 'lib/cocoapods-xzdevelop/xz_external_sources.rb', line 59 def self.clone_dev(params,podfile_path,podname) if !params.key?(:git) puts "dev model need git source" exit end devpod_path = File.dirname(podfile_path) unless Dir.exist?("#{devpod_path}/DevPods") Dir.chdir(devpod_path) `mkdir DevPods` end if params[:binary] == true hasframework = false itselfpath = findposepec("#{devpod_path}/DevPods",podname) if !itselfpath.empty? Find.find(itselfpath) do |path| if path.end_with?('.framework') hasframework = true end end end if !itselfpath.empty? && !hasframework `rm -rf #{itselfpath}` elsif !itselfpath.empty? && hasframework params.clear() params[:path] = itselfpath return params end itselfpath = findposepec("#{devpod_path}/DevPods",podname) if itselfpath.empty? # 下载二进制包 然后更改path gitv = params[:tag] binary_url = "http://10.0.2.77/staticpods/#{podname}/#{podname}-#{gitv}.zip" downloadpath = "#{devpod_path}/DevPods" downloadermanager = Pod::Downloader::Http.new(downloadpath,binary_url,{}) full_path = "#{downloadpath}/#{podname}-#{gitv}.zip" downloadermanager.download_file(full_path) downloadermanager.verify_checksum(full_path) `unzip -d #{downloadpath}/#{podname}-#{gitv} #{full_path}` `rm -rf #{full_path}` # 使用 Downloader 下载并自动解压 params.clear # 注意一下路径问题 params[:path] = "#{downloadpath}/#{podname}-#{gitv}" return params end else hasframework = false itselfpath = findposepec("#{devpod_path}/DevPods",podname) if !itselfpath.empty? Find.find(itselfpath) do |path| if path.end_with?('.framework') hasframework = true end end end if !itselfpath.empty? && hasframework `rm -rf #{itselfpath}` elsif !itselfpath.empty? && !hasframework params.clear() params[:path] = itselfpath return params end gitsource = params[:git] itselfpath = findposepec("#{devpod_path}/DevPods",podname) if itselfpath.empty? Dir.chdir("#{devpod_path}/DevPods") `git clone #{gitsource}` if $?.exitstatus == 0 itselfpath = findposepec("#{devpod_path}/DevPods",podname) if params.key?(:tag) || params.key?(:commit) Dir.chdir(itselfpath) gittag = params[:tag] gitcomm = params[:commit] gitbranch = params[:branch] if gittag `git checkout #{gittag}` elsif gitcomm `git checkout #{gitcomm}` elsif gitbranch `git checkout #{gitbranch}` end end end else `echo start` end if $?.exitstatus != 0 puts("git soure maybe error please check #{podname} --> #{gitsource}") exit else itselfpath = findposepec("#{devpod_path}/DevPods",podname) params.clear() params[:path] = itselfpath puts "dev process params #{params}" return params end end end |
.concrete_class_from_params(params, podfile_path, podname) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/cocoapods-xzdevelop/xz_external_sources.rb', line 3 def self.concrete_class_from_params(params,podfile_path,podname) puts "concrete_class_from_params xzdevelop plugin--> #{params}" if podfile_path process_custome_parameters(params,podfile_path,podname) end if params.key?(:podspec) PodspecSource elsif params.key?(:path) PathSource elsif Downloader.(params) DownloaderSource end end |
.findposepec(podpath, podname) ⇒ Object
182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/cocoapods-xzdevelop/xz_external_sources.rb', line 182 def self.findposepec(podpath,podname) itselfpath = '' Find.find(podpath) do |path| if !File.directory?(path) if path.end_with?('.podspec') specname = File.basename(path).delete_suffix('.podspec') if specname == podname itselfpath = File.dirname(path) end end end end itselfpath end |
.process_custome_parameters(params, podfile_path, podname) ⇒ Object
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 |
# File 'lib/cocoapods-xzdevelop/xz_external_sources.rb', line 17 def self.process_custome_parameters(params,podfile_path,podname) devpod_path = File.dirname(podfile_path) if params.key?(:dev) && params.key?(:binary) if params[:dev] == true && params[:binary] == true params = clone_dev(params,podfile_path,podname) elsif params[:dev] == true && params[:binary] == false params = clone_dev(params,podfile_path,podname) elsif params[:dev] == false && params[:binary] == true params = clone_binary(params,podfile_path,podname) elsif params[:dev] == false && params[:binary] == false params = clone_binary(params,podfile_path,podname) end elsif params.key?(:dev) if params[:dev] == true params = clone_dev(params,podfile_path,podname) else params.delete(:dev) if Dir.exist?("#{devpod_path}/DevPods") itselfpath = findposepec("#{devpod_path}/DevPods",podname) if !itselfpath.empty? `rm -rf #{itselfpath}` end end end elsif params.key?(:binary) if params[:binary] == true params = clone_binary(params,podfile_path,podname) else params.delete(:binary) if Dir.exist?("#{devpod_path}/DevPods") itselfpath = findposepec("#{devpod_path}/DevPods",podname) if !itselfpath.empty? `rm -rf #{itselfpath}` end end end else params = clone_binary(params,podfile_path,podname) end params end |