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 +4 -4
- data/lib/halfling/request.rb +39 -0
- data/lib/halfling/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e5ab8825507b4c564214851f6a5e341d3b50618
|
4
|
+
data.tar.gz: d329b6de24ac1a56da79cb4d1ec8a71eb6874942
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/halfling/version.rb
CHANGED
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.
|
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
|