json_requester 1.0.12 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -1
  3. data/lib/json_requester.rb +3 -1
  4. metadata +12 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0845954f6576fcb489054c9dba9649432baf657c49e83e77bfcc0e5c70cc0e89'
4
- data.tar.gz: cbe77bc53e67caedf438644d5f5302fa5bbf78761f79a96762b3b401c126b035
3
+ metadata.gz: cc7d06fc0826a6e7c0de5aa79a3f0f3bfa8825939594a46bd0f94d00fff2b4e2
4
+ data.tar.gz: 251126b9edcdd2c645f7510f388d6ab5f80b4954695c309c99bb402758a6ec10
5
5
  SHA512:
6
- metadata.gz: aa8352783d500877db5023c7d9f77d0cd5488e9af3418c25fba9e7cbb863e4e247bb40e534919e42ea15137636de0ced368c54d2148883e2c7139fe1e6386948
7
- data.tar.gz: e0da8dcf1a2faaefedee3724d46fa56945db6d0495674a776870b813719c81299b8f5f10dad3aef0f2083995a609ba9e90d1994cf58477bf23d00e1ff1ce1772
6
+ metadata.gz: d2eddf1750ef801739e6dae0108a085954b3e0d41276f171a365ba5df5bb99f84ce666467fdcb2c5824c9a6c6be9a35976e219a3e2c95cd848e00e5bae5cd92b
7
+ data.tar.gz: 7d2d352b07533fd5906ddf8ea08687d8e320cd1dad193f46abe576bc0b4b304981956e8f87ef84fe32794d958554531dd2cbfffbbd9b676e4cebf84b7f121384
data/README.md CHANGED
@@ -13,7 +13,8 @@ $ gem install json_requester
13
13
  ```ruby
14
14
  host = 'http://httpbingo.org'
15
15
  # `timeout` at Faraday gem default is 60 secs.
16
- requester = JsonRequester.new(host, timeout: 120)
16
+ # `user_agent` at Faraday gem default is like "Faraday v1.10.0", it would be deep_merge at Faraday default setting.
17
+ requester = JsonRequester.new(host, timeout: 120, user_agent: 'My Agent 1.2')
17
18
 
18
19
  http_method = :get # :get / :post / :put / :delete
19
20
  path = ''
@@ -4,11 +4,12 @@ require 'json'
4
4
  class JsonRequester
5
5
  attr_reader :host, :conn
6
6
 
7
- def initialize(host, multipart: false, ssl_verify: true, timeout: 60)
7
+ def initialize(host, multipart: false, ssl_verify: true, timeout: 60, user_agent: '')
8
8
  @host = host
9
9
  @multipart = multipart
10
10
  @ssl_verify = ssl_verify
11
11
  @timeout = timeout
12
+ @user_agent = user_agent.strip.to_s
12
13
  end
13
14
 
14
15
  def http_send(http_method, path, params={}, headers={}, sort_params: true, need_response_header: false)
@@ -73,6 +74,7 @@ class JsonRequester
73
74
  def init_conn(sort_params: true)
74
75
  # https://lostisland.github.io/faraday/#/customization/index?id=order-of-parameters
75
76
  Faraday::NestedParamsEncoder.sort_params = sort_params # faraday default is true
77
+ Faraday.default_connection_options = { headers: { user_agent: @user_agent } } unless @user_agent.empty?
76
78
 
77
79
  Faraday.new(url: host, ssl: { verify: @ssl_verify }) do |faraday|
78
80
  faraday.request :multipart if @multipart # multipart form POST request
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_requester
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.12
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JiaRou Lee
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-26 00:00:00.000000000 Z
11
+ date: 2023-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,34 +16,34 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '1.10'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 1.0.0
22
+ version: 1.10.3
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: '1.0'
29
+ version: '1.10'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 1.0.0
32
+ version: 1.10.3
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: pry
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 0.14.1
39
+ version: 0.14.2
40
40
  type: :development
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: 0.14.1
46
+ version: 0.14.2
47
47
  description: wrapper of faraday
48
48
  email: laura34963@kdanmobile.com
49
49
  executables: []
@@ -59,7 +59,7 @@ licenses:
59
59
  metadata:
60
60
  source_code_uri: https://github.com/kdan-mobile-software-ltd/json_requester
61
61
  changelog_uri: https://github.com/kdan-mobile-software-ltd/json_requester/blob/master/CHANGELOG.md
62
- post_install_message:
62
+ post_install_message:
63
63
  rdoc_options:
64
64
  - "--charset=UTF-8"
65
65
  require_paths:
@@ -75,8 +75,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  requirements: []
78
- rubygems_version: 3.2.32
79
- signing_key:
78
+ rubygems_version: 3.4.10
79
+ signing_key:
80
80
  specification_version: 4
81
81
  summary: Basic Wrapper of Faraday
82
82
  test_files: []