strelka 0.0.1.pre.216 → 0.0.1.pre.219

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data.tar.gz.sig CHANGED
Binary file
@@ -168,27 +168,34 @@ module Strelka::App::Errors
168
168
 
169
169
  # If the app or any plugins threw a finish, look for a handler for the status code
170
170
  # and call it if one is found.
171
- if status_response
172
- request.notes[:status_info] = status_response
173
- response = request.response
174
- status = status_response[:status]
175
- self.log.info "[:errors] Handling a status response: %d" % [ status ]
176
-
177
- # If we can't find a custom handler for this status, re-throw
178
- # to the default handler instead
179
- handler = self.status_handler_for( status ) or
180
- throw( :finish, status_response )
181
-
182
- # The handler is an UnboundMethod, so bind it to the app instance
183
- # and call it
184
- response.status = status
185
- response = handler.bind( self ).call( response, status_response )
186
- end
171
+ response = self.handle_status_response( request, status_response ) if status_response
187
172
 
188
173
  return response
189
174
  end
190
175
 
191
176
 
177
+ ### Return a response built out of the +status_info+ for the specified +request+ if there
178
+ ### is a custom handler. If there isn't one, rethrows to the main :finish handler.
179
+ def handle_status_response( request, status_info )
180
+ status = status_info[:status]
181
+
182
+ # If we can't find a custom handler for this status, re-throw
183
+ # to the default handler instead
184
+ handler = self.status_handler_for( status ) or
185
+ throw( :finish, status_info )
186
+ self.log.info "Using custom handler %p for status response: %d: %s" % [ handler, status, status_info ]
187
+
188
+ # Set up the request's response with the right status code
189
+ request.notes[:status_info] = status_info
190
+ response = request.response
191
+ response.status = status
192
+
193
+ # The handler is an UnboundMethod, so bind it to the app instance
194
+ # and call it
195
+ return handler.bind( self ).call( response, status_info )
196
+ end
197
+
198
+
192
199
  ### Find a status handler for the given +status_code+ and return it as an UnboundMethod.
193
200
  def status_handler_for( status_code )
194
201
  self.log.debug "[:errors] Looking for a status handler for %d responses" % [ status_code ]
@@ -149,8 +149,8 @@ module Strelka::App::Templating
149
149
  # The map of template names to Inversion::Template instances.
150
150
  attr_reader :template_map
151
151
 
152
- # The layout template (an Inversion::Template), if one was declarted
153
- attr_reader :layout
152
+ # The layout template (an Inversion::Template), if one was declared
153
+ attr_accessor :layout
154
154
 
155
155
 
156
156
  ### Return the template keyed by the given +name+.
@@ -374,6 +374,11 @@ module Strelka
374
374
  }
375
375
  end
376
376
 
377
+ # Log using the instance logger if possible, else use the global one
378
+ logger = self.respond_to?( :log ) ? self.log : Strelka.log
379
+ logmethod = status_info[:status] > 399 ? logger.method(:error) : logger.method(:info)
380
+ logmethod.call "Finishing with status %d: %s" % [ status_info[:status], status_info[:message] ]
381
+
377
382
  throw :finish, status_info
378
383
  end
379
384
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strelka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.pre.216
4
+ version: 0.0.1.pre.219
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -36,7 +36,7 @@ cert_chain:
36
36
  YUhDS0xaZFNLai9SSHVUT3QrZ2JsUmV4OEZBaDhOZUEKY21saFhlNDZwWk5K
37
37
  Z1dLYnhaYWg4NWpJang5NWhSOHZPSStOQU01aUg5a09xSzEzRHJ4YWNUS1Bo
38
38
  cWo1UGp3RgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
39
- date: 2012-05-03 00:00:00.000000000 Z
39
+ date: 2012-05-04 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: trollop
metadata.gz.sig CHANGED
Binary file