crowdin-api 0.4.0 → 1.0.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.
metadata CHANGED
@@ -1,86 +1,190 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crowdin-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Crowdin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-14 00:00:00.000000000 Z
11
+ date: 2021-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: open-uri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 0.2.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 0.1.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 0.2.0
13
33
  - !ruby/object:Gem::Dependency
14
34
  name: rest-client
15
35
  requirement: !ruby/object:Gem::Requirement
16
36
  requirements:
17
37
  - - ">="
18
38
  - !ruby/object:Gem::Version
19
- version: '0'
39
+ version: 2.0.0
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: 2.1.0
20
43
  type: :runtime
21
44
  prerelease: false
22
45
  version_requirements: !ruby/object:Gem::Requirement
23
46
  requirements:
24
47
  - - ">="
25
48
  - !ruby/object:Gem::Version
26
- version: '0'
49
+ version: 2.0.0
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: 2.1.0
53
+ - !ruby/object:Gem::Dependency
54
+ name: bundler
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '2.2'
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 2.2.32
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '2.2'
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 2.2.32
73
+ - !ruby/object:Gem::Dependency
74
+ name: rake
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '13.0'
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 13.0.6
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '13.0'
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 13.0.6
27
93
  - !ruby/object:Gem::Dependency
28
94
  name: rspec
29
95
  requirement: !ruby/object:Gem::Requirement
30
96
  requirements:
31
97
  - - "~>"
32
98
  - !ruby/object:Gem::Version
33
- version: '0'
99
+ version: '3.10'
34
100
  type: :development
35
101
  prerelease: false
36
102
  version_requirements: !ruby/object:Gem::Requirement
37
103
  requirements:
38
104
  - - "~>"
39
105
  - !ruby/object:Gem::Version
40
- version: '0'
106
+ version: '3.10'
41
107
  - !ruby/object:Gem::Dependency
42
- name: bundler
108
+ name: rubocop
43
109
  requirement: !ruby/object:Gem::Requirement
44
110
  requirements:
45
111
  - - "~>"
46
112
  - !ruby/object:Gem::Version
47
- version: '1.9'
113
+ version: '1.23'
48
114
  type: :development
49
115
  prerelease: false
50
116
  version_requirements: !ruby/object:Gem::Requirement
51
117
  requirements:
52
118
  - - "~>"
53
119
  - !ruby/object:Gem::Version
54
- version: '1.9'
120
+ version: '1.23'
55
121
  - !ruby/object:Gem::Dependency
56
- name: rake
122
+ name: sinatra
57
123
  requirement: !ruby/object:Gem::Requirement
58
124
  requirements:
59
125
  - - "~>"
60
126
  - !ruby/object:Gem::Version
61
- version: '10.0'
127
+ version: '2.1'
62
128
  type: :development
63
129
  prerelease: false
64
130
  version_requirements: !ruby/object:Gem::Requirement
65
131
  requirements:
66
132
  - - "~>"
67
133
  - !ruby/object:Gem::Version
68
- version: '10.0'
69
- description: Ruby Client for the Crowdin API
134
+ version: '2.1'
135
+ - !ruby/object:Gem::Dependency
136
+ name: webmock
137
+ requirement: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - "~>"
140
+ - !ruby/object:Gem::Version
141
+ version: '3.14'
142
+ type: :development
143
+ prerelease: false
144
+ version_requirements: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - "~>"
147
+ - !ruby/object:Gem::Version
148
+ version: '3.14'
149
+ description: Ruby Client for the Crowdin API. Documentation - https://support.crowdin.com/api/v2/.
70
150
  email:
71
151
  - support@crowdin.net
72
- executables: []
152
+ executables:
153
+ - crowdin-console
73
154
  extensions: []
74
- extra_rdoc_files:
75
- - README.md
76
- - LICENSE
155
+ extra_rdoc_files: []
77
156
  files:
157
+ - ".github/workflows/build-and-publish.yml"
158
+ - ".github/workflows/test-and-lint.yml"
159
+ - ".gitignore"
160
+ - ".rspec"
161
+ - ".rubocop.yml"
162
+ - ".rubocop_todo.yml"
163
+ - CODE_OF_CONDUCT.md
164
+ - CONTRIBUTING.md
165
+ - Gemfile
78
166
  - LICENSE
79
167
  - README.md
168
+ - Rakefile
169
+ - bin/crowdin-console
170
+ - bin/setup
171
+ - crowdin-api.gemspec
80
172
  - lib/crowdin-api.rb
81
- - lib/crowdin-api/errors.rb
82
- - lib/crowdin-api/methods.rb
83
- - lib/crowdin-api/version.rb
173
+ - lib/crowdin-api/api-resources/languages.rb
174
+ - lib/crowdin-api/api-resources/projects.rb
175
+ - lib/crowdin-api/api-resources/source_files.rb
176
+ - lib/crowdin-api/api-resources/storages.rb
177
+ - lib/crowdin-api/api-resources/translation_status.rb
178
+ - lib/crowdin-api/api-resources/translations.rb
179
+ - lib/crowdin-api/client/client.rb
180
+ - lib/crowdin-api/client/configuration.rb
181
+ - lib/crowdin-api/client/version.rb
182
+ - lib/crowdin-api/core/errors.rb
183
+ - lib/crowdin-api/core/payload.rb
184
+ - lib/crowdin-api/core/request.rb
185
+ - spec/core/config-instance_spec.rb
186
+ - spec/crowdin-api_spec.rb
187
+ - spec/spec_helper.rb
84
188
  homepage: https://github.com/crowdin/crowdin-api/
85
189
  licenses:
86
190
  - MIT
@@ -100,8 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
204
  - !ruby/object:Gem::Version
101
205
  version: '0'
102
206
  requirements: []
103
- rubyforge_project:
104
- rubygems_version: 2.4.8
207
+ rubygems_version: 3.0.3.1
105
208
  signing_key:
106
209
  specification_version: 4
107
210
  summary: Client library to manage translations on Crowdin
@@ -1,23 +0,0 @@
1
- module Crowdin
2
- class API
3
-
4
- module Errors
5
- class Error < StandardError
6
- attr_reader :error_code
7
- attr_reader :error_message
8
- attr_reader :message
9
-
10
- def initialize(error_code, error_message)
11
- @error_code = error_code.to_i
12
- @error_message = error_message
13
- @message = "#{error_code}: #{error_message}"
14
- end
15
-
16
- def to_s
17
- @message
18
- end
19
- end
20
- end
21
-
22
- end
23
- end
@@ -1,427 +0,0 @@
1
- module Crowdin
2
- # A wrapper and interface to the Crowdin api. Please visit the Crowdin developers
3
- # site for a full explaination of what each of the Crowdin api methods
4
- # expect and perform.
5
- #
6
- # https://crowdin.com/page/api
7
-
8
- class API
9
-
10
- # Add new file to Crowdin project.
11
- #
12
- # == Parameters
13
- #
14
- # files - Array of files that should be added to Crowdin project.
15
- # file is a Hash { :dest, :source, :title, :export_pattern }
16
- # * :dest - file name with path in Crowdin project (required)
17
- # * :source - path for uploaded file (required)
18
- # * :title - title in Crowdin UI (optional)
19
- # * :export_pattern - Resulted file name (optional)
20
- #
21
- # Optional:
22
- # * :branch - a branch name.
23
- # If the branch is not exists Crowdin will be return an error:
24
- # "error":{
25
- # "code":8,
26
- # "message":"File was not found"
27
- # }
28
- #
29
- # == Request
30
- #
31
- # POST https://api.crowdin.com/api/project/{project-identifier}/add-file?key={project-key}
32
- #
33
- def add_file(files, params = {})
34
- params[:files] = Hash[files.map { |f| [
35
- f[:dest] || raise(ArgumentError, "'`:dest`' is required"),
36
- ::File.open(f[:source] || raise(ArgumentError, "'`:source` is required'"))
37
- ] }]
38
-
39
- params[:titles] = Hash[files.map { |f| [f[:dest], f[:title]] }]
40
- params[:titles].delete_if { |k, v| v.nil? }
41
-
42
- params[:export_patterns] = Hash[files.map { |f| [f[:dest], f[:export_pattern]] }]
43
- params[:export_patterns].delete_if { |k, v| v.nil? }
44
-
45
- params.delete_if { |k, v| v.to_s.empty? }
46
-
47
- request(
48
- :method => :post,
49
- :path => "/api/project/#{@project_id}/add-file",
50
- :query => params,
51
- )
52
- end
53
-
54
- # Upload fresh version of your localization file to Crowdin.
55
- #
56
- # == Parameters
57
- #
58
- # files - Array of files that should be updated in Crowdin project.
59
- # file is a Hash { :dest, :source }
60
- # * :dest - file name with path in Crowdin project (required)
61
- # * :source - path for uploaded file (required)
62
- # * :title - title in Crowdin UI (optional)
63
- # * :export_pattern - Resulted file name (optional)
64
- #
65
- # Optional:
66
- # * :branch - a branch name
67
- #
68
- # == Request
69
- #
70
- # POST https://api.crowdin.com/api/project/{project-identifier}/update-file?key={project-key}
71
- #
72
- def update_file(files, params = {})
73
- params[:files] = Hash[files.map { |f|
74
- dest = f[:dest] || raise(ArgumentError, "'`:dest` is required'")
75
- source = ::File.open(f[:source] || raise(ArgumentError, "'`:source` is required'"))
76
- source.define_singleton_method(:original_filename) do
77
- dest
78
- end
79
- [dest, source]
80
- }]
81
-
82
- params[:titles] = Hash[files.map { |f| [f[:dest], f[:title]] }]
83
- params[:titles].delete_if { |k, v| v.nil? }
84
-
85
- params[:export_patterns] = Hash[files.map { |f| [f[:dest], f[:export_pattern]] }]
86
- params[:export_patterns].delete_if { |k, v| v.nil? }
87
-
88
- params.delete_if { |k, v| v.to_s.empty? }
89
-
90
- request(
91
- :method => :post,
92
- :path => "/api/project/#{@project_id}/update-file",
93
- :query => params,
94
- )
95
- end
96
-
97
- # Upload existing translations to your Crowdin project.
98
- #
99
- # == Parameters
100
- #
101
- # files - Array of files that should be added to Crowdin project.
102
- # file is a Hash { :dest, :source }
103
- # * :dest - file name with path in Crowdin project (required)
104
- # * :source - path for uploaded file (required)
105
- # language - Target language. With a single call it's possible to upload translations for several
106
- # files but only into one of the languages. (required)
107
- #
108
- # Optional:
109
- # * :import_duplicates (default: false)
110
- # * :import_eq_suggestions (default: false)
111
- # * :auto_approve_imported (default: false)
112
- # * :branch - a branch name
113
- #
114
- # == Request
115
- #
116
- # POST https://api.crowdin.com/api/project/{project-identifier}/upload-translation?key={project-key}
117
- #
118
- def upload_translation(files, language, params = {})
119
- params[:files] = Hash[files.map { |f| [
120
- f[:dest] || raise(ArgumentError, "`:dest` is required"),
121
- ::File.open(f[:source] || raise(ArgumentError, "`:source` is required"))
122
- ] }]
123
-
124
- params[:language] = language
125
-
126
- request(
127
- :method => :post,
128
- :path => "/api/project/#{@project_id}/upload-translation",
129
- :query => params,
130
- )
131
- end
132
-
133
- # Download ZIP file with translations. You can choose the language of translation you need or download all of them at once.
134
- #
135
- # Note: If you would like to download the most recent translations you may want to use export API method before downloading.
136
- #
137
- # Optional:
138
- # * :output - a name of ZIP file with translations
139
- # * :branch - a branch name
140
- #
141
- # == Request
142
- #
143
- # GET https://api.crowdin.com/api/project/{project-identifier}/download/{package}.zip?key={project-key}
144
- #
145
- def download_translation(language = 'all', params = {})
146
- request(
147
- :method => :get,
148
- :path => "/api/project/#{@project_id}/download/#{language}.zip",
149
- :output => params.delete(:output),
150
- :query => params,
151
- )
152
- end
153
-
154
- # Upload your glossarries for Crowdin Project in TBX file format.
155
- #
156
- # == Request
157
- #
158
- # POST https://api.crowdin.com/api/project/{project-identifier}/upload-glossary?key={project-key}
159
- #
160
- def upload_glossary(file)
161
- # raise "#{path} file does not exist" unless ::File.exist?(path)
162
- file = ::File.open(file, 'rb')
163
-
164
- request(
165
- :method => :post,
166
- :path => "/api/project/#{@project_id}/upload-glossary",
167
- :query => { :file => file },
168
- )
169
- end
170
-
171
- # Upload your Translation Memory for Crowdin Project in TMX file format.
172
- #
173
- # == Request
174
- #
175
- # POST https://api.crowdin.com/api/project/{project-identifier}/upload-tm?key={project-key}
176
- #
177
- def upload_tm(file)
178
- file = ::File.open(file, 'rb')
179
-
180
- request(
181
- :method => :post,
182
- :path => "/api/project/#{@project_id}/upload-tm",
183
- :query => { :file => file },
184
- )
185
- end
186
-
187
- # Add directory to Crowdin project.
188
- #
189
- # == Parameters
190
- #
191
- # name - directory name (with path if nested directory should be created). (required)
192
- #
193
- # Optional:
194
- # * :is_branch - create new branch. Valid values - 0, 1. Only when create root directory.
195
- # * :branch - a branch name.
196
- #
197
- # == Request
198
- #
199
- # POST https://api.crowdin.com/api/project/{project-identifier}/add-directory?key={project-key}
200
- #
201
- def add_directory(name, params = {})
202
- params[:name] = name
203
-
204
- request(
205
- :method => :post,
206
- :path => "/api/project/#{@project_id}/add-directory",
207
- :query => params,
208
- )
209
- end
210
-
211
- # Delete Crowdin project directory. All nested files and directories will be deleted too.
212
- #
213
- # == Parameters
214
- #
215
- # name - Directory path (or just name if the directory is in root) (required)
216
- # :branch - a branch name (optional)
217
- #
218
- # FIXME
219
- # When you try to remove the branch directory Crowdin will be return an error:
220
- # "error":{
221
- # "code":17,
222
- # "message":"Specified directory was not found"
223
- # }
224
- #
225
- # == Request
226
- #
227
- # POST https://api.crowdin.com/api/project/{project-identifier}/delete-directory?key={project-key}
228
- #
229
- def delete_directory(name, params = {})
230
- params[:name] = name
231
-
232
- request(
233
- :method => :post,
234
- :path => "/api/project/#{@project_id}/delete-directory",
235
- :query => params,
236
- )
237
- end
238
-
239
-
240
- # Rename or change directory attributes.
241
- #
242
- # == Parameters
243
- #
244
- # name - Full directory path that should be modified (e.g. /MainPage/AboutUs).
245
- #
246
- # Optional:
247
- # * :new_name - new directory name (not contain path, name only)
248
- # * :title - new directory title to be displayed in Crowdin UI
249
- # * :export_pattern - new directory export pattern
250
- # * :branch - a branch name
251
- #
252
- # == Request
253
- #
254
- # POST https://api.crowdin.com/api/project/{project-identifier}/change-directory?key={project-key}
255
- #
256
- def change_directory(name, params = {})
257
- params[:name] = name
258
-
259
- request(
260
- :method => :post,
261
- :path => "/api/project/#{@project_id}/change-directory",
262
- :query => params,
263
- )
264
- end
265
-
266
-
267
- # Delete file from Crowdin project. All the translations will be lost without ability to restore them.
268
- #
269
- # == Request
270
- #
271
- # POST https://api.crowdin.com/api/project/{project-identifier}/delete-file?key={project-key}
272
- #
273
- def delete_file(file)
274
- request(
275
- :method => :post,
276
- :path => "/api/project/#{@project_id}/delete-file",
277
- :query => { :file => file },
278
- )
279
- end
280
-
281
- # Download Crowdin project glossaries as TBX file.
282
- #
283
- # == Request
284
- #
285
- # GET https://api.crowdin.com/api/project/{project-identifier}/download-glossary?key={project-key}
286
- #
287
- def download_glossary(params = {})
288
- request(
289
- :method => :get,
290
- :path => "/api/project/#{@project_id}/download-glossary",
291
- :output => params[:output],
292
- )
293
- end
294
-
295
- # Download Crowdin project Translation Memory as TMX file.
296
- #
297
- # == Request
298
- #
299
- # GET https://api.crowdin.com/api/project/{project-identifier}/download-tm?key={project-key}
300
- #
301
- def download_tm(params = {})
302
- request(
303
- :method => :get,
304
- :path => "/api/project/#{@project_id}/download-tm",
305
- :output => params[:output],
306
- )
307
- end
308
-
309
- # Build ZIP archive with the latest translations.
310
- #
311
- # Please note that this method can be invoked only every 30 minutes.
312
- # Also API call will be ignored if there were no any changes in project since last export.
313
- #
314
- # Optional:
315
- # * :branch - a branch name
316
- #
317
- # == Request
318
- #
319
- # GET https://api.crowdin.com/api/project/{project-identifier}/export?key={project-key}
320
- #
321
- def export_translations(params = {})
322
- request(
323
- :method => :get,
324
- :path => "/api/project/#{@project_id}/export",
325
- :query => params,
326
- )
327
- end
328
-
329
-
330
- # Get supported languages list with Crowdin codes mapped to locale name and standarded codes.
331
- #
332
- # == Request
333
- #
334
- # GET https://api.crowdin.com/api/project/{project-identifier}/supported-languages?key={project-key}
335
- #
336
- def supported_languages
337
- request(
338
- :method => :get,
339
- :path => "/api/project/#{@project_id}/supported-languages",
340
- )
341
- end
342
-
343
- # Track your Crowdin project translation progress by language.
344
- #
345
- # == Request
346
- #
347
- # POST https://api.crowdin.com/api/project/{project-identifier}/status?key={project-key}
348
- #
349
- def translations_status
350
- request(
351
- :method => :post,
352
- :path => "/api/project/#{@project_id}/status",
353
- )
354
- end
355
-
356
- # Get Crowdin Project details.
357
- #
358
- # == Request
359
- #
360
- # POST https://api.crowdin.com/api/project/{project-identifier}/info?key={project-key}
361
- #
362
- def project_info
363
- request(
364
- :method => :post,
365
- :path => "/api/project/#{@project_id}/info",
366
- )
367
- end
368
-
369
- # Create new Crowdin project.
370
- # Important: The API method requires Account API Key. This key can not be found on your profile pages.
371
- #
372
- # == Request
373
- #
374
- # POST https://api.crowdin.com/api/account/create-project?account-key={account-key}
375
- #
376
- def create_project(params = {})
377
- request(
378
- :method => :post,
379
- :path => "/api/account/create-project",
380
- :query => params,
381
- )
382
- end
383
-
384
- # Edit Crowdin project.
385
- #
386
- # == Request
387
- #
388
- # POST https://api.crowdin.com/api/project/{project-identifier}/edit-project?key={key}
389
- #
390
- def edit_project(params = {})
391
- request(
392
- :method => :post,
393
- :path => "/api/project/#{@project_id}/edit-project",
394
- :query => params,
395
- )
396
- end
397
-
398
- # Delete Crowdin project with all translations.
399
- #
400
- # == Request
401
- #
402
- # POST https://api.crowdin.com/api/project/{project-identifier}/delete-project?key={project-key}
403
- #
404
- def delete_project
405
- request(
406
- :method => :post,
407
- :path => "/api/project/#{@project_id}/delete-project",
408
- )
409
- end
410
-
411
- # Get Crowdin Project details.
412
- # Important: The API method requires Account API Key. This key can not be found on your profile pages.
413
- #
414
- # == Request
415
- #
416
- # GET https://api.crowdin.com/api/account/get-projects?account-key={account-key}
417
- #
418
- def get_projects(login)
419
- request(
420
- :method => :get,
421
- :path => "/api/account/get-projects",
422
- :query => { :login => login },
423
- )
424
- end
425
-
426
- end
427
- end
@@ -1,5 +0,0 @@
1
- module Crowdin
2
- class API
3
- VERSION = "0.4.0"
4
- end
5
- end