lhc 3.1.0 → 3.1.1

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
  SHA1:
3
- metadata.gz: c9340ca162d9f5d5ad49d6a703e327d849f5b3ef
4
- data.tar.gz: dbcbccfb870b4f438669b02f388f1e8eeb96ea69
3
+ metadata.gz: a313eb836f98fd351f84b17f9fced2f0d3c89dde
4
+ data.tar.gz: 3d694a9a7b02371bad5accbbacfb3b90e2895de4
5
5
  SHA512:
6
- metadata.gz: 90f2ebae04ec5b322858cda86ac30bc985863c26aad6aab7478d615844a7676827caa7b4ecd5fe78982ec8a3d3be6198ad2b61d87ae918cc0a9e97d807c42b7c
7
- data.tar.gz: 5854c0038f5ae2190a4175279b1ea8d8ffc46480efd2adeffbe6ba0062390851df2621003e2357d865e4a66fe7c829014c069b6c9b36f48fa8499beae5643cab
6
+ metadata.gz: a831f27b91dfdb214d7e65767d3ce8b2775d6dd0b2646ebff14fd71bc54d27f1ed8a99c64b601d6294a6db57a9bf88522854f06d13aff9dae3b0e8d6bdff4451
7
+ data.tar.gz: b507a4579cba072c5e47a2d8053e11403ba9f9232919ccd6d32f56a05a3cd25612c508d8651b14cf1ca0ebdcf36a80662c3a732547136446ac499d88ffde91fd
@@ -22,6 +22,11 @@ class LHC::Endpoint
22
22
  end
23
23
  end
24
24
 
25
+ # Endpoint options are immutable
26
+ def options
27
+ @options.deep_dup
28
+ end
29
+
25
30
  # Removes keys from provided params hash
26
31
  # when they are used for interpolation.
27
32
  def remove_interpolated_params!(params)
@@ -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
- return unless (endpoint = LHC.config.endpoints[options[:url]])
75
- endpoint.options.deep_merge!(options)
76
- options.deep_merge!(endpoint.options)
77
- options[:url] = endpoint.url
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
@@ -1,3 +1,3 @@
1
1
  module LHC
2
- VERSION = "3.1.0"
2
+ VERSION = "3.1.1"
3
3
  end
@@ -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.0
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-10-29 00:00:00.000000000 Z
11
+ date: 2015-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus