pixab 2.5.0 → 2.6.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: 65ac3034471869b3d54c91cb78037e992a5afa7e14c04a778d19de6a8550da2a
4
- data.tar.gz: cae519a48fd8ad1abd49f4787895c6d9b37cdf9d06fb22516e3b6f7c30a1e247
3
+ metadata.gz: 33b23dbba4b6ae53666ba3ff936c868143cc3a7926d7bf61738a3cc0709a092b
4
+ data.tar.gz: 86b9a0d5878707673ba300b87ae77837d7ff22cba239ab012598f0ae30e6c8e4
5
5
  SHA512:
6
- metadata.gz: 22e700b31c5ba8f69ff5c353dc8758629d9e4e0a38c149899a07aad127f5f9e8a3b5941491b0715687cbce4fc06b515acaf40383f5bc1b927a543ebbba4352d3
7
- data.tar.gz: a8931cca6d82419583204f6ebf7aae5415e2cd2d4f61f926be3c515258c11d2d34d076f01a16c043389409dc60d338ec76c70d22f6196e833f4a59fcc0cbcc22
6
+ metadata.gz: e418e5acf0a57ece9ccc811a460c58b97a8105dc67ba70a92826af07f9d8883e0816099cbf6a0e97b03318a48282234335a9ce4de7eb9fc6627db77bc10e4df3
7
+ data.tar.gz: 79536dd5536769dfc6392eaf7ebc17ade6129a3add815776d562f78fd9b0ad400b1b3755d1463805a1d72f2ca8f4f92eb6e164fe2ce8ba8f94507bcea938160c
data/exe/pixab CHANGED
@@ -7,7 +7,7 @@ require_relative '../lib/projects/MergeRequest.rb'
7
7
  require_relative '../lib/projects/ComponentSynchronizer.rb'
8
8
  require_relative '../lib/projects/Package.rb'
9
9
  require_relative '../lib/localization/phrase/Localization.rb'
10
- require_relative '../lib/localization/smartcat/LocalizationSmartcat.rb'
10
+ require_relative '../lib/localization/smartcat/SmartcatBatch.rb'
11
11
  require_relative '../lib/localization/smartcat/LocalizationSmartcatImport.rb'
12
12
  require_relative '../lib/localization/smartcat/LocalizationSmartcatMerge.rb'
13
13
  require_relative '../lib/mbox/Mbox.rb'
@@ -51,10 +51,10 @@ when 'localize'
51
51
  when 'merge'
52
52
  Pixab::LocalizationSmartcatMerge.new.run(ARGV[2..-1])
53
53
  else
54
- Pixab::LocalizationSmartcat.new.run(ARGV[1..-1])
54
+ Pixab::SmartcatBatch.new.run(ARGV[1..-1])
55
55
  end
56
56
  else
57
- Pixab::LocalizationSmartcat.new.run(ARGV[1..-1])
57
+ Pixab::SmartcatBatch.new.run(ARGV[1..-1])
58
58
  end
59
59
  when 'mbox'
60
60
  Pixab::Mbox.new.run(ARGV[1..-1])
@@ -71,15 +71,18 @@ module Pixab
71
71
  export_params = generate_export_params
72
72
  download_url = 'https://smartcat.com/api/integration/v1/document/export'
73
73
 
74
- puts "\n🚀 正在导出#{@collections}文案...".green
74
+ puts "\n📥 正在导出【#{@collections}】文案".green
75
75
  export_id = fetch_export_id(export_url, export_params)
76
76
  export_id = export_id.tr('"','')
77
- puts "\n📥 正在下载#{@collections}文案...".green
78
- if download_zip_file_with_retry(download_url, export_id)
79
- unzip_file(Localization_FILE_NAME)
80
- puts "\n✅ #{@collections}文案更新已完成!".green
77
+ unless download_zip_file_with_retry(download_url, export_id)
78
+ return
81
79
  end
82
80
 
81
+ unless unzip_file(Localization_FILE_NAME)
82
+ return
83
+ end
84
+
85
+ puts "\n✅ #{@collections}文案更新已完成!".green
83
86
  end
84
87
 
85
88
  # 第一步:通过POST请求获取export ID
@@ -127,19 +130,26 @@ module Pixab
127
130
 
128
131
  # 第三步:解压缩ZIP文件
129
132
  def unzip_file(zip_path)
130
- Zip::File.open(zip_path) do |zip_file|
131
- case platform
132
- when 'android'
133
- unzip_file_android(zip_file)
134
- when 'iOS'
135
- unzip_file_iOS(zip_file)
136
- else
137
- unzip_file_common(zip_file)
133
+ is_success = true
134
+ begin
135
+ Zip::File.open(zip_path) do |zip_file|
136
+ case platform
137
+ when 'android'
138
+ unzip_file_android(zip_file)
139
+ when 'iOS'
140
+ unzip_file_iOS(zip_file)
141
+ else
142
+ unzip_file_common(zip_file)
143
+ end
138
144
  end
145
+ rescue Zip::Error => e
146
+ puts "\nError: #{e.message}".red
147
+ is_success = false
139
148
  end
140
149
 
141
150
  File.delete(zip_path) if File.exist?(zip_path)
142
151
 
152
+ return is_success
143
153
  end
144
154
 
145
155
  def unzip_file_common(zip_file)
data/lib/pixab/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pixab
4
- VERSION = "2.5.0"
4
+ VERSION = "2.6.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pixab
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - 廖再润