celluloid-http 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/celluloid-http.gemspec +1 -0
- data/lib/celluloid-http/response.rb +10 -0
- data/lib/celluloid-http/version.rb +1 -1
- data/lib/celluloid-http.rb +1 -0
- data/test/unit/response_test.rb +12 -0
- metadata +18 -2
data/celluloid-http.gemspec
CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
|
+
gem.add_runtime_dependency('rack')
|
20
21
|
gem.add_runtime_dependency('celluloid-io')
|
21
22
|
gem.add_runtime_dependency('http_parser.rb')
|
22
23
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
class Celluloid::Http::Response
|
2
2
|
extend Forwardable
|
3
3
|
|
4
|
+
STATUS_CODES = Rack::Utils::HTTP_STATUS_CODES
|
5
|
+
|
4
6
|
def_delegators :parser, :<<
|
5
7
|
|
6
8
|
attr_writer :status
|
@@ -35,4 +37,12 @@ class Celluloid::Http::Response
|
|
35
37
|
@parser ||= Http::Parser.new(self)
|
36
38
|
end
|
37
39
|
|
40
|
+
def reason
|
41
|
+
STATUS_CODES[status]
|
42
|
+
end
|
43
|
+
|
44
|
+
def sym_status
|
45
|
+
reason.downcase.gsub(/\s|-/, '_').to_sym
|
46
|
+
end
|
47
|
+
|
38
48
|
end
|
data/lib/celluloid-http.rb
CHANGED
data/test/unit/response_test.rb
CHANGED
@@ -27,5 +27,17 @@ class ResponseTest < TestCase
|
|
27
27
|
assert_equal "en", response.headers["Content-Language"]
|
28
28
|
end
|
29
29
|
|
30
|
+
def test_symbol_ok_http_status
|
31
|
+
response = Celluloid::Http::Response.new(200)
|
32
|
+
|
33
|
+
assert_equal :ok, response.sym_status
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_symbol_not_found_http_status
|
37
|
+
response = Celluloid::Http::Response.new(404)
|
38
|
+
|
39
|
+
assert_equal :not_found, response.sym_status
|
40
|
+
end
|
41
|
+
|
30
42
|
|
31
43
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: celluloid-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rack
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
14
30
|
- !ruby/object:Gem::Dependency
|
15
31
|
name: celluloid-io
|
16
32
|
requirement: !ruby/object:Gem::Requirement
|