lara-sdk 1.5.0 → 1.5.1
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/glossaries.rb +41 -14
- data/lib/lara/models/glossaries.rb +9 -0
- 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: 62e105c3ffc01c98306c18210a43776511f1bde4564b8b74adf6a6b1386b0db5
|
|
4
|
+
data.tar.gz: 94bf072420119b0a757e7f7ea06fc8323d7a2c6b0b36c5c4f0293fd05007945e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 11eccbd54efe8c818365d53355f5ff48da6069d2ee6bd1d4f609f340ac6b9ff3ef6579b8623b25fdaf5f62442f3e1f3cf38397d2a56970791f6e207eaf3d0076
|
|
7
|
+
data.tar.gz: 951b8a2d41a38b019192e35b451186f07924b85c845167a096a96ee6b46437c2af4411282cc85b5222e70f1daa52452a76f9492507c08ec1dcf0067040fd1962
|
data/lib/lara/glossaries.rb
CHANGED
|
@@ -18,6 +18,7 @@ module Lara
|
|
|
18
18
|
all.include?(format)
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
|
+
|
|
21
22
|
def initialize(client)
|
|
22
23
|
@client = client
|
|
23
24
|
@polling_interval = 2
|
|
@@ -62,26 +63,35 @@ module Lara
|
|
|
62
63
|
end
|
|
63
64
|
|
|
64
65
|
# @param content_type [String] Either FileFormat::UNIDIRECTIONAL or FileFormat::MULTIDIRECTIONAL
|
|
66
|
+
# @param gzip [Boolean] When true, compress the CSV before upload and set compression=gzip
|
|
67
|
+
# @param callback_url [String,nil] Optional URL notified when the import completes
|
|
65
68
|
# @return [Lara::Models::GlossaryImport]
|
|
66
|
-
def import_csv(id, csv_path, content_type: FileFormat::UNIDIRECTIONAL, gzip:
|
|
69
|
+
def import_csv(id, csv_path, content_type: FileFormat::UNIDIRECTIONAL, gzip: false,
|
|
70
|
+
callback_url: nil)
|
|
67
71
|
unless FileFormat.valid?(content_type)
|
|
68
72
|
raise ArgumentError, "Invalid content_type. Supported formats: #{FileFormat.all.join(', ')}"
|
|
69
73
|
end
|
|
70
74
|
|
|
71
|
-
require "stringio"
|
|
72
|
-
require "zlib"
|
|
73
75
|
basename = File.basename(csv_path)
|
|
76
|
+
if gzip
|
|
77
|
+
require "stringio"
|
|
78
|
+
require "zlib"
|
|
79
|
+
|
|
80
|
+
buffer = StringIO.new
|
|
81
|
+
gz = Zlib::GzipWriter.new(buffer, 7, Zlib::DEFAULT_STRATEGY)
|
|
82
|
+
File.open(csv_path, "rb") { |_f| IO.copy_stream(_f, gz) }
|
|
83
|
+
gz.finish
|
|
84
|
+
buffer.rewind
|
|
85
|
+
|
|
86
|
+
body = { "compression" => "gzip" }
|
|
87
|
+
files = { "csv" => Faraday::UploadIO.new(buffer, "application/gzip", "#{basename}.gz") }
|
|
88
|
+
else
|
|
89
|
+
body = {}
|
|
90
|
+
files = { "csv" => Faraday::UploadIO.new(csv_path, "text/csv", basename) }
|
|
91
|
+
end
|
|
74
92
|
|
|
75
|
-
buffer = StringIO.new
|
|
76
|
-
gz = Zlib::GzipWriter.new(buffer, 7, Zlib::DEFAULT_STRATEGY)
|
|
77
|
-
File.open(csv_path, "rb") { |_f| IO.copy_stream(_f, gz) }
|
|
78
|
-
gz.finish
|
|
79
|
-
buffer.rewind
|
|
80
|
-
|
|
81
|
-
body = { "compression" => "gzip" }
|
|
82
93
|
body["content_type"] = content_type unless content_type == FileFormat::UNIDIRECTIONAL
|
|
83
|
-
|
|
84
|
-
files = { "csv" => Faraday::UploadIO.new(buffer, "application/gzip", "#{basename}.gz") }
|
|
94
|
+
body["callback_url"] = callback_url if callback_url
|
|
85
95
|
Lara::Models::GlossaryImport.new(**@client.post("/v2/glossaries/#{id}/import",
|
|
86
96
|
body: body, files: files).transform_keys(&:to_sym))
|
|
87
97
|
end
|
|
@@ -120,6 +130,21 @@ module Lara
|
|
|
120
130
|
params: { content_type: content_type, source: source }.compact)
|
|
121
131
|
end
|
|
122
132
|
|
|
133
|
+
# @param callback_url [String] URL notified when the export is ready
|
|
134
|
+
# @param content_type [String] Either FileFormat::UNIDIRECTIONAL or FileFormat::MULTIDIRECTIONAL
|
|
135
|
+
# @param source [String, nil] Optional source language (unidirectional exports only)
|
|
136
|
+
# @return [Lara::Models::GlossaryExport]
|
|
137
|
+
def export_async(id, callback_url:, content_type: FileFormat::UNIDIRECTIONAL, source: nil)
|
|
138
|
+
unless FileFormat.valid?(content_type)
|
|
139
|
+
raise ArgumentError, "Invalid content_type. Supported formats: #{FileFormat.all.join(', ')}"
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
params = { callback_url: callback_url, content_type: content_type }
|
|
143
|
+
params[:source] = source if source
|
|
144
|
+
Lara::Models::GlossaryExport.new(**@client.get("/v2/glossaries/#{id}/export/async",
|
|
145
|
+
params: params).transform_keys(&:to_sym))
|
|
146
|
+
end
|
|
147
|
+
|
|
123
148
|
# @param glossary_id [String] The glossary ID
|
|
124
149
|
# @param terms [Array<Hash>] Array of term hashes with :language and :value keys
|
|
125
150
|
# @param guid [String, nil] Optional unique identifier for multidirectional glossary units
|
|
@@ -128,7 +153,8 @@ module Lara
|
|
|
128
153
|
body = { terms: terms }
|
|
129
154
|
body[:guid] = guid if guid
|
|
130
155
|
|
|
131
|
-
Lara::Models::GlossaryImport.new(**@client.put("/v2/glossaries/#{glossary_id}/content",
|
|
156
|
+
Lara::Models::GlossaryImport.new(**@client.put("/v2/glossaries/#{glossary_id}/content",
|
|
157
|
+
body: body).transform_keys(&:to_sym))
|
|
132
158
|
end
|
|
133
159
|
|
|
134
160
|
# @param glossary_id [String] The glossary ID
|
|
@@ -140,7 +166,8 @@ module Lara
|
|
|
140
166
|
body[:guid] = guid if guid
|
|
141
167
|
body[:term] = term if term
|
|
142
168
|
|
|
143
|
-
Lara::Models::GlossaryImport.new(**@client.delete("/v2/glossaries/#{glossary_id}/content",
|
|
169
|
+
Lara::Models::GlossaryImport.new(**@client.delete("/v2/glossaries/#{glossary_id}/content",
|
|
170
|
+
body: body).transform_keys(&:to_sym))
|
|
144
171
|
end
|
|
145
172
|
end
|
|
146
173
|
end
|
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.5.
|
|
4
|
+
version: 1.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Translated
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-06-
|
|
11
|
+
date: 2026-06-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|