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
- .from_params(params, dependency, podfile_path, can_cache) ⇒ Object
- .process_custome_parameters(params, podfile_path, podname) ⇒ Object
Class Method Details
.clone_binary(params, podfile_path, podname) ⇒ Object
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/cocoapods-xzdevelop/xz_external_sources.rb', line 174 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
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 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/cocoapods-xzdevelop/xz_external_sources.rb', line 73 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") FileUtils.mkdir "#{devpod_path}/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? devpods_path = "#{devpod_path}/DevPods" puts "start clone source code" `git -C #{devpods_path} clone --quiet #{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 -C #{itselfpath} checkout #{gittag}` elsif gitcomm `git -C #{itselfpath} checkout #{gitcomm}` elsif gitbranch `git -C #{itselfpath} 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
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cocoapods-xzdevelop/xz_external_sources.rb', line 16 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
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/cocoapods-xzdevelop/xz_external_sources.rb', line 196 def self.findposepec(podpath,podname) itselfpath = '' Find.find(podpath) do |path| if !File.directory?(path) if path.end_with?('.podspec') specname = File.basename(path) specarr = specname.split('.') specname = specarr[0] if specname == podname itselfpath = File.dirname(path) end end end end itselfpath end |
.from_params(params, dependency, podfile_path, can_cache) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/cocoapods-xzdevelop/xz_external_sources.rb', line 6 def self.from_params(params, dependency, podfile_path, can_cache) name = dependency.root_name if klass = concrete_class_from_params(params,podfile_path,name) klass.new(name, params, podfile_path, can_cache) else msg = "Unknown external source parameters for `#{name}`: `#{params}`" raise Informative, msg end end |
.process_custome_parameters(params, podfile_path, podname) ⇒ Object
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 66 67 68 69 70 71 |
# File 'lib/cocoapods-xzdevelop/xz_external_sources.rb', line 30 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) params = params end params end |