strelka 0.0.3 → 0.1.0
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/ChangeLog +36 -2
- data/History.rdoc +9 -0
- data/bin/strelka +1 -0
- data/lib/strelka/app/parameters.rb +2 -0
- data/lib/strelka/app/restresources.rb +1 -1
- data/lib/strelka/httprequest.rb +5 -2
- data/lib/strelka/mixins.rb +54 -0
- data/lib/strelka/paramvalidator.rb +645 -689
- data/lib/strelka/plugins.rb +7 -2
- data/lib/strelka.rb +2 -2
- data/spec/strelka/app_spec.rb +4 -2
- data/spec/strelka/httprequest_spec.rb +33 -0
- data/spec/strelka/paramvalidator_spec.rb +7 -3
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
data/ChangeLog
CHANGED
@@ -1,8 +1,42 @@
|
|
1
|
+
2012-11-02 Michael Granger <ged@FaerieMUD.org>
|
2
|
+
|
3
|
+
* lib/strelka/app/parameters.rb, lib/strelka/app/restresources.rb,
|
4
|
+
lib/strelka/mixins.rb, lib/strelka/paramvalidator.rb,
|
5
|
+
lib/strelka/plugins.rb, spec/strelka/paramvalidator_spec.rb:
|
6
|
+
Rewrite ParamValidator to simplify, remove dependency on
|
7
|
+
FormValidator.
|
8
|
+
[49716850bd29] [github/master, tip]
|
9
|
+
|
10
|
+
2012-11-02 Mahlon E. Smith <mahlon@martini.nu>
|
11
|
+
|
12
|
+
* lib/strelka/httprequest.rb, spec/strelka/httprequest_spec.rb:
|
13
|
+
Allow entity-bodies for HTTP verbs that don't explicitly forbid them
|
14
|
+
in RFC.
|
15
|
+
[a733dfe529a4]
|
16
|
+
|
17
|
+
2012-10-23 Michael Granger <ged@FaerieMUD.org>
|
18
|
+
|
19
|
+
* .hgtags:
|
20
|
+
Added tag v0.0.3 for changeset d30a7dfea73a
|
21
|
+
[a0f594ed081c]
|
22
|
+
|
23
|
+
* .hgsigs:
|
24
|
+
Added signature for changeset 4cb76b1531ef
|
25
|
+
[d30a7dfea73a] [v0.0.3]
|
26
|
+
|
27
|
+
* History.rdoc, lib/strelka.rb:
|
28
|
+
Bump patch version, update history.
|
29
|
+
[4cb76b1531ef]
|
30
|
+
|
31
|
+
* lib/strelka/app.rb, spec/strelka/app_spec.rb:
|
32
|
+
Fix the template-path auto-discovery for some configurations.
|
33
|
+
[a4e246d895cf]
|
34
|
+
|
1
35
|
2012-10-17 Michael Granger <ged@FaerieMUD.org>
|
2
36
|
|
3
37
|
* .hgtags:
|
4
38
|
Added tag v0.0.2 for changeset f4507caebfb7
|
5
|
-
[e163f60cfa3d]
|
39
|
+
[e163f60cfa3d]
|
6
40
|
|
7
41
|
* .hgsigs:
|
8
42
|
Added signature for changeset 485638c9ec10
|
@@ -122,7 +156,7 @@
|
|
122
156
|
|
123
157
|
* lib/strelka/authprovider.rb, spec/strelka/authprovider_spec.rb:
|
124
158
|
Fix the documentation and specs for AuthProvider#authorize.
|
125
|
-
[accb655c57b4]
|
159
|
+
[accb655c57b4] [github/master@default]
|
126
160
|
|
127
161
|
2012-10-03 Michael Granger <ged@FaerieMUD.org>
|
128
162
|
|
data/History.rdoc
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
== v0.1.0 [2012-11-02] Michael Granger <ged@FaerieMUD.org>
|
2
|
+
|
3
|
+
- Add --version to the command line tool
|
4
|
+
- Fix some documentation
|
5
|
+
- Rewrite ParamValidator to simplify, remove dependency on FormValidator.
|
6
|
+
- Allow entity-bodies for HTTP verbs that don't explicitly forbid them
|
7
|
+
in RFC.
|
8
|
+
|
9
|
+
|
1
10
|
== v0.0.3 [2012-10-23] Michael Granger <ged@FaerieMUD.org>
|
2
11
|
|
3
12
|
- Fix the template-path auto-discovery for some configurations.
|
data/bin/strelka
CHANGED
@@ -95,6 +95,7 @@ module Strelka::App::Parameters
|
|
95
95
|
### Strelka::ParamValidator.
|
96
96
|
def param( name, *args )
|
97
97
|
self.log.debug "New param %p" % [ name ]
|
98
|
+
self.log.debug " adding parameter %p to %p" % [ name, self.paramvalidator ]
|
98
99
|
self.paramvalidator.add( name, *args )
|
99
100
|
end
|
100
101
|
|
@@ -112,6 +113,7 @@ module Strelka::App::Parameters
|
|
112
113
|
def inherited( subclass )
|
113
114
|
super
|
114
115
|
subclass.instance_variable_set( :@paramvalidator, self.paramvalidator.dup )
|
116
|
+
self.log.debug "Adding param validator: %p" % [ self.paramvalidator ]
|
115
117
|
end
|
116
118
|
|
117
119
|
end # module ClassMethods
|
@@ -324,7 +324,7 @@ module Strelka::App::RestResources
|
|
324
324
|
finish_with( HTTP::NOT_FOUND, "no such %s [%p]" % [ rsrcobj.name, id ] )
|
325
325
|
|
326
326
|
newvals = req.params.valid
|
327
|
-
newvals.delete( pkey.
|
327
|
+
newvals.delete( pkey.to_sym )
|
328
328
|
self.log.debug "Updating %p with new values: %p" % [ resource, newvals ]
|
329
329
|
|
330
330
|
begin
|
data/lib/strelka/httprequest.rb
CHANGED
@@ -126,7 +126,8 @@ class Strelka::HTTPRequest < Mongrel2::HTTPRequest
|
|
126
126
|
|
127
127
|
|
128
128
|
### Parse the request parameters and return them as a Hash. For GET requests, these are
|
129
|
-
###
|
129
|
+
### taken from the query arguments. For requests that commonly
|
130
|
+
### contain an entity-body, try and parse that.
|
130
131
|
###
|
131
132
|
### # For a handler with a route of '/user', for the request:
|
132
133
|
### # "GET /user/1/profile?checkbox=1&checkbox=2&text=foo HTTP/1.1"
|
@@ -139,8 +140,10 @@ class Strelka::HTTPRequest < Mongrel2::HTTPRequest
|
|
139
140
|
@params = self.parse_query_args
|
140
141
|
when :POST, :PUT
|
141
142
|
@params = self.parse_form_data
|
143
|
+
when :TRACE
|
144
|
+
self.log.debug "No parameters for a TRACE request."
|
142
145
|
else
|
143
|
-
|
146
|
+
@params = self.parse_form_data if self.content_type
|
144
147
|
end
|
145
148
|
end
|
146
149
|
|
data/lib/strelka/mixins.rb
CHANGED
@@ -218,6 +218,43 @@ module Strelka
|
|
218
218
|
hash[ key ] = Hash.new( &Strelka::DataUtilities.method(:autovivify) )
|
219
219
|
end
|
220
220
|
|
221
|
+
|
222
|
+
### Return a version of the given +hash+ with its keys transformed
|
223
|
+
### into Strings from whatever they were before.
|
224
|
+
def stringify_keys( hash )
|
225
|
+
newhash = {}
|
226
|
+
|
227
|
+
hash.each do |key,val|
|
228
|
+
if val.is_a?( Hash )
|
229
|
+
newhash[ key.to_s ] = stringify_keys( val )
|
230
|
+
else
|
231
|
+
newhash[ key.to_s ] = val
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
return newhash
|
236
|
+
end
|
237
|
+
|
238
|
+
|
239
|
+
### Return a duplicate of the given +hash+ with its identifier-like keys
|
240
|
+
### transformed into symbols from whatever they were before.
|
241
|
+
def symbolify_keys( hash )
|
242
|
+
newhash = {}
|
243
|
+
|
244
|
+
hash.each do |key,val|
|
245
|
+
keysym = key.to_s.dup.untaint.to_sym
|
246
|
+
|
247
|
+
if val.is_a?( Hash )
|
248
|
+
newhash[ keysym ] = symbolify_keys( val )
|
249
|
+
else
|
250
|
+
newhash[ keysym ] = val
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
return newhash
|
255
|
+
end
|
256
|
+
alias_method :internify_keys, :symbolify_keys
|
257
|
+
|
221
258
|
end # module DataUtilities
|
222
259
|
|
223
260
|
|
@@ -268,6 +305,23 @@ module Strelka
|
|
268
305
|
end
|
269
306
|
|
270
307
|
|
308
|
+
### Create a reader in the form of a predicate for the given +attrname+.
|
309
|
+
def attr_predicate( attrname )
|
310
|
+
attrname = attrname.to_s.chomp( '?' )
|
311
|
+
define_method( "#{attrname}?" ) do
|
312
|
+
instance_variable_get( "@#{attrname}" ) ? true : false
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
|
317
|
+
### Create a reader in the form of a predicate for the given +attrname+
|
318
|
+
### as well as a regular writer method.
|
319
|
+
def attr_predicate_accessor( attrname )
|
320
|
+
attrname = attrname.to_s.chomp( '?' )
|
321
|
+
attr_writer( attrname )
|
322
|
+
attr_predicate( attrname )
|
323
|
+
end
|
324
|
+
|
271
325
|
end # module MethodUtilities
|
272
326
|
|
273
327
|
|