mongrel2 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,9 @@
1
+ == v0.9.0 [2011-10-12] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ - Fix Mongrel2::Table not duping/cloning its internal values.
4
+ - Set a default Content-type header in HTTP responses
5
+
6
+
1
7
  == v0.8.0 [2011-10-12] Michael Granger <ged@FaerieMUD.org>
2
8
 
3
9
  - Split out the normalization of HTTP response headers into two
@@ -14,10 +14,10 @@ module Mongrel2
14
14
  abort "\n\n>>> Mongrel2 requires Ruby 1.9.2 or later. <<<\n\n" if RUBY_VERSION < '1.9.2'
15
15
 
16
16
  # Library version constant
17
- VERSION = '0.8.0'
17
+ VERSION = '0.9.0'
18
18
 
19
19
  # Version-control revision constant
20
- REVISION = %q$Revision: 986182bd469e $
20
+ REVISION = %q$Revision: 180ebbaeb4a0 $
21
21
 
22
22
 
23
23
  require 'mongrel2/logging'
@@ -153,6 +153,7 @@ class Mongrel2::HTTPResponse < Mongrel2::Response
153
153
 
154
154
  headers[:date] ||= Time.now.httpdate
155
155
  headers[:content_length] ||= self.get_content_length
156
+ headers[:content_type] ||= DEFAULT_CONTENT_TYPE
156
157
 
157
158
  return headers
158
159
  end
@@ -50,8 +50,28 @@ class Mongrel2::Table
50
50
 
51
51
 
52
52
  ### Make sure the inner Hash is unique on duplications.
53
- def initialize_copy( orig_table ) # :nodoc:
54
- @hash = orig_table.to_hash
53
+ def initialize_dup( * ) # :nodoc:
54
+ @hash = @hash.dup
55
+ @hash.each do |k, v|
56
+ if v.is_a?( Array )
57
+ @hash[ k ] = v.map( &:dup )
58
+ else
59
+ @hash[ k ] = v.dup
60
+ end
61
+ end
62
+ end
63
+
64
+
65
+ ### Make sure the inner Hash is unique on clones.
66
+ def initialize_clone( * ) # :nodoc:
67
+ @hash = @hash.clone
68
+ @hash.each do |k, v|
69
+ if v.is_a?( Array )
70
+ @hash[ k ] = v.map( &:clone )
71
+ else
72
+ @hash[ k ] = v.clone
73
+ end
74
+ end
55
75
  end
56
76
 
57
77
 
@@ -31,7 +31,7 @@ describe Mongrel2::HTTPResponse do
31
31
  end
32
32
 
33
33
  before( :each ) do
34
- @response = Mongrel2::HTTPResponse.new( TEST_UUID, 299, :content_type => 'text/html' )
34
+ @response = Mongrel2::HTTPResponse.new( TEST_UUID, 299 )
35
35
  end
36
36
 
37
37
  after( :all ) do
@@ -44,16 +44,18 @@ describe Mongrel2::HTTPResponse do
44
44
  end
45
45
 
46
46
  it "allows headers to be set when the response is created" do
47
- @response.headers.content_type.should == 'text/html'
47
+ response = Mongrel2::HTTPResponse.new( TEST_UUID, 299, :content_type => 'image/jpeg' )
48
+ response.headers.content_type.should == 'image/jpeg'
48
49
  end
49
50
 
50
51
  it "is a No Content response if not set otherwise" do
51
52
  @response.status_line.should == 'HTTP/1.1 204 No Content'
52
53
  end
53
54
 
54
- it "sets Date and Content-length headers automatically if they haven't been set" do
55
+ it "sets Date, Content-type, and Content-length headers automatically if they haven't been set" do
55
56
  @response << "Some stuff."
56
57
 
58
+ @response.header_data.should =~ %r{Content-type: #{Mongrel2::HTTPResponse::DEFAULT_CONTENT_TYPE}}i
57
59
  @response.header_data.should =~ /Content-length: 11/i
58
60
  @response.header_data.should =~ /Date: #{HTTP_DATE}/i
59
61
  end
@@ -68,10 +70,6 @@ describe Mongrel2::HTTPResponse do
68
70
  @response.body.should be_empty()
69
71
  end
70
72
 
71
- it "knows it hasn't been handled" do
72
- @response.should_not be_handled()
73
- end
74
-
75
73
  it "stringifies to a valid RFC2616 response string" do
76
74
  @response.to_s.should =~ HTTP_RESPONSE
77
75
  end
@@ -128,14 +126,15 @@ describe Mongrel2::HTTPResponse do
128
126
  @response.get_content_length.should == length - 100
129
127
  end
130
128
 
131
- it "knows that it has been handled even if the status is set to NOT_FOUND" do
132
- @response.status = HTTP::NOT_FOUND
129
+ it "knows whether or not it has been handled" do
130
+ @response.should_not be_handled()
131
+ @response.status = HTTP::OK
133
132
  @response.should be_handled()
134
133
  end
135
134
 
136
- it "knows if it has not yet been handled" do
137
- @response.should_not be_handled()
138
- @response.status = HTTP::OK
135
+ it "knows that it has been handled even if the status is set to NOT_FOUND" do
136
+ @response.reset
137
+ @response.status = HTTP::NOT_FOUND
139
138
  @response.should be_handled()
140
139
  end
141
140
 
@@ -185,25 +184,14 @@ describe Mongrel2::HTTPResponse do
185
184
 
186
185
 
187
186
  it "knows what the response content type is" do
188
- headers = mock( 'headers' )
189
- @response.stub!( :headers ).and_return( headers )
190
-
191
- headers.should_receive( :[] ).
192
- with( :content_type ).
193
- and_return( 'text/erotica' )
194
-
187
+ @response.headers['Content-Type'] = 'text/erotica'
195
188
  @response.content_type.should == 'text/erotica'
196
189
  end
197
190
 
198
191
 
199
192
  it "can modify the response content type" do
200
- headers = mock( 'headers' )
201
- @response.stub!( :headers ).and_return( headers )
202
-
203
- headers.should_receive( :[]= ).
204
- with( :content_type, 'image/nude' )
205
-
206
193
  @response.content_type = 'image/nude'
194
+ @response.headers['Content-Type'].should == 'image/nude'
207
195
  end
208
196
 
209
197
 
@@ -133,11 +133,17 @@ describe Mongrel2::Table do
133
133
 
134
134
 
135
135
  it "dupes its inner hash when duped" do
136
- newtable = @table.dup
136
+ @table['foom'] = 'a string'
137
+ @table['frong'] = %w[eenie meenie mynie moe]
137
138
 
139
+ newtable = @table.dup
138
140
  newtable['idkfa'] = 'god'
141
+ newtable[:foom] << " and another string"
142
+ newtable[:frong][3].replace( "mississipi" )
143
+
139
144
  @table.should_not include( 'idkfa' )
140
- @table.should be_empty()
145
+ @table[:foom].should == 'a string'
146
+ @table[:frong][3].should == 'moe'
141
147
  end
142
148
 
143
149
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongrel2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -52,7 +52,7 @@ date: 2011-10-12 00:00:00.000000000Z
52
52
  dependencies:
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: nokogiri
55
- requirement: &70231616719680 !ruby/object:Gem::Requirement
55
+ requirement: &70233021488600 !ruby/object:Gem::Requirement
56
56
  none: false
57
57
  requirements:
58
58
  - - ~>
@@ -60,10 +60,10 @@ dependencies:
60
60
  version: '1.5'
61
61
  type: :runtime
62
62
  prerelease: false
63
- version_requirements: *70231616719680
63
+ version_requirements: *70233021488600
64
64
  - !ruby/object:Gem::Dependency
65
65
  name: sequel
66
- requirement: &70231616719240 !ruby/object:Gem::Requirement
66
+ requirement: &70233021487960 !ruby/object:Gem::Requirement
67
67
  none: false
68
68
  requirements:
69
69
  - - ~>
@@ -71,10 +71,10 @@ dependencies:
71
71
  version: '3.26'
72
72
  type: :runtime
73
73
  prerelease: false
74
- version_requirements: *70231616719240
74
+ version_requirements: *70233021487960
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: amalgalite
77
- requirement: &70231616718820 !ruby/object:Gem::Requirement
77
+ requirement: &70233021487340 !ruby/object:Gem::Requirement
78
78
  none: false
79
79
  requirements:
80
80
  - - ~>
@@ -82,10 +82,10 @@ dependencies:
82
82
  version: '1.1'
83
83
  type: :runtime
84
84
  prerelease: false
85
- version_requirements: *70231616718820
85
+ version_requirements: *70233021487340
86
86
  - !ruby/object:Gem::Dependency
87
87
  name: tnetstring
88
- requirement: &70231616718300 !ruby/object:Gem::Requirement
88
+ requirement: &70233021486780 !ruby/object:Gem::Requirement
89
89
  none: false
90
90
  requirements:
91
91
  - - ~>
@@ -93,10 +93,10 @@ dependencies:
93
93
  version: '0.3'
94
94
  type: :runtime
95
95
  prerelease: false
96
- version_requirements: *70231616718300
96
+ version_requirements: *70233021486780
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: yajl-ruby
99
- requirement: &70231616717720 !ruby/object:Gem::Requirement
99
+ requirement: &70233021486140 !ruby/object:Gem::Requirement
100
100
  none: false
101
101
  requirements:
102
102
  - - ~>
@@ -104,10 +104,10 @@ dependencies:
104
104
  version: '0.8'
105
105
  type: :runtime
106
106
  prerelease: false
107
- version_requirements: *70231616717720
107
+ version_requirements: *70233021486140
108
108
  - !ruby/object:Gem::Dependency
109
109
  name: zmq
110
- requirement: &70231616717260 !ruby/object:Gem::Requirement
110
+ requirement: &70233021485440 !ruby/object:Gem::Requirement
111
111
  none: false
112
112
  requirements:
113
113
  - - ~>
@@ -115,10 +115,10 @@ dependencies:
115
115
  version: 2.1.4
116
116
  type: :runtime
117
117
  prerelease: false
118
- version_requirements: *70231616717260
118
+ version_requirements: *70233021485440
119
119
  - !ruby/object:Gem::Dependency
120
120
  name: hoe-mercurial
121
- requirement: &70231616716720 !ruby/object:Gem::Requirement
121
+ requirement: &70233021484760 !ruby/object:Gem::Requirement
122
122
  none: false
123
123
  requirements:
124
124
  - - ~>
@@ -126,10 +126,10 @@ dependencies:
126
126
  version: 1.3.1
127
127
  type: :development
128
128
  prerelease: false
129
- version_requirements: *70231616716720
129
+ version_requirements: *70233021484760
130
130
  - !ruby/object:Gem::Dependency
131
131
  name: hoe-highline
132
- requirement: &70231616716140 !ruby/object:Gem::Requirement
132
+ requirement: &70233021484020 !ruby/object:Gem::Requirement
133
133
  none: false
134
134
  requirements:
135
135
  - - ~>
@@ -137,10 +137,10 @@ dependencies:
137
137
  version: 0.0.1
138
138
  type: :development
139
139
  prerelease: false
140
- version_requirements: *70231616716140
140
+ version_requirements: *70233021484020
141
141
  - !ruby/object:Gem::Dependency
142
142
  name: configurability
143
- requirement: &70231616715540 !ruby/object:Gem::Requirement
143
+ requirement: &70233021483100 !ruby/object:Gem::Requirement
144
144
  none: false
145
145
  requirements:
146
146
  - - ~>
@@ -148,10 +148,10 @@ dependencies:
148
148
  version: '1.0'
149
149
  type: :development
150
150
  prerelease: false
151
- version_requirements: *70231616715540
151
+ version_requirements: *70233021483100
152
152
  - !ruby/object:Gem::Dependency
153
153
  name: rspec
154
- requirement: &70231616715060 !ruby/object:Gem::Requirement
154
+ requirement: &70233021482360 !ruby/object:Gem::Requirement
155
155
  none: false
156
156
  requirements:
157
157
  - - ~>
@@ -159,10 +159,10 @@ dependencies:
159
159
  version: '2.4'
160
160
  type: :development
161
161
  prerelease: false
162
- version_requirements: *70231616715060
162
+ version_requirements: *70233021482360
163
163
  - !ruby/object:Gem::Dependency
164
164
  name: hoe
165
- requirement: &70231616714540 !ruby/object:Gem::Requirement
165
+ requirement: &70233021481580 !ruby/object:Gem::Requirement
166
166
  none: false
167
167
  requirements:
168
168
  - - ~>
@@ -170,7 +170,7 @@ dependencies:
170
170
  version: '2.12'
171
171
  type: :development
172
172
  prerelease: false
173
- version_requirements: *70231616714540
173
+ version_requirements: *70233021481580
174
174
  description: ! "Ruby-Mongrel2 is a complete Ruby (1.9-only) connector for \nMongrel2[http://mongrel2.org/].\n\nThis
175
175
  library includes configuration-database ORM classes, a Ruby\nimplementation of the
176
176
  'm2sh' tool, a configuration DSL for generating config\ndatabases in pure Ruby,
metadata.gz.sig CHANGED
@@ -1 +1 @@
1
- =��>zM��G&+�!U��.
1
+ h�8ޑ5�Y�{潍u�W㍡{tزܞ�{���:�HQ�� ��I8� ���u��A��H�\� 4w���|� h��gFA��H�[>ݤ�J�Q)%���8*�H�+Ba������LEJM�Sg��=��0Ӓ�/B��=�ǑK��"�����:�l�ӝ�����0=��cl�i]��BK\a��W���D�}U�!�������O0�zt�H�i��%'��C*�p �������u^Q�u