ruby-lokalise-api 4.3.0 → 4.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d4e828a877250b7e76e2134f9d9bbc8e4749519d0adfcad12fbfa25f65b52a9
4
- data.tar.gz: 4d8d9236940e3fdd0796b92b09544eab9565c9a41c2e16d589a8f30c07628e4d
3
+ metadata.gz: 4147ca27a676c98d74fa654c4244212aa7e296855d4bda492fd061a3a3a02347
4
+ data.tar.gz: 59c042db99a7f2899baef674319ec18ab9ee193f3581f35b40fd92b0c43118bb
5
5
  SHA512:
6
- metadata.gz: c1d6d1c7f192cd70a60c2f07b4fb70c16e9b7c3bfa1a3c0834eed9569c59f7dca38d042187a5a8b99122905ea0eb3adf7b574f8f41d85763d08b0d50ff03305e
7
- data.tar.gz: 13dfc2c81e9057dd8ece7513f74d3d0d793040fa9755470f7167f1dd1724d93275a7c75f64ecabfc0da1d43c3ec86e5b9eca73ea87ba191188643b330899b282
6
+ metadata.gz: 38e44afa51cb74149fb4b7aff68d958232f39d111bef8927835fc9bd012c8738ac0a4a4c175ab1bc9e7b2a846135a5f4ff5473845d562d45d408200e439abedf
7
+ data.tar.gz: 67cc5c58134b64955f65595f5b5797c72adbaa8dbe9e239fff0d434044e3a599c0eea4dd7418bbbb2834b9cd8f9e7572258f07a514f80c048508cfba408cd2d0
@@ -4,7 +4,7 @@
4
4
  2. [Create a topic branch.][branch]
5
5
  3. Implement your feature or bug fix.
6
6
  4. Don't forget to add specs and make sure they pass by running `rspec .`.
7
- 5. Make sure your code complies with the style guide by running `rubocop`. `rubocop -a` can automatically fix most issues for you.
7
+ 5. Make sure your code complies with the style guide by running `rubocop`. `rubocop -a` can automatically fix most issues for you. Run `rubocop -A` to make it more aggressive.
8
8
  6. If necessary, add documentation for your feature or bug fix.
9
9
  7. Commit and push your changes.
10
10
  8. [Submit a pull request.][pr]
data/README.md CHANGED
@@ -47,4 +47,4 @@ Detailed documentation can be found at [lokalise.github.io/ruby-lokalise-api](ht
47
47
 
48
48
  This gem is licensed under the [BSD 3 Clause license](https://github.com/lokalise/ruby-lokalise-api/blob/master/LICENSE). Prior to version 4 the license type was MIT.
49
49
 
50
- Copyright (c) [Lokalise team](http://lokalise.co), [Ilya Bodrov](http://bodrovis.tech)
50
+ Copyright (c) [Lokalise team](http://lokalise.co) and [Ilya Bodrov](http://bodrovis.tech)
@@ -39,7 +39,8 @@ module Lokalise
39
39
  class << self
40
40
  # Create a new error from an HTTP response
41
41
  def from_response(body)
42
- new body['error']['message'].to_s
42
+ msg = body.key?('error') ? body['error']['message'] : body['message']
43
+ new msg.to_s
43
44
  end
44
45
  end
45
46
 
@@ -58,7 +58,7 @@ module Lokalise
58
58
  def respond_with(response, client)
59
59
  body = custom_load response.body
60
60
  uri = Addressable::URI.parse response.env.url
61
- respond_with_error(response.status, body) if body.respond_to?(:has_key?) && body.key?('error')
61
+ respond_with_error response.status, body if response.status.between?(400, 599) || (body.respond_to?(:has_key?) && body.key?('error'))
62
62
  extract_headers_from(response).
63
63
  merge('content' => body,
64
64
  'client' => client,
@@ -74,7 +74,7 @@ module Lokalise
74
74
  end
75
75
 
76
76
  def respond_with_error(code, body)
77
- raise(Lokalise::Error, body['error']) unless Lokalise::Error::ERRORS.key? code
77
+ raise(Lokalise::Error, body['error'] || body) unless Lokalise::Error::ERRORS.key? code
78
78
 
79
79
  raise Lokalise::Error::ERRORS[code].from_response(body)
80
80
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lokalise
4
- VERSION = '4.3.0'
4
+ VERSION = '4.3.1'
5
5
  end
@@ -15,6 +15,14 @@ RSpec.describe Lokalise::Error do
15
15
  end.to raise_error(described_class)
16
16
  end
17
17
 
18
+ it 'handles an exception when the response does not contain an error key' do
19
+ expect do
20
+ VCR.use_cassette('error_no_error_key') do
21
+ get 'projects', Lokalise.client('invalid')
22
+ end
23
+ end.to raise_error(Lokalise::Error::BadRequest)
24
+ end
25
+
18
26
  it 'raises BadRequest when API token is invalid' do
19
27
  expect do
20
28
  VCR.use_cassette('error_invalid_token') do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lokalise-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.0
4
+ version: 4.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Bodrov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-15 00:00:00.000000000 Z
11
+ date: 2021-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -348,7 +348,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
348
348
  - !ruby/object:Gem::Version
349
349
  version: '0'
350
350
  requirements: []
351
- rubygems_version: 3.2.23
351
+ rubygems_version: 3.2.26
352
352
  signing_key:
353
353
  specification_version: 4
354
354
  summary: Ruby interface to the Lokalise API
@@ -370,11 +370,11 @@ test_files:
370
370
  - spec/lib/ruby-lokalise-api/rest/screenshots_spec.rb
371
371
  - spec/lib/ruby-lokalise-api/rest/snapshots_spec.rb
372
372
  - spec/lib/ruby-lokalise-api/rest/tasks_spec.rb
373
- - spec/lib/ruby-lokalise-api/rest/teams_spec.rb
374
- - spec/lib/ruby-lokalise-api/rest/team_users_spec.rb
375
373
  - spec/lib/ruby-lokalise-api/rest/team_user_groups_spec.rb
376
- - spec/lib/ruby-lokalise-api/rest/translations_spec.rb
374
+ - spec/lib/ruby-lokalise-api/rest/team_users_spec.rb
375
+ - spec/lib/ruby-lokalise-api/rest/teams_spec.rb
377
376
  - spec/lib/ruby-lokalise-api/rest/translation_providers_spec.rb
377
+ - spec/lib/ruby-lokalise-api/rest/translations_spec.rb
378
378
  - spec/lib/ruby-lokalise-api/rest/webhooks_spec.rb
379
379
  - spec/lib/ruby-lokalise-api/utils/snakecase_spec.rb
380
380
  - spec/lib/ruby-lokalise-api_spec.rb