lhc 7.2.0 → 7.3.0

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
  SHA1:
3
- metadata.gz: 7dd0e9ffa97a410938b008214a1169dd92baad1a
4
- data.tar.gz: 0c3e70e1aed73f71ab15cc8956f268c95ee4961e
3
+ metadata.gz: c3be90fe7f5118c0d39672fc3bd3d8977c5c29ef
4
+ data.tar.gz: 1ebb19663db886f14fcae7e8ce5cf9c3fa895d85
5
5
  SHA512:
6
- metadata.gz: b7ef93685b6321f92e3d211a15503b34f67acbaa6395ccf866f13b0ad1f03f14b42008a70e350950c124738ecd94e553f9aa0149026cac84b760287a18651be5
7
- data.tar.gz: e348b6290e471eaec282c9cb883d129284029ea8644b4899fb5288f40c4c96ce24d03fb4c97ba30c1ded064df56945b2b77e96b212c2e24727b29ff606e395c4
6
+ metadata.gz: c7b6d90013ea2ff3eb3bcd23af36ee3a47d8b6e36ce8079a38dd9c8f86f1d777a8b293399a82fbb65383847b2b8c66b61d0eb71b5eb83590c48e8bc300231a27
7
+ data.tar.gz: 65d6c5d0a893662d7553f0589dfd5121c44d124eedddccc93ddc857618c3888b371af52801db4b31184bd61e6b5ce791d1c43c88dde14eccdd2da52a64f48261
data/README.md CHANGED
@@ -112,6 +112,22 @@ DON'T
112
112
  LHC.get('http://local.ch?q=Restaurant')
113
113
  ```
114
114
 
115
+ ### Array Parameter Encoding
116
+
117
+ LHC can encode array parameters in URLs in two ways. The default is `:rack` which generates URL parameters compatible with Rack and Rails.
118
+
119
+ ```ruby
120
+ LHC.get('http://local.ch', params: { q: [1, 2] })
121
+ # http://local.ch?q[]=1&q[]=2
122
+ ```
123
+
124
+ Some Java-based apps expect their arrays in the `:multi` format:
125
+
126
+ ```ruby
127
+ LHC.get('http://local.ch', params: { q: [1, 2] }, params_encoding: :multi)
128
+ # http://local.ch?q=1&q=2
129
+ ```
130
+
115
131
  ## Encoding
116
132
 
117
133
  LHC, by default, encodes urls:
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.requirements << 'Ruby >= 2.0.0'
21
21
  s.required_ruby_version = '>= 2.0.0'
22
22
 
23
- s.add_dependency 'typhoeus'
23
+ s.add_dependency 'typhoeus', '>= 0.11'
24
24
  s.add_dependency 'activesupport', '>= 4.2'
25
25
  s.add_dependency 'addressable'
26
26
 
@@ -6,7 +6,7 @@ require 'active_support/core_ext/object/deep_dup'
6
6
  # and it communicates with interceptors.
7
7
  class LHC::Request
8
8
 
9
- TYPHOEUS_OPTIONS ||= [:params, :method, :body, :headers, :follow_location]
9
+ TYPHOEUS_OPTIONS ||= [:params, :method, :body, :headers, :follow_location, :params_encoding]
10
10
 
11
11
  attr_accessor :response, :options, :raw, :format, :error_handler, :errors_ignored
12
12
 
@@ -1,3 +1,3 @@
1
1
  module LHC
2
- VERSION ||= '7.2.0'
2
+ VERSION ||= '7.3.0'
3
3
  end
@@ -0,0 +1,24 @@
1
+ require 'rails_helper'
2
+
3
+ describe LHC::Request do
4
+ context 'without an encoding setting' do
5
+ it 'encodes array params in default rack format' do
6
+ stub_request(:get, 'http://datastore/q?a%5B%5D=1&a%5B%5D=2&a%5B%5D=3')
7
+ LHC.get('http://datastore/q', params: { a: [1, 2, 3] })
8
+ end
9
+ end
10
+
11
+ context 'with encoding set to :rack' do
12
+ it 'encodes array params in rack format' do
13
+ stub_request(:get, 'http://datastore/q?a%5B%5D=1&a%5B%5D=2&a%5B%5D=3')
14
+ LHC.get('http://datastore/q', params: { a: [1, 2, 3] }, params_encoding: :rack)
15
+ end
16
+ end
17
+
18
+ context 'with encoding set to :multi' do
19
+ it 'encodes array params in multi format' do
20
+ stub_request(:get, 'http://datastore/q?a=1&a=2&a=3')
21
+ LHC.get('http://datastore/q', params: { a: [1, 2, 3] }, params_encoding: :multi)
22
+ end
23
+ end
24
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhc
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.2.0
4
+ version: 7.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/local-ch/lhc/contributors
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '0.11'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '0.11'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -322,6 +322,7 @@ files:
322
322
  - spec/request/ignore_errors_spec.rb
323
323
  - spec/request/option_dup_spec.rb
324
324
  - spec/request/parallel_requests_spec.rb
325
+ - spec/request/params_encoding_spec.rb
325
326
  - spec/request/request_without_rails_spec.rb
326
327
  - spec/request/url_patterns_spec.rb
327
328
  - spec/response/body_spec.rb
@@ -454,6 +455,7 @@ test_files:
454
455
  - spec/request/ignore_errors_spec.rb
455
456
  - spec/request/option_dup_spec.rb
456
457
  - spec/request/parallel_requests_spec.rb
458
+ - spec/request/params_encoding_spec.rb
457
459
  - spec/request/request_without_rails_spec.rb
458
460
  - spec/request/url_patterns_spec.rb
459
461
  - spec/response/body_spec.rb