ruby-lokalise-api 8.0.0 → 9.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.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/ruby_lokalise_api/base_client.rb +2 -0
- data/lib/ruby_lokalise_api/client.rb +0 -2
- data/lib/ruby_lokalise_api/connection.rb +12 -7
- data/lib/ruby_lokalise_api/endpoints/base_endpoint.rb +8 -15
- data/lib/ruby_lokalise_api/oauth2_client.rb +0 -2
- data/lib/ruby_lokalise_api/request.rb +1 -1
- data/lib/ruby_lokalise_api/version.rb +1 -1
- data/ruby-lokalise-api.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33c8b8383d4e08130e6a27af7bf66d512d4db1546e3b572f9860a67c4c280281
|
4
|
+
data.tar.gz: a6a2bdbd9ad4f394a32b725135c1327e64ffa82cddcb2523d4d1f166932d7d73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f68a55a77660fb86e4b4ba138f9092afeaf12462865dbd6fb72efe773593428667348c887b297af44896fcbad4272fd02e19016708b5570c90fb95a3e68b182
|
7
|
+
data.tar.gz: e7359331fe700fe781cf16de68cc9d44d143e96eb43cf6ab4b5d250eb3b2be52bb23c738ba9548d7fbe298895fdc688cb0b7c06f2cbda38049ca83e8f7c944a1
|
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|

|
4
4
|

|
5
|
+
[](https://coveralls.io/github/lokalise/ruby-lokalise-api?branch=master)
|
5
6
|

|
6
7
|
|
7
8
|
Official opinionated Ruby interface for the [Lokalise API](https://developers.lokalise.com/reference/lokalise-rest-api) that represents returned data as Ruby objects.
|
@@ -4,6 +4,8 @@ module RubyLokaliseApi
|
|
4
4
|
# This class contains the base client. Inherited by Client (regular API client)
|
5
5
|
# and OAuth2Client (used for OAuth-2 based authentication)
|
6
6
|
class BaseClient
|
7
|
+
include RubyLokaliseApi::Rest
|
8
|
+
|
7
9
|
attr_reader :token, :token_header
|
8
10
|
attr_accessor :timeout, :open_timeout
|
9
11
|
|
@@ -4,8 +4,8 @@ module RubyLokaliseApi
|
|
4
4
|
# Module to setup connection using Faraday
|
5
5
|
module Connection
|
6
6
|
# Creates a new Faraday object with specified params
|
7
|
-
def connection(endpoint)
|
8
|
-
Faraday.new(options(endpoint), request_params_for(endpoint.client)) do |faraday|
|
7
|
+
def connection(endpoint, params = {})
|
8
|
+
Faraday.new(options(endpoint, params), request_params_for(endpoint.client)) do |faraday|
|
9
9
|
faraday.adapter Faraday.default_adapter
|
10
10
|
faraday.request(:gzip)
|
11
11
|
end
|
@@ -13,16 +13,21 @@ module RubyLokaliseApi
|
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
|
-
def options(endpoint)
|
17
|
-
|
16
|
+
def options(endpoint, params)
|
17
|
+
req_params = __base_options(endpoint)
|
18
18
|
client = endpoint.client
|
19
19
|
|
20
20
|
if client.respond_to?(:token) && client.respond_to?(:token_header)
|
21
|
-
|
21
|
+
req_params[:headers][client.token_header] = client.token
|
22
22
|
end
|
23
|
-
params[:headers][:accept_encoding] = 'gzip,deflate,br'
|
24
23
|
|
25
|
-
|
24
|
+
# Sending content-type is needed only when the body is actually present
|
25
|
+
# Trying to send this header in other cases seems to result in error 500
|
26
|
+
req_params[:headers]['Content-type'] = 'application/json' if !params[:get_request] && endpoint.req_params
|
27
|
+
|
28
|
+
req_params[:headers][:accept_encoding] = 'gzip,deflate,br'
|
29
|
+
|
30
|
+
req_params
|
26
31
|
end
|
27
32
|
|
28
33
|
def __base_options(endpoint)
|
@@ -10,6 +10,7 @@ module RubyLokaliseApi
|
|
10
10
|
|
11
11
|
BASE_URL = ''
|
12
12
|
PARTIAL_URI_TEMPLATE = '{/segments*}'
|
13
|
+
HTTP_METHODS = %i[get post put delete patch].freeze
|
13
14
|
|
14
15
|
def initialize(client, params = {})
|
15
16
|
@query_params = params[:query].to_array
|
@@ -34,24 +35,16 @@ module RubyLokaliseApi
|
|
34
35
|
base_url + uri
|
35
36
|
end
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
return true if HTTP_METHODS_REGEXP.match?(method.to_s)
|
43
|
-
|
44
|
-
super
|
45
|
-
end
|
46
|
-
|
47
|
-
def method_missing(method, *_args)
|
48
|
-
if method.to_s =~ HTTP_METHODS_REGEXP
|
49
|
-
send Regexp.last_match(1), self
|
50
|
-
else
|
51
|
-
super
|
38
|
+
# Creates methods like `do_post`, `do_get` that proxy calls to the
|
39
|
+
# corresponding methods in the `Request` module
|
40
|
+
HTTP_METHODS.each do |method_postfix|
|
41
|
+
define_method "do_#{method_postfix}" do
|
42
|
+
send method_postfix, self
|
52
43
|
end
|
53
44
|
end
|
54
45
|
|
46
|
+
private
|
47
|
+
|
55
48
|
def base_query(*_args); end
|
56
49
|
|
57
50
|
def partial_uri(*_args)
|
@@ -9,7 +9,7 @@ module RubyLokaliseApi
|
|
9
9
|
# Sends a GET request
|
10
10
|
def get(endpoint)
|
11
11
|
respond_with(
|
12
|
-
connection(endpoint).get(prepare(endpoint.uri), endpoint.req_params),
|
12
|
+
connection(endpoint, get_request: true).get(prepare(endpoint.uri), endpoint.req_params),
|
13
13
|
endpoint
|
14
14
|
)
|
15
15
|
end
|
data/ruby-lokalise-api.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.homepage = 'https://github.com/lokalise/ruby-lokalise-api'
|
13
13
|
spec.license = 'BSD-3-Clause'
|
14
14
|
spec.platform = Gem::Platform::RUBY
|
15
|
-
spec.required_ruby_version = '>=
|
15
|
+
spec.required_ruby_version = '>= 3.0'
|
16
16
|
|
17
17
|
spec.files = Dir['README.md', 'LICENSE',
|
18
18
|
'CHANGELOG.md', 'lib/**/*.rb', 'lib/ruby_lokalise_api/data/*.yml',
|
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
|
+
version: 9.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Krukowski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -390,14 +390,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
390
390
|
requirements:
|
391
391
|
- - ">="
|
392
392
|
- !ruby/object:Gem::Version
|
393
|
-
version: '
|
393
|
+
version: '3.0'
|
394
394
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
395
395
|
requirements:
|
396
396
|
- - ">="
|
397
397
|
- !ruby/object:Gem::Version
|
398
398
|
version: '0'
|
399
399
|
requirements: []
|
400
|
-
rubygems_version: 3.4.
|
400
|
+
rubygems_version: 3.4.21
|
401
401
|
signing_key:
|
402
402
|
specification_version: 4
|
403
403
|
summary: Ruby interface to the Lokalise API
|