vcr-proxy 0.1.7 → 0.1.8

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
  SHA256:
3
- metadata.gz: 0d8ddc70f252fa0504e7d602ddd0fe64efc3d8d54525599cf88b9309cff87f32
4
- data.tar.gz: 618a6338a2b4280dc817244528d76d3b21d6aa8ef27b1b88495786f47f474e37
3
+ metadata.gz: 497e6654e537b72efe963d09f428607ca0663107736d953e4f497556e272ab66
4
+ data.tar.gz: 294caaf5cdde3f99cd4d75455588c63847be864dec193bf2a8c36bb21c6beb52
5
5
  SHA512:
6
- metadata.gz: 87bfcf2ec0036b1b9a40a2220f1cfefc3fa8b6d8273af40a50b1cdd75d219bd0583169adbbd4796581d3c66f85e00762c3016fc22638944df880d6e5daf6fe1a
7
- data.tar.gz: 109847e6649f964a9d6fd7da856a7361be8557a4a8db7c242eff47417715bb671df0f4a0b4133a42e7ad0bec38c20d199003c05ca0e1dddde42eeb28d3702cfa
6
+ metadata.gz: 88352b8c422417e4332a0626b95b14929f223bc285b5b0e03932efec10f588a27d15f7b1b5907fc21933ebdf5dcdffa73c170c1a286b801a388488f4cd29fce1
7
+ data.tar.gz: f5916fc1ef9dd17c64cf8a5e49261132d9a18b67c15b2f7e1846d8c8ffbf1067f2b86494f849829c002a3160f5af6a7a43e67525a69cb85b60fbf3f02dbb0b1b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vcr-proxy (0.1.7)
4
+ vcr-proxy (0.1.8)
5
5
  faraday
6
6
  sinatra
7
7
  vcr
data/lib/vcr/proxy/app.rb CHANGED
@@ -15,9 +15,8 @@ class App < Sinatra::Base
15
15
  vcr_wrapper('post') do
16
16
  uri = URI("#{VCR::Proxy.config}#{request.path}")
17
17
  uri.query = URI.encode_www_form(request.params)
18
- response = Faraday.post(uri, request.body.read, 'Content-Type' => 'application/json')
19
- status response.status
20
- response.body
18
+ response = Faraday.post(uri, request.body.read, request_headers)
19
+ relay_response(response)
21
20
  end
22
21
  end
23
22
 
@@ -25,15 +24,29 @@ class App < Sinatra::Base
25
24
  vcr_wrapper('get') do
26
25
  uri = URI("#{VCR::Proxy.config.endpoint}#{request.path}")
27
26
  uri.query = URI.encode_www_form(request.params)
28
- response = Faraday.get(uri, request.params, {'Accept' => 'application/json'})
29
- status response.status
30
- response.body
27
+ response = Faraday.get(uri, request.params, request_headers)
28
+ relay_response(response)
31
29
  end
32
30
  end
33
31
 
32
+ def relay_response(response)
33
+ puts response.headers.to_h
34
+ status response.status
35
+ response.body
36
+ end
37
+
38
+ def request_headers
39
+ @request_headers ||= env.select { |k, _v| k.start_with? 'HTTP_' }
40
+ .collect { |key, val| [key.sub(/^HTTP_/, ''), val] }
41
+ .collect { |key, val| "#{key}: #{val}<br>" }
42
+ .sort
43
+ end
44
+
34
45
  def vcr_wrapper(verb)
35
46
  key = "#{request.path}/#{verb}/#{request.params.to_json}"
36
- VCR.use_cassette(key, match_requests_on: VCR::Proxy.config.match_requests_on) do
47
+ match_requests_on = VCR::Proxy.config.match_requests_on
48
+
49
+ VCR.use_cassette(key, match_requests_on: match_requests_on) do
37
50
  yield
38
51
  end
39
52
  end
@@ -1,5 +1,5 @@
1
1
  module VCR
2
2
  module Proxy
3
- VERSION = "0.1.7"
3
+ VERSION = "0.1.8"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vcr-proxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - José Galisteo