lontara_utilities 3.0.2 → 3.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db8b37fbf6e0f5bd904bad6c5df9e3b009fbffee1bb801b4376c3b7a0f2a6da1
4
- data.tar.gz: c3b4f53bd41d0c35e98277b8ab95681a7c43e3914e3ce62e4987a0577d98f918
3
+ metadata.gz: 4756cd27d3f55e0d430ed095bc5d343fca09bc93d76e20437c179c711fccd2e0
4
+ data.tar.gz: 675d3676af0f25881c2ca615160ba93936db0336e3f239eca3b6d8572e3c9909
5
5
  SHA512:
6
- metadata.gz: f083e7c8f188d01e48ce0ed5f9350f6299f85e8af649b428777381a4a3ef4fffea4e42599e252689a40b8c7fd7d963501c6dc510e8d90dd2e85823cfb8bedb33
7
- data.tar.gz: 67d941927b1e5247d92e7380de2f57844301ef83dd3cff03a35cb63af0eaf98cd12dccd7110364366d2261e86df597931c7c1c3207ebc86f23b9192b580602ec
6
+ metadata.gz: 0b2409ecc4c054822ce5756f2d020bf8d50238fbb82e6b5a8d349c11fd170dd36ac60b44ea5627e296e0b4d400c0ecbbe536832fb4d51215f3ecc898d8ec06ae
7
+ data.tar.gz: 46bd2babae345b0f71cb7874a7bb3c5b4505558dfd5ac48f12e0698c543e6ce166c3cb1c77a26295065440fd7a4dc27ae402ef2986528151045d8360f34b5df5
data/.gitignore CHANGED
@@ -1,3 +1,2 @@
1
1
  lontara.gem
2
2
  recovery_codes
3
- build.sh
data/Gemfile.lock CHANGED
@@ -1,10 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lontara_utilities (3.0.0)
4
+ lontara_utilities (3.1.0)
5
5
  bunny (~> 2.20)
6
- connection_pool (~> 2.3)
6
+ connection_pool (~> 2.4)
7
7
  faraday (~> 2.7)
8
+ faraday-net_http_persistent (~> 2.0)
8
9
  json (~> 2.6)
9
10
  securerandom (~> 0.2)
10
11
  uri (~> 0.12)
@@ -12,47 +13,55 @@ PATH
12
13
  GEM
13
14
  remote: https://rubygems.org/
14
15
  specs:
15
- addressable (2.8.4)
16
+ addressable (2.8.6)
16
17
  public_suffix (>= 2.0.2, < 6.0)
17
18
  amq-protocol (2.3.2)
18
- bunny (2.20.3)
19
+ bigdecimal (3.1.6)
20
+ bunny (2.22.0)
19
21
  amq-protocol (~> 2.3, >= 2.3.1)
20
22
  sorted_set (~> 1, >= 1.0.2)
21
23
  byebug (11.1.3)
22
- connection_pool (2.4.0)
23
- crack (0.4.5)
24
+ connection_pool (2.4.1)
25
+ crack (1.0.0)
26
+ bigdecimal
24
27
  rexml
25
- diff-lcs (1.5.0)
26
- faraday (2.7.4)
27
- faraday-net_http (>= 2.0, < 3.1)
28
- ruby2_keywords (>= 0.0.4)
29
- faraday-net_http (3.0.2)
30
- hashdiff (1.0.1)
31
- json (2.6.3)
32
- public_suffix (5.0.1)
28
+ diff-lcs (1.5.1)
29
+ faraday (2.9.0)
30
+ faraday-net_http (>= 2.0, < 3.2)
31
+ faraday-net_http (3.1.0)
32
+ net-http
33
+ faraday-net_http_persistent (2.1.0)
34
+ faraday (~> 2.5)
35
+ net-http-persistent (~> 4.0)
36
+ hashdiff (1.1.0)
37
+ json (2.7.1)
38
+ net-http (0.4.1)
39
+ uri
40
+ net-http-persistent (4.0.2)
41
+ connection_pool (~> 2.2)
42
+ public_suffix (5.0.4)
33
43
  rbtree (0.4.6)
34
- rexml (3.2.5)
35
- rspec (3.12.0)
36
- rspec-core (~> 3.12.0)
37
- rspec-expectations (~> 3.12.0)
38
- rspec-mocks (~> 3.12.0)
39
- rspec-core (3.12.2)
40
- rspec-support (~> 3.12.0)
41
- rspec-expectations (3.12.3)
44
+ rexml (3.2.6)
45
+ rspec (3.13.0)
46
+ rspec-core (~> 3.13.0)
47
+ rspec-expectations (~> 3.13.0)
48
+ rspec-mocks (~> 3.13.0)
49
+ rspec-core (3.13.0)
50
+ rspec-support (~> 3.13.0)
51
+ rspec-expectations (3.13.0)
42
52
  diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.12.0)
44
- rspec-mocks (3.12.5)
53
+ rspec-support (~> 3.13.0)
54
+ rspec-mocks (3.13.0)
45
55
  diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.12.0)
47
- rspec-support (3.12.0)
48
- ruby2_keywords (0.0.5)
49
- securerandom (0.2.2)
50
- set (1.0.3)
56
+ rspec-support (~> 3.13.0)
57
+ rspec-support (3.13.0)
58
+ securerandom (0.3.1)
59
+ set (1.1.0)
51
60
  sorted_set (1.0.3)
52
61
  rbtree
53
62
  set (~> 1.0)
54
- uri (0.12.1)
55
- webmock (3.18.1)
63
+ uri (0.13.0)
64
+ webmock (3.21.2)
56
65
  addressable (>= 2.8.0)
57
66
  crack (>= 0.3.2)
58
67
  hashdiff (>= 0.4.0, < 2.0.0)
data/build.sh ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+
3
+ # Delete lontara build first
4
+ rm lontara.gem
5
+
6
+ # Then build gem from gemspec
7
+ gem build lontara-utilities.gemspec -o lontara.gem
@@ -25,18 +25,14 @@ module LontaraUtilities
25
25
  attr_reader :method, :url, :headers, :body, :params, :timeout
26
26
 
27
27
  def call
28
- connection.send(method, url) do |req|
29
- req.body = parsed_body if body
30
- req.params = params if params
31
- req.options.timeout = timeout
32
- req.options.open_timeout = timeout
33
- end
34
- end
35
-
36
- def connection
37
- Faraday.new do |faraday|
38
- faraday.headers = headers
39
- faraday.adapter Faraday.default_adapter
28
+ HTTPClient.connection.with do |conn|
29
+ conn.send(method, url) do |req|
30
+ req.headers = headers
31
+ req.body = parsed_body if body
32
+ req.params = params if params
33
+ req.options.timeout = timeout
34
+ req.options.open_timeout = timeout
35
+ end
40
36
  end
41
37
  end
42
38
 
@@ -3,6 +3,8 @@
3
3
  require 'json'
4
4
  require 'uri'
5
5
  require 'faraday'
6
+ require 'faraday/net_http_persistent'
7
+ require 'connection_pool'
6
8
 
7
9
  require_relative 'git'
8
10
  require_relative 'http_client/body_parser'
@@ -44,14 +46,17 @@ module LontaraUtilities
44
46
  # JSON.parse(request.body)
45
47
  #
46
48
  module HTTPClient
47
- def self.new(method, url:, **options)
48
- Request.new(method, url:, **options).perform
49
+ def self.connection
50
+ @connection ||= ::ConnectionPool::Wrapper.new(size: 5, timeout: 5) do
51
+ Faraday.new do |faraday|
52
+ faraday.adapter :net_http_persistent
53
+ end
54
+ end
49
55
  end
50
56
 
51
- # Use predifined method to make HTTP request.
52
57
  %i[get post put delete patch].each do |method|
53
58
  define_singleton_method(method) do |url:, **options|
54
- Request.new(method, url:, **options).perform
59
+ Request.new(method, url: url, **options).perform
55
60
  end
56
61
  end
57
62
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LontaraUtilities
4
- VERSION = '3.0.2'
4
+ VERSION = '3.1.0'
5
5
  end
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency 'bunny', '~> 2.20'
27
27
  spec.add_dependency 'connection_pool', '~> 2.4'
28
28
  spec.add_dependency 'faraday', '~> 2.7'
29
+ spec.add_dependency 'faraday-net_http_persistent', '~> 2.0'
29
30
  spec.add_dependency 'json', '~> 2.6'
30
31
  spec.add_dependency 'securerandom', '~> 0.2'
31
32
  spec.add_dependency 'uri', '~> 0.12'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lontara_utilities
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdul Hakim Ghaniy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-12 00:00:00.000000000 Z
11
+ date: 2024-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: faraday-net_http_persistent
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: json
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -152,6 +166,7 @@ files:
152
166
  - Gemfile.lock
153
167
  - LICENSE
154
168
  - README.md
169
+ - build.sh
155
170
  - lib/lontara.rb
156
171
  - lib/lontara_utilities.rb
157
172
  - lib/lontara_utilities/base_error.rb
@@ -194,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
209
  - !ruby/object:Gem::Version
195
210
  version: '0'
196
211
  requirements: []
197
- rubygems_version: 3.3.26
212
+ rubygems_version: 3.4.21
198
213
  signing_key:
199
214
  specification_version: 4
200
215
  summary: Lontara Utilities provided by Lontara.app