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/lib/strelka/plugins.rb
CHANGED
@@ -220,11 +220,16 @@ module Strelka
|
|
220
220
|
extend( cm_mod )
|
221
221
|
cm_mod.instance_variables.each do |ivar|
|
222
222
|
next if instance_variable_defined?( ivar )
|
223
|
-
|
223
|
+
|
224
224
|
ival = cm_mod.instance_variable_get( ivar )
|
225
|
+
copy = Strelka::DataUtilities.deep_copy( ival )
|
226
|
+
|
227
|
+
self.log.debug " copying class instance variable %s (%p)" % [ ivar, copy ]
|
225
228
|
|
226
229
|
# Don't duplicate modules/classes or immediates
|
227
|
-
instance_variable_set( ivar,
|
230
|
+
instance_variable_set( ivar, copy )
|
231
|
+
self.log.debug " instance variable %p set to %p in %p" %
|
232
|
+
[ ivar, self.instance_variable_get(ivar), self ]
|
228
233
|
end
|
229
234
|
end
|
230
235
|
end
|
data/lib/strelka.rb
CHANGED
@@ -24,10 +24,10 @@ module Strelka
|
|
24
24
|
log_as :strelka
|
25
25
|
|
26
26
|
# Library version constant
|
27
|
-
VERSION = '0.0
|
27
|
+
VERSION = '0.1.0'
|
28
28
|
|
29
29
|
# Version-control revision constant
|
30
|
-
REVISION = %q$Revision:
|
30
|
+
REVISION = %q$Revision: a6be71c3d94d $
|
31
31
|
|
32
32
|
require 'strelka/constants'
|
33
33
|
require 'strelka/exceptions'
|
data/spec/strelka/app_spec.rb
CHANGED
@@ -303,12 +303,13 @@ describe Strelka::App do
|
|
303
303
|
|
304
304
|
it "uses the app's ID constant for the appid if .run is called without one" do
|
305
305
|
@app.const_set( :ID, 'testing-app' )
|
306
|
+
conn = double( "Mongrel2 connection", close: true )
|
306
307
|
|
307
308
|
Mongrel2::Handler.should_receive( :connection_info_for ).with( 'testing-app' ).
|
308
309
|
and_return([ TEST_SEND_SPEC, TEST_RECV_SPEC ])
|
309
310
|
Mongrel2::Connection.should_receive( :new ).
|
310
311
|
with( 'testing-app', TEST_SEND_SPEC, TEST_RECV_SPEC ).
|
311
|
-
and_return(
|
312
|
+
and_return( conn )
|
312
313
|
|
313
314
|
@app.run
|
314
315
|
end
|
@@ -318,12 +319,13 @@ describe Strelka::App do
|
|
318
319
|
@app.class_eval do
|
319
320
|
def self::name; "My::First::Blog" ; end
|
320
321
|
end
|
322
|
+
conn = double( "Mongrel2 connection", close: true )
|
321
323
|
|
322
324
|
Mongrel2::Handler.should_receive( :connection_info_for ).with( 'my-first-blog' ).
|
323
325
|
and_return([ TEST_SEND_SPEC, TEST_RECV_SPEC ])
|
324
326
|
Mongrel2::Connection.should_receive( :new ).
|
325
327
|
with( 'my-first-blog', TEST_SEND_SPEC, TEST_RECV_SPEC ).
|
326
|
-
and_return(
|
328
|
+
and_return( conn )
|
327
329
|
|
328
330
|
@app.run
|
329
331
|
end
|
@@ -201,6 +201,39 @@ describe Strelka::HTTPRequest do
|
|
201
201
|
end
|
202
202
|
|
203
203
|
|
204
|
+
context "a DELETE request without a content type" do
|
205
|
+
before( :each ) do
|
206
|
+
@req = @request_factory.delete( '/directory/path' )
|
207
|
+
end
|
208
|
+
|
209
|
+
|
210
|
+
it "Doesn't respond with a 400 (BAD_REQUEST)" do
|
211
|
+
@req.params.should be_nil
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
|
216
|
+
context "a DELETE request with a 'multipart/form-data' body" do
|
217
|
+
|
218
|
+
before( :each ) do
|
219
|
+
@req = @request_factory.delete( '/directory/path',
|
220
|
+
'Content-type' => 'multipart/form-data; boundary=--a_boundary' )
|
221
|
+
end
|
222
|
+
|
223
|
+
it "returns a hash for form parameters" do
|
224
|
+
@req.body = "----a_boundary\r\n" +
|
225
|
+
%{Content-Disposition: form-data; name="reason"\r\n} +
|
226
|
+
%{\r\n} +
|
227
|
+
%{I really don't like this path.\r\n} +
|
228
|
+
%{----a_boundary--\r\n}
|
229
|
+
|
230
|
+
@req.params.should == {'reason' => "I really don't like this path."}
|
231
|
+
end
|
232
|
+
|
233
|
+
end
|
234
|
+
|
235
|
+
|
236
|
+
|
204
237
|
context "a POST request without a content type" do
|
205
238
|
before( :each ) do
|
206
239
|
@req = @request_factory.post( '/directory/path', '' )
|
@@ -90,7 +90,7 @@ describe Strelka::ParamValidator do
|
|
90
90
|
it "raises an exception on an unknown constraint type" do
|
91
91
|
expect {
|
92
92
|
@validator.add( :foo, $stderr )
|
93
|
-
}.to raise_error( /no
|
93
|
+
}.to raise_error( /no constraint type for a #{$stderr.class.name} validation spec/i )
|
94
94
|
end
|
95
95
|
|
96
96
|
it "retains its profile through a copy" do
|
@@ -272,18 +272,22 @@ describe Strelka::ParamValidator do
|
|
272
272
|
end
|
273
273
|
|
274
274
|
it "capitalizes the names of simple fields for descriptions" do
|
275
|
+
@validator.add( :required, :string )
|
275
276
|
@validator.get_description( "required" ).should == 'Required'
|
276
277
|
end
|
277
278
|
|
278
279
|
it "splits apart underbarred field names into capitalized words for descriptions" do
|
280
|
+
@validator.add( :rodent_size, :string )
|
279
281
|
@validator.get_description( "rodent_size" ).should == 'Rodent Size'
|
280
282
|
end
|
281
283
|
|
282
284
|
it "uses the key for descriptions of hash fields" do
|
285
|
+
@validator.add( 'rodent[size]', :string )
|
283
286
|
@validator.get_description( "rodent[size]" ).should == 'Size'
|
284
287
|
end
|
285
288
|
|
286
289
|
it "uses separate capitalized words for descriptions of hash fields with underbarred keys " do
|
290
|
+
@validator.add( 'castle[baron_id]', :string )
|
287
291
|
@validator.get_description( "castle[baron_id]" ).should == 'Baron Id'
|
288
292
|
end
|
289
293
|
|
@@ -323,7 +327,7 @@ describe Strelka::ParamValidator do
|
|
323
327
|
@validator.add( 'recipe[ingredient][name]', :string )
|
324
328
|
@validator.add( 'recipe[ingredient][cost]', :string )
|
325
329
|
@validator.add( 'recipe[yield]', :string )
|
326
|
-
@validator.untaint_all_constraints
|
330
|
+
@validator.untaint_all_constraints = true
|
327
331
|
|
328
332
|
args = {
|
329
333
|
'recipe[ingredient][rarity]'.taint => 'super-rare'.taint,
|
@@ -1049,7 +1053,7 @@ describe Strelka::ParamValidator do
|
|
1049
1053
|
|
1050
1054
|
it "rejects parameters for fields with Proc constraints if the Proc returns a false value" do
|
1051
1055
|
@validator.add( :creation_date ) do |input|
|
1052
|
-
Date.parse( input )
|
1056
|
+
Date.parse( input ) rescue nil
|
1053
1057
|
end
|
1054
1058
|
@validator.validate( 'creation_date' => '::::' )
|
1055
1059
|
|
data.tar.gz.sig
CHANGED
Binary file
|
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
|
4
|
+
version: 0.1.0
|
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-
|
39
|
+
date: 2012-12-28 00:00:00.000000000 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: configurability
|
metadata.gz.sig
CHANGED
Binary file
|