Class: LgPodPlugin::GitHubArchive
- Inherits:
-
Object
- Object
- LgPodPlugin::GitHubArchive
- Defined in:
- lib/lg_pod_plugin/git/github_archive.rb
Instance Method Summary collapse
- #download ⇒ Object
-
#download_archive_zip(project_name) ⇒ Object
下载某个文件zip格式.
- #github_download_branch_zip(root_path) ⇒ Object
- #github_download_commit_zip(root_path) ⇒ Object
- #github_download_tag_zip(root_path) ⇒ Object
-
#initialize(checkout_options = {}) ⇒ GitHubArchive
constructor
A new instance of GitHubArchive.
Constructor Details
#initialize(checkout_options = {}) ⇒ GitHubArchive
Returns a new instance of GitHubArchive.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/lg_pod_plugin/git/github_archive.rb', line 15 def initialize( = {}) self.git = [:git] self.tag = [:tag] self.name = [:name] self.path = [:path] self.spec = [:spec] self.config = [:config] self.commit = [:commit] self.branch = [:branch] @checkout_options = end |
Instance Method Details
#download ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/lg_pod_plugin/git/github_archive.rb', line 27 def download if self.git && self.tag self.github_download_tag_zip self.path elsif self.git && self.branch self.github_download_branch_zip self.path elsif self.git && self.commit self.github_download_commit_zip self.path end end |
#download_archive_zip(project_name) ⇒ Object
下载某个文件zip格式
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 |
# File 'lib/lg_pod_plugin/git/github_archive.rb', line 93 def download_archive_zip(project_name) base_url = LUtils.get_gitlab_base_url(self.git) if base_url.include?("https://github.com/") repo_name = base_url.split("https://github.com/", 0).last elsif base_url.include?("[email protected]:") repo_name = base_url.split("[email protected]:", 0).last else repo_name = nil end return nil unless repo_name if self.git && self.tag download_url = "https://codeload.github.com/#{repo_name}/tar.gz/refs/tags/#{self.tag}" [{ "filename" => "#{project_name}.tar.gz", "url" => download_url }] elsif self.git && self.branch if self.branch == "HEAD" download_url = "https://gh.api.99988866.xyz/" + "#{base_url}" + "/archive/#{self.branch}.tar.gz" [{ "filename" => "#{project_name}.tar.gz", "url" => download_url }] else download_url = "https://codeload.github.com/#{repo_name}/tar.gz/refs/heads/#{self.branch}" [{ "filename" => "#{project_name}.tar.gz", "url" => download_url }] end elsif self.git && self.commit download_url = "https://codeload.github.com/#{repo_name}/tar.gz/#{self.commit}" return [{ "filename" => "#{project_name}.tar.gz", "url" => download_url }] else nil end end |
#github_download_branch_zip(root_path) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/lg_pod_plugin/git/github_archive.rb', line 56 def github_download_branch_zip(root_path) project_name = LUtils.get_git_project_name self.git download_urls = self.download_archive_zip(project_name) download_params = Hash.new download_params["name"] = self.name download_params["type"] = "github-branch" download_params["path"] = root_path.to_path download_params["download_urls"] = download_urls if self.spec download_params["podspec"] = self.spec download_params["source_files"] = self.spec.source_files.keys else download_params["podspec"] = nil download_params["source_files"] = ["All"] end download_params end |
#github_download_commit_zip(root_path) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/lg_pod_plugin/git/github_archive.rb', line 74 def github_download_commit_zip(root_path) project_name = LUtils.get_git_project_name self.git download_urls = self.download_archive_zip(project_name) download_params = Hash.new download_params["name"] = self.name download_params["type"] = "github-commit" download_params["path"] = root_path.to_path download_params["download_urls"] = download_urls if self.spec download_params["podspec"] = self.spec download_params["source_files"] = self.spec.source_files.keys else download_params["podspec"] = nil download_params["source_files"] = ["All"] end download_params end |
#github_download_tag_zip(root_path) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/lg_pod_plugin/git/github_archive.rb', line 37 def github_download_tag_zip(root_path) project_name = LUtils.get_git_project_name self.git download_urls = self.download_archive_zip(project_name) download_params = Hash.new download_params["name"] = self.name download_params["type"] = "github-tag" download_params["path"] = root_path.to_path download_params["download_urls"] = download_urls if self.spec download_params["podspec"] = self.spec download_params["source_files"] = self.spec.source_files.keys download_params["podspec_content"] = nil else download_params["podspec"] = nil download_params["source_files"] = ["All"] end download_params end |