lg_pod_plugin 1.0.3 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/lib/git/author.rb +14 -0
  3. data/lib/git/base/factory.rb +101 -0
  4. data/lib/git/base.rb +670 -0
  5. data/lib/git/branch.rb +126 -0
  6. data/lib/git/branches.rb +71 -0
  7. data/lib/git/config.rb +22 -0
  8. data/lib/git/diff.rb +155 -0
  9. data/lib/git/encoding_utils.rb +33 -0
  10. data/lib/git/escaped_path.rb +77 -0
  11. data/lib/git/index.rb +5 -0
  12. data/lib/git/lib.rb +1215 -0
  13. data/lib/git/log.rb +135 -0
  14. data/lib/git/object.rb +312 -0
  15. data/lib/git/path.rb +31 -0
  16. data/lib/git/remote.rb +36 -0
  17. data/lib/git/repository.rb +6 -0
  18. data/lib/git/stash.rb +27 -0
  19. data/lib/git/stashes.rb +55 -0
  20. data/lib/git/status.rb +199 -0
  21. data/lib/git/url.rb +127 -0
  22. data/lib/git/version.rb +5 -0
  23. data/lib/git/working_directory.rb +4 -0
  24. data/lib/git/worktree.rb +38 -0
  25. data/lib/git/worktrees.rb +47 -0
  26. data/lib/git.rb +326 -0
  27. data/lib/lg_pod_plugin/database.rb +104 -104
  28. data/lib/lg_pod_plugin/downloader.rb +98 -0
  29. data/lib/lg_pod_plugin/file_path.rb +8 -4
  30. data/lib/lg_pod_plugin/git_util.rb +188 -80
  31. data/lib/lg_pod_plugin/install.rb +61 -80
  32. data/lib/lg_pod_plugin/l_cache.rb +236 -0
  33. data/lib/lg_pod_plugin/l_util.rb +39 -0
  34. data/lib/lg_pod_plugin/log.rb +26 -0
  35. data/lib/lg_pod_plugin/request.rb +140 -0
  36. data/lib/lg_pod_plugin/string.rb +33 -0
  37. data/lib/lg_pod_plugin/version.rb +1 -1
  38. data/lib/lg_pod_plugin.rb +6 -60
  39. data/lib/rchardet/big5freq.rb +927 -0
  40. data/lib/rchardet/big5prober.rb +42 -0
  41. data/lib/rchardet/chardistribution.rb +250 -0
  42. data/lib/rchardet/charsetgroupprober.rb +110 -0
  43. data/lib/rchardet/charsetprober.rb +70 -0
  44. data/lib/rchardet/codingstatemachine.rb +67 -0
  45. data/lib/rchardet/constants.rb +42 -0
  46. data/lib/rchardet/escprober.rb +90 -0
  47. data/lib/rchardet/escsm.rb +245 -0
  48. data/lib/rchardet/eucjpprober.rb +88 -0
  49. data/lib/rchardet/euckrfreq.rb +597 -0
  50. data/lib/rchardet/euckrprober.rb +42 -0
  51. data/lib/rchardet/euctwfreq.rb +431 -0
  52. data/lib/rchardet/euctwprober.rb +42 -0
  53. data/lib/rchardet/gb18030freq.rb +474 -0
  54. data/lib/rchardet/gb18030prober.rb +42 -0
  55. data/lib/rchardet/hebrewprober.rb +289 -0
  56. data/lib/rchardet/jisfreq.rb +571 -0
  57. data/lib/rchardet/jpcntx.rb +229 -0
  58. data/lib/rchardet/langbulgarianmodel.rb +229 -0
  59. data/lib/rchardet/langcyrillicmodel.rb +330 -0
  60. data/lib/rchardet/langgreekmodel.rb +227 -0
  61. data/lib/rchardet/langhebrewmodel.rb +202 -0
  62. data/lib/rchardet/langhungarianmodel.rb +226 -0
  63. data/lib/rchardet/langthaimodel.rb +201 -0
  64. data/lib/rchardet/latin1prober.rb +147 -0
  65. data/lib/rchardet/mbcharsetprober.rb +89 -0
  66. data/lib/rchardet/mbcsgroupprober.rb +47 -0
  67. data/lib/rchardet/mbcssm.rb +542 -0
  68. data/lib/rchardet/sbcharsetprober.rb +122 -0
  69. data/lib/rchardet/sbcsgroupprober.rb +58 -0
  70. data/lib/rchardet/sjisprober.rb +88 -0
  71. data/lib/rchardet/universaldetector.rb +179 -0
  72. data/lib/rchardet/utf8prober.rb +87 -0
  73. data/lib/rchardet/version.rb +3 -0
  74. data/lib/rchardet.rb +67 -0
  75. data/lib/zip/central_directory.rb +212 -0
  76. data/lib/zip/compressor.rb +9 -0
  77. data/lib/zip/constants.rb +115 -0
  78. data/lib/zip/crypto/decrypted_io.rb +40 -0
  79. data/lib/zip/crypto/encryption.rb +11 -0
  80. data/lib/zip/crypto/null_encryption.rb +43 -0
  81. data/lib/zip/crypto/traditional_encryption.rb +99 -0
  82. data/lib/zip/decompressor.rb +31 -0
  83. data/lib/zip/deflater.rb +34 -0
  84. data/lib/zip/dos_time.rb +53 -0
  85. data/lib/zip/entry.rb +719 -0
  86. data/lib/zip/entry_set.rb +88 -0
  87. data/lib/zip/errors.rb +19 -0
  88. data/lib/zip/extra_field/generic.rb +44 -0
  89. data/lib/zip/extra_field/ntfs.rb +94 -0
  90. data/lib/zip/extra_field/old_unix.rb +46 -0
  91. data/lib/zip/extra_field/universal_time.rb +77 -0
  92. data/lib/zip/extra_field/unix.rb +39 -0
  93. data/lib/zip/extra_field/zip64.rb +70 -0
  94. data/lib/zip/extra_field/zip64_placeholder.rb +15 -0
  95. data/lib/zip/extra_field.rb +103 -0
  96. data/lib/zip/file.rb +468 -0
  97. data/lib/zip/filesystem.rb +643 -0
  98. data/lib/zip/inflater.rb +54 -0
  99. data/lib/zip/input_stream.rb +180 -0
  100. data/lib/zip/ioextras/abstract_input_stream.rb +122 -0
  101. data/lib/zip/ioextras/abstract_output_stream.rb +43 -0
  102. data/lib/zip/ioextras.rb +36 -0
  103. data/lib/zip/null_compressor.rb +15 -0
  104. data/lib/zip/null_decompressor.rb +19 -0
  105. data/lib/zip/null_input_stream.rb +10 -0
  106. data/lib/zip/output_stream.rb +198 -0
  107. data/lib/zip/pass_thru_compressor.rb +23 -0
  108. data/lib/zip/pass_thru_decompressor.rb +31 -0
  109. data/lib/zip/streamable_directory.rb +15 -0
  110. data/lib/zip/streamable_stream.rb +52 -0
  111. data/lib/zip/version.rb +3 -0
  112. data/lib/zip.rb +72 -0
  113. metadata +107 -33
  114. data/lib/lg_pod_plugin/cache.rb +0 -226
  115. data/lib/lg_pod_plugin/download.rb +0 -140
  116. data/lib/lg_pod_plugin/pod_spec.rb +0 -66
@@ -1,94 +1,221 @@
1
1
  require 'pp'
2
2
  require 'git'
3
- require_relative 'cache'
3
+ require_relative 'l_util'
4
+ require_relative 'request'
5
+ require_relative 'l_cache'
4
6
 
5
7
  module LgPodPlugin
6
8
 
7
- class GitUtil
8
- # attr_accessor :git
9
- # attr_accessor :tag
10
- # attr_accessor :path
11
- # attr_accessor :name
12
- # attr_accessor :commit
13
- # attr_accessor :branch
14
- # attr_accessor :temp_git_path
15
- REQUIRED_ATTRS ||= %i[git tag path name commit branch temp_git_path is_cache].freeze
16
- attr_accessor(*REQUIRED_ATTRS)
9
+ class LGitUtil
17
10
 
18
- def initialize
19
- super
20
- end
11
+ REQUIRED_ATTRS ||= %i[git tag path name commit branch].freeze
12
+ attr_accessor(*REQUIRED_ATTRS)
21
13
 
22
- def git_init(name, options = {})
14
+ def initialize(name, options = {})
23
15
  self.name = name
24
16
  self.git = options[:git]
25
17
  self.tag = options[:tag]
26
18
  self.path = options[:path]
27
19
  self.branch = options[:branch]
28
20
  self.commit = options[:commit]
29
- self.is_cache = options[:depth]
30
21
  end
31
22
 
32
- def git_clone(path)
33
- if self.branch
34
- temp_git_path = path.join("l-temp-pod")
35
- LgPodPlugin.log_yellow "git clone --template= --single-branch --depth 1 --branch #{self.branch} #{self.git}"
36
- system("git clone --template= --single-branch --depth 1 --branch #{self.branch} #{self.git} #{temp_git_path}")
37
- temp_git_path
38
- else
39
- nil
23
+ # 根据branch 下载 zip 包
24
+ def git_download_branch_zip(path, temp_name)
25
+ token = ""
26
+ file_name = "#{temp_name}.zip"
27
+ base_url = self.git[0...self.git.length - 4]
28
+ project_name = base_url.split("/").last
29
+ unless project_name
30
+ return self.git_clone_by_branch(path, temp_name)
31
+ end
32
+ download_url = base_url + "/-/archive/" + self.branch + "/#{project_name}-#{self.branch}.zip"
33
+ LgPodPlugin.log_blue "开始下载 => #{download_url}"
34
+ system("curl --header PRIVATE-TOKEN:#{token} -o #{file_name} --connect-timeout 15 #{download_url}")
35
+ unless File.exist?(file_name)
36
+ LgPodPlugin.log_red("下载zip包失败, 尝试git clone #{self.git}")
37
+ return self.git_clone_by_branch(path, temp_name)
38
+ end
39
+ # 解压文件
40
+ result = LUtils.unzip_file(path.join(file_name).to_path, "./")
41
+ new_file_name = "#{project_name}-#{self.branch}"
42
+ unless result && File.exist?(new_file_name)
43
+ LgPodPlugin.log_red("解压文件失败, 尝试git clone #{self.git}")
44
+ return self.git_clone_by_branch(path, temp_name)
40
45
  end
46
+ path.join(new_file_name)
41
47
  end
42
48
 
43
- def git_checkout(branch)
44
- system("git checkout -b #{branch}")
49
+ # 通过tag下载zip包
50
+ def git_download_tag_zip(path, temp_name)
51
+ token = ""
52
+ base_url = self.git[0...self.git.length - 4]
53
+ project_name = base_url.split("/").last
54
+ unless project_name
55
+ return self.git_clone_by_tag(path, temp_name)
56
+ end
57
+ file_name = "#{temp_name}.zip"
58
+ download_url = base_url + "/-/archive/" + self.tag + "/#{project_name}-#{self.tag}.zip"
59
+ # 下载文件
60
+ LgPodPlugin.log_blue "开始下载 => #{download_url}"
61
+ system("curl -s --header PRIVATE-TOKEN:#{token} -o #{file_name} #{download_url}")
62
+ unless File.exist?(file_name)
63
+ LgPodPlugin.log_red("下载zip包失败, 尝试git clone #{self.git}")
64
+ return self.git_clone_by_tag(path, temp_name)
65
+ end
66
+ # 解压文件
67
+ result = LUtils.unzip_file(path.join(file_name).to_path, "./")
68
+ new_file_name = "#{project_name}-#{self.tag}"
69
+ unless result && File.exist?(new_file_name)
70
+ LgPodPlugin.log_red("解压文件失败, 尝试git clone #{self.git}")
71
+ return self.git_clone_by_tag(path, temp_name)
72
+ end
73
+ path.join(new_file_name)
45
74
  end
46
-
47
- def git_switch(branch)
48
- system("git switch #{branch}")
75
+ # 通过 commit 下载zip包
76
+ def git_download_commit_zip(path, temp_name)
77
+ token = ""
78
+ base_url = self.git[0...self.git.length - 4]
79
+ project_name = base_url.split("/").last
80
+ unless project_name
81
+ return self.git_clone_by_commit(path, temp_name)
82
+ end
83
+ file_name = "#{temp_name}.zip"
84
+ download_url = base_url + "/-/archive/" + self.commit + "/#{project_name}-#{self.commit}.zip"
85
+ # 下载文件
86
+ LgPodPlugin.log_blue "开始下载 => #{download_url}"
87
+ system("curl -s --header PRIVATE-TOKEN:#{token} -o #{file_name} #{download_url}")
88
+ unless File.exist?(file_name)
89
+ LgPodPlugin.log_red("下载zip包失败, 尝试git clone #{self.git}")
90
+ return self.git_clone_by_commit(path, temp_name)
91
+ end
92
+ # 解压文件
93
+ result = LUtils.unzip_file(path.join(file_name).to_path, "./")
94
+ new_file_name = "#{project_name}-#{self.commit}"
95
+ unless result && File.exist?(new_file_name)
96
+ LgPodPlugin.log_red("解压文件失败, 尝试git clone #{self.git}")
97
+ return self.git_clone_by_commit(path, temp_name)
98
+ end
99
+ path.join(new_file_name)
100
+ end
101
+
102
+ def git_clone_by_branch(path, temp_name)
103
+ LgPodPlugin.log_blue "git clone --depth=1 --branch #{self.branch} #{self.git}"
104
+ system("git clone --depth=1 -b #{self.branch} #{self.git} #{temp_name}")
105
+ path.join(temp_name)
106
+ end
107
+
108
+ def git_clone_by_tag(path, temp_name)
109
+ LgPodPlugin.log_blue "git clone --tag #{self.tag} #{self.git}"
110
+ system("git clone --depth=1 -b #{self.tag} #{self.git} #{temp_name}")
111
+ path.join(temp_name)
112
+ end
113
+
114
+ def git_clone_by_commit(path, temp_name)
115
+ LgPodPlugin.log_blue "git clone #{self.git}"
116
+ Git.init(temp_name)
117
+ FileUtils.chdir(temp_name)
118
+ system("git remote add origin #{self.git}")
119
+ system("git fetch origin #{self.commit}")
120
+ system("git reset --hard FETCH_HEAD")
121
+ path.join(temp_name)
49
122
  end
50
123
 
51
- #noinspection RubyNilAnalysis
52
- def pre_download_git_remote(path, branch)
53
- lg_pod_path = Pathname(path)
54
- root_path = FileManager.download_director
55
- pod_info_db = SqliteDb.instance.select_table(self.name, branch)
56
- if lg_pod_path.exist? && pod_info_db.branch
57
- return lg_pod_path
124
+ # clone 代码仓库
125
+ def git_clone_repository(path)
126
+ FileUtils.chdir(path)
127
+ temp_name = "lg_temp_pod"
128
+ if self.git && self.tag
129
+ if self.git.include?("xxx/capp/iOS")
130
+ return git_download_tag_zip(path, temp_name)
131
+ else
132
+ return self.git_clone_by_tag(path, temp_name)
133
+ end
134
+ elsif self.git && self.branch
135
+ if self.git.include?("xxx/capp/iOS")
136
+ return self.git_download_branch_zip(path, temp_name)
137
+ else
138
+ return self.git_clone_by_branch(path, temp_name)
139
+ end
140
+ elsif self.git && self.commit
141
+ if self.git.include?("xxx/capp/iOS")
142
+ return self.git_download_commit_zip(path, temp_name)
143
+ else
144
+ return self.git_clone_by_commit(path, temp_name)
145
+ end
58
146
  end
147
+ end
59
148
 
60
- FileUtils.chdir(root_path)
61
- temp_path = root_path.join("temp")
149
+ # def git_checkout(branch)
150
+ # system("git checkout -b #{branch}")
151
+ # end
152
+ #
153
+ # def git_switch(branch)
154
+ # system("git switch #{branch}")
155
+ # end
156
+
157
+ def request_params
158
+ hash_map = {:git => git}
159
+ if git && tag
160
+ hash_map[:tag] = tag
161
+ hash_map[:commit] = self.commit
162
+ else
163
+ hash_map[:commit] = commit
164
+ end
165
+ hash_map
166
+ end
167
+
168
+ def pre_download_git_repository
169
+ temp_path = LFileManager.download_director.join("temp")
62
170
  if temp_path.exist?
63
- FileUtils.rm_r(temp_path)
171
+ FileUtils.rm_rf(temp_path)
172
+ end
173
+ lg_pod_path = LRequest.shared.cache.cache_root
174
+ unless lg_pod_path.exist?
175
+ lg_pod_path.mkdir(0700)
64
176
  end
65
- temp_path.mkdir(0700)
66
- FileUtils.chdir(temp_path)
67
- #clone仓库
68
- get_temp_folder = git_clone(temp_path)
177
+ get_temp_folder = git_clone_repository(lg_pod_path)
69
178
  #下载 git 仓库失败
70
179
  unless get_temp_folder.exist?
71
180
  return nil
72
181
  end
73
-
74
- if self.is_cache
75
- pod_root_director = FileManager.download_pod_path(name)
76
- unless pod_root_director.exist?
77
- FileUtils.mkdir(pod_root_director)
182
+ LgPodPlugin::LCache.cache_pod(self.name, get_temp_folder, self.request_params)
183
+ FileUtils.chdir(LFileManager.download_director)
184
+ FileUtils.rm_rf(lg_pod_path)
185
+ end
186
+
187
+ # 获取最新的一条 commit 信息
188
+ def self.git_ls_remote_refs(git, branch, tag, commit)
189
+ if branch
190
+ LgPodPlugin.log_yellow "git ls-remote #{git} #{branch}"
191
+ new_commit = %x(git ls-remote #{git} #{branch}).split(" ").first
192
+ return [branch, new_commit]
193
+ end
194
+ ls = Git.ls_remote(git, :head => true )
195
+ if tag
196
+ map = ls["tags"]
197
+ keys = map.keys
198
+ idx = keys.index("#{tag}")
199
+ unless idx
200
+ return [nil, nil]
78
201
  end
79
- FileUtils.mv(get_temp_folder, lg_pod_path)
80
- temp_path.rmdir
81
- lg_pod_path
202
+ key = keys[idx]
203
+ new_commit = map[key][:sha]
204
+ return [nil, new_commit]
82
205
  else
83
- commit = GitUtil.git_ls_remote_refs(self.git, self.branch)
84
- LgPodPlugin::Cache.cache_pod(self.name, get_temp_folder, true, {:git => self.git, :commit => commit})
85
- system("cd ..")
86
- system("rm -rf #{get_temp_folder.to_path}")
87
- return lg_pod_path
206
+ new_commit = new_branch = nil
207
+ find_commit = commit ? commit : ls["head"][:sha]
208
+ ls["branches"].each do |key, value|
209
+ sha = value[:sha]
210
+ next if sha != find_commit
211
+ new_branch = key
212
+ new_commit = find_commit
213
+ return [new_branch, new_commit]
214
+ end
215
+ return [new_branch , new_commit]
88
216
  end
89
-
90
217
  end
91
-
218
+
92
219
  # 本地pod库git操作
93
220
  def git_local_pod_check(path)
94
221
  FileUtils.chdir(path)
@@ -117,31 +244,12 @@ module LgPodPlugin
117
244
  self.should_pop_stash(git, current_branch)
118
245
  end
119
246
  end
120
-
121
- # 获取最新的一条 commit 信息
122
- def self.git_ls_remote_refs(git, branch)
123
- last_commit = nil
124
- LgPodPlugin.log_yellow "git ls-remote #{git} #{branch}"
125
- sha = %x(git ls-remote #{git} #{branch}).split(" ").first
126
- if sha
127
- last_commit = sha
128
- return last_commit
129
- else
130
- ls = Git.ls_remote(git, :refs => true )
131
- find_branch = ls["branches"][branch]
132
- if find_branch
133
- last_commit = find_branch[:sha]
134
- return last_commit
135
- end
136
- return nil
137
- end
138
- end
139
-
140
247
  # 是否pull 代码
141
248
  def should_pull(git, branch, new_commit = nil)
142
- git_url = git.remote.url
249
+ new_branch = branch ||= self.branch
250
+ git_url = git.remote.url ||= self.git
143
251
  if new_commit == nil
144
- new_commit = GitUtil.git_ls_remote_refs(git_url, branch)
252
+ _, new_commit = LGitUtil.git_ls_remote_refs(git_url, new_branch,nil, nil)
145
253
  end
146
254
  local_commit = git.log(1).to_s #本地最后一条 commit hash 值
147
255
  if local_commit != new_commit
@@ -1,18 +1,17 @@
1
1
  require 'pp'
2
2
  require 'git'
3
3
  require 'cgi'
4
- require 'sqlite3'
5
4
  require 'cocoapods'
5
+ require_relative 'request'
6
6
  require_relative 'database'
7
- require_relative 'download'
8
7
  require_relative 'git_util'
9
- require_relative 'pod_spec'
8
+ require_relative 'downloader.rb'
10
9
 
11
10
  module LgPodPlugin
12
11
 
13
12
  class Installer
14
13
 
15
- REQUIRED_ATTRS ||= %i[name version options profile target real_name downloader git_util].freeze
14
+ REQUIRED_ATTRS ||= %i[name version options target real_name workspace].freeze
16
15
  attr_accessor(*REQUIRED_ATTRS)
17
16
 
18
17
  def initialize(profile, name, *requirements)
@@ -22,12 +21,11 @@ module LgPodPlugin
22
21
  self.name = name
23
22
  end
24
23
  self.real_name = name
25
- self.profile = profile
26
- self.git_util = GitUtil.new
27
- self.downloader = Downloader.new
24
+ self.workspace = profile.send(:defined_in_file).dirname
28
25
  self.target = profile.send(:current_target_definition)
29
26
 
30
27
  unless requirements && !requirements.empty?
28
+ LRequest.shared.setup_pod_info(self.name, self.workspace, nil)
31
29
  self.lg_pod(self.real_name, requirements)
32
30
  return
33
31
  end
@@ -38,38 +36,52 @@ module LgPodPlugin
38
36
  elsif "#{first.class}" == "Hash"
39
37
  self.options = first
40
38
  end
41
-
42
- hash_map = requirements[0].last
43
- if "#{hash_map.class}" == "Hash"
44
- self.options = hash_map
39
+ hash_map = nil
40
+ last = requirements[0].last
41
+ if "#{last.class}" == "Hash"
42
+ hash_map = last
43
+ end
44
+ git = hash_map[:git]
45
+ if hash_map && git
46
+ tag = hash_map[:tag]
47
+ branch = hash_map[:branch]
48
+ commit = hash_map[:commit]
49
+ if tag
50
+ hash_map.delete(:branch)
51
+ hash_map.delete(:commit)
52
+ elsif commit
53
+ hash_map.delete(:tag)
54
+ hash_map.delete(:branch)
55
+ elsif branch
56
+ hash_map.delete(:tag)
57
+ hash_map.delete(:commit)
58
+ end
45
59
  end
46
-
60
+ self.options = hash_map
61
+ LRequest.shared.setup_pod_info(self.name, self.workspace, hash_map)
47
62
  self.lg_pod(name, requirements)
48
-
49
63
  end
50
64
 
51
65
  public
52
- # @param [Object] name
53
- # @param [Hash] options
54
- # @return [Object] nil
55
66
  def lg_pod(name, *requirements)
56
67
  unless name
57
68
  raise StandardError, 'A dependency requires a name.'
58
69
  end
59
70
 
60
- if !requirements
71
+ # 根据pod name安装, pod 'AFNetworking'
72
+ unless requirements
61
73
  self.target.store_pod(self.real_name)
62
74
  return
63
75
  end
64
-
76
+ # 根据name, version 安装, pod 'AFNetworking', "1.0.1"
65
77
  if self.version && !self.options
66
78
  self.target.store_pod(self.real_name, self.version)
67
79
  return
68
80
  end
69
-
81
+ # 根据name, version 安装, pod 'AFNetworking', "1.0.1", :configurations => ["Debug"]
70
82
  if self.version && self.options
71
83
  hash_map = self.options
72
- hash_map.delete(:depth)
84
+ # hash_map.delete(:cache)
73
85
  self.target.store_pod(self.real_name, self.version, hash_map)
74
86
  return
75
87
  end
@@ -80,85 +92,54 @@ module LgPodPlugin
80
92
  return
81
93
  end
82
94
 
83
- real_path = nil
84
- tag = hash_map[:tag]
85
- url = hash_map[:git]
86
95
  path = hash_map[:path]
87
- commit = hash_map[:commit]
88
- branch = hash_map[:branch]
89
- is_cache = options[:depth]
90
96
  if path
91
- profile_path = self.profile.send(:defined_in_file).dirname
92
- real_path = Pathname.new(path).expand_path(profile_path)
93
- end
94
- # 找到本地组件库 执行 git pull
95
- if real_path && File.directory?(real_path)
96
- hash_map[:path] = real_path
97
- hash_map.delete(:depth)
98
- self.install_local_pod(self.name, hash_map)
99
- return
100
- end
101
-
102
- # 根据tag, commit下载文件
103
- hash_map.delete(:path)
104
- if (tag && url) || (commit && url)
105
- hash_map.delete(:depth)
106
- hash_map.delete(:branch)
107
- self.target.store_pod(self.real_name, hash_map)
108
- return
109
- end
110
-
111
- # 根据 branch 下载代码
112
- if url
113
- hash_map.delete(:tag)
114
- hash_map.delete(:commit)
115
- self.downloader.download_init(self.name, hash_map)
116
- self.downloader.pre_download_pod(self.git_util)
117
- hash_map.delete(:depth)
118
- self.target.store_pod(self.real_name, hash_map)
97
+ self.install_local_pod(name, path, options)
98
+ else
99
+ hash_map.delete(:path)
100
+ self.install_remote_pod(name, hash_map)
119
101
  end
120
102
 
121
-
122
103
  end
123
104
 
124
105
  public
125
- def install_form_specs(spec_path = nil)
126
- spec_path ||= './Specs'
127
- path = File.expand_path(spec_path, Dir.pwd)
128
- file_objects = Dir.glob(File.expand_path("*.rb", path)).map do |file_path|
129
- #读取 xxx.rb文件
130
- Spec.form_file(file_path)
131
- end
132
- # 便利出每一个pod对安装信息
133
- file_objects.each do |file|
134
- if file.install
135
- options = file.pod_requirements
136
- self.lg_pod(file.name, options)
137
- end
106
+ def install_remote_pod(name, options = {})
107
+ git = options[:git]
108
+ if git
109
+ LRequest.shared.downloader.pre_download_pod
110
+ self.target.store_pod(self.real_name, options)
111
+ else
112
+ LgPodPlugin.log_red "pod `#{name}` 的参数 path, git , tag , commit不正确"
138
113
  end
139
-
140
114
  end
141
115
 
142
116
  public
143
- def install_local_pod(name, options = {})
117
+ #安装本地pod
118
+ def install_local_pod(name, relative_path, options = {})
144
119
  hash_map = options
145
- local_path = options[:path]
146
- branch = options[:branch]
147
- unless Dir.glob(File.expand_path(".git", local_path)).count > 0
148
- LgPodPlugin.log_red("pod `#{name}` at path => #{local_path} 找不到.git目录")
120
+ absolute_path = Pathname.new(relative_path).expand_path(self.workspace)
121
+
122
+ unless absolute_path.exist?
123
+ hash_map.delete(:path)
124
+ self.install_remote_pod(name, hash_map)
149
125
  return
150
126
  end
151
- unless Dir.glob(File.expand_path("#{name}.podspec", local_path)).count > 0
152
- LgPodPlugin.log_red("pod `#{name}` at path => #{local_path} 找不到#{name}.podspec文件")
127
+
128
+ if Dir.glob(File.expand_path(".git", absolute_path)).empty?
129
+ hash_map.delete(:path)
130
+ self.install_remote_pod(name, hash_map)
153
131
  return
154
132
  end
155
133
 
156
- self.git_util.git_init(name, :branch => branch, :path => local_path)
157
- self.git_util.git_local_pod_check(local_path)
158
- hash_map[:path] = local_path.to_path
134
+ if Dir.glob(File.expand_path("#{name}.podspec", absolute_path)).empty?
135
+ hash_map.delete(:path)
136
+ self.install_remote_pod(name, hash_map)
137
+ return
138
+ end
139
+ # LRequest.shared.git_util.git_local_pod_check(absolute_path)
159
140
  hash_map.delete(:tag)
160
141
  hash_map.delete(:git)
161
- hash_map.delete(:depth)
142
+ # hash_map.delete(:cache)
162
143
  hash_map.delete(:commit)
163
144
  hash_map.delete(:branch)
164
145
  # 安装本地私有组件库