strelka 0.0.1.pre.224 → 0.0.1.pre.229

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
data/ChangeLog CHANGED
@@ -1,10 +1,124 @@
1
+ 2012-05-09 Michael Granger <ged@FaerieMUD.org>
2
+
3
+ * lib/strelka/cookieset.rb, spec/strelka/cookieset_spec.rb:
4
+ Add delegation for some more Set methods to CookieSet
5
+ [c88faf6871e7] [tip]
6
+
7
+ 2012-05-08 Michael Granger <ged@FaerieMUD.org>
8
+
9
+ * .rvm.gems, Rakefile, lib/strelka/app.rb, lib/strelka/app/auth.rb,
10
+ lib/strelka/app/negotiation.rb, lib/strelka/app/parameters.rb,
11
+ lib/strelka/app/restresources.rb, lib/strelka/app/routing.rb,
12
+ lib/strelka/app/sessions.rb, lib/strelka/authprovider/basic.rb,
13
+ lib/strelka/cookie.rb, lib/strelka/cookieset.rb,
14
+ lib/strelka/plugins.rb, lib/strelka/session/db.rb,
15
+ lib/strelka/session/default.rb, spec/lib/helpers.rb,
16
+ spec/strelka/app/filters_spec.rb,
17
+ spec/strelka/app/restresources_spec.rb,
18
+ spec/strelka/app/routing_spec.rb, spec/strelka/app/sessions_spec.rb,
19
+ spec/strelka/httprequest/session_spec.rb:
20
+ Convert class-/module-level logging to Loggability API.
21
+ [751512af4f1f]
22
+
23
+ 2012-05-07 Mahlon E. Smith <mahlon@martini.nu>
24
+
25
+ * lib/strelka/app/templating.rb:
26
+ Provide access to the request during layout template wrapping, so
27
+ handlers can potentially override the method and attach arbitrary
28
+ request attributes to the layout.
29
+ [1fc0cf040a1e] [github/master]
30
+
31
+ 2012-05-07 Michael Granger <ged@FaerieMUD.org>
32
+
33
+ * spec/lib/helpers.rb:
34
+ Removed some leftover logging code from pre-Loggability.
35
+ [60fdf52af868]
36
+
37
+ 2012-05-07 Mahlon E. Smith <mahlon@martini.nu>
38
+
39
+ * lib/strelka/httprequest.rb, spec/strelka/httprequest_spec.rb:
40
+ Add a simple shortcut method for URI redirection.
41
+ [eb22b0f1372c]
42
+
43
+ * lib/strelka/httprequest/session.rb,
44
+ spec/strelka/httprequest/session_spec.rb:
45
+ Add a method to completely purge a session, from the request object.
46
+ [b8ed17e550e2]
47
+
48
+ 2012-05-07 Michael Granger <ged@FaerieMUD.org>
49
+
50
+ * lib/strelka/app.rb:
51
+ Move Strelka::App.devmode? above ::configure.
52
+
53
+ This is required when the App config is loaded by the deferred
54
+ loader.
55
+ [09e467f68dca]
56
+
57
+ * .rvm.gems, Rakefile, bin/strelka, lib/strelka.rb,
58
+ lib/strelka/app.rb, lib/strelka/app/auth.rb,
59
+ lib/strelka/app/routing.rb, lib/strelka/app/sessions.rb,
60
+ lib/strelka/authprovider.rb, lib/strelka/authprovider/basic.rb,
61
+ lib/strelka/authprovider/hostaccess.rb, lib/strelka/cookie.rb,
62
+ lib/strelka/httprequest.rb, lib/strelka/httprequest/acceptparams.rb,
63
+ lib/strelka/httpresponse.rb, lib/strelka/mixins.rb,
64
+ lib/strelka/paramvalidator.rb, lib/strelka/router.rb,
65
+ lib/strelka/router/default.rb, lib/strelka/router/exclusive.rb,
66
+ lib/strelka/session.rb, lib/strelka/session/db.rb,
67
+ lib/strelka/session/default.rb, spec/lib/helpers.rb,
68
+ spec/strelka/mixins_spec.rb:
69
+ Convert to Loggability for logging.
70
+ [4f0cbd7b3070]
71
+
72
+ 2012-05-03 Michael Granger <ged@FaerieMUD.org>
73
+
74
+ * bin/strelka:
75
+ Run started apps directly instead of counting on the app to run
76
+ itself
77
+ [7a2694d364b3]
78
+
79
+ * lib/strelka/app/errors.rb:
80
+ Extract a method from the status response part of the :errors
81
+ plugin.
82
+ [2b827b37bae5]
83
+
84
+ * lib/strelka/app/templating.rb:
85
+ Make the #layout method an accessor in the :templating plugin
86
+ [b3dc560d0863]
87
+
88
+ * lib/strelka/mixins.rb:
89
+ Log uses of finish_with
90
+ [01cd0a6edde9]
91
+
92
+ * MILESTONES.rdoc:
93
+ Add another task to MILESTONES
94
+ [22e60aaebaea]
95
+
96
+ * .rvm.gems, MILESTONES.rdoc, README.rdoc, lib/strelka.rb,
97
+ lib/strelka/app.rb, lib/strelka/app/templating.rb,
98
+ lib/strelka/httprequest/acceptparams.rb:
99
+ Add some documentation
100
+ [5bd05add55ad]
101
+
102
+ 2012-05-02 Michael Granger <ged@FaerieMUD.org>
103
+
104
+ * MILESTONES.rdoc, Manifest.txt:
105
+ Adding a MILESTONES file.
106
+
107
+ We'll use this as a checklist of what needs to be done for the next
108
+ release.
109
+ [d8e74e3bf97b]
110
+
111
+ * lib/strelka/logging.rb:
112
+ Change fatal output color to be more readable
113
+ [403cf0ef01f0]
114
+
1
115
  2012-04-25 Michael Granger <ged@FaerieMUD.org>
2
116
 
3
117
  * lib/strelka/app.rb, lib/strelka/plugins.rb,
4
118
  spec/strelka/httpresponse/negotiation_spec.rb,
5
119
  spec/strelka/plugins_spec.rb:
6
120
  Add an #application_stack method to the PluginLoader mixin
7
- [7427a74ae313] [tip]
121
+ [7427a74ae313]
8
122
 
9
123
  * lib/strelka/app.rb, spec/strelka/app_spec.rb:
10
124
  Add configurable ::devmode? setting to Strelka::App
@@ -28,7 +142,7 @@
28
142
 
29
143
  * lib/strelka/app/templating.rb, spec/strelka/app/templating_spec.rb:
30
144
  Refactored on of the big methods in :templating.
31
- [f933118fb9db] [github/master]
145
+ [f933118fb9db]
32
146
 
33
147
  2012-04-23 Michael Granger <ged@FaerieMUD.org>
34
148
 
data/Rakefile CHANGED
@@ -27,11 +27,11 @@ hoespec = Hoe.spec 'strelka' do
27
27
  self.dependency 'sysexits', '~> 1.0'
28
28
  self.dependency 'formvalidator', '~> 0.1'
29
29
  self.dependency 'inversion', '~> 0.8'
30
- self.dependency 'mongrel2', '~> 0.20'
30
+ self.dependency 'mongrel2', '~> 0.22'
31
31
  self.dependency 'uuidtools', '~> 2.1'
32
32
  self.dependency 'configurability', '~> 1.0'
33
33
  self.dependency 'pluginfactory', '~> 1.0'
34
- self.dependency 'loggability', '~> 0.0'
34
+ self.dependency 'loggability', '~> 0.1'
35
35
 
36
36
  self.dependency 'hoe-deveiate', '~> 0.1', :developer
37
37
  self.dependency 'hoe-manualgen', '~> 0.3', :developer
data/lib/strelka/app.rb CHANGED
@@ -73,16 +73,16 @@ class Strelka::App < Mongrel2::Handler
73
73
  ### Calculate a default application ID for the class based on either its ID
74
74
  ### constant or its name and return it.
75
75
  def self::default_appid
76
- Strelka.log.info "Looking up appid for %p" % [ self.class ]
76
+ self.log.info "Looking up appid for %p" % [ self.class ]
77
77
  appid = nil
78
78
 
79
79
  if self.const_defined?( :ID )
80
80
  appid = self.const_get( :ID )
81
- Strelka.log.info " app has an ID: %p" % [ appid ]
81
+ self.log.info " app has an ID: %p" % [ appid ]
82
82
  else
83
83
  appid = ( self.name || "anonymous#{self.object_id}" ).downcase
84
84
  appid.gsub!( /[^[:alnum:]]+/, '-' )
85
- Strelka.log.info " deriving one from the class name: %p" % [ appid ]
85
+ self.log.info " deriving one from the class name: %p" % [ appid ]
86
86
  end
87
87
 
88
88
  return appid
@@ -92,7 +92,7 @@ class Strelka::App < Mongrel2::Handler
92
92
  ### Return a Hash of Strelka app files as Pathname objects from installed gems,
93
93
  ### keyed by gemspec name .
94
94
  def self::discover_paths
95
- Strelka.log.debug "Local paths: %s" % [ Strelka.datadir + APP_GLOB_PATTERN ]
95
+ self.log.debug "Local paths: %s" % [ Strelka.datadir + APP_GLOB_PATTERN ]
96
96
 
97
97
  appfiles = {
98
98
  '' => Pathname.glob( Strelka.datadir + APP_GLOB_PATTERN )
@@ -103,7 +103,7 @@ class Strelka::App < Mongrel2::Handler
103
103
  gemspec.dependencies.find {|dep| dep.name == 'strelka'}
104
104
  end
105
105
 
106
- Strelka.log.debug "Found %d gems with a Strelka dependency" % [ gems.length ]
106
+ self.log.debug "Found %d gems with a Strelka dependency" % [ gems.length ]
107
107
 
108
108
  # Find all the files under those gems' data directories that match the application
109
109
  # pattern
@@ -112,11 +112,11 @@ class Strelka::App < Mongrel2::Handler
112
112
  next if appfiles.key?( gemspec.name )
113
113
  appfiles[ gemspec.name ] = []
114
114
 
115
- Strelka.log.debug " checking %s for apps in its datadir" % [ gemspec.name ]
115
+ self.log.debug " checking %s for apps in its datadir" % [ gemspec.name ]
116
116
  pattern = File.join( gemspec.full_gem_path, "data", gemspec.name, APP_GLOB_PATTERN )
117
- Strelka.log.debug " glob pattern is: %p" % [ pattern ]
117
+ self.log.debug " glob pattern is: %p" % [ pattern ]
118
118
  gemapps = Pathname.glob( pattern )
119
- Strelka.log.debug " found %d app files" % [ gemapps.length ]
119
+ self.log.debug " found %d app files" % [ gemapps.length ]
120
120
  appfiles[ gemspec.name ] += gemapps
121
121
  end
122
122
 
@@ -129,22 +129,22 @@ class Strelka::App < Mongrel2::Handler
129
129
  discovered_apps = []
130
130
  app_paths = self.discover_paths
131
131
 
132
- Strelka.log.debug "Loading apps from %d discovered paths" % [ app_paths.length ]
132
+ self.log.debug "Loading apps from %d discovered paths" % [ app_paths.length ]
133
133
  app_paths.each do |gemname, paths|
134
- Strelka.log.debug " loading gem %s" % [ gemname ]
134
+ self.log.debug " loading gem %s" % [ gemname ]
135
135
  gem( gemname ) unless gemname == ''
136
136
 
137
- Strelka.log.debug " loading apps from %s: %d handlers" % [ gemname, paths.length ]
137
+ self.log.debug " loading apps from %s: %d handlers" % [ gemname, paths.length ]
138
138
  paths.each do |path|
139
139
  classes = begin
140
140
  Strelka::App.load( path )
141
141
  rescue StandardError, ScriptError => err
142
- Strelka.log.error "%p while loading Strelka apps from %s: %s" %
142
+ self.log.error "%p while loading Strelka apps from %s: %s" %
143
143
  [ err.class, path, err.message ]
144
- Strelka.log.debug "Backtrace: %s" % [ err.backtrace.join("\n\t") ]
144
+ self.log.debug "Backtrace: %s" % [ err.backtrace.join("\n\t") ]
145
145
  []
146
146
  end
147
- Strelka.log.debug " loaded app classes: %p" % [ classes ]
147
+ self.log.debug " loaded app classes: %p" % [ classes ]
148
148
 
149
149
  discovered_apps += classes
150
150
  end
@@ -157,12 +157,12 @@ class Strelka::App < Mongrel2::Handler
157
157
  ### Load the specified +file+, and return any Strelka::App subclasses that are loaded
158
158
  ### as a result.
159
159
  def self::load( file )
160
- Strelka.log.debug "Loading application/s from %p" % [ file ]
160
+ self.log.debug "Loading application/s from %p" % [ file ]
161
161
  @loading_file = Pathname( file ).expand_path
162
162
  self.subclasses.delete( @loading_file )
163
163
  Kernel.load( @loading_file.to_s )
164
164
  new_subclasses = self.subclasses[ @loading_file ]
165
- Strelka.log.debug " loaded %d new app class/es" % [ new_subclasses.size ]
165
+ self.log.debug " loaded %d new app class/es" % [ new_subclasses.size ]
166
166
 
167
167
  return new_subclasses
168
168
  ensure
@@ -189,7 +189,7 @@ class Strelka::App < Mongrel2::Handler
189
189
  self.devmode = $DEBUG ? true : false
190
190
  end
191
191
 
192
- Strelka.log.info "Enabled developer mode." if self.devmode?
192
+ self.log.info "Enabled developer mode." if self.devmode?
193
193
  end
194
194
 
195
195
 
@@ -286,9 +286,9 @@ module Strelka::App::Auth
286
286
  @auth_provider = Strelka::AuthProvider.get_subclass( type )
287
287
  end
288
288
 
289
- Strelka.log.debug "Auth provider %p" % [ @auth_provider ]
289
+ self.log.debug "Auth provider %p" % [ @auth_provider ]
290
290
  @auth_provider ||= Strelka::AuthProvider.get_subclass( DEFAULT_AUTH_PROVIDER )
291
- Strelka.log.debug "Auth provider %p" % [ @auth_provider ]
291
+ self.log.debug "Auth provider %p" % [ @auth_provider ]
292
292
  return @auth_provider
293
293
  end
294
294
 
@@ -350,7 +350,7 @@ module Strelka::App::Auth
350
350
 
351
351
  criteria.each do |pattern|
352
352
  pattern.gsub!( %r{^/+|/+$}, '' ) if pattern.respond_to?( :gsub! )
353
- Strelka.log.debug " adding require_auth for %p" % [ pattern ]
353
+ self.log.debug " adding require_auth for %p" % [ pattern ]
354
354
  self.positive_auth_criteria[ pattern ] = block
355
355
  end
356
356
  end
@@ -369,7 +369,7 @@ module Strelka::App::Auth
369
369
 
370
370
  criteria.each do |pattern|
371
371
  pattern.gsub!( %r{^/+|/+$}, '' ) if pattern.respond_to?( :gsub! )
372
- Strelka.log.debug " adding no_auth for %p" % [ pattern ]
372
+ self.log.debug " adding no_auth for %p" % [ pattern ]
373
373
  self.negative_auth_criteria[ pattern ] = block
374
374
  end
375
375
  end
@@ -381,7 +381,7 @@ module Strelka::App::Auth
381
381
  ### Extension callback -- extend the HTTPRequest class with Auth
382
382
  ### support when this plugin is loaded.
383
383
  def self::included( object )
384
- Strelka.log.debug "Extending Request with Auth mixin"
384
+ self.log.debug "Extending Request with Auth mixin"
385
385
  Strelka::HTTPRequest.class_eval { include Strelka::HTTPRequest::Auth }
386
386
  super
387
387
  end
@@ -82,7 +82,7 @@ module Strelka::App::Negotiation
82
82
  ### Extension callback -- extend the HTTPRequest and HTTPResponse classes with Negotiation
83
83
  ### support when this plugin is loaded.
84
84
  def self::included( object )
85
- Strelka.log.debug "Extending Request and Response with Negotiation mixins"
85
+ self.log.debug "Extending Request and Response with Negotiation mixins"
86
86
  Strelka::HTTPRequest.class_eval { include Strelka::HTTPRequest::Negotiation }
87
87
  Strelka::HTTPResponse.class_eval { include Strelka::HTTPResponse::Negotiation }
88
88
  super
@@ -94,7 +94,7 @@ module Strelka::App::Parameters
94
94
  ### +constraint+. The +constraint+ can be any of the types supported by
95
95
  ### Strelka::ParamValidator.
96
96
  def param( name, *args )
97
- Strelka.log.debug "New param %p" % [ name ]
97
+ self.log.debug "New param %p" % [ name ]
98
98
  self.paramvalidator.add( name, *args )
99
99
  end
100
100
 
@@ -117,7 +117,7 @@ module Strelka::App::RestResources
117
117
  ### Expose the specified +rsrcobj+ (which should be an object that responds to #dataset
118
118
  ### and returns a Sequel::Dataset)
119
119
  def resource( rsrcobj, options={} )
120
- Strelka.log.debug "Adding REST resource for %p" % [ rsrcobj ]
120
+ self.log.debug "Adding REST resource for %p" % [ rsrcobj ]
121
121
  options = self.service_options.merge( options )
122
122
 
123
123
  # Figure out what the resource name is, and make the route from it
@@ -128,7 +128,7 @@ module Strelka::App::RestResources
128
128
  self.add_parameters( rsrcobj, options )
129
129
 
130
130
  # Make and install handler methods
131
- Strelka.log.debug " adding readers"
131
+ self.log.debug " adding readers"
132
132
  self.add_options_handler( route, rsrcobj, options )
133
133
  self.add_read_handler( route, rsrcobj, options )
134
134
  self.add_collection_read_handler( route, rsrcobj, options )
@@ -136,7 +136,7 @@ module Strelka::App::RestResources
136
136
  # Add handler methods for the mutator parts of the API unless
137
137
  # the resource is read-only
138
138
  if options[:readonly]
139
- Strelka.log.debug " skipping mutators (read-only set)"
139
+ self.log.debug " skipping mutators (read-only set)"
140
140
  else
141
141
  self.add_collection_create_handler( route, rsrcobj, options )
142
142
  self.add_update_handler( route, rsrcobj, options )
@@ -152,10 +152,10 @@ module Strelka::App::RestResources
152
152
 
153
153
  ### Add parameter declarations for parameters related to +rsrcobj+.
154
154
  def add_parameters( rsrcobj, options )
155
- Strelka.log.debug "Declaring validations for columns from %p" % [ rsrcobj ]
155
+ self.log.debug "Declaring validations for columns from %p" % [ rsrcobj ]
156
156
  self.untaint_all_constraints
157
157
  rsrcobj.db_schema.each do |col, config|
158
- Strelka.log.debug " %s (%p)" % [ col, config[:type] ]
158
+ self.log.debug " %s (%p)" % [ col, config[:type] ]
159
159
  param col, config[:type]
160
160
  end
161
161
  end
@@ -165,7 +165,7 @@ module Strelka::App::RestResources
165
165
  ### OPTIONS /resources
166
166
  def add_options_handler( route, rsrcobj, options )
167
167
  # :TODO: Documentation for HTML mode (possibly using http://swagger.wordnik.com/)
168
- Strelka.log.debug "Adding OPTIONS handler for %p" % [ route, rsrcobj ]
168
+ self.log.debug "Adding OPTIONS handler for %p" % [ route, rsrcobj ]
169
169
  self.add_route( :OPTIONS, route, options ) do |req|
170
170
  self.log.debug "OPTIONS handler!"
171
171
  verbs = self.class.resource_verbs[ route ].sort
@@ -191,7 +191,7 @@ module Strelka::App::RestResources
191
191
  pkey = rsrcobj.primary_key
192
192
  route = "#{route_prefix}/:#{pkey}"
193
193
 
194
- Strelka.log.debug "Creating handler for reading a single %p: GET %s" % [ rsrcobj, route ]
194
+ self.log.debug "Creating handler for reading a single %p: GET %s" % [ rsrcobj, route ]
195
195
  self.add_route( :GET, route, options ) do |req|
196
196
  finish_with( HTTP::BAD_REQUEST, req.params.error_messages.join("\n") ) unless
197
197
  req.params.okay?
@@ -214,7 +214,7 @@ module Strelka::App::RestResources
214
214
  ### Sequel::Model class or a ducktype-alike.
215
215
  ### GET /resources
216
216
  def add_collection_read_handler( route, rsrcobj, options )
217
- Strelka.log.debug "Creating handler for reading collections of %p: GET %s" % [ rsrcobj, route ]
217
+ self.log.debug "Creating handler for reading collections of %p: GET %s" % [ rsrcobj, route ]
218
218
  self.add_route( :GET, route, options ) do |req|
219
219
  finish_with( HTTP::BAD_REQUEST, req.params.error_messages.join("\n") ) unless
220
220
  req.params.okay?
@@ -241,7 +241,7 @@ module Strelka::App::RestResources
241
241
  ### Add a handler method for creating a new instance of +rsrcobj+.
242
242
  ### POST /resources
243
243
  def add_collection_create_handler( route, rsrcobj, options )
244
- Strelka.log.debug "Creating handler for creating %p resources: POST %s" % [ rsrcobj, route ]
244
+ self.log.debug "Creating handler for creating %p resources: POST %s" % [ rsrcobj, route ]
245
245
 
246
246
  self.add_route( :POST, route, options ) do |req|
247
247
  finish_with( HTTP::BAD_REQUEST, req.params.error_messages.join(", ") ) unless
@@ -279,7 +279,7 @@ module Strelka::App::RestResources
279
279
  pkey = rsrcobj.primary_key
280
280
  route = "#{route_prefix}/:#{pkey}"
281
281
 
282
- Strelka.log.debug "Creating handler for creating %p resources: POST %s" % [ rsrcobj, route ]
282
+ self.log.debug "Creating handler for creating %p resources: POST %s" % [ rsrcobj, route ]
283
283
  self.add_route( :PUT, route, options ) do |req|
284
284
  finish_with( HTTP::BAD_REQUEST, req.params.error_messages.join(", ") ) unless
285
285
  req.params.okay?
@@ -312,7 +312,7 @@ module Strelka::App::RestResources
312
312
  ### PUT /resources
313
313
  def add_collection_update_handler( route, rsrcobj, options )
314
314
  pkey = rsrcobj.primary_key
315
- Strelka.log.debug "Creating handler for updating every %p resources: PUT %s" % [ rsrcobj, route ]
315
+ self.log.debug "Creating handler for updating every %p resources: PUT %s" % [ rsrcobj, route ]
316
316
 
317
317
  self.add_route( :PUT, route, options ) do |req|
318
318
  finish_with( HTTP::BAD_REQUEST, req.params.error_messages.join(", ") ) unless
@@ -379,7 +379,7 @@ module Strelka::App::RestResources
379
379
  ### DELETE /resources
380
380
  def add_collection_deletion_handler( route, rsrcobj, options )
381
381
  pkey = rsrcobj.primary_key
382
- Strelka.log.debug "Creating handler for deleting every %p resources: DELETE %s" %
382
+ self.log.debug "Creating handler for deleting every %p resources: DELETE %s" %
383
383
  [ rsrcobj, route ]
384
384
 
385
385
  self.add_route( :DELETE, route, options ) do |req|
@@ -411,7 +411,7 @@ module Strelka::App::RestResources
411
411
  # :TODO: Support multiple args? (customers/by_city_state/{city}/{state})
412
412
  rsrcobj.dataset_methods.each do |name, proc|
413
413
  if proc.parameters.length > 1
414
- Strelka.log.debug " skipping dataset method %p: more than 1 argument" % [ name ]
414
+ self.log.debug " skipping dataset method %p: more than 1 argument" % [ name ]
415
415
  next
416
416
  end
417
417
 
@@ -420,16 +420,16 @@ module Strelka::App::RestResources
420
420
  # or a parameter-type more gracefully.
421
421
  param = proc.parameters.first[1]
422
422
  route = "%s/%s/:%s" % [ route_prefix, name, param ]
423
- Strelka.log.debug " route for dataset method %s: %s" % [ name, route ]
423
+ self.log.debug " route for dataset method %s: %s" % [ name, route ]
424
424
  self.add_dataset_read_handler( route, rsrcobj, name, param, options )
425
425
  end
426
426
 
427
427
  # Add composite service routes for each association
428
- Strelka.log.debug "Adding composite resource routes for %p" % [ rsrcobj ]
428
+ self.log.debug "Adding composite resource routes for %p" % [ rsrcobj ]
429
429
  rsrcobj.association_reflections.each do |name, refl|
430
430
  pkey = rsrcobj.primary_key
431
431
  route = "%s/:%s/%s" % [ route_prefix, pkey, name ]
432
- Strelka.log.debug " route for associated %p objects via the %s association: %s" %
432
+ self.log.debug " route for associated %p objects via the %s association: %s" %
433
433
  [ refl[:class_name], name, route ]
434
434
  self.add_composite_read_handler( route, rsrcobj, name, options )
435
435
  end
@@ -440,7 +440,7 @@ module Strelka::App::RestResources
440
440
  ### Add a GET route for the dataset method +dsname+ for the given +rsrcobj+ at the
441
441
  ### given +path+.
442
442
  def add_dataset_read_handler( path, rsrcobj, dsname, param, options )
443
- Strelka.log.debug "Adding dataset method read handler: %s" % [ path ]
443
+ self.log.debug "Adding dataset method read handler: %s" % [ path ]
444
444
 
445
445
  self.add_route( :GET, path, options ) do |req|
446
446
  self.log.debug "Resource dataset GET request for dataset %s on %p" % [ dsname, rsrcobj ]
@@ -474,7 +474,7 @@ module Strelka::App::RestResources
474
474
  ### +path+.
475
475
  def add_composite_read_handler( path, rsrcobj, association, options )
476
476
  pkey = rsrcobj.primary_key
477
- Strelka.log.debug "Adding composite read handler for association: %s" % [ association ]
477
+ self.log.debug "Adding composite read handler for association: %s" % [ association ]
478
478
 
479
479
  self.add_route( :GET, path, options ) do |req|
480
480
  finish_with( HTTP::BAD_REQUEST, req.params.error_messages.join("\n") ) unless
@@ -166,7 +166,7 @@ module Strelka::App::Routing
166
166
  ### Get/set the router class to use for mapping requests to handlers to +newclass.
167
167
  def router( newclass=nil )
168
168
  if newclass
169
- Strelka.log.info "%p router class set to: %p" % [ self, newclass ]
169
+ self.log.info "%p router class set to: %p" % [ self, newclass ]
170
170
  self.routerclass = newclass
171
171
  end
172
172
 
@@ -182,7 +182,7 @@ module Strelka::App::Routing
182
182
  # route pattern into its components
183
183
  methodparts = [ verb.upcase ]
184
184
  patternparts = self.split_route_pattern( pattern )
185
- Strelka.log.debug "Split pattern %p into parts: %p" % [ pattern, patternparts ]
185
+ self.log.debug "Split pattern %p into parts: %p" % [ pattern, patternparts ]
186
186
 
187
187
  # Make a method name from the directories and the named captures of the patterns
188
188
  # in the route
@@ -193,11 +193,11 @@ module Strelka::App::Routing
193
193
  methodparts << part
194
194
  end
195
195
  end
196
- Strelka.log.debug " route methodname parts are: %p" % [ methodparts ]
196
+ self.log.debug " route methodname parts are: %p" % [ methodparts ]
197
197
  methodname = methodparts.join( '_' )
198
198
 
199
199
  # Define the method using the block from the route as its body
200
- Strelka.log.debug " adding route method %p for %p route: %p" % [ methodname, verb, block ]
200
+ self.log.debug " adding route method %p for %p route: %p" % [ methodname, verb, block ]
201
201
  define_method( methodname, &block )
202
202
 
203
203
  # Remove any existing route for the same verb, patternparts, and options
@@ -223,7 +223,7 @@ module Strelka::App::Routing
223
223
  return pattern.split( '/' ).collect do |component|
224
224
 
225
225
  if component.start_with?( ':' )
226
- Strelka.log.debug "translating parameter component %p to a regexp" % [component]
226
+ self.log.debug "translating parameter component %p to a regexp" % [component]
227
227
  raise ScriptError,
228
228
  "parameter-based routing not supported without a 'parameters' plugin" unless
229
229
  self.respond_to?( :paramvalidator )
@@ -165,9 +165,9 @@ module Strelka::App::Sessions
165
165
  ### Extension callback -- extend the HTTPRequest classes with Session
166
166
  ### support when this plugin is loaded.
167
167
  def self::included( object )
168
- Strelka.log.debug "Extending Request with Session mixin"
168
+ self.log.debug "Extending Request with Session mixin"
169
169
  Strelka::HTTPRequest.class_eval { include Strelka::HTTPRequest::Session }
170
- Strelka.log.debug "Extending Response with Session mixin"
170
+ self.log.debug "Extending Response with Session mixin"
171
171
  Strelka::HTTPResponse.class_eval { include Strelka::HTTPResponse::Session }
172
172
  super
173
173
  end
@@ -191,7 +191,7 @@ module Strelka::App::Templating
191
191
  return response
192
192
 
193
193
  # Wrap the template in a layout if there is one
194
- template = self.wrap_in_layout( template )
194
+ template = self.wrap_in_layout( template, request )
195
195
 
196
196
  # Set some default stuff on the top-level template
197
197
  self.set_common_attributes( template, request )
@@ -235,7 +235,7 @@ module Strelka::App::Templating
235
235
 
236
236
  ### Wrap the specified +content+ template in the layout template and
237
237
  ### return it. If there isn't a layout declared, just return +content+ as-is.
238
- def wrap_in_layout( content )
238
+ def wrap_in_layout( content, request )
239
239
  return content unless self.layout
240
240
 
241
241
  self.layout.reload if self.layout.changed?
@@ -55,7 +55,7 @@ class Strelka::AuthProvider::Basic < Strelka::AuthProvider
55
55
  ### Configurability API -- configure the auth provider instance.
56
56
  def self::configure( config=nil )
57
57
  if config
58
- Strelka.log.debug "Configuring Basic authprovider: %p" % [ config ]
58
+ self.log.debug "Configuring Basic authprovider: %p" % [ config ]
59
59
  self.realm = config['realm'] if config['realm']
60
60
  self.users = config['users'] if config['users']
61
61
  else
@@ -103,39 +103,39 @@ class Strelka::Cookie
103
103
  ### one or more new Strelka::Cookie objects, keyed by name.
104
104
  def self::parse( header )
105
105
  return {} if header.nil? or header.empty?
106
- Strelka.log.debug "Parsing cookie header: %p" % [ header ]
106
+ self.log.debug "Parsing cookie header: %p" % [ header ]
107
107
  cookies = []
108
108
  version = 0
109
109
  header = header.strip
110
110
 
111
111
  # "$Version" = value
112
112
  if COOKIE_VERSION.match( header )
113
- Strelka.log.debug " Found cookie version %p" % [ $1 ]
113
+ self.log.debug " Found cookie version %p" % [ $1 ]
114
114
  version = Integer( dequote($1) )
115
115
  header.slice!( COOKIE_VERSION )
116
116
  end
117
117
 
118
118
  # 1*((";" | ",") NAME "=" VALUE [";" path] [";" domain])
119
119
  header.split( /[,;]\s*/ ).each do |pair|
120
- Strelka.log.debug " Found pair %p" % [ pair ]
120
+ self.log.debug " Found pair %p" % [ pair ]
121
121
  key, valstr = pair.split( /=/, 2 ).collect {|s| s.strip }
122
122
 
123
123
  case key
124
124
  when COOKIE_PATH
125
- Strelka.log.debug " -> cookie-path %p" % [ valstr ]
125
+ self.log.debug " -> cookie-path %p" % [ valstr ]
126
126
  cookies.last.path = dequote( valstr ) unless cookies.empty?
127
127
 
128
128
  when COOKIE_DOMAIN
129
- Strelka.log.debug " -> cookie-domain %p" % [ valstr ]
129
+ self.log.debug " -> cookie-domain %p" % [ valstr ]
130
130
  cookies.last.domain = dequote( valstr ) unless cookies.empty?
131
131
 
132
132
  when HTTP_TOKEN
133
133
  values = parse_valuestring( valstr )
134
- Strelka.log.debug " -> cookie-values %p" % [ values ]
134
+ self.log.debug " -> cookie-values %p" % [ values ]
135
135
  cookies << new( key, values, :version => version )
136
136
 
137
137
  else
138
- Strelka.log.warn \
138
+ self.log.warn \
139
139
  "Malformed cookie header %p: %p is not a valid token; ignoring" %
140
140
  [ header, key ]
141
141
  end
@@ -2,10 +2,12 @@
2
2
  # vim: set nosta noet ts=4 sw=4:
3
3
  # encoding: utf-8
4
4
 
5
- require 'strelka' unless defined?( Strelka )
6
- require 'strelka/cookie'
7
5
  require 'set'
8
6
  require 'forwardable'
7
+ require 'loggability'
8
+
9
+ require 'strelka' unless defined?( Strelka )
10
+ require 'strelka/cookie'
9
11
 
10
12
 
11
13
  # An object class which provides a convenient way of accessing a set of Strelka::Cookies.
@@ -35,16 +37,21 @@ require 'forwardable'
35
37
  # * Jeremiah Jordan <phaedrus@FaerieMUD.org>
36
38
  #
37
39
  class Strelka::CookieSet
38
- extend Forwardable
40
+ extend Forwardable,
41
+ Loggability
39
42
  include Enumerable
40
43
 
41
44
 
45
+ # Loggability API -- send logs through the :strelka logger
46
+ log_to :strelka
47
+
48
+
42
49
  ### Parse the Cookie header of the specified +request+ into Strelka::Cookie objects
43
50
  ### and return them in a new CookieSet.
44
51
  def self::parse( request )
45
- Strelka.log.debug "Parsing cookies from header: %p" % [ request.header.cookie ]
52
+ self.log.debug "Parsing cookies from header: %p" % [ request.header.cookie ]
46
53
  cookies = Strelka::Cookie.parse( request.header.cookie )
47
- Strelka.log.debug " found %d cookies: %p" % [ cookies.length, cookies ]
54
+ self.log.debug " found %d cookies: %p" % [ cookies.length, cookies ]
48
55
  return new( cookies.values )
49
56
  end
50
57
 
@@ -63,15 +70,9 @@ class Strelka::CookieSet
63
70
  public
64
71
  ######
65
72
 
66
- def_delegators :@cookie_set, :each
73
+ def_delegators :@cookie_set, :each, :empty?, :member?, :length, :size
67
74
 
68
75
 
69
- ### Returns the number of cookies in the cookieset
70
- def length
71
- return @cookie_set.length
72
- end
73
- alias_method :size, :length
74
-
75
76
 
76
77
  ### Index operator method: returns the Strelka::Cookie with the given +name+ if it
77
78
  ### exists in the cookieset.
@@ -50,6 +50,12 @@ module Strelka::HTTPRequest::Session
50
50
  alias_method :has_session?, :session?
51
51
 
52
52
 
53
+ ### Returns +true+ if the request has loaded its session.
54
+ def session_loaded?
55
+ return @session ? true : false
56
+ end
57
+
58
+
53
59
  ### Return the session associated with the request, creating it if necessary.
54
60
  def session
55
61
  unless @session
@@ -85,10 +85,16 @@ module Strelka::HTTPResponse::Session
85
85
  alias_method :has_session?, :session?
86
86
 
87
87
 
88
+ ### Returns +true+ if the response or its request has already loaded the session.
89
+ def session_loaded?
90
+ return @session || self.request.session_loaded?
91
+ end
92
+
93
+
88
94
  ### Tell the associated session to save itself and set up the session ID in the
89
95
  ### response, if one exists.
90
96
  def save_session
91
- if self.session?
97
+ if self.session_loaded?
92
98
  self.log.debug "Saving session: %p" % [ self.session ]
93
99
  self.session.save( self )
94
100
  else
@@ -5,6 +5,7 @@
5
5
  require 'set'
6
6
  require 'tsort'
7
7
 
8
+ require 'loggability'
8
9
  require 'strelka' unless defined?( Strelka )
9
10
  require 'strelka/mixins'
10
11
 
@@ -28,11 +29,18 @@ module Strelka
28
29
 
29
30
  # Plugin Module extension -- adds registration, load-order support, etc.
30
31
  module Plugin
32
+ extend Loggability
33
+
34
+ # Loggability API -- send logs through the :strelka logger
35
+ log_to :strelka
36
+
31
37
 
32
38
  ### Extension hook -- Extend the given object with methods for setting it
33
39
  ### up as a plugin for its containing namespace.
34
40
  def self::extended( object )
35
41
  super
42
+ object.extend( Loggability )
43
+ object.log_to( :strelka )
36
44
 
37
45
  # Find the plugin's namespace container, which will be the
38
46
  # pluggable class/module
@@ -41,18 +49,18 @@ module Strelka
41
49
  mod.const_get( name )
42
50
  end
43
51
 
44
- Strelka.log.debug "Extending %p as a Strelka::Plugin for %p" % [ object, pluggable ]
52
+ self.log.debug "Extending %p as a Strelka::Plugin for %p" % [ object, pluggable ]
45
53
  object.successors = Set.new
46
54
  object.pluggable = pluggable
47
55
 
48
56
  # Register any pending dependencies for the newly-loaded plugin
49
57
  name = object.plugin_name
50
58
  if (( deps = pluggable.loaded_plugins[name] ))
51
- Strelka.log.debug " installing deferred deps for %p" % [ name ]
59
+ self.log.debug " installing deferred deps for %p" % [ name ]
52
60
  object.run_after( *deps )
53
61
  end
54
62
 
55
- Strelka.log.debug " adding %p (%p) to the plugin registry for %p" %
63
+ self.log.debug " adding %p (%p) to the plugin registry for %p" %
56
64
  [ name, object, pluggable ]
57
65
  pluggable.loaded_plugins[ name ] = object
58
66
  end
@@ -88,7 +96,7 @@ module Strelka
88
96
  if mod.respond_to?( :run_after )
89
97
  mod.run_after( name )
90
98
  else
91
- Strelka.log.debug "%p plugin not yet loaded; setting up pending deps" % [ other_name ]
99
+ self.log.debug "%p plugin not yet loaded; setting up pending deps" % [ other_name ]
92
100
  mod << name
93
101
  end
94
102
  end
@@ -98,7 +106,7 @@ module Strelka
98
106
  ### Register the receiver as needing to be run after +other_plugins+ for requests, and
99
107
  ### *before* them for responses.
100
108
  def run_after( *other_plugins )
101
- Strelka.log.debug " %p will run after %p" % [ self, other_plugins ]
109
+ self.log.debug " %p will run after %p" % [ self, other_plugins ]
102
110
  self.successors.merge( other_plugins )
103
111
  end
104
112
 
@@ -113,6 +121,8 @@ module Strelka
113
121
  ### object.
114
122
  def self::extended( mod )
115
123
  super
124
+ mod.extend( Loggability )
125
+ mod.log_to( :strelka )
116
126
  mod.loaded_plugins = Strelka::PluginRegistry.new
117
127
  mod.plugin_path_prefix = mod.name.downcase.gsub( /::/, File::SEPARATOR )
118
128
  end
@@ -156,7 +166,7 @@ module Strelka
156
166
 
157
167
  ### Load the plugins with the given +names+ and install them.
158
168
  def plugins( *names )
159
- Strelka.log.info "Adding plugins: %s" % [ names.flatten.map(&:to_s).join(', ') ]
169
+ self.log.info "Adding plugins: %s" % [ names.flatten.map(&:to_s).join(', ') ]
160
170
 
161
171
  # Load the associated Plugin Module objects
162
172
  names.flatten.each {|name| self.load_plugin(name) }
@@ -174,7 +184,7 @@ module Strelka
174
184
  plugin = self.loaded_plugins[ name ]
175
185
  end
176
186
 
177
- Strelka.log.debug " registering %p" % [ name ]
187
+ self.log.debug " registering %p" % [ name ]
178
188
  self.register_plugin( plugin )
179
189
  end
180
190
  end
@@ -205,12 +215,12 @@ module Strelka
205
215
  def register_plugin( mod )
206
216
  if mod.const_defined?( :ClassMethods )
207
217
  cm_mod = mod.const_get(:ClassMethods)
208
- Strelka.log.debug " adding class methods from %p" % [ cm_mod ]
218
+ self.log.debug " adding class methods from %p" % [ cm_mod ]
209
219
 
210
220
  extend( cm_mod )
211
221
  cm_mod.instance_variables.each do |ivar|
212
222
  next if instance_variable_defined?( ivar )
213
- Strelka.log.debug " copying class instance variable %s" % [ ivar ]
223
+ self.log.debug " copying class instance variable %s" % [ ivar ]
214
224
  ival = cm_mod.instance_variable_get( ivar )
215
225
 
216
226
  # Don't duplicate modules/classes or immediates
@@ -233,12 +243,12 @@ module Strelka
233
243
  ### of the plugins themselves.
234
244
  def install_plugins
235
245
  if self.plugins_installed?
236
- Strelka.log.warn "Plugins were already installed for %p from %p" %
246
+ self.log.warn "Plugins were already installed for %p from %p" %
237
247
  [ self, self.plugins_installed_from ]
238
- Strelka.log.info "I'll attempt to install any new ones, but plugin ordering"
239
- Strelka.log.info "and other functionality might exhibit strange behavior."
248
+ self.log.info "I'll attempt to install any new ones, but plugin ordering"
249
+ self.log.info "and other functionality might exhibit strange behavior."
240
250
  else
241
- Strelka.log.info "Installing plugins for %p." % [ self ]
251
+ self.log.info "Installing plugins for %p." % [ self ]
242
252
  end
243
253
 
244
254
  sorted_plugins = self.loaded_plugins.tsort.reverse
@@ -247,11 +257,11 @@ module Strelka
247
257
  mod = self.loaded_plugins[ name ]
248
258
 
249
259
  unless @plugins.include?( name ) || @plugins.include?( mod )
250
- Strelka.log.debug " skipping %s" % [ name ]
260
+ self.log.debug " skipping %s" % [ name ]
251
261
  next
252
262
  end
253
263
 
254
- Strelka.log.info " including %p." % [ mod ]
264
+ self.log.info " including %p." % [ mod ]
255
265
  include( mod )
256
266
  end
257
267
 
@@ -262,7 +272,7 @@ module Strelka
262
272
  ### Return the list of plugin modules that are in effect for the current
263
273
  ### app.
264
274
  def application_stack
265
- Strelka.log.debug "Ancestors are: %p" % [ self.class.ancestors ]
275
+ self.log.debug "Ancestors are: %p" % [ self.class.ancestors ]
266
276
  return self.ancestors.select {|mod| mod.respond_to?(:plugin_name) }
267
277
  end
268
278
 
@@ -270,7 +280,7 @@ module Strelka
270
280
  ### Output the application stack into the logfile.
271
281
  def dump_application_stack
272
282
  stack = self.application_stack.map( &:plugin_name )
273
- Strelka.log.info "Application stack: request -> %s" % [ stack.join(" -> ") ]
283
+ self.log.info "Application stack: request -> %s" % [ stack.join(" -> ") ]
274
284
  end
275
285
 
276
286
  end # module PluginLoader
@@ -75,10 +75,10 @@ class Strelka::Session::Db < Strelka::Session::Default
75
75
  ###
76
76
  def self::initialize_sessions_table
77
77
  if self.db.table_exists?( @table_name )
78
- Strelka.log.debug "Using existing sessions table for %p" % [ db ]
78
+ self.log.debug "Using existing sessions table for %p" % [ db ]
79
79
 
80
80
  else
81
- Strelka.log.debug "Creating new sessions table for %p" % [ db ]
81
+ self.log.debug "Creating new sessions table for %p" % [ db ]
82
82
  self.db.create_table( @table_name ) do
83
83
  text :session_id, :index => true
84
84
  text :session
@@ -82,7 +82,7 @@ class Strelka::Session::Default < Strelka::Session
82
82
  if cookie.value =~ /^([[:xdigit:]]+)$/i
83
83
  return $1.untaint
84
84
  else
85
- Strelka.log.warn "Request with a malformed session cookie: %p" % [ request ]
85
+ self.log.warn "Request with a malformed session cookie: %p" % [ request ]
86
86
  return nil
87
87
  end
88
88
  end
@@ -99,9 +99,9 @@ class Strelka::Session::Default < Strelka::Session
99
99
  ### Return +true+ if the given +request+ has a session token which corresponds
100
100
  ### to an existing session key.
101
101
  def self::has_session_for?( request )
102
- Strelka.log.debug "Checking request (%s/%d) for session." % [ request.sender_id, request.conn_id ]
102
+ self.log.debug "Checking request (%s/%d) for session." % [ request.sender_id, request.conn_id ]
103
103
  id = self.get_existing_session_id( request ) or return false
104
- Strelka.log.debug " got a session ID: %p" % [ id ]
104
+ self.log.debug " got a session ID: %p" % [ id ]
105
105
  return @sessions.key?( id )
106
106
  end
107
107
 
data/spec/lib/helpers.rb CHANGED
@@ -27,6 +27,7 @@ if ENV['COVERAGE']
27
27
  end
28
28
  end
29
29
 
30
+ require 'loggability'
30
31
  require 'configurability'
31
32
  require 'pathname'
32
33
  require 'tmpdir'
@@ -44,33 +45,6 @@ require 'spec/lib/constants'
44
45
  module Strelka::SpecHelpers
45
46
  include Strelka::TestConstants
46
47
 
47
- class ArrayLogger
48
- ### Create a new ArrayLogger that will append content to +array+.
49
- def initialize( array )
50
- @array = array
51
- end
52
-
53
- ### Write the specified +message+ to the array.
54
- def write( message )
55
- @array << message
56
- end
57
-
58
- ### No-op -- this is here just so Logger doesn't complain
59
- def close; end
60
-
61
- end # class ArrayLogger
62
-
63
-
64
- unless defined?( LEVEL )
65
- LEVEL = {
66
- :debug => Logger::DEBUG,
67
- :info => Logger::INFO,
68
- :warn => Logger::WARN,
69
- :error => Logger::ERROR,
70
- :fatal => Logger::FATAL,
71
- }
72
- end
73
-
74
48
  ###############
75
49
  module_function
76
50
  ###############
@@ -90,7 +64,7 @@ module Strelka::SpecHelpers
90
64
 
91
65
 
92
66
  ### Alter the output of the default log formatter to be pretty in SpecMate output
93
- def setup_logging( level=Logger::FATAL )
67
+ def setup_logging( level=:fatal )
94
68
 
95
69
  # Only do this when executing from a spec in TextMate
96
70
  if ENV['HTML_LOGGING'] || (ENV['TM_FILENAME'] && ENV['TM_FILENAME'] =~ /_spec\.rb/)
@@ -41,15 +41,12 @@ describe Strelka::App::Filters do
41
41
  describe "an including App" do
42
42
 
43
43
  before( :each ) do
44
- Strelka.log.debug "Creating a new Strelka::App"
45
44
  @app = Class.new( Strelka::App ) do
46
45
  plugin :filters
47
46
  def initialize( appid='params-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC )
48
47
  super
49
48
  end
50
49
  end
51
- Strelka.log.debug " App class is: %p, filters array: 0x%016x" %
52
- [ @app, @app.filters.object_id * 2 ]
53
50
  end
54
51
 
55
52
  it "has its filters config inherited by subclasses" do
@@ -45,7 +45,6 @@ describe Strelka::App::RestResources do
45
45
  describe "an including App" do
46
46
 
47
47
  before( :each ) do
48
- Strelka.log.debug "Creating a new Strelka::App"
49
48
  @app = Class.new( Strelka::App ) do
50
49
  plugin :restresources
51
50
  def initialize( appid='rest-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC )
@@ -41,15 +41,12 @@ describe Strelka::App::Routing do
41
41
  describe "an including App" do
42
42
 
43
43
  before( :each ) do
44
- Strelka.log.debug "Creating a new Strelka::App"
45
44
  @app = Class.new( Strelka::App ) do
46
45
  plugin :routing
47
46
  def initialize( appid='params-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC )
48
47
  super
49
48
  end
50
49
  end
51
- Strelka.log.debug " App class is: %p, routes array: 0x%016x" %
52
- [ @app, @app.routes.object_id * 2 ]
53
50
  end
54
51
 
55
52
 
@@ -85,8 +85,8 @@ describe Strelka::App::Sessions do
85
85
 
86
86
  before( :each ) do
87
87
  @app = Class.new( Strelka::App ) do
88
- Strelka.log.info "Anonymous App class: %p" % [ self ]
89
- Strelka.log.info "ID constant is: %p" % [ const_defined?(:ID) ? const_get(:ID) : "(not defined)" ]
88
+ self.log.info "Anonymous App class: %p" % [ self ]
89
+ self.log.info "ID constant is: %p" % [ const_defined?(:ID) ? const_get(:ID) : "(not defined)" ]
90
90
 
91
91
  self::ID = 'monkeyshines'
92
92
  # Guard against ID leakage
@@ -101,6 +101,7 @@ describe Strelka::App::Sessions do
101
101
 
102
102
  def handle_request( req )
103
103
  super do
104
+ self.log.debug "Session is: %p" % [ req.session ]
104
105
  req.session[ :test ] = 'session data'
105
106
  req.response
106
107
  end
@@ -27,6 +27,14 @@ describe Strelka::CookieSet do
27
27
  end
28
28
 
29
29
 
30
+ it "delegates some methods to its underlying Set" do
31
+ cookie = Strelka::Cookie.new( 'pants', 'baggy' )
32
+
33
+ @cookieset.should be_empty()
34
+ @cookieset.length.should == 0
35
+ @cookieset.member?( cookie ).should be_false()
36
+ end
37
+
30
38
  it "is able to enummerate over each cookie in the set" do
31
39
  pants_cookie = Strelka::Cookie.new( 'pants', 'baggy' )
32
40
  shirt_cookie = Strelka::Cookie.new( 'shirt', 'pirate' )
@@ -35,7 +35,6 @@ describe Strelka::HTTPRequest::Session, "-extended request" do
35
35
 
36
36
  before( :each ) do
37
37
  @req = @request_factory.get( '/service/user/estark' )
38
- Strelka.log.debug "Extending request %p" % [ @req ]
39
38
  @req.extend( described_class )
40
39
  end
41
40
 
@@ -110,13 +109,22 @@ describe Strelka::HTTPRequest::Session, "-extended request" do
110
109
  context "and a corresponding entry in the database" do
111
110
 
112
111
  before( :each ) do
113
- @req.session[ :test ] = true
112
+ Strelka::Session::Default.sessions[ @sess_id ] = {}
114
113
  end
115
114
 
116
115
  it "knows that it has a session" do
117
116
  @req.should have_session()
118
117
  end
119
118
 
119
+ it "knows when its session hasn't been loaded" do
120
+ @req.session_loaded?.should be_false()
121
+ end
122
+
123
+ it "knows when its session has been loaded" do
124
+ @req.session # Load it
125
+ @req.session_loaded?.should be_true()
126
+ end
127
+
120
128
  it "can purge the session from the database" do
121
129
  @req.should have_session()
122
130
  @req.destroy_session
@@ -130,12 +130,33 @@ describe Strelka::HTTPResponse::Session, "-extended response" do
130
130
  @res.should have_session()
131
131
  end
132
132
 
133
- it "saves the session via itself when told to do so" do
133
+ it "knows that its session has been loaded if it has one" do
134
+ @res.session
135
+ @res.session_loaded?.should be_true()
136
+ end
137
+
138
+ it "knows that its session has been loaded if its request has one" do
139
+ @res.request.session
140
+ @res.session_loaded?.should be_true()
141
+ end
142
+
143
+ it "knows that its session hasn't been loaded if neither its request not itself has one" do
144
+ @res.session_loaded?.should be_false()
145
+ end
146
+
147
+ it "saves the session via itself if it was loaded" do
134
148
  @res.cookies.should_not include( @cookie_name )
149
+ @res.session
135
150
  @res.save_session
136
151
  @res.cookies[ @cookie_name ].value.should == @sess_id
137
152
  end
138
153
 
154
+ it "doesn't save the session via itself if it wasn't loaded" do
155
+ @res.cookies.should_not include( @cookie_name )
156
+ @res.save_session
157
+ @res.cookies.should be_empty()
158
+ end
159
+
139
160
  end
140
161
 
141
162
  end
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.224
4
+ version: 0.0.1.pre.229
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-07 00:00:00.000000000 Z
39
+ date: 2012-05-09 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: trollop
@@ -125,7 +125,7 @@ dependencies:
125
125
  requirements:
126
126
  - - ~>
127
127
  - !ruby/object:Gem::Version
128
- version: '0.20'
128
+ version: '0.22'
129
129
  type: :runtime
130
130
  prerelease: false
131
131
  version_requirements: !ruby/object:Gem::Requirement
@@ -133,7 +133,7 @@ dependencies:
133
133
  requirements:
134
134
  - - ~>
135
135
  - !ruby/object:Gem::Version
136
- version: '0.20'
136
+ version: '0.22'
137
137
  - !ruby/object:Gem::Dependency
138
138
  name: uuidtools
139
139
  requirement: !ruby/object:Gem::Requirement
@@ -189,7 +189,7 @@ dependencies:
189
189
  requirements:
190
190
  - - ~>
191
191
  - !ruby/object:Gem::Version
192
- version: '0.0'
192
+ version: '0.1'
193
193
  type: :runtime
194
194
  prerelease: false
195
195
  version_requirements: !ruby/object:Gem::Requirement
@@ -197,7 +197,7 @@ dependencies:
197
197
  requirements:
198
198
  - - ~>
199
199
  - !ruby/object:Gem::Version
200
- version: '0.0'
200
+ version: '0.1'
201
201
  - !ruby/object:Gem::Dependency
202
202
  name: hoe-mercurial
203
203
  requirement: !ruby/object:Gem::Requirement
metadata.gz.sig CHANGED
Binary file