lhc 3.1.0 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lhc/endpoint.rb +5 -0
- data/lib/lhc/request.rb +8 -5
- data/lib/lhc/version.rb +1 -1
- data/spec/config/endpoints_spec.rb +15 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a313eb836f98fd351f84b17f9fced2f0d3c89dde
|
4
|
+
data.tar.gz: 3d694a9a7b02371bad5accbbacfb3b90e2895de4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a831f27b91dfdb214d7e65767d3ce8b2775d6dd0b2646ebff14fd71bc54d27f1ed8a99c64b601d6294a6db57a9bf88522854f06d13aff9dae3b0e8d6bdff4451
|
7
|
+
data.tar.gz: b507a4579cba072c5e47a2d8053e11403ba9f9232919ccd6d32f56a05a3cd25612c508d8651b14cf1ca0ebdcf36a80662c3a732547136446ac499d88ffde91fd
|
data/lib/lhc/endpoint.rb
CHANGED
data/lib/lhc/request.rb
CHANGED
@@ -12,7 +12,7 @@ class LHC::Request
|
|
12
12
|
attr_accessor :response, :options, :raw
|
13
13
|
|
14
14
|
def initialize(options, self_executing = true)
|
15
|
-
self.options = options.deep_dup
|
15
|
+
self.options = options.deep_dup || {}
|
16
16
|
use_configured_endpoint!
|
17
17
|
generate_url_from_template!
|
18
18
|
self.iprocessor = LHC::InterceptorProcessor.new(self)
|
@@ -71,10 +71,13 @@ class LHC::Request
|
|
71
71
|
# Get configured endpoint and use it for doing the request.
|
72
72
|
# Explicit request options are overriding configured options.
|
73
73
|
def use_configured_endpoint!
|
74
|
-
|
75
|
-
endpoint
|
76
|
-
options
|
77
|
-
|
74
|
+
endpoint = LHC.config.endpoints[self.options[:url]]
|
75
|
+
return unless endpoint
|
76
|
+
# explicit options override endpoint options
|
77
|
+
new_options = endpoint.options.deep_merge(self.options)
|
78
|
+
# set new options
|
79
|
+
self.options = new_options
|
80
|
+
self.options[:url] = endpoint.url
|
78
81
|
end
|
79
82
|
|
80
83
|
# Generates URL from a URL template
|
data/lib/lhc/version.rb
CHANGED
@@ -46,4 +46,19 @@ describe LHC do
|
|
46
46
|
expect(LHC.config.endpoints[:datastore].url).to eq 'http://datastore.lb-service'
|
47
47
|
end
|
48
48
|
end
|
49
|
+
|
50
|
+
context 'configured enpoints with default params' do
|
51
|
+
|
52
|
+
before(:each) do
|
53
|
+
LHC.config.endpoint(:telemarketers, 'http://datastore.lb-service/v2/spamnumbers?order_by=-user_frequency&swiss_number=true&offset=0&limit=:limit', params: { limit: 200 })
|
54
|
+
stub_request(:get, 'http://datastore.lb-service/v2/spamnumbers?limit=200&offset=0&order_by=-user_frequency&swiss_number=true')
|
55
|
+
.to_return(status: 200)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'is possible to call them multiple times with default params' do
|
59
|
+
LHC.get(:telemarketers)
|
60
|
+
LHC.get(:telemarketers)
|
61
|
+
LHC.get(:telemarketers)
|
62
|
+
end
|
63
|
+
end
|
49
64
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lhc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- local.ch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|