cocoapods-anker-ar 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 16401c71eaa53378e7477371a859c8fa24d15f9f19afb4f16aa346064f7cb625
4
- data.tar.gz: 9b6394c29855c198f343a67f884bbfe9e004c89655b4faf77313aac812d9064a
3
+ metadata.gz: a12a0c8334bae3fa0d0b53a6a5cf0480ca0d0fa2fec3d3b9a0eb324b67534a05
4
+ data.tar.gz: d8bff5397f7262b366e5ad61b22424defe4d4a74dd36860c3df1014ec7ba8919
5
5
  SHA512:
6
- metadata.gz: 78d8352d2476d37be3219373f0b1f0b9e5749537958054e7f74534d3fc5d2adfc1cf6a2cad704a75b541886516f90a16870b85e0c26ca524a89d0ca7b4b07ef0
7
- data.tar.gz: 72c3f836e17875feda638a7f925c27be388de5f51502e87f298a3c4b386d0966f995e9e02188af999ab3add9a07b37a0f6bd609dddb99bf9b687edb4c3b5b64a
6
+ metadata.gz: de8a4b20398dff205da4f52e982b5edbc5e5fdd428e3e51c0c1e2b9f18d1e732f6aa8c4633a0e52b82c7e07cee39763f7a0bbd985ae07b9900bb3eb399f8b0f6
7
+ data.tar.gz: 2a18ff5a74d03cb4c790e70961b581bb82623ffa0cbc56157afae15bb80f7c41814766862a03572d0926cb4d40d02b7abf20dd433a6c0c3b65a8966d8e407eaa
@@ -1,3 +1,3 @@
1
1
  module CocoapodsAnkerAr
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -110,8 +110,9 @@ module Pod
110
110
  pod_root = File.dirname Pathname(@podspec).realpath
111
111
  path_list = Pod::Sandbox::PathList.new(pod_root)
112
112
 
113
- file_accessors ||= spec.available_platforms.flat_map do |platform|
114
- Pod::Sandbox::FileAccessor.new(path_list, spec.consumer(platform))
113
+ all_specs = [spec] + spec.recursive_subspecs
114
+ file_accessors ||= spec.available_platforms.flat_map do |platform|
115
+ all_specs.map { |s| Pod::Sandbox::FileAccessor.new(path_list, s.consumer(platform)) }
115
116
  end
116
117
 
117
118
  pod_files = Pod::Sandbox::FileAccessor.all_files(file_accessors).map do |path|
@@ -92,45 +92,109 @@ module Pod
92
92
  def update(_show_output)
93
93
  require 'json'
94
94
  require 'coding_ar_util'
95
+ require 'typhoeus'
96
+ require 'etc'
95
97
 
96
98
  changed_spec_paths = []
97
99
  UI.puts "Updating CODING-AR-backed repo #{name}".yellow if _show_output
98
- Pathname.glob(repo.join('**/*/*.json')).map do |f|
100
+
101
+ files = Pathname.glob(repo.join('**/*/*.json'))
102
+ spec_requests = []
103
+
104
+ files.each do |f|
99
105
  begin
100
106
  origin_content = File.read(f)
101
- spec = JSON.parse origin_content
107
+ spec = JSON.parse(origin_content)
102
108
  spec_url = "#{url}/Specs/#{spec['name']}/#{spec['version']}/#{spec['name']}.podspec.json"
103
- UI.puts "- Fetch #{spec_url}" if _show_output
104
- FileUtils.mkdir_p File.dirname(f)
105
- CodingArUtil.download(spec_url, f)
106
- latest_content = File.read(f)
107
- FileUtils.rm_rf(File.dirname(f)) if latest_content.to_s.start_with?('Pod not found')
108
- JSON.parse latest_content
109
- changed_spec_paths.push(f) if origin_content != latest_content
110
- rescue RuntimeError => e
111
- if e.message.include?('Spec not found')
112
- UI.puts "- Skipping #{spec['name']} #{spec['version']}: Spec not found".yellow if _show_output
113
- next
114
- elsif e.message.include?('URL using bad/illegal format') || e.message.include?('missing URL')
115
- UI.puts "- Skipping #{spec['name']} #{spec['version']}: Invalid URL format".yellow if _show_output
116
- next
117
- else
118
- UI.puts "- Skipping #{spec['name']} #{spec['version']}: #{e.message}".yellow if _show_output
119
- next
120
- end
109
+ spec_requests << {
110
+ file: f,
111
+ url: spec_url,
112
+ origin_content: origin_content,
113
+ spec_name: spec['name'],
114
+ spec_version: spec['version']
115
+ }
121
116
  rescue JSON::ParserError => e
122
117
  UI.puts "- Skipping #{f}: Invalid JSON format".yellow if _show_output
123
- next
124
118
  rescue => e
125
119
  UI.puts "- Skipping #{f}: #{e.message}".yellow if _show_output
126
- next
127
120
  end
128
121
  end
129
- UI.puts "Successfully update CODING-AR-backed repo #{name}".green if _show_output
130
122
 
123
+ return [] if spec_requests.empty?
124
+
125
+ max_concurrency = [[Etc.nprocessors * 2, 4].max, 20].min
126
+ UI.puts "Fetching #{spec_requests.size} specs with #{max_concurrency} concurrent connections...".yellow if _show_output
127
+
128
+ start_time = Time.now
129
+ hydra = Typhoeus::Hydra.new(max_concurrency: max_concurrency)
130
+
131
+ spec_requests.each do |req|
132
+ request = Typhoeus::Request.new(
133
+ req[:url],
134
+ method: :get,
135
+ netrc: :optional,
136
+ netrc_file: ENV[CodingArUtil::CODING_AR_NETRC_PATH_ENV] || Netrc.default_path,
137
+ followlocation: true,
138
+ headers: { 'User-Agent' => CodingArUtil::USER_AGENT }
139
+ )
140
+
141
+ request.on_complete do |response|
142
+ handle_spec_response(response, req, changed_spec_paths, _show_output)
143
+ end
144
+
145
+ hydra.queue(request)
146
+ end
147
+
148
+ hydra.run
149
+ elapsed = Time.now - start_time
150
+
151
+ UI.puts "Fetched #{spec_requests.size} specs in #{elapsed.round(2)}s (#{(spec_requests.size / elapsed).round(1)} specs/sec)".green if _show_output
152
+ UI.puts "Successfully update CODING-AR-backed repo #{name}".green if _show_output
131
153
  []
132
154
  end
133
155
 
156
+ def handle_spec_response(response, req, changed_spec_paths, show_output)
157
+ file = req[:file]
158
+ spec_name = req[:spec_name]
159
+ spec_version = req[:spec_version]
160
+ origin_content = req[:origin_content]
161
+
162
+ UI.puts "- Fetch #{req[:url]}" if show_output
163
+
164
+ if response.code == 0
165
+ UI.puts "- Skipping #{spec_name} #{spec_version}: #{response.return_message}".yellow if show_output
166
+ return
167
+ elsif response.code != 200
168
+ error_msg = response.body.to_s
169
+ if error_msg.include?('Spec not found') || error_msg.include?('not found')
170
+ UI.puts "- Skipping #{spec_name} #{spec_version}: Spec not found".yellow if show_output
171
+ elsif error_msg.include?('URL using bad/illegal format') || error_msg.include?('missing URL')
172
+ UI.puts "- Skipping #{spec_name} #{spec_version}: Invalid URL format".yellow if show_output
173
+ else
174
+ UI.puts "- Skipping #{spec_name} #{spec_version}: HTTP #{response.code}".yellow if show_output
175
+ end
176
+ return
177
+ end
178
+
179
+ begin
180
+ latest_content = response.body
181
+ if latest_content.to_s.start_with?('Pod not found')
182
+ FileUtils.rm_rf(File.dirname(file))
183
+ return
184
+ end
185
+
186
+ JSON.parse(latest_content)
187
+ FileUtils.mkdir_p(File.dirname(file))
188
+ File.open(file, 'wb') { |f| f << latest_content }
189
+
190
+ changed_spec_paths.push(file) if origin_content != latest_content
191
+ rescue JSON::ParserError => e
192
+ UI.puts "- Skipping #{spec_name} #{spec_version}: Invalid JSON in response".yellow if show_output
193
+ rescue => e
194
+ UI.puts "- Skipping #{spec_name} #{spec_version}: #{e.message}".yellow if show_output
195
+ end
196
+ end
197
+
134
198
  def updateable?
135
199
  true
136
200
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-anker-ar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dark Liu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-12-12 00:00:00.000000000 Z
11
+ date: 2026-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler