halfling 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 60af41861262deea4db31889c565acee9e4ea7d0
4
- data.tar.gz: 90046eb9bab88f07ad6ed368eead6ed07a764548
3
+ metadata.gz: 5e5ab8825507b4c564214851f6a5e341d3b50618
4
+ data.tar.gz: d329b6de24ac1a56da79cb4d1ec8a71eb6874942
5
5
  SHA512:
6
- metadata.gz: 04b99b435b8efdb6b73d1ef8aae47a6001f47acddab639a1c362795721bf148b017d1a53fad706248c820f927996cffbecb0e02b84b3d6f1473c117c5142e09c
7
- data.tar.gz: 1523479f035bb4eb767053faead0acbe915a6728a62a5f8af66b5cf09d8b2aa60b7cefb50b55869eb155ffa993eec6a8224d9370ed45a715f2092a7090d5971d
6
+ metadata.gz: 8411c8b7efcf1aafcc72cc6b0c84d7f06eb12e527a1d69c2aa5502649e0688ad804353974bdac5178aad90aa7d4915d6c01bdd844b5005599b44ee6007e65d4e
7
+ data.tar.gz: b2f0ca666289c41d77bff0e72960848b83bbeecb47c33109d7917b80cace43fceece7acdaedf3316d2bf149982d06a728cfa3f205016b8a3d8027f2daaa30306
@@ -0,0 +1,39 @@
1
+ require "hobbit/request"
2
+
3
+ module Hobbit
4
+ class Request
5
+ class RequestHeaders
6
+ include Enumerable
7
+ def initialize(env)
8
+ @env=env
9
+ end
10
+
11
+ def each
12
+ @env.each do |var_name, val|
13
+ if String === var_name
14
+ if (match=var_name.match(/^HTTP_(.*)$/))
15
+ header_name=match[1]
16
+ unless header_name == "VERSION"
17
+ yield header_name.split('_').map(&:capitalize).join('-'), val if block_given?
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ def [](header_name)
25
+ @env[self.class.header_name_to_env_var(header_name)]
26
+ end
27
+ def self.header_name_to_env_var(header_name)
28
+ "HTTP_#{header_name.upcase.gsub("-", "_")}"
29
+ end
30
+ end
31
+
32
+ def header(name)
33
+ env[RequestHeaders.header_name_to_env_var(name)]
34
+ end
35
+ def headers
36
+ @headers_enumerable||=RequestHeaders.new(env)
37
+ end
38
+ end
39
+ end
@@ -1,3 +1,3 @@
1
1
  module Halfling
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: halfling
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leo P.
@@ -177,6 +177,7 @@ files:
177
177
  - halfling.gemspec
178
178
  - lib/halfling.rb
179
179
  - lib/halfling/base.rb
180
+ - lib/halfling/request.rb
180
181
  - lib/halfling/response.rb
181
182
  - lib/halfling/version.rb
182
183
  homepage: https://github.com/slact/halfling