blueprint_agreement 0.1.1 → 0.1.2

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: 8eb140bc814d88a4c62aac4f35a36a89acd29118
4
- data.tar.gz: 638e565604f981a5737dbb50a581c251574e0c54
3
+ metadata.gz: e5a1e036ac9271954e3c96329a28c2d4c86cb747
4
+ data.tar.gz: 910db3562b5e51afd8afda394510bcb4b42ec0b7
5
5
  SHA512:
6
- metadata.gz: e5b4a35fefd12c6d8cdd9b663976c6228ee8a95f69b8f742addeabb23ce907bec18a52252c7d73616291a1695d65adec0230ef33e1b067fdd3ff9f90b9eca31b
7
- data.tar.gz: 61fc8c9d225ffd15d160a47d38aa743674341895a21bf315edb7ee5da312c5931b6fc43f24dc2be4484977b352bb9e5f880bea67dd89df56a39ea5dfd8760c25
6
+ metadata.gz: 992d8e4b3b696bc0b3ddf582b0c21b8a1305aa54a99d58c45961c2f8c3881b9ba532515e2a0a0b38fb9afe4fcd1af08f145a593649c78ee3d3e4b0fac511c286
7
+ data.tar.gz: 828c36905e2a2e3901cdcf58770bf902162c9679fec3303c7248c3291d7945996de51172cfd3c5cc5abe93599227fa5ded28811e32f0531875e79e1e5116db13
data/README.md CHANGED
@@ -18,7 +18,7 @@ Note: This Gem Is Currently on Development.
18
18
 
19
19
  Add this line to your application's Gemfile:
20
20
 
21
- gem 'blueprint-agreement'
21
+ gem 'blueprint_agreement'
22
22
 
23
23
  And then execute:
24
24
 
@@ -29,7 +29,7 @@ module BlueprintAgreement
29
29
 
30
30
  def install
31
31
  print "installing drakov.."
32
- pid = Process.spawn "sudo npm install -g drakov"
32
+ pid = Process.spawn "npm install -g drakov"
33
33
  Process.wait pid
34
34
  print "Drakov installed 🍺 "
35
35
  end
@@ -61,6 +61,15 @@ module BlueprintAgreement
61
61
  "HTTP_COOKIE" => "Cookie",
62
62
  }
63
63
 
64
+ DEFAULT_HEADERS = %w[
65
+ HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_ENCODING
66
+ HTTP_ACCEPT_LANGUAGE HTTP_CACHE_CONTROL HTTP_FROM
67
+ HTTP_NEGOTIATE HTTP_PRAGMA HTTP_CLIENT_IP
68
+ HTTP_X_FORWARDED_FOR HTTP_ORIGIN HTTP_VERSION
69
+ HTTP_X_CSRF_TOKEN HTTP_X_REQUEST_ID HTTP_X_FORWARDED_HOST
70
+ SERVER_ADDR
71
+ ].freeze
72
+
64
73
  def initialize(context)
65
74
  @context = context
66
75
  end
@@ -82,11 +91,21 @@ module BlueprintAgreement
82
91
  end
83
92
 
84
93
  def headers
85
- HEADER_PATCH.each_with_object({}) do |header, result|
94
+ headers = {}
95
+
96
+ DEFAULT_HEADERS.each do |env|
97
+ next unless @context.request.env.key?(env)
98
+ key = env.sub(/^HTTP_/n, '').downcase
99
+ headers[key] = @context.request.env[env]
100
+ end
101
+
102
+ HEADER_PATCH.each do |header|
86
103
  header_name, key = header
87
104
  next unless @context.request.env.key?(header_name)
88
- result[key] = @context.request.env[header_name]
89
- end.compact
105
+ headers[key] = @context.request.env[header_name]
106
+ end
107
+
108
+ headers.compact
90
109
  end
91
110
 
92
111
  def request
@@ -1,3 +1,3 @@
1
1
  module BlueprintAgreement
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -64,3 +64,20 @@ API Blueprint** and as such you can **parse** it with the
64
64
  {
65
65
  "cookie": "have a cookie!"
66
66
  }
67
+
68
+ # GET /extra_headers
69
+ + Request (application/json)
70
+
71
+ + Headers
72
+
73
+ Cookie: cookie=have-a-cookie
74
+ Accept: application/json
75
+ Version: v1
76
+
77
+ + Response 200 (application/json)
78
+
79
+ + Body
80
+
81
+ {
82
+ "cookie": "have a cookie!"
83
+ }
@@ -26,6 +26,22 @@ describe "Rails" do
26
26
  last_response.shall_agree_upon('hello_api.md')
27
27
  end
28
28
  end
29
+
30
+ describe 'extra_headers' do
31
+ let(:env) do
32
+ {
33
+ 'HTTP_COOKIE' => 'cookie=have-a-cookie',
34
+ 'CONTENT_TYPE' => 'application/json',
35
+ 'HTTP_ACCEPT' => 'application/json',
36
+ 'HTTP_VERSION' => 'v1'
37
+ }
38
+ end
39
+
40
+ let(:endpoint) { '/extra_headers' }
41
+ it 'returns a valid request' do
42
+ last_response.shall_agree_upon('hello_api.md')
43
+ end
44
+ end
29
45
  end
30
46
 
31
47
  describe "Rack Test" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blueprint_agreement
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charly Palencia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-14 00:00:00.000000000 Z
11
+ date: 2017-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport