lingotek-cli 0.1.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.
- data/LICENSE +0 -0
- data/README.md +0 -0
- data/VERSION +1 -0
- data/bin/lingotek-cli +326 -0
- data/lib/lingotek-cli/client.rb +112 -0
- data/lib/lingotek-cli/version.rb +3 -0
- data/lib/lingotek-cli.rb +5 -0
- metadata +103 -0
data/LICENSE
ADDED
File without changes
|
data/README.md
ADDED
File without changes
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/lingotek-cli
ADDED
@@ -0,0 +1,326 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'main'
|
4
|
+
|
5
|
+
require_relative '../lib/lingotek-cli'
|
6
|
+
|
7
|
+
include LingotekCli
|
8
|
+
|
9
|
+
|
10
|
+
Main do
|
11
|
+
|
12
|
+
mode 'setapi' do
|
13
|
+
option('u') do
|
14
|
+
argument :required
|
15
|
+
description 'Url for api'
|
16
|
+
end
|
17
|
+
|
18
|
+
option('k') do
|
19
|
+
argument :required
|
20
|
+
description 'Oauth client key'
|
21
|
+
end
|
22
|
+
|
23
|
+
option('s') do
|
24
|
+
argument :required
|
25
|
+
description 'Oauth client secret'
|
26
|
+
end
|
27
|
+
|
28
|
+
option('l') do
|
29
|
+
argument :required
|
30
|
+
description 'User identity'
|
31
|
+
end
|
32
|
+
|
33
|
+
def run
|
34
|
+
opts = { key: params['k'].value, secret: params['s'].value, external_id: params['l'].value, url: params['u'].value }
|
35
|
+
puts Client.oauth( opts )
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
mode 'user' do
|
40
|
+
mode 'validate' do
|
41
|
+
option('p') do
|
42
|
+
argument :required
|
43
|
+
description 'Password to be validated'
|
44
|
+
end
|
45
|
+
|
46
|
+
option('l') do
|
47
|
+
argument :required
|
48
|
+
description 'User identity, if not given the one in the config file will be used'
|
49
|
+
end
|
50
|
+
|
51
|
+
def run
|
52
|
+
puts Client.validateCredentials(params['p'].value, params['l'].value)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
mode 'local-login' do
|
57
|
+
option('p') do
|
58
|
+
argument :required
|
59
|
+
description 'Password to be validated'
|
60
|
+
end
|
61
|
+
|
62
|
+
option('l') do
|
63
|
+
argument :required
|
64
|
+
description 'User identity, if not given the one in the config file will be used'
|
65
|
+
end
|
66
|
+
|
67
|
+
def run
|
68
|
+
puts Client.allowLocalLogin(params['p'].value, params['l'].value)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
mode 'project' do
|
74
|
+
mode 'list' do
|
75
|
+
def run
|
76
|
+
puts Client.listProjects
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
mode 'add-vault' do
|
81
|
+
option('pi') do
|
82
|
+
argument :required
|
83
|
+
description 'Project ID'
|
84
|
+
end
|
85
|
+
|
86
|
+
option('i') do
|
87
|
+
argument :required
|
88
|
+
description 'TM Vault ID'
|
89
|
+
end
|
90
|
+
|
91
|
+
option('p') do
|
92
|
+
argument :optional
|
93
|
+
description 'Public vault flag. If this is set to "true", then TMs from the vault will be shared with all users on the system.'
|
94
|
+
end
|
95
|
+
|
96
|
+
def run
|
97
|
+
puts Client.allowLocalLogin(params['p'].value, params['l'].value)
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
mode 'remove' do
|
103
|
+
option('i') do
|
104
|
+
argument :required
|
105
|
+
description 'Id of the project to remove'
|
106
|
+
end
|
107
|
+
|
108
|
+
def run
|
109
|
+
puts Client.removeProject(projectId: params['i'].value)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
mode 'create' do
|
114
|
+
|
115
|
+
option('n') do
|
116
|
+
argument :required
|
117
|
+
description 'Name of the project'
|
118
|
+
end
|
119
|
+
|
120
|
+
option('w') do
|
121
|
+
argument :required
|
122
|
+
description 'Id of the workflow with which this project is associated'
|
123
|
+
end
|
124
|
+
|
125
|
+
option('c') do
|
126
|
+
argument :required
|
127
|
+
description 'Id of the company with which this project is associated'
|
128
|
+
end
|
129
|
+
|
130
|
+
option('s') do
|
131
|
+
argument :optional
|
132
|
+
description 'Search public vault flag'
|
133
|
+
end
|
134
|
+
|
135
|
+
def run
|
136
|
+
puts Client.addProject(projectName: params['n'].value, workflowId: params['w'].value, searchPublic: params['s'].value, companyId: params['c'].value)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
mode 'document' do
|
142
|
+
mode 'create' do
|
143
|
+
option('i') do
|
144
|
+
argument :required
|
145
|
+
description 'Id of the project to remove'
|
146
|
+
end
|
147
|
+
|
148
|
+
option('f') do
|
149
|
+
argument :required
|
150
|
+
description 'File path of the document'
|
151
|
+
end
|
152
|
+
|
153
|
+
option('r') do
|
154
|
+
argument :required
|
155
|
+
description 'Format of the document'
|
156
|
+
end
|
157
|
+
|
158
|
+
option('s') do
|
159
|
+
argument :required
|
160
|
+
description 'Source locale (ex pt_BR)'
|
161
|
+
end
|
162
|
+
|
163
|
+
option('n') do
|
164
|
+
argument :required
|
165
|
+
description 'Display name of the document'
|
166
|
+
end
|
167
|
+
|
168
|
+
option('v') do
|
169
|
+
argument :required
|
170
|
+
description 'Vault id'
|
171
|
+
end
|
172
|
+
|
173
|
+
option('t') do
|
174
|
+
argument :required
|
175
|
+
description 'The target language parameter is a multi-parameter. More than one value can be assigned for the parameter name in order to denote multiple target languages. (ex pt_BR,es_ES)'
|
176
|
+
end
|
177
|
+
|
178
|
+
option('w') do
|
179
|
+
argument :optional
|
180
|
+
description 'Boolean "true" or "false" weather we should apply the project level workflow when adding targets. This defaults to false if not set.)'
|
181
|
+
end
|
182
|
+
def run
|
183
|
+
puts Client.addDocumentWithTargets(params['i'].value, params['f'].value, params['r'].value, params['s'].value, params['n'].value, params['v'].value, params['t'].value, params['w'].value)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
mode 'analyze' do
|
189
|
+
mode 'run' do
|
190
|
+
option('n') do
|
191
|
+
argument :required
|
192
|
+
description 'Name of the Report'
|
193
|
+
end
|
194
|
+
|
195
|
+
option('i') do
|
196
|
+
argument :required
|
197
|
+
description 'Id of the project to remove'
|
198
|
+
end
|
199
|
+
|
200
|
+
option('v') do
|
201
|
+
argument :required
|
202
|
+
description 'Vault ids (ex 12,2,3,2)'
|
203
|
+
end
|
204
|
+
|
205
|
+
def run
|
206
|
+
puts Client.analyzeProject(params['i'].value, params['n'].value, params['v'].value)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
mode 'get' do
|
211
|
+
option('g') do
|
212
|
+
argument :required
|
213
|
+
description 'Report group'
|
214
|
+
end
|
215
|
+
|
216
|
+
def run
|
217
|
+
puts Client.getAnalysis(params['g'].value)
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
mode 'glossary' do
|
223
|
+
mode 'create' do
|
224
|
+
|
225
|
+
option('n') do
|
226
|
+
argument :required
|
227
|
+
description 'Name of the glossary to add'
|
228
|
+
end
|
229
|
+
|
230
|
+
def run
|
231
|
+
puts Client.addGlossary(name)
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
mode 'upload' do
|
236
|
+
option('i') do
|
237
|
+
argument :required
|
238
|
+
description 'Id of the translation memory vault to upload the TMX file into.'
|
239
|
+
end
|
240
|
+
|
241
|
+
option('f') do
|
242
|
+
argument :required
|
243
|
+
description 'File path to import into tm vault'
|
244
|
+
end
|
245
|
+
|
246
|
+
option('c') do
|
247
|
+
argument :optional
|
248
|
+
description 'CSV file format'
|
249
|
+
end
|
250
|
+
|
251
|
+
option('x') do
|
252
|
+
argument :optional
|
253
|
+
description 'XLST file format'
|
254
|
+
end
|
255
|
+
|
256
|
+
def run
|
257
|
+
if params['x']
|
258
|
+
puts Client.uploadXLSToGlossary(params['i'].value, params['f'].value )
|
259
|
+
elsif params['c']
|
260
|
+
puts Client.uploadCSVToGlossary(params['i'].value, params['f'].value )
|
261
|
+
else
|
262
|
+
puts Client.uploadTBXToGlossary(params['i'].value, params['f'].value )
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
mode 'vault' do
|
269
|
+
|
270
|
+
mode 'create' do
|
271
|
+
option('n') do
|
272
|
+
argument :required
|
273
|
+
description 'Name of the translation memory vault'
|
274
|
+
end
|
275
|
+
|
276
|
+
option('p') do
|
277
|
+
argument :optinal
|
278
|
+
description 'Public vault flag. If this is set to "true", then TMs from the vault will be shared with all users on the system.'
|
279
|
+
end
|
280
|
+
|
281
|
+
def run
|
282
|
+
puts Client.addTMVault(params['n'].value,params['p'].value)
|
283
|
+
end
|
284
|
+
|
285
|
+
end
|
286
|
+
|
287
|
+
mode 'upload' do
|
288
|
+
|
289
|
+
option('i') do
|
290
|
+
argument :required
|
291
|
+
description 'Id of the translation memory vault to upload the TMX file into.'
|
292
|
+
end
|
293
|
+
|
294
|
+
option('f') do
|
295
|
+
argument :required
|
296
|
+
description 'File path to import into tm vault'
|
297
|
+
end
|
298
|
+
|
299
|
+
option('n') do
|
300
|
+
argument :required
|
301
|
+
description 'Name of translation memory document created in tm vault'
|
302
|
+
end
|
303
|
+
|
304
|
+
option('x') do
|
305
|
+
argument :optional
|
306
|
+
description 'set the file format for the vault, default is tmx'
|
307
|
+
end
|
308
|
+
|
309
|
+
def run
|
310
|
+
if params['x'].value
|
311
|
+
puts Client.uploadXliffToTMVault(params['i'].value,params['f'].value, params['n'].value)
|
312
|
+
else
|
313
|
+
puts Client.uploadTMXToTMVault(params['i'].value,params['f'].value, params['n'].value)
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
|
319
|
+
end
|
320
|
+
|
321
|
+
|
322
|
+
def run
|
323
|
+
puts Main::Usage.default_usage(self).to_s
|
324
|
+
end
|
325
|
+
|
326
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'parseconfig'
|
2
|
+
|
3
|
+
require 'lingotek-client'
|
4
|
+
|
5
|
+
module LingotekCli
|
6
|
+
|
7
|
+
HOME_CONFIG="#{Dir::home}/.lingotek"
|
8
|
+
SETTINGS_CONFIG = "#{HOME_CONFIG}/settings"
|
9
|
+
|
10
|
+
class Client
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def oauth( opts = {} )
|
14
|
+
key = opts[:key]
|
15
|
+
secret = opts[:secret]
|
16
|
+
url = opts[:url]
|
17
|
+
external_id = opts[:external_id]
|
18
|
+
|
19
|
+
config.add_to_group('oauth', 'key', key) if key
|
20
|
+
config.add_to_group('oauth', 'secret', secret) if secret
|
21
|
+
config.add_to_group('api', 'url', url) if url
|
22
|
+
config.add_to_group('api', 'external_id', external_id) if external_id
|
23
|
+
save_config
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def addDocumentWithTargets(id, file_path, format, src_lang, doc_name, vaultId, target_lang, apply_workflow)
|
28
|
+
file = File.new(file_path)
|
29
|
+
api.addDocumentWithTargets(projectId: id, file: file, encoding: file.external_encoding.to_s, format: format, sourceLanguage: src_lang, documentName: doc_name, tmVaultId: vaultId, targetLanguage: target_lang, applyWorkflow: apply_workflow)
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
def analyzeProject(id, report, vaults)
|
34
|
+
vaults ||= ''
|
35
|
+
api.analyzeProject(projectId: id, reportName: report, tmVaultId: vaults.split(','), projectDocuments: true)
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
def addTMVault(vault_name, is_public)
|
40
|
+
api.addTMVault(tmVaultName: vault_name, isPublic: is_public)
|
41
|
+
end
|
42
|
+
|
43
|
+
def uploadTMXToTMVault(id, file_path, name)
|
44
|
+
api.uploadTMXToTMVault(tmVaultId: id, file: File.new(file_path), name: name)
|
45
|
+
end
|
46
|
+
|
47
|
+
def uploadXliffToTMVault(id, file_path, name)
|
48
|
+
api.uploadXliffToTMVault(tmVaultId: id, file: File.new(file_path), name: name)
|
49
|
+
end
|
50
|
+
|
51
|
+
def getAnalysis(group)
|
52
|
+
api.getAnalysis group: group
|
53
|
+
end
|
54
|
+
|
55
|
+
def listProjects
|
56
|
+
api.listProjects
|
57
|
+
end
|
58
|
+
|
59
|
+
def uploadXLSToGlossary(id, file_path)
|
60
|
+
api.uploadXLSToGlossary(glossaryId: id, file: File.new(file_path))
|
61
|
+
end
|
62
|
+
|
63
|
+
def uploadCSVToGlossary(id, file_path)
|
64
|
+
api.uploadCSVToGlossary(glossaryId: id, file: File.new(file_path))
|
65
|
+
end
|
66
|
+
|
67
|
+
def uploadTBXToGlossary(id, file_path)
|
68
|
+
api.uploadTBXToGlossary(glossaryId: id, file: File.new(file_path))
|
69
|
+
end
|
70
|
+
|
71
|
+
def addGlossary(name)
|
72
|
+
api.addGlossary(glossaryName: name, asTerminology: true)
|
73
|
+
end
|
74
|
+
def addProjectTMVault(id, vault_id, is_public)
|
75
|
+
api.addProjectTMVault(project_id: id, index_id: vault_id, isPublic: is_public)
|
76
|
+
end
|
77
|
+
|
78
|
+
def addProject(opts)
|
79
|
+
api.addProject(opts)
|
80
|
+
end
|
81
|
+
|
82
|
+
def removeProject(id)
|
83
|
+
api.removeProject projectId: id
|
84
|
+
end
|
85
|
+
|
86
|
+
def validateCredentials(password, external_id)
|
87
|
+
api.validateCredentials(password: password, externalId: external_id)
|
88
|
+
end
|
89
|
+
|
90
|
+
def allowLocalLogin(password, external_id)
|
91
|
+
api.allowLocalLogin(password: password, externalId: external_id)
|
92
|
+
end
|
93
|
+
|
94
|
+
def api
|
95
|
+
@api_conn ||= LingotekClient::Api.new(config['api']['url'], config['oauth']['key'], config['oauth']['secret'], config['api']['external_id'])
|
96
|
+
end
|
97
|
+
|
98
|
+
def config
|
99
|
+
FileUtils.mkdir_p(HOME_CONFIG) unless Dir.exists?(HOME_CONFIG)
|
100
|
+
FileUtils.touch(SETTINGS_CONFIG) unless File.exists?(SETTINGS_CONFIG)
|
101
|
+
@config ||= ParseConfig.new(SETTINGS_CONFIG)
|
102
|
+
end
|
103
|
+
|
104
|
+
def save_config
|
105
|
+
File.open(SETTINGS_CONFIG, 'w') do |f|
|
106
|
+
config.write(f)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
end
|
data/lib/lingotek-cli.rb
ADDED
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lingotek-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Fernando Ribeiro
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: main
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: parseconfig
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: lingotek-client
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.1.0
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.1.0
|
62
|
+
description: Client lib for lingotek apis
|
63
|
+
email:
|
64
|
+
- fribeiro@lingotek.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files:
|
68
|
+
- LICENSE
|
69
|
+
- README.md
|
70
|
+
files:
|
71
|
+
- lib/lingotek-cli.rb
|
72
|
+
- lib/lingotek-cli/version.rb
|
73
|
+
- lib/lingotek-cli/client.rb
|
74
|
+
- bin/lingotek-cli
|
75
|
+
- VERSION
|
76
|
+
- LICENSE
|
77
|
+
- README.md
|
78
|
+
homepage: http://lingotek.com
|
79
|
+
licenses: []
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options:
|
82
|
+
- --charset=UTF-8
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ! '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.3.6
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 1.8.24
|
100
|
+
signing_key:
|
101
|
+
specification_version: 3
|
102
|
+
summary: Lib that allows to connect with lingotek apis
|
103
|
+
test_files: []
|