ruby-lokalise-api 2.8.0 → 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile +2 -0
- data/README.md +1 -0
- data/Rakefile +6 -1
- data/lib/ruby-lokalise-api.rb +2 -0
- data/lib/ruby-lokalise-api/client.rb +2 -0
- data/lib/ruby-lokalise-api/collections/base.rb +2 -0
- data/lib/ruby-lokalise-api/collections/branch.rb +3 -1
- data/lib/ruby-lokalise-api/collections/contributor.rb +2 -0
- data/lib/ruby-lokalise-api/collections/custom_translation_status.rb +3 -1
- data/lib/ruby-lokalise-api/collections/file.rb +2 -0
- data/lib/ruby-lokalise-api/collections/key.rb +2 -0
- data/lib/ruby-lokalise-api/collections/key_comment.rb +2 -0
- data/lib/ruby-lokalise-api/collections/order.rb +2 -0
- data/lib/ruby-lokalise-api/collections/payment_card.rb +2 -0
- data/lib/ruby-lokalise-api/collections/project.rb +2 -0
- data/lib/ruby-lokalise-api/collections/project_comment.rb +2 -0
- data/lib/ruby-lokalise-api/collections/project_language.rb +2 -0
- data/lib/ruby-lokalise-api/collections/screenshot.rb +2 -0
- data/lib/ruby-lokalise-api/collections/snapshot.rb +2 -0
- data/lib/ruby-lokalise-api/collections/system_language.rb +2 -0
- data/lib/ruby-lokalise-api/collections/task.rb +2 -0
- data/lib/ruby-lokalise-api/collections/team.rb +2 -0
- data/lib/ruby-lokalise-api/collections/team_user.rb +2 -0
- data/lib/ruby-lokalise-api/collections/team_user_group.rb +3 -1
- data/lib/ruby-lokalise-api/collections/translation.rb +2 -0
- data/lib/ruby-lokalise-api/collections/translation_provider.rb +2 -0
- data/lib/ruby-lokalise-api/collections/webhook.rb +2 -0
- data/lib/ruby-lokalise-api/connection.rb +3 -1
- data/lib/ruby-lokalise-api/error.rb +2 -0
- data/lib/ruby-lokalise-api/json_handler.rb +4 -0
- data/lib/ruby-lokalise-api/request.rb +2 -0
- data/lib/ruby-lokalise-api/resources/base.rb +2 -0
- data/lib/ruby-lokalise-api/resources/branch.rb +2 -0
- data/lib/ruby-lokalise-api/resources/contributor.rb +3 -1
- data/lib/ruby-lokalise-api/resources/custom_translation_status.rb +3 -1
- data/lib/ruby-lokalise-api/resources/file.rb +2 -0
- data/lib/ruby-lokalise-api/resources/key.rb +2 -0
- data/lib/ruby-lokalise-api/resources/key_comment.rb +4 -2
- data/lib/ruby-lokalise-api/resources/order.rb +2 -0
- data/lib/ruby-lokalise-api/resources/payment_card.rb +2 -0
- data/lib/ruby-lokalise-api/resources/project.rb +2 -0
- data/lib/ruby-lokalise-api/resources/project_comment.rb +3 -1
- data/lib/ruby-lokalise-api/resources/project_language.rb +4 -2
- data/lib/ruby-lokalise-api/resources/screenshot.rb +2 -0
- data/lib/ruby-lokalise-api/resources/snapshot.rb +2 -0
- data/lib/ruby-lokalise-api/resources/system_language.rb +3 -1
- data/lib/ruby-lokalise-api/resources/task.rb +2 -0
- data/lib/ruby-lokalise-api/resources/team.rb +2 -0
- data/lib/ruby-lokalise-api/resources/team_user.rb +3 -1
- data/lib/ruby-lokalise-api/resources/team_user_group.rb +4 -2
- data/lib/ruby-lokalise-api/resources/translation.rb +2 -0
- data/lib/ruby-lokalise-api/resources/translation_provider.rb +2 -0
- data/lib/ruby-lokalise-api/resources/webhook.rb +2 -0
- data/lib/ruby-lokalise-api/rest/branches.rb +2 -0
- data/lib/ruby-lokalise-api/rest/comments.rb +2 -0
- data/lib/ruby-lokalise-api/rest/contributors.rb +2 -0
- data/lib/ruby-lokalise-api/rest/custom_translation_statuses.rb +2 -0
- data/lib/ruby-lokalise-api/rest/files.rb +2 -0
- data/lib/ruby-lokalise-api/rest/keys.rb +2 -0
- data/lib/ruby-lokalise-api/rest/languages.rb +2 -0
- data/lib/ruby-lokalise-api/rest/orders.rb +2 -0
- data/lib/ruby-lokalise-api/rest/payment_cards.rb +2 -0
- data/lib/ruby-lokalise-api/rest/projects.rb +2 -0
- data/lib/ruby-lokalise-api/rest/screenshots.rb +2 -0
- data/lib/ruby-lokalise-api/rest/snapshots.rb +2 -0
- data/lib/ruby-lokalise-api/rest/tasks.rb +2 -0
- data/lib/ruby-lokalise-api/rest/team_user_group.rb +2 -0
- data/lib/ruby-lokalise-api/rest/team_users.rb +2 -0
- data/lib/ruby-lokalise-api/rest/teams.rb +2 -0
- data/lib/ruby-lokalise-api/rest/translation_providers.rb +2 -0
- data/lib/ruby-lokalise-api/rest/translations.rb +2 -0
- data/lib/ruby-lokalise-api/rest/webhooks.rb +2 -0
- data/lib/ruby-lokalise-api/utils/attribute_helpers.rb +2 -0
- data/lib/ruby-lokalise-api/utils/endpoint_helpers.rb +2 -0
- data/lib/ruby-lokalise-api/utils/string_utils.rb +2 -0
- data/lib/ruby-lokalise-api/version.rb +3 -1
- data/ruby-lokalise-api.gemspec +7 -2
- data/spec/lib/ruby-lokalise-api/connection_spec.rb +10 -7
- data/spec/lib/ruby-lokalise-api/custom_json_parser_spec.rb +9 -5
- data/spec/lib/ruby-lokalise-api/error_spec.rb +7 -4
- data/spec/lib/ruby-lokalise-api/rest/branches_spec.rb +7 -5
- data/spec/lib/ruby-lokalise-api/rest/comments_spec.rb +7 -5
- data/spec/lib/ruby-lokalise-api/rest/contributors_spec.rb +6 -4
- data/spec/lib/ruby-lokalise-api/rest/custom_translation_statuses_spec.rb +6 -4
- data/spec/lib/ruby-lokalise-api/rest/files_spec.rb +4 -2
- data/spec/lib/ruby-lokalise-api/rest/keys_spec.rb +8 -6
- data/spec/lib/ruby-lokalise-api/rest/languages_spec.rb +8 -6
- data/spec/lib/ruby-lokalise-api/rest/orders_spec.rb +4 -2
- data/spec/lib/ruby-lokalise-api/rest/payment_cards_spec.rb +5 -3
- data/spec/lib/ruby-lokalise-api/rest/projects_spec.rb +6 -4
- data/spec/lib/ruby-lokalise-api/rest/screenshots_spec.rb +6 -4
- data/spec/lib/ruby-lokalise-api/rest/snapshots_spec.rb +6 -4
- data/spec/lib/ruby-lokalise-api/rest/tasks_spec.rb +6 -4
- data/spec/lib/ruby-lokalise-api/rest/team_user_groups_spec.rb +8 -6
- data/spec/lib/ruby-lokalise-api/rest/team_users_spec.rb +6 -4
- data/spec/lib/ruby-lokalise-api/rest/teams_spec.rb +2 -0
- data/spec/lib/ruby-lokalise-api/rest/translation_providers_spec.rb +4 -2
- data/spec/lib/ruby-lokalise-api/rest/translations_spec.rb +8 -6
- data/spec/lib/ruby-lokalise-api/rest/webhooks_spec.rb +4 -2
- data/spec/lib/ruby-lokalise-api/utils/snakecase_spec.rb +2 -0
- data/spec/lib/ruby-lokalise-api_spec.rb +12 -9
- data/spec/spec_helper.rb +8 -1
- data/spec/support/test_client.rb +2 -0
- data/spec/support/vcr.rb +2 -0
- metadata +49 -7
data/ruby-lokalise-api.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require File.expand_path('lib/ruby-lokalise-api/version', __dir__)
|
2
4
|
|
3
5
|
Gem::Specification.new do |spec|
|
@@ -21,14 +23,17 @@ Gem::Specification.new do |spec|
|
|
21
23
|
spec.require_paths = ['lib']
|
22
24
|
|
23
25
|
spec.add_dependency 'addressable', '~> 2.5'
|
24
|
-
spec.add_dependency 'faraday', '~> 0
|
26
|
+
spec.add_dependency 'faraday', '~> 1.0'
|
27
|
+
spec.add_dependency 'json', '~> 2.3'
|
25
28
|
|
29
|
+
spec.add_development_dependency 'codecov', '~> 0.1'
|
26
30
|
spec.add_development_dependency 'dotenv', '~> 2.5'
|
27
31
|
spec.add_development_dependency 'oj', '~> 3.8'
|
28
32
|
spec.add_development_dependency 'rake', '~> 13.0'
|
29
33
|
spec.add_development_dependency 'rspec', '~> 3.6'
|
30
34
|
spec.add_development_dependency 'rubocop', '~> 0.60'
|
31
|
-
spec.add_development_dependency 'rubocop-performance', '~> 1.
|
35
|
+
spec.add_development_dependency 'rubocop-performance', '~> 1.5'
|
36
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 1.37'
|
32
37
|
spec.add_development_dependency 'simplecov', '~> 0.16'
|
33
38
|
spec.add_development_dependency 'vcr', '~> 5.0'
|
34
39
|
end
|
@@ -1,8 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.describe Lokalise::Connection do
|
2
4
|
include described_class
|
3
5
|
|
4
|
-
before
|
5
|
-
|
6
|
+
before { Lokalise.reset_client! }
|
7
|
+
|
8
|
+
after do
|
6
9
|
Lokalise.reset_client!
|
7
10
|
Faraday.default_adapter = :net_http
|
8
11
|
end
|
@@ -14,7 +17,7 @@ RSpec.describe Lokalise::Connection do
|
|
14
17
|
expect(conn.headers['X-api-token']).to eq(test_client.token)
|
15
18
|
end
|
16
19
|
|
17
|
-
it '
|
20
|
+
it 'allows to customize timeouts' do
|
18
21
|
custom_client = Lokalise.client(ENV['LOKALISE_API_TOKEN'],
|
19
22
|
open_timeout: 100, timeout: 500)
|
20
23
|
conn = connection custom_client
|
@@ -29,14 +32,14 @@ RSpec.describe Lokalise::Connection do
|
|
29
32
|
expect(another_conn.options.open_timeout).to eq(200)
|
30
33
|
end
|
31
34
|
|
32
|
-
it '
|
35
|
+
it 'is possible to customize adapter' do
|
33
36
|
conn = connection test_client
|
34
|
-
expect(conn.builder.
|
37
|
+
expect(conn.builder.adapter).to eq(Faraday::Adapter::NetHttp)
|
35
38
|
|
36
39
|
Faraday.default_adapter = :excon
|
37
40
|
|
38
41
|
another_conn = connection test_client
|
39
|
-
expect(another_conn.builder.
|
40
|
-
expect(conn.builder.
|
42
|
+
expect(another_conn.builder.adapter).to eq(Faraday::Adapter::Excon)
|
43
|
+
expect(conn.builder.adapter).to eq(Faraday::Adapter::NetHttp)
|
41
44
|
end
|
42
45
|
end
|
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'oj'
|
2
4
|
|
3
|
-
RSpec.describe
|
5
|
+
RSpec.describe Lokalise::JsonHandler do
|
4
6
|
let(:loaded_json) do
|
5
7
|
{'projects' => [{'project_id' => '547879415c01a0e6e0b855.29978928',
|
6
8
|
'name' => 'demo phoenix copy',
|
@@ -25,7 +27,8 @@ RSpec.describe 'Custom JSON parser' do
|
|
25
27
|
'{":name":"rspec proj",":description":"demo project for rspec"}'
|
26
28
|
end
|
27
29
|
|
28
|
-
|
30
|
+
# rubocop:disable RSpec/LeakyConstantDeclaration
|
31
|
+
before do
|
29
32
|
module Lokalise
|
30
33
|
module JsonHandler
|
31
34
|
def custom_dump(obj)
|
@@ -39,7 +42,7 @@ RSpec.describe 'Custom JSON parser' do
|
|
39
42
|
end
|
40
43
|
end
|
41
44
|
|
42
|
-
after
|
45
|
+
after do
|
43
46
|
module Lokalise
|
44
47
|
module JsonHandler
|
45
48
|
def custom_dump(obj)
|
@@ -52,8 +55,9 @@ RSpec.describe 'Custom JSON parser' do
|
|
52
55
|
end
|
53
56
|
end
|
54
57
|
end
|
58
|
+
# rubocop:enable RSpec/LeakyConstantDeclaration
|
55
59
|
|
56
|
-
it '
|
60
|
+
it 'allows to customize #load' do
|
57
61
|
expect(Oj).to receive(:load).and_return(loaded_json)
|
58
62
|
expect(JSON).not_to receive(:parse)
|
59
63
|
projects = VCR.use_cassette('all_projects_pagination') do
|
@@ -65,7 +69,7 @@ RSpec.describe 'Custom JSON parser' do
|
|
65
69
|
expect(projects.collection.first.name).to eq('demo phoenix copy')
|
66
70
|
end
|
67
71
|
|
68
|
-
it '
|
72
|
+
it 'allows to customize #dump' do
|
69
73
|
expect(Oj).to receive(:dump).and_return(dumped_json)
|
70
74
|
expect(JSON).not_to receive(:dump)
|
71
75
|
project = VCR.use_cassette('new_project') do
|
@@ -1,10 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.describe Lokalise::Error do
|
2
4
|
include Lokalise::Request
|
3
5
|
|
4
|
-
before
|
5
|
-
|
6
|
+
before { Lokalise.reset_client! }
|
7
|
+
|
8
|
+
after { Lokalise.reset_client! }
|
6
9
|
|
7
|
-
it '
|
10
|
+
it 'raises BadRequest when API token is invalid' do
|
8
11
|
expect do
|
9
12
|
VCR.use_cassette('error_invalid_token') do
|
10
13
|
get 'projects', Lokalise.client('invalid')
|
@@ -12,7 +15,7 @@ RSpec.describe Lokalise::Error do
|
|
12
15
|
end.to raise_error(Lokalise::Error::BadRequest)
|
13
16
|
end
|
14
17
|
|
15
|
-
it '
|
18
|
+
it 'raises NotFound when the provided path cannot be found' do
|
16
19
|
expect do
|
17
20
|
VCR.use_cassette('error_not_found') do
|
18
21
|
get 'invalid_path', test_client
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.describe Lokalise::Client do
|
2
4
|
let(:project_id) { '803826145ba90b42d5d860.46800099' }
|
3
5
|
let(:branch_id) { 41_302 }
|
4
6
|
|
5
7
|
describe '#branches' do
|
6
|
-
it '
|
8
|
+
it 'returns all branches' do
|
7
9
|
branches = VCR.use_cassette('all_branches') do
|
8
10
|
test_client.branches project_id
|
9
11
|
end.collection
|
@@ -11,7 +13,7 @@ RSpec.describe Lokalise::Client do
|
|
11
13
|
expect(branches.count).to eq(1)
|
12
14
|
end
|
13
15
|
|
14
|
-
it '
|
16
|
+
it 'supports pagination' do
|
15
17
|
branches = VCR.use_cassette('all_branches_pagination') do
|
16
18
|
test_client.branches project_id, limit: 1, page: 1
|
17
19
|
end
|
@@ -82,8 +84,8 @@ RSpec.describe Lokalise::Client do
|
|
82
84
|
expect(response['branch']['name']).to eq(branch.name)
|
83
85
|
end
|
84
86
|
|
85
|
-
context 'branch chained
|
86
|
-
it '
|
87
|
+
context 'when branch methods are chained' do
|
88
|
+
it 'supports merge' do
|
87
89
|
branch = VCR.use_cassette('create_branch_to_merge2') do
|
88
90
|
test_client.create_branch project_id, name: 'merge-me-plz'
|
89
91
|
end
|
@@ -102,7 +104,7 @@ RSpec.describe Lokalise::Client do
|
|
102
104
|
expect(response['branch']['name']).to eq(branch.name)
|
103
105
|
end
|
104
106
|
|
105
|
-
it '
|
107
|
+
it 'supports update and destroy' do
|
106
108
|
branch = VCR.use_cassette('create_another_branch') do
|
107
109
|
test_client.create_branch project_id, name: 'ruby-second-branch'
|
108
110
|
end
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.describe Lokalise::Client do
|
2
4
|
let(:project_id) { '803826145ba90b42d5d860.46800099' }
|
3
5
|
let(:key_id) { 15_305_182 }
|
4
6
|
let(:another_key_id) { 15_519_786 }
|
5
7
|
|
6
8
|
describe '#comments' do
|
7
|
-
it '
|
9
|
+
it 'returns all comments' do
|
8
10
|
comments = VCR.use_cassette('all_comments') do
|
9
11
|
test_client.comments project_id, key_id
|
10
12
|
end.collection
|
@@ -12,7 +14,7 @@ RSpec.describe Lokalise::Client do
|
|
12
14
|
expect(comments.count).to eq(3)
|
13
15
|
end
|
14
16
|
|
15
|
-
it '
|
17
|
+
it 'supports pagination' do
|
16
18
|
comments = VCR.use_cassette('all_comments_pagination') do
|
17
19
|
test_client.comments project_id, key_id, limit: 1, page: 2
|
18
20
|
end
|
@@ -29,7 +31,7 @@ RSpec.describe Lokalise::Client do
|
|
29
31
|
expect(comments.prev_page?).to eq(true)
|
30
32
|
expect(comments.first_page?).to eq(false)
|
31
33
|
|
32
|
-
expect(comments.client).to be_an_instance_of(
|
34
|
+
expect(comments.client).to be_an_instance_of(described_class)
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
@@ -85,8 +87,8 @@ RSpec.describe Lokalise::Client do
|
|
85
87
|
expect(response['comment_deleted']).to eq(true)
|
86
88
|
end
|
87
89
|
|
88
|
-
context 'comment chained
|
89
|
-
it '
|
90
|
+
context 'when comment methods are chained' do
|
91
|
+
it 'supports destroy' do
|
90
92
|
comment = VCR.use_cassette('create_another_comment') do
|
91
93
|
test_client.create_comments project_id, another_key_id, comment: 'chained comment'
|
92
94
|
end.collection.first
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.describe Lokalise::Client do
|
2
4
|
let(:project_id) { '803826145ba90b42d5d860.46800099' }
|
3
5
|
let(:contributor_id) { 25_953 }
|
4
6
|
|
5
7
|
describe '#contributors' do
|
6
|
-
it '
|
8
|
+
it 'returns all contributors' do
|
7
9
|
contributors = VCR.use_cassette('all_contributors') do
|
8
10
|
test_client.contributors project_id
|
9
11
|
end.collection
|
@@ -12,7 +14,7 @@ RSpec.describe Lokalise::Client do
|
|
12
14
|
expect(contributors.first.fullname).to eq('John Doe')
|
13
15
|
end
|
14
16
|
|
15
|
-
it '
|
17
|
+
it 'supports pagination' do
|
16
18
|
contributors = VCR.use_cassette('all_contributors_pagination') do
|
17
19
|
test_client.contributors project_id, limit: 1, page: 2
|
18
20
|
end
|
@@ -83,8 +85,8 @@ RSpec.describe Lokalise::Client do
|
|
83
85
|
expect(response['contributor_deleted']).to eq(true)
|
84
86
|
end
|
85
87
|
|
86
|
-
context 'contributor chained
|
87
|
-
it '
|
88
|
+
context 'when contributor methods are chained' do
|
89
|
+
it 'supports update and destroy' do
|
88
90
|
contributor = VCR.use_cassette('create_another_contributor') do
|
89
91
|
test_client.create_contributors project_id,
|
90
92
|
email: 'demo@test.com',
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.describe Lokalise::Client do
|
2
4
|
let(:project_id) { '803826145ba90b42d5d860.46800099' }
|
3
5
|
let(:status_id) { 128 }
|
4
6
|
let(:new_status_id) { 126 }
|
5
7
|
|
6
8
|
describe '#translation_statuses' do
|
7
|
-
it '
|
9
|
+
it 'returns all statuses' do
|
8
10
|
statuses = VCR.use_cassette('all_translation_statuses') do
|
9
11
|
test_client.translation_statuses project_id
|
10
12
|
end.collection
|
@@ -13,7 +15,7 @@ RSpec.describe Lokalise::Client do
|
|
13
15
|
expect(statuses.first.status_id).to eq(status_id)
|
14
16
|
end
|
15
17
|
|
16
|
-
it '
|
18
|
+
it 'supports pagination' do
|
17
19
|
statuses = VCR.use_cassette('all_translation_statuses_pagination') do
|
18
20
|
test_client.translation_statuses project_id, limit: 1, page: 2
|
19
21
|
end
|
@@ -85,8 +87,8 @@ RSpec.describe Lokalise::Client do
|
|
85
87
|
expect(response).to include('#f2d600')
|
86
88
|
end
|
87
89
|
|
88
|
-
context 'translation status chained
|
89
|
-
it '
|
90
|
+
context 'when translation status methods are chained' do
|
91
|
+
it 'supports update and destroy' do
|
90
92
|
status = VCR.use_cassette('create_another_translation_status') do
|
91
93
|
test_client.create_translation_status project_id,
|
92
94
|
title: 'rspec',
|