Class: Pod::Podfile
- Inherits:
-
Object
- Object
- Pod::Podfile
- Defined in:
- lib/ppdbiu.rb
Instance Method Summary collapse
Instance Method Details
#makeup_pods(url) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ppdbiu.rb', line 5 def makeup_pods(url) UI.title "makeup pods dependency from #{url}" file = "dependency.json" dependencies = peform_request(url) if dependencies #1.保存json File.delete(file) if File.exist?(file) File.open(file, "w") { |io| io.syswrite(JSON.generate(dependencies))} #2.安装依赖 ppd_pod(dependencies) else #1.读取本地保存的json json = File.read(file) if File.exist?(file) dependencies = JSON.parse(json) #2.安装依赖 ppd_pod(dependencies) if dependencies end end |
#peform_request(url) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/ppdbiu.rb', line 46 def peform_request(url) require 'rest' require 'json' headers = { 'Content-Type' => 'application/json' } response = REST.get(url, headers) if response.ok? body = JSON.parse(response.body) body else CoreUI.warn "Request to #{url} failed - #{response.status_code}" nil end end |
#ppd_pod(dependencies) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ppdbiu.rb', line 24 def ppd_pod(dependencies) dependencies.each { |key, value| version = value.fetch("version", nil) if version pod(key, version) else hash = {} value.each{ |rKey, rValue| hash[:git] = rValue if rKey == "git" hash[:branch] = rValue if rKey == "branch" hash[:tag] = rValue if rKey == "tag" hash[:commit] = rValue if rKey == "commit" hash[:configuration] = rValue if rKey == "configuration" hash[:path] = rValue if rKey == "path" hash[:podspec] = rValue if rKey == "podspec" hash[:subspecs] = rValue if rKey == "subspecs" } pod(key, hash) end } end |