pixab 1.7.2 → 1.7.5

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: 4146df9c65aca34df839f71672eeafb17a87c0f11ce6e8da797be55254be3d0e
4
- data.tar.gz: b5a627d359ea03d2f0eaae853bf3370a46407d04f7c9e7e752628e9805a90108
3
+ metadata.gz: 5caf285f26d4a55e734aad944c40ca46b1f8458fc83e73cbdd4e2195ad57afdc
4
+ data.tar.gz: 8625302238e71910fc595c340fdc99e05d53ebb9465ad27743fc0907c9bbbaa0
5
5
  SHA512:
6
- metadata.gz: 024a39ab63245acab281016dffc0dc663f13174ff4f12ee0d25a9981a0eb0de7f5a0c7dc1962f8a6b3a9dc2270058d577e9f93666a246c6641cf7f91831aa534
7
- data.tar.gz: 361c49c8054f9da6793a3089b77d3b4f076d80f5b6c20f504a18b40d5a14f912b7411e92c2eb2f4f4e1005b600d22be86da389577e5838ad3cbb0763ee392276
6
+ metadata.gz: fffb6152204d9d77677edc3f256e583057f8c594f3cee9b31acc711c4f5a075cfb63b23a51ad07ace23cf83940045499ebf3d66820abb338dc02de03f0418b43
7
+ data.tar.gz: be6024b8c34ed9e744b95e37a4968d7c3cad1133ea683a1d0eb3117bbdb46005a0287fa160ad9b21dfe4cbd8dc57fb4d7bdbdd013099164f731bfb44c46d40c6
@@ -14,8 +14,9 @@ module Pixab
14
14
  Localization_FILE_NAME = 'Localization.zip'
15
15
 
16
16
  Project_AirBrush = '6cd2db15-6325-43ae-9087-f78aca9bec9a'
17
+ Project_AirBrushVideo = '16cbeffd-bb6e-46e8-a32e-9c79d23a796f'
17
18
 
18
- attr_accessor :projects, :tags, :platform, :collections
19
+ attr_accessor :projects, :tags, :platform, :collections, :languages
19
20
 
20
21
  def initialize()
21
22
  @projects = Project_AirBrush
@@ -30,10 +31,20 @@ module Pixab
30
31
  @platform = 'android'
31
32
  @tags = 'android'
32
33
  @collections = 'AirBrush'
34
+ @languages = 'en,ru,tr,de,fr,zh-Hans,zh-Hant,pt-BR,es,ar'
33
35
  when '--ab-iOS'
34
36
  @platform = 'iOS'
35
37
  @tags = 'iOS'
36
38
  @collections = 'AirBrush'
39
+ @languages = 'en,ru,tr,de,fr,zh-Hans,zh-Hant,pt-BR,es,ar'
40
+ when '--abv-iOS'
41
+ @projects = Project_AirBrushVideo
42
+ @platform = 'iOS'
43
+ @tags = 'iOS'
44
+ when '--abv-android'
45
+ @projects = Project_AirBrushVideo
46
+ @platform = 'android'
47
+ @tags = 'android'
37
48
  end
38
49
  end
39
50
 
@@ -48,6 +59,8 @@ module Pixab
48
59
  @platform = commands[index + 1]
49
60
  when '--collections'
50
61
  @collections = commands[index + 1]
62
+ when '--languages'
63
+ @languages = commands[index + 1]
51
64
  end
52
65
  end
53
66
 
@@ -83,17 +96,7 @@ module Pixab
83
96
  end
84
97
 
85
98
  # 第二步:循环尝试下载ZIP文件
86
- def download_zip_file_with_retry(download_url, export_id, max_retries=30)
87
- # 加载动画字符
88
- spinner = Enumerator.new do |e|
89
- loop do
90
- e.yield '|'
91
- e.yield '/'
92
- e.yield '-'
93
- e.yield '\\'
94
- end
95
- end
96
-
99
+ def download_zip_file_with_retry(download_url, export_id, max_retries=60)
97
100
  retries = 0
98
101
  while retries < max_retries
99
102
  uri = URI("#{download_url}/#{export_id}")
@@ -108,17 +111,15 @@ module Pixab
108
111
  File.open(Localization_FILE_NAME, "wb") { |file| file.write(response.body) }
109
112
  return true
110
113
  else
111
- # 等待1秒后重试
112
- # 打印动画字符
113
- print "\r#{spinner.next}"
114
- sleep 0.5
115
- print "\r#{spinner.next}"
116
- sleep 0.5
117
114
  retries += 1
115
+ dots = '.' * retries
116
+ print "\r#{dots}"
117
+ # 等待1秒后重试
118
+ sleep 1
118
119
  end
119
120
  end
120
121
 
121
- puts "Failed to download after #{max_retries} retries. Export ID: #{export_id}"
122
+ puts "\nFailed to download after #{max_retries} retries. Export ID: #{export_id}"
122
123
  return false
123
124
  end
124
125
 
@@ -144,10 +145,12 @@ module Pixab
144
145
  f_path = extract_localization_file_path(f.name)
145
146
  FileUtils.mkdir_p(File.dirname(f_path))
146
147
  content = f.get_input_stream.read
147
- localization_content = content.gsub(/=\s*".*";/) do |match|
148
- match.gsub('%s', '%@')
148
+ if projects == Project_AirBrush
149
+ content = content.gsub(/=\s*".*";/) do |match|
150
+ match.gsub('%s', '%@')
151
+ end
149
152
  end
150
- File.write(f_path, localization_content)
153
+ File.write(f_path, content)
151
154
  end
152
155
  end
153
156
 
@@ -178,12 +181,20 @@ module Pixab
178
181
  'include-default-language' => nil,
179
182
  }
180
183
 
184
+ unless languages.nil?
185
+ export_params['languages'] = languages
186
+ end
187
+
181
188
  if !platform.nil?
182
189
  format = nil
183
190
  template = nil
184
191
  if platform == 'android'
185
192
  format = 'android-xml'
186
- template = '{LOCALE:ANDROID}/strings_ph.xml'
193
+ if projects == Project_AirBrush
194
+ template = '{LOCALE:ANDROID}/strings_ph.xml'
195
+ else
196
+ template = '{LOCALE:ANDROID}/strings.xml'
197
+ end
187
198
  else
188
199
  format = 'ios-strings'
189
200
  template = '{LOCALE:IOS}.lproj/Localizable.strings'
@@ -200,39 +211,75 @@ module Pixab
200
211
  end
201
212
 
202
213
  def extract_localization_file_path(zip_file_path)
203
- if platform.nil? || platform != 'android'
204
- return zip_file_path
205
- end
214
+ case projects
215
+ when Project_AirBrush
216
+ if platform.nil? || platform != 'android'
217
+ return zip_file_path
218
+ end
206
219
 
207
-
208
- path = File.dirname(zip_file_path)
209
- localization = ''
210
- case path
211
- when 'en'
220
+ path = File.dirname(zip_file_path)
212
221
  localization = ''
213
- when 'fr'
214
- localization = '-fr-rFR'
215
- when 'ru'
216
- localization = '-ru-rRU'
217
- when 'zh-rHans'
218
- localization = '-zh-rCN'
219
- when 'tr'
220
- localization = '-tr-rTR'
221
- when 'pt-rBR'
222
- localization = '-pt'
223
- else
224
- localization = "-#{path}"
222
+ case path
223
+ when 'en'
224
+ localization = ''
225
+ when 'fr'
226
+ localization = '-fr-rFR'
227
+ when 'ru'
228
+ localization = '-ru-rRU'
229
+ when 'zh-rHans'
230
+ localization = '-zh-rCN'
231
+ when 'tr'
232
+ localization = '-tr-rTR'
233
+ when 'pt-rBR'
234
+ localization = '-pt'
235
+ else
236
+ localization = "-#{path}"
237
+ end
238
+ return "values#{localization}/#{File.basename(zip_file_path)}"
239
+
240
+ when Project_AirBrushVideo
241
+ if platform.nil?
242
+ return zip_file_path
243
+ end
244
+
245
+ case platform
246
+ when 'android'
247
+ path = File.dirname(zip_file_path)
248
+ localization = ''
249
+ case path
250
+ when 'en'
251
+ localization = ''
252
+ when 'zh-rHans'
253
+ localization = '-zh-rCN'
254
+ when 'zh-rHant'
255
+ localization = '-zh-rHK'
256
+ else
257
+ localization = "-#{path}"
258
+ end
259
+ return "values#{localization}/#{File.basename(zip_file_path)}"
260
+ when 'iOS'
261
+ path = File.dirname(zip_file_path)
262
+ localization = zip_file_path
263
+ case path
264
+ when 'pt-PT.lproj'
265
+ localization = File.join('pt.lproj', File.basename(zip_file_path))
266
+ end
267
+ return localization
268
+ end
225
269
  end
226
- return "values#{localization}/#{File.basename(zip_file_path)}"
270
+
227
271
  end
228
272
 
229
273
  def is_ignored_file_path(file_path)
230
- if platform != 'android'
231
- return false
274
+ case projects
275
+ when Project_AirBrush
276
+ return false unless platform == 'android'
277
+
278
+ path = File.dirname(file_path)
279
+ return path == 'zh-rHant' ? true : false
232
280
  end
233
281
 
234
- path = File.dirname(file_path)
235
- return path == 'zh-rHant' ? true : false
282
+ return false
236
283
  end
237
284
 
238
285
  end
data/lib/pixab/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pixab
4
- VERSION = "1.7.2"
4
+ VERSION = "1.7.5"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pixab
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.2
4
+ version: 1.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - 廖再润
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-06 00:00:00.000000000 Z
11
+ date: 2023-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored2