Class: LgPodPlugin::LRequest
- Inherits:
-
Object
- Object
- LgPodPlugin::LRequest
- Includes:
- Singleton
- Defined in:
- lib/lg_pod_plugin/request.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
缓存.
-
#checkout_options ⇒ Object
传入的请求参数.
-
#config ⇒ Object
配置.
-
#downloader ⇒ Object
下载类.
-
#git_util ⇒ Object
git 工具类.
-
#is_update ⇒ Object
是否更新.
-
#libs ⇒ Object
需要更新的 pod 集合.
-
#lock_info ⇒ Object
lock_info.
-
#name ⇒ Object
pod name.
-
#net_ping ⇒ Object
网络ip 信息.
-
#request_params ⇒ Object
实际下载请求参数.
-
#single_git ⇒ Object
是否是还有 git 地址参数.
-
#token ⇒ Object
当前token.
-
#workspace ⇒ Object
工作目录.
Class Method Summary collapse
Instance Method Summary collapse
- #get_cache_key_params ⇒ Object
- #get_lock_info ⇒ Object
- #get_lock_params ⇒ Object
-
#get_request_params ⇒ Object
获取下载参数.
- #setup_pod_info(name, workspace, options = {}) ⇒ Object
Instance Attribute Details
#cache ⇒ Object
缓存
19 20 21 |
# File 'lib/lg_pod_plugin/request.rb', line 19 def cache @cache end |
#checkout_options ⇒ Object
传入的请求参数
39 40 41 |
# File 'lib/lg_pod_plugin/request.rb', line 39 def @checkout_options end |
#config ⇒ Object
配置
21 22 23 |
# File 'lib/lg_pod_plugin/request.rb', line 21 def config @config end |
#downloader ⇒ Object
下载类
33 34 35 |
# File 'lib/lg_pod_plugin/request.rb', line 33 def downloader @downloader end |
#git_util ⇒ Object
git 工具类
29 30 31 |
# File 'lib/lg_pod_plugin/request.rb', line 29 def git_util @git_util end |
#is_update ⇒ Object
是否更新
23 24 25 |
# File 'lib/lg_pod_plugin/request.rb', line 23 def is_update @is_update end |
#libs ⇒ Object
需要更新的 pod 集合
31 32 33 |
# File 'lib/lg_pod_plugin/request.rb', line 31 def libs @libs end |
#lock_info ⇒ Object
lock_info
35 36 37 |
# File 'lib/lg_pod_plugin/request.rb', line 35 def lock_info @lock_info end |
#name ⇒ Object
pod name
15 16 17 |
# File 'lib/lg_pod_plugin/request.rb', line 15 def name @name end |
#net_ping ⇒ Object
网络ip 信息
41 42 43 |
# File 'lib/lg_pod_plugin/request.rb', line 41 def net_ping @net_ping end |
#request_params ⇒ Object
实际下载请求参数
37 38 39 |
# File 'lib/lg_pod_plugin/request.rb', line 37 def request_params @request_params end |
#single_git ⇒ Object
是否是还有 git 地址参数
27 28 29 |
# File 'lib/lg_pod_plugin/request.rb', line 27 def single_git @single_git end |
#token ⇒ Object
当前token
17 18 19 |
# File 'lib/lg_pod_plugin/request.rb', line 17 def token @token end |
#workspace ⇒ Object
工作目录
25 26 27 |
# File 'lib/lg_pod_plugin/request.rb', line 25 def workspace @workspace end |
Class Method Details
.shared ⇒ Object
166 167 168 |
# File 'lib/lg_pod_plugin/request.rb', line 166 def self.shared return LRequest.instance end |
Instance Method Details
#get_cache_key_params ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/lg_pod_plugin/request.rb', line 62 def get_cache_key_params hash_map = Hash.new git = self.[:git] ||= self.request_params[:git] tag = self.[:tag] ||= self.request_params[:tag] branch = self.[:branch] ||= self.request_params[:branch] commit = self.[:commit] ||= self.request_params[:commit] return hash_map unless git hash_map[:git] = git if git && commit hash_map[:commit] = commit elsif git && tag hash_map[:tag] = tag elsif git && branch && commit hash_map[:commit] = commit end hash_map end |
#get_lock_info ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/lg_pod_plugin/request.rb', line 44 def get_lock_info lock_file = self.workspace.join("Podfile.lock") if lock_file.exist? begin json = YAML.load_file(lock_file.to_path) rescue json = {} end external_source = json["EXTERNAL SOURCES"] ||= {} = json["CHECKOUT OPTIONS"] ||= {} { "external_source" => external_source, "checkout_options" => } else { "external_source" => {}, "checkout_options" => {} } end end |
#get_lock_params ⇒ Object
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 |
# File 'lib/lg_pod_plugin/request.rb', line 81 def get_lock_params begin _external_source = self.lock_info["external_source"][self.name] ||= {} = self.lock_info["checkout_options"][self.name] ||= {} rescue _external_source = {} = {} end git = self.[:git] tag = self.[:tag] commit = self.[:commit] branch = self.[:branch] lock_commit = [:commit] ||= "" lock_branch = _external_source[:branch] ||= "" hash_map = Hash.new hash_map[:git] = git if git if git && tag hash_map[:tag] = tag return hash_map elsif git && branch if branch == lock_branch && !self.is_update hash_map[:branch] = branch if branch hash_map[:commit] = lock_commit if lock_commit return hash_map else hash_map[:branch] = branch if branch _, new_commit = LGitUtil.git_ls_remote_refs(self.name ,git, branch, tag, commit) if new_commit && (new_commit != lock_commit) hash_map[:commit] = new_commit hash_map["is_delete"] = false else hash_map["is_delete"] = true end end elsif git && commit hash_map[:commit] = commit if commit return hash_map else _, new_commit = LGitUtil.git_ls_remote_refs(self.name ,git, branch, tag, commit) if (new_commit != lock_commit) hash_map[:commit] = new_commit hash_map["is_delete"] = false else hash_map[:commit] = new_commit if new_commit hash_map["is_delete"] = true end end hash_map end |
#get_request_params ⇒ Object
获取下载参数
136 137 138 139 140 141 |
# File 'lib/lg_pod_plugin/request.rb', line 136 def get_request_params if self.lock_info == nil self.lock_info = self.get_lock_info end Hash.new.merge!(self.get_lock_params) end |
#setup_pod_info(name, workspace, options = {}) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/lg_pod_plugin/request.rb', line 144 def setup_pod_info(name, workspace, = {}) self.name = name tag = [:tag] git = [:git] commit = [:commit] branch = [:branch] self.workspace = workspace if (git && branch) || (git && commit) || (git && tag) self.single_git = false else self.single_git = true end self.net_ping = Ping.new(git) self.net_ping.network_ok = self.net_ping.ping self. = Hash.new.deep_merge() self.request_params = self.get_request_params self.config = LConfig.getConfig(git) self.cache = LCache.new(self.workspace) self.git_util = LGitUtil.new(name, self.) self.downloader = LDownloader.new(name, self.) end |