webbed 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/.gitignore +22 -0
  2. data/.travis.yml +7 -0
  3. data/.yardopts +6 -0
  4. data/Gemfile +5 -13
  5. data/Guardfile +5 -0
  6. data/README.md +36 -31
  7. data/Rakefile +7 -14
  8. data/lib/webbed.rb +28 -6
  9. data/lib/webbed/generic_message.rb +27 -15
  10. data/lib/webbed/headers.rb +2 -0
  11. data/lib/webbed/helpers/entity_headers_helper.rb +62 -0
  12. data/lib/webbed/helpers/method_helper.rb +83 -0
  13. data/lib/webbed/helpers/rack_request_helper.rb +86 -0
  14. data/lib/webbed/helpers/rack_response_helper.rb +56 -0
  15. data/lib/webbed/helpers/request_headers_helper.rb +62 -0
  16. data/lib/webbed/helpers/request_uri_helper.rb +34 -0
  17. data/lib/webbed/helpers/response_headers_helper.rb +48 -0
  18. data/lib/webbed/helpers/scheme_helper.rb +26 -0
  19. data/lib/webbed/http_version.rb +88 -33
  20. data/lib/webbed/media_type.rb +160 -0
  21. data/lib/webbed/method.rb +63 -33
  22. data/lib/webbed/request.rb +65 -21
  23. data/lib/webbed/response.rb +65 -24
  24. data/lib/webbed/status_code.rb +84 -17
  25. data/lib/webbed/version.rb +1 -1
  26. data/test/support/assertions.rb +17 -0
  27. data/test/support/runner.rb +326 -0
  28. data/test/test_helper.rb +13 -0
  29. data/test/webbed/generic_message_test.rb +44 -0
  30. data/test/webbed/headers_test.rb +31 -0
  31. data/test/webbed/helpers/entity_headers_helper_test.rb +68 -0
  32. data/test/webbed/helpers/method_helper_test.rb +151 -0
  33. data/test/webbed/helpers/rack_request_helper_test.rb +108 -0
  34. data/test/webbed/helpers/rack_response_helper_test.rb +33 -0
  35. data/test/webbed/helpers/request_headers_helper_test.rb +57 -0
  36. data/test/webbed/helpers/request_uri_helper_test.rb +32 -0
  37. data/test/webbed/helpers/response_headers_helper_test.rb +46 -0
  38. data/test/webbed/helpers/scheme_helper_test.rb +28 -0
  39. data/test/webbed/http_version_test.rb +52 -0
  40. data/test/webbed/media_type_test.rb +100 -0
  41. data/test/webbed/method_test.rb +160 -0
  42. data/test/webbed/request_test.rb +74 -0
  43. data/test/webbed/response_test.rb +86 -0
  44. data/test/webbed/status_code_test.rb +105 -0
  45. data/webbed.gemspec +31 -0
  46. metadata +128 -41
@@ -0,0 +1,105 @@
1
+ require 'test_helper'
2
+
3
+ module WebbedTest
4
+ class StatusCodeTest < TestCase
5
+ test '#initialize with string' do
6
+ status_code = Webbed::StatusCode.new('200')
7
+ assert_equal 200, status_code.to_i
8
+ assert_equal '200', status_code.to_s
9
+ assert_equal 'OK', status_code.default_reason_phrase
10
+ end
11
+
12
+ test '#initialize with number' do
13
+ status_code = Webbed::StatusCode.new(200)
14
+ assert_equal 200, status_code.to_i
15
+ assert_equal '200', status_code.to_s
16
+ assert_equal 'OK', status_code.default_reason_phrase
17
+ end
18
+
19
+ test 'caching' do
20
+ status_code_1 = Webbed::StatusCode.new(200)
21
+ status_code_2 = Webbed::StatusCode.new(200)
22
+ assert_same status_code_2, status_code_1
23
+ end
24
+
25
+ test '#informational?' do
26
+ status_code = Webbed::StatusCode.new(100)
27
+
28
+ assert status_code.informational?
29
+ refute status_code.successful?
30
+ refute status_code.redirection?
31
+ refute status_code.client_error?
32
+ refute status_code.server_error?
33
+ refute status_code.unknown?
34
+ refute status_code.error?
35
+ end
36
+
37
+ test '#successful?' do
38
+ status_code = Webbed::StatusCode.new(200)
39
+
40
+ refute status_code.informational?
41
+ assert status_code.successful?
42
+ refute status_code.redirection?
43
+ refute status_code.client_error?
44
+ refute status_code.server_error?
45
+ refute status_code.unknown?
46
+ refute status_code.error?
47
+ end
48
+
49
+ test '#redirection?' do
50
+ status_code = Webbed::StatusCode.new(300)
51
+
52
+ refute status_code.informational?
53
+ refute status_code.successful?
54
+ assert status_code.redirection?
55
+ refute status_code.client_error?
56
+ refute status_code.server_error?
57
+ refute status_code.unknown?
58
+ refute status_code.error?
59
+ end
60
+
61
+ test '#client_error?' do
62
+ status_code = Webbed::StatusCode.new(400)
63
+
64
+ refute status_code.informational?
65
+ refute status_code.successful?
66
+ refute status_code.redirection?
67
+ assert status_code.client_error?
68
+ refute status_code.server_error?
69
+ refute status_code.unknown?
70
+ assert status_code.error?
71
+ end
72
+
73
+ test '#server_error?' do
74
+ status_code = Webbed::StatusCode.new(500)
75
+
76
+ refute status_code.informational?
77
+ refute status_code.successful?
78
+ refute status_code.redirection?
79
+ refute status_code.client_error?
80
+ assert status_code.server_error?
81
+ refute status_code.unknown?
82
+ assert status_code.error?
83
+ end
84
+
85
+ test '#unknown?' do
86
+ status_code = Webbed::StatusCode.new(600)
87
+
88
+ refute status_code.informational?
89
+ refute status_code.successful?
90
+ refute status_code.redirection?
91
+ refute status_code.client_error?
92
+ refute status_code.server_error?
93
+ assert status_code.unknown?
94
+ refute status_code.error?
95
+ end
96
+
97
+ test 'comparisons' do
98
+ ok = Webbed::StatusCode.new(200)
99
+ found = Webbed::StatusCode.new(302)
100
+
101
+ assert_equal 200, ok
102
+ assert_comparable ok, found
103
+ end
104
+ end
105
+ end
data/webbed.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'webbed/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'webbed'
7
+ s.version = Webbed::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ['Alexander Kern']
10
+ s.email = ['alex@kernul.com']
11
+ s.homepage = 'http://github.com/CapnKernul/webbed'
12
+ s.summary = 'Take control of HTTP.'
13
+ s.description = 'Sane library for manipulating HTTP messages.'
14
+
15
+ s.rubyforge_project = 'webbed'
16
+
17
+ s.add_dependency 'addressable'
18
+
19
+ s.add_development_dependency 'minitest', '~> 2.0'
20
+ s.add_development_dependency 'mocha'
21
+ # s.add_development_dependency 'guard-minitest'
22
+ s.add_development_dependency 'ansi'
23
+ s.add_development_dependency 'ruby-progressbar'
24
+ s.add_development_dependency 'maruku'
25
+ s.add_development_dependency 'test_declarative'
26
+
27
+ s.files = `git ls-files`.split("\n")
28
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
29
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
30
+ s.require_paths = ['lib']
31
+ end
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webbed
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
4
+ prerelease:
5
+ version: 0.2.0
11
6
  platform: ruby
12
7
  authors:
13
8
  - Alexander Kern
@@ -15,40 +10,89 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2010-07-27 00:00:00 -07:00
13
+ date: 2011-05-21 00:00:00 -07:00
19
14
  default_executable:
20
15
  dependencies:
21
16
  - !ruby/object:Gem::Dependency
22
- version_requirements: &id001 !ruby/object:Gem::Requirement
17
+ name: addressable
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
23
31
  none: false
24
32
  requirements:
25
33
  - - ~>
26
34
  - !ruby/object:Gem::Version
27
- hash: 1
28
- segments:
29
- - 2
30
- - 1
31
- version: "2.1"
32
- requirement: *id001
33
- name: addressable
35
+ version: "2.0"
36
+ type: :development
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: mocha
34
40
  prerelease: false
35
- type: :runtime
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ type: :development
48
+ version_requirements: *id003
36
49
  - !ruby/object:Gem::Dependency
37
- version_requirements: &id002 !ruby/object:Gem::Requirement
50
+ name: ansi
51
+ prerelease: false
52
+ requirement: &id004 !ruby/object:Gem::Requirement
38
53
  none: false
39
54
  requirements:
40
55
  - - ">="
41
56
  - !ruby/object:Gem::Version
42
- hash: 3
43
- segments:
44
- - 0
45
57
  version: "0"
46
- requirement: *id002
47
- name: rake
58
+ type: :development
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: ruby-progressbar
48
62
  prerelease: false
63
+ requirement: &id005 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: "0"
49
69
  type: :development
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: maruku
73
+ prerelease: false
74
+ requirement: &id006 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: "0"
80
+ type: :development
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: test_declarative
84
+ prerelease: false
85
+ requirement: &id007 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: "0"
91
+ type: :development
92
+ version_requirements: *id007
50
93
  description: Sane library for manipulating HTTP messages.
51
- email: alex@kernul.com
94
+ email:
95
+ - alex@kernul.com
52
96
  executables: []
53
97
 
54
98
  extensions: []
@@ -56,19 +100,52 @@ extensions: []
56
100
  extra_rdoc_files: []
57
101
 
58
102
  files:
103
+ - .gitignore
104
+ - .travis.yml
105
+ - .yardopts
106
+ - Gemfile
107
+ - Guardfile
108
+ - LICENSE
109
+ - README.md
110
+ - Rakefile
111
+ - lib/webbed.rb
59
112
  - lib/webbed/generic_message.rb
60
113
  - lib/webbed/headers.rb
114
+ - lib/webbed/helpers/entity_headers_helper.rb
115
+ - lib/webbed/helpers/method_helper.rb
116
+ - lib/webbed/helpers/rack_request_helper.rb
117
+ - lib/webbed/helpers/rack_response_helper.rb
118
+ - lib/webbed/helpers/request_headers_helper.rb
119
+ - lib/webbed/helpers/request_uri_helper.rb
120
+ - lib/webbed/helpers/response_headers_helper.rb
121
+ - lib/webbed/helpers/scheme_helper.rb
61
122
  - lib/webbed/http_version.rb
123
+ - lib/webbed/media_type.rb
62
124
  - lib/webbed/method.rb
63
125
  - lib/webbed/request.rb
64
126
  - lib/webbed/response.rb
65
127
  - lib/webbed/status_code.rb
66
128
  - lib/webbed/version.rb
67
- - lib/webbed.rb
68
- - LICENSE
69
- - README.md
70
- - Rakefile
71
- - Gemfile
129
+ - test/support/assertions.rb
130
+ - test/support/runner.rb
131
+ - test/test_helper.rb
132
+ - test/webbed/generic_message_test.rb
133
+ - test/webbed/headers_test.rb
134
+ - test/webbed/helpers/entity_headers_helper_test.rb
135
+ - test/webbed/helpers/method_helper_test.rb
136
+ - test/webbed/helpers/rack_request_helper_test.rb
137
+ - test/webbed/helpers/rack_response_helper_test.rb
138
+ - test/webbed/helpers/request_headers_helper_test.rb
139
+ - test/webbed/helpers/request_uri_helper_test.rb
140
+ - test/webbed/helpers/response_headers_helper_test.rb
141
+ - test/webbed/helpers/scheme_helper_test.rb
142
+ - test/webbed/http_version_test.rb
143
+ - test/webbed/media_type_test.rb
144
+ - test/webbed/method_test.rb
145
+ - test/webbed/request_test.rb
146
+ - test/webbed/response_test.rb
147
+ - test/webbed/status_code_test.rb
148
+ - webbed.gemspec
72
149
  has_rdoc: true
73
150
  homepage: http://github.com/CapnKernul/webbed
74
151
  licenses: []
@@ -83,27 +160,37 @@ required_ruby_version: !ruby/object:Gem::Requirement
83
160
  requirements:
84
161
  - - ">="
85
162
  - !ruby/object:Gem::Version
86
- hash: 57
87
- segments:
88
- - 1
89
- - 8
90
- - 7
91
- version: 1.8.7
163
+ version: "0"
92
164
  required_rubygems_version: !ruby/object:Gem::Requirement
93
165
  none: false
94
166
  requirements:
95
167
  - - ">="
96
168
  - !ruby/object:Gem::Version
97
- hash: 3
98
- segments:
99
- - 0
100
169
  version: "0"
101
170
  requirements: []
102
171
 
103
172
  rubyforge_project: webbed
104
- rubygems_version: 1.3.7
173
+ rubygems_version: 1.6.2
105
174
  signing_key:
106
175
  specification_version: 3
107
176
  summary: Take control of HTTP.
108
- test_files: []
109
-
177
+ test_files:
178
+ - test/support/assertions.rb
179
+ - test/support/runner.rb
180
+ - test/test_helper.rb
181
+ - test/webbed/generic_message_test.rb
182
+ - test/webbed/headers_test.rb
183
+ - test/webbed/helpers/entity_headers_helper_test.rb
184
+ - test/webbed/helpers/method_helper_test.rb
185
+ - test/webbed/helpers/rack_request_helper_test.rb
186
+ - test/webbed/helpers/rack_response_helper_test.rb
187
+ - test/webbed/helpers/request_headers_helper_test.rb
188
+ - test/webbed/helpers/request_uri_helper_test.rb
189
+ - test/webbed/helpers/response_headers_helper_test.rb
190
+ - test/webbed/helpers/scheme_helper_test.rb
191
+ - test/webbed/http_version_test.rb
192
+ - test/webbed/media_type_test.rb
193
+ - test/webbed/method_test.rb
194
+ - test/webbed/request_test.rb
195
+ - test/webbed/response_test.rb
196
+ - test/webbed/status_code_test.rb