lara-sdk 1.7.0 → 1.8.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 +4 -4
- data/lib/lara/client.rb +1 -1
- data/lib/lara/glossaries.rb +34 -28
- data/lib/lara/memories.rb +6 -12
- data/lib/lara/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 40c690defef56e7663867a644181be99f0a6cc6576abc9b4d7f79e57193c3853
|
|
4
|
+
data.tar.gz: 6d847c2b8b5caeaef7a45ec6624906a9b26ba29ff3105ea76e2eab7eb4d84adf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ec70756013dfda0e007d16fcc2c165836b737017c1a8ad198cfe9d4763694c2a251d069ed9a177d3683b636fdae997a40559a1d6743c8c632387cfa5c628e3bf
|
|
7
|
+
data.tar.gz: e8672051a95c85a847d66560c5ccbbb16dcbaf2b2d1060f5468d4b609b30cb007b8e1c823c96df2f01259b16da4cd50e5c6272823dec68ba0f90ef00669e608e
|
data/lib/lara/client.rb
CHANGED
|
@@ -218,7 +218,7 @@ module Lara
|
|
|
218
218
|
return response.body if raw_response
|
|
219
219
|
|
|
220
220
|
content_type = response.headers["content-type"] || response.headers["Content-Type"]
|
|
221
|
-
return response.body if content_type&.include?("text/csv")
|
|
221
|
+
return response.body if content_type&.include?("text/csv") || content_type&.include?("application/xml")
|
|
222
222
|
|
|
223
223
|
if callback || (body && body[:reasoning])
|
|
224
224
|
parse_stream_response(response.body, &callback)
|
data/lib/lara/glossaries.rb
CHANGED
|
@@ -6,10 +6,11 @@ module Lara
|
|
|
6
6
|
module FileFormat
|
|
7
7
|
UNIDIRECTIONAL = "csv/table-uni"
|
|
8
8
|
MULTIDIRECTIONAL = "csv/table-multi"
|
|
9
|
+
TBX = "tbx"
|
|
9
10
|
|
|
10
11
|
# @return [Array<String>] All supported formats
|
|
11
12
|
def self.all
|
|
12
|
-
[UNIDIRECTIONAL, MULTIDIRECTIONAL]
|
|
13
|
+
[UNIDIRECTIONAL, MULTIDIRECTIONAL, TBX]
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
# @param format [String] The format to validate
|
|
@@ -91,33 +92,28 @@ module Lara
|
|
|
91
92
|
Lara::Models::GlossaryCounts.new(**@client.get("/v2/glossaries/#{id}/counts").transform_keys(&:to_sym))
|
|
92
93
|
end
|
|
93
94
|
|
|
94
|
-
#
|
|
95
|
-
# @param
|
|
95
|
+
# Import options are independent keyword arguments; omitted options use their defaults.
|
|
96
|
+
# @param content_type [String] One of FileFormat.all; defaults to UNIDIRECTIONAL
|
|
97
|
+
# @param gzip [Boolean] Whether the supplied file is already gzip-compressed; defaults to false
|
|
96
98
|
# @param callback_url [String,nil] Optional URL notified when the import completes
|
|
97
99
|
# @return [Lara::Models::GlossaryImport]
|
|
98
|
-
def
|
|
99
|
-
|
|
100
|
+
def import_file(id, file_path, content_type: FileFormat::UNIDIRECTIONAL, gzip: false,
|
|
101
|
+
callback_url: nil)
|
|
100
102
|
unless FileFormat.valid?(content_type)
|
|
101
103
|
raise ArgumentError, "Invalid content_type. Supported formats: #{FileFormat.all.join(', ')}"
|
|
102
104
|
end
|
|
103
105
|
|
|
104
|
-
basename = File.basename(
|
|
105
|
-
if gzip
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
body = { "compression" => "gzip" }
|
|
116
|
-
files = { "csv" => Faraday::UploadIO.new(buffer, "application/gzip", "#{basename}.gz") }
|
|
117
|
-
else
|
|
118
|
-
body = {}
|
|
119
|
-
files = { "csv" => Faraday::UploadIO.new(csv_path, "text/csv", basename) }
|
|
120
|
-
end
|
|
106
|
+
basename = File.basename(file_path)
|
|
107
|
+
mime_type = if gzip
|
|
108
|
+
"application/gzip"
|
|
109
|
+
elsif content_type == FileFormat::TBX
|
|
110
|
+
"application/xml"
|
|
111
|
+
else
|
|
112
|
+
"text/csv"
|
|
113
|
+
end
|
|
114
|
+
files = { "csv" => Faraday::UploadIO.new(file_path, mime_type, basename) }
|
|
115
|
+
body = {}
|
|
116
|
+
body["compression"] = "gzip" if gzip
|
|
121
117
|
|
|
122
118
|
body["content_type"] = content_type unless content_type == FileFormat::UNIDIRECTIONAL
|
|
123
119
|
body["callback_url"] = callback_url if callback_url
|
|
@@ -125,6 +121,16 @@ module Lara
|
|
|
125
121
|
body: body, files: files).transform_keys(&:to_sym))
|
|
126
122
|
end
|
|
127
123
|
|
|
124
|
+
# @deprecated Use #import_file instead.
|
|
125
|
+
def import_csv(id, csv_path, content_type: FileFormat::UNIDIRECTIONAL, gzip: false,
|
|
126
|
+
callback_url: nil)
|
|
127
|
+
warn "[DEPRECATION] import_csv is deprecated; use import_file instead.", uplevel: 1
|
|
128
|
+
unless [FileFormat::UNIDIRECTIONAL, FileFormat::MULTIDIRECTIONAL].include?(content_type)
|
|
129
|
+
raise ArgumentError, "import_csv only supports CSV formats; use import_file for TBX files."
|
|
130
|
+
end
|
|
131
|
+
import_file(id, csv_path, content_type: content_type, gzip: gzip, callback_url: callback_url)
|
|
132
|
+
end
|
|
133
|
+
|
|
128
134
|
# @return [Lara::Models::GlossaryImport]
|
|
129
135
|
def get_import_status(import_id)
|
|
130
136
|
Lara::Models::GlossaryImport.new(**@client.get("/v2/glossaries/imports/#{import_id}").transform_keys(&:to_sym))
|
|
@@ -146,10 +152,10 @@ module Lara
|
|
|
146
152
|
current
|
|
147
153
|
end
|
|
148
154
|
|
|
149
|
-
# Exports
|
|
150
|
-
# @param content_type [String]
|
|
151
|
-
# @param source [String, nil]
|
|
152
|
-
# @return [String]
|
|
155
|
+
# Exports the glossary in the requested format.
|
|
156
|
+
# @param content_type [String] One of the formats returned by FileFormat.all
|
|
157
|
+
# @param source [String, nil] Required for unidirectional CSV; omit for multidirectional CSV and TBX
|
|
158
|
+
# @return [String] Raw CSV or TBX content
|
|
153
159
|
def export(id, content_type: FileFormat::UNIDIRECTIONAL, source: nil)
|
|
154
160
|
unless FileFormat.valid?(content_type)
|
|
155
161
|
raise ArgumentError, "Invalid content_type. Supported formats: #{FileFormat.all.join(', ')}"
|
|
@@ -160,8 +166,8 @@ module Lara
|
|
|
160
166
|
end
|
|
161
167
|
|
|
162
168
|
# @param callback_url [String] URL notified when the export is ready
|
|
163
|
-
# @param content_type [String]
|
|
164
|
-
# @param source [String, nil]
|
|
169
|
+
# @param content_type [String] One of the formats returned by FileFormat.all
|
|
170
|
+
# @param source [String, nil] Required for unidirectional CSV; omit for multidirectional CSV and TBX
|
|
165
171
|
# @return [Lara::Models::GlossaryExport]
|
|
166
172
|
def export_async(id, callback_url:, content_type: FileFormat::UNIDIRECTIONAL, source: nil)
|
|
167
173
|
unless FileFormat.valid?(content_type)
|
data/lib/lara/memories.rb
CHANGED
|
@@ -144,20 +144,14 @@ module Lara
|
|
|
144
144
|
end
|
|
145
145
|
end
|
|
146
146
|
|
|
147
|
+
# @param gzip [Boolean] Whether the supplied file is already gzip-compressed; defaults to false
|
|
147
148
|
# @return [Lara::Models::MemoryImport]
|
|
148
|
-
def import_tmx(id, tmx_path, callback_url: nil)
|
|
149
|
-
require "stringio"
|
|
150
|
-
require "zlib"
|
|
149
|
+
def import_tmx(id, tmx_path, gzip: false, callback_url: nil)
|
|
151
150
|
basename = File.basename(tmx_path)
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
gz.finish
|
|
157
|
-
buffer.rewind
|
|
158
|
-
|
|
159
|
-
files = { "tmx" => Faraday::UploadIO.new(buffer, "application/gzip", "#{basename}.gz") }
|
|
160
|
-
body = { "compression" => "gzip" }
|
|
151
|
+
mime_type = gzip ? "application/gzip" : "application/xml"
|
|
152
|
+
files = { "tmx" => Faraday::UploadIO.new(tmx_path, mime_type, basename) }
|
|
153
|
+
body = {}
|
|
154
|
+
body["compression"] = "gzip" if gzip
|
|
161
155
|
body["callback_url"] = callback_url if callback_url
|
|
162
156
|
Lara::Models::MemoryImport.new(**@client.post("/v2/memories/#{id}/import",
|
|
163
157
|
body: body, files: files).transform_keys(&:to_sym))
|
data/lib/lara/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lara-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Translated
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-09-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|