crowdin-api 1.7.0 → 1.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test-and-lint.yml +2 -1
- data/.release-it.json +5 -0
- data/Gemfile.lock +8 -5
- data/README.md +3 -3
- data/crowdin-api.gemspec +2 -1
- data/lib/crowdin-api/api_resources/storages.rb +1 -1
- data/lib/crowdin-api/api_resources/translations.rb +2 -1
- data/lib/crowdin-api/client/version.rb +1 -1
- data/lib/crowdin-api/core/send_request.rb +2 -3
- data/spec/api_resources/storages_spec.rb +19 -3
- data/spec/api_resources/translations_spec.rb +40 -3
- data/spec/spec_helper.rb +2 -2
- metadata +30 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff9548440dd2a2a312ae867def3cdcfd0fccd70c2bb1341380483a94776a09f1
|
4
|
+
data.tar.gz: 67f2e731d323f60d9af9cd917b535fece3524e3467802be69ecaad1a377fae7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bd609157edfa0b5368266142ba8b905d1ff032f237fc73227fd4d25d0ff34098190957bea2840f3278570cf5d8010f5b34e2623d98dce3a2abf49127bf9b79a
|
7
|
+
data.tar.gz: 73dc2a5962b51193fc9376d0644ee3daef308a0f2bfc797e3fcbb6a28ca8c3e26ce40107863ff4b3dda8598e715eb5405467640bcbdf6b2b2cf133053ad9b435
|
data/.release-it.json
CHANGED
@@ -24,6 +24,11 @@
|
|
24
24
|
"file": "lib/crowdin-api/client/version.rb",
|
25
25
|
"search": "VERSION = '\\d+\\.\\d+\\.\\d+'",
|
26
26
|
"replace": "VERSION = '{{versionWithoutPrerelease}}'"
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"file": "Gemfile.lock",
|
30
|
+
"search": "crowdin-api \\(\\d+\\.\\d+\\.\\d+\\)",
|
31
|
+
"replace": "crowdin-api ({{versionWithoutPrerelease}})"
|
27
32
|
}
|
28
33
|
]
|
29
34
|
}
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
crowdin-api (1.
|
4
|
+
crowdin-api (1.8.1)
|
5
5
|
open-uri (>= 0.1.0, < 0.2.0)
|
6
6
|
rest-client (>= 2.0.0, < 2.2.0)
|
7
7
|
|
@@ -11,8 +11,6 @@ GEM
|
|
11
11
|
addressable (2.8.6)
|
12
12
|
public_suffix (>= 2.0.2, < 6.0)
|
13
13
|
ast (2.4.2)
|
14
|
-
codecov (0.6.0)
|
15
|
-
simplecov (>= 0.15, < 0.22)
|
16
14
|
coderay (1.1.3)
|
17
15
|
crack (0.4.5)
|
18
16
|
rexml
|
@@ -75,10 +73,13 @@ GEM
|
|
75
73
|
rubocop-ast (1.30.0)
|
76
74
|
parser (>= 3.2.1.0)
|
77
75
|
ruby-progressbar (1.13.0)
|
78
|
-
simplecov (0.
|
76
|
+
simplecov (0.22.0)
|
79
77
|
docile (~> 1.1)
|
80
78
|
simplecov-html (~> 0.11)
|
81
79
|
simplecov_json_formatter (~> 0.1)
|
80
|
+
simplecov-cobertura (2.1.0)
|
81
|
+
rexml
|
82
|
+
simplecov (~> 0.19)
|
82
83
|
simplecov-html (0.12.3)
|
83
84
|
simplecov_json_formatter (0.1.4)
|
84
85
|
unf (0.1.4)
|
@@ -92,16 +93,18 @@ GEM
|
|
92
93
|
yard (0.9.34)
|
93
94
|
|
94
95
|
PLATFORMS
|
96
|
+
arm64-darwin-23
|
95
97
|
x86_64-linux
|
96
98
|
|
97
99
|
DEPENDENCIES
|
98
100
|
bundler (~> 2.2, >= 2.2.32)
|
99
|
-
codecov (~> 0.6.0)
|
100
101
|
crowdin-api!
|
101
102
|
pry (~> 0.14.1)
|
102
103
|
rake (~> 13.0, >= 13.0.6)
|
103
104
|
rspec (~> 3.10)
|
104
105
|
rubocop (~> 1.23)
|
106
|
+
simplecov (~> 0.22)
|
107
|
+
simplecov-cobertura (~> 2.1)
|
105
108
|
webmock (~> 3.14)
|
106
109
|
yard (~> 0.9.28)
|
107
110
|
|
data/README.md
CHANGED
@@ -35,7 +35,7 @@ Crowdin API is a full-featured RESTful API that helps you to integrate localizat
|
|
35
35
|
Add this line to your application's Gemfile:
|
36
36
|
|
37
37
|
```gemfile
|
38
|
-
gem 'crowdin-api', '~> 1.
|
38
|
+
gem 'crowdin-api', '~> 1.8.1'
|
39
39
|
```
|
40
40
|
|
41
41
|
And then execute:
|
@@ -120,8 +120,8 @@ storage = crowdin.add_storage('YourFilename.extension')
|
|
120
120
|
|
121
121
|
# Download file
|
122
122
|
file = crowdin.download_file(your_file_id, your_destination, your_project_id)
|
123
|
-
# your_destination - filename or absolute path to file, optional
|
124
|
-
# Without destination option file will be saved
|
123
|
+
# your_destination - filename or absolute path to the file, optional
|
124
|
+
# Without a destination option, the file will not be saved automatically
|
125
125
|
# project_id is optional, as it can be initialized with a Crowdin Client
|
126
126
|
|
127
127
|
# File revisions
|
data/crowdin-api.gemspec
CHANGED
@@ -23,10 +23,11 @@ Gem::Specification.new do |gem|
|
|
23
23
|
gem.add_runtime_dependency 'rest-client', '>= 2.0.0', '< 2.2.0'
|
24
24
|
|
25
25
|
gem.add_development_dependency 'bundler', '~> 2.2', '>= 2.2.32'
|
26
|
-
gem.add_development_dependency 'codecov', '~> 0.6.0'
|
27
26
|
gem.add_development_dependency 'pry', '~> 0.14.1'
|
28
27
|
gem.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
|
29
28
|
gem.add_development_dependency 'rspec', '~> 3.10'
|
30
29
|
gem.add_development_dependency 'rubocop', '~> 1.23'
|
30
|
+
gem.add_development_dependency 'simplecov', '~> 0.22'
|
31
|
+
gem.add_development_dependency 'simplecov-cobertura', '~> 2.1'
|
31
32
|
gem.add_development_dependency 'webmock', '~> 3.14'
|
32
33
|
end
|
@@ -22,7 +22,7 @@ module Crowdin
|
|
22
22
|
def add_storage(file = nil)
|
23
23
|
file || raise_parameter_is_required_error(:file)
|
24
24
|
|
25
|
-
file
|
25
|
+
file = File.open(file, 'r')
|
26
26
|
headers = { 'Content-Type' => 'application/octet-stream', 'Crowdin-API-FileName' => File.basename(file) }
|
27
27
|
|
28
28
|
request = Web::Request.new(
|
@@ -44,7 +44,8 @@ module Crowdin
|
|
44
44
|
file_id || raise_parameter_is_required_error(:file_id)
|
45
45
|
project_id || raise_project_id_is_required_error
|
46
46
|
|
47
|
-
|
47
|
+
etag = query.delete(:eTag)
|
48
|
+
headers = etag ? { 'If-None-Match' => etag } : {}
|
48
49
|
|
49
50
|
request = Web::Request.new(
|
50
51
|
connection,
|
@@ -44,7 +44,7 @@ module Crowdin
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def fetch_response_data(doc)
|
47
|
-
if doc['data'].is_a?(Hash) && doc['data']['url']
|
47
|
+
if @file_destination && doc['data'].is_a?(Hash) && doc['data']['url']
|
48
48
|
download_file(doc['data']['url'])
|
49
49
|
else
|
50
50
|
doc
|
@@ -53,8 +53,7 @@ module Crowdin
|
|
53
53
|
|
54
54
|
def download_file(url)
|
55
55
|
download = URI.parse(url).open
|
56
|
-
destination = @file_destination
|
57
|
-
.match(/filename=("?)(.+)\1/)[2]
|
56
|
+
destination = @file_destination
|
58
57
|
|
59
58
|
IO.copy_stream(download, destination)
|
60
59
|
|
@@ -11,10 +11,26 @@ describe Crowdin::ApiResources::Storages do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
describe '#add_storage' do
|
14
|
-
|
14
|
+
subject(:add_storage) { @crowdin.add_storage(file) }
|
15
|
+
|
16
|
+
let(:file) { 'README.md' }
|
17
|
+
|
18
|
+
it 'uploads the file to the storage', :default do
|
19
|
+
expected_response = 'expected_response'
|
20
|
+
|
15
21
|
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/storages")
|
16
|
-
|
17
|
-
|
22
|
+
.with(
|
23
|
+
body: File.read(file),
|
24
|
+
headers: {
|
25
|
+
'Content-Type' => 'application/octet-stream',
|
26
|
+
'Crowdin-API-FileName' => File.basename(file)
|
27
|
+
}
|
28
|
+
)
|
29
|
+
.to_return(
|
30
|
+
body: JSON.dump(expected_response)
|
31
|
+
)
|
32
|
+
|
33
|
+
is_expected.to eq(expected_response)
|
18
34
|
end
|
19
35
|
end
|
20
36
|
|
@@ -31,12 +31,49 @@ describe Crowdin::ApiResources::Translations do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
describe '#build_project_file_translation' do
|
34
|
+
subject(:build_project_file_translation) do
|
35
|
+
@crowdin.build_project_file_translation(file_id, query, destination, project_id)
|
36
|
+
end
|
37
|
+
|
34
38
|
let(:file_id) { 1 }
|
39
|
+
let(:query) { { targetLanguageId: target_language_id } }
|
40
|
+
let(:destination) { nil }
|
41
|
+
|
42
|
+
let(:target_language_id) { 'expected_language_id' }
|
43
|
+
|
44
|
+
it 'builds project file translation', :default do
|
45
|
+
expected_response = 'expected_response'
|
35
46
|
|
36
|
-
it 'when request are valid', :default do
|
37
47
|
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations/builds/files/#{file_id}")
|
38
|
-
|
39
|
-
|
48
|
+
.with(
|
49
|
+
body: JSON.dump(query)
|
50
|
+
)
|
51
|
+
.to_return(
|
52
|
+
body: JSON.dump(expected_response)
|
53
|
+
)
|
54
|
+
|
55
|
+
is_expected.to eq(expected_response)
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'when the `eTag` query param is passed' do
|
59
|
+
let(:query) { { targetLanguageId: 'expected_language_id', eTag: etag } }
|
60
|
+
|
61
|
+
let(:etag) { 'expected_etag' }
|
62
|
+
|
63
|
+
it 'builds project file translation for new changes after the passed `eTag`', :default do
|
64
|
+
expected_response = 'expected_response'
|
65
|
+
|
66
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations/builds/files/#{file_id}")
|
67
|
+
.with(
|
68
|
+
body: JSON.dump({ targetLanguageId: target_language_id }),
|
69
|
+
headers: { 'If-None-Match' => etag }
|
70
|
+
)
|
71
|
+
.to_return(
|
72
|
+
body: JSON.dump(expected_response)
|
73
|
+
)
|
74
|
+
|
75
|
+
is_expected.to eq(expected_response)
|
76
|
+
end
|
40
77
|
end
|
41
78
|
end
|
42
79
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'simplecov'
|
4
|
-
require '
|
4
|
+
require 'simplecov-cobertura'
|
5
5
|
|
6
6
|
SimpleCov.start
|
7
|
-
SimpleCov.formatter = SimpleCov::Formatter::
|
7
|
+
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
|
8
8
|
|
9
9
|
require 'webmock/rspec'
|
10
10
|
require 'crowdin-api'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crowdin-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Crowdin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: open-uri
|
@@ -70,20 +70,6 @@ dependencies:
|
|
70
70
|
- - ">="
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: 2.2.32
|
73
|
-
- !ruby/object:Gem::Dependency
|
74
|
-
name: codecov
|
75
|
-
requirement: !ruby/object:Gem::Requirement
|
76
|
-
requirements:
|
77
|
-
- - "~>"
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
version: 0.6.0
|
80
|
-
type: :development
|
81
|
-
prerelease: false
|
82
|
-
version_requirements: !ruby/object:Gem::Requirement
|
83
|
-
requirements:
|
84
|
-
- - "~>"
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
version: 0.6.0
|
87
73
|
- !ruby/object:Gem::Dependency
|
88
74
|
name: pry
|
89
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -146,6 +132,34 @@ dependencies:
|
|
146
132
|
- - "~>"
|
147
133
|
- !ruby/object:Gem::Version
|
148
134
|
version: '1.23'
|
135
|
+
- !ruby/object:Gem::Dependency
|
136
|
+
name: simplecov
|
137
|
+
requirement: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - "~>"
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0.22'
|
142
|
+
type: :development
|
143
|
+
prerelease: false
|
144
|
+
version_requirements: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - "~>"
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0.22'
|
149
|
+
- !ruby/object:Gem::Dependency
|
150
|
+
name: simplecov-cobertura
|
151
|
+
requirement: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - "~>"
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '2.1'
|
156
|
+
type: :development
|
157
|
+
prerelease: false
|
158
|
+
version_requirements: !ruby/object:Gem::Requirement
|
159
|
+
requirements:
|
160
|
+
- - "~>"
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '2.1'
|
149
163
|
- !ruby/object:Gem::Dependency
|
150
164
|
name: webmock
|
151
165
|
requirement: !ruby/object:Gem::Requirement
|