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 +4 -4
- data/README.md +16 -0
- data/lhc.gemspec +1 -1
- data/lib/lhc/request.rb +1 -1
- data/lib/lhc/version.rb +1 -1
- data/spec/request/params_encoding_spec.rb +24 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3be90fe7f5118c0d39672fc3bd3d8977c5c29ef
|
4
|
+
data.tar.gz: 1ebb19663db886f14fcae7e8ce5cf9c3fa895d85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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:
|
data/lhc.gemspec
CHANGED
@@ -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
|
|
data/lib/lhc/request.rb
CHANGED
@@ -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
|
|
data/lib/lhc/version.rb
CHANGED
@@ -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.
|
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
|