strelka 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/History.rdoc +5 -0
- data/Rakefile +2 -2
- data/lib/strelka.rb +2 -2
- data/lib/strelka/app/auth.rb +1 -1
- data/lib/strelka/app/parameters.rb +14 -18
- data/lib/strelka/app/restresources.rb +3 -3
- data/lib/strelka/authprovider.rb +5 -8
- data/lib/strelka/httprequest/auth.rb +1 -1
- data/lib/strelka/httpresponse.rb +1 -1
- data/lib/strelka/paramvalidator.rb +1 -1
- data/lib/strelka/router.rb +7 -10
- data/lib/strelka/session.rb +7 -10
- data/spec/strelka/app/auth_spec.rb +1 -1
- data/spec/strelka/app/restresources_spec.rb +1 -1
- data/spec/strelka/authprovider_spec.rb +1 -1
- data/spec/strelka/router_spec.rb +1 -1
- data/spec/strelka/session_spec.rb +1 -1
- metadata +7 -7
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 395204eaca2231acafa0f31e6dd55ec96b51199e
|
4
|
+
data.tar.gz: 3c36c895a536b326353896d69d63e0d177d10224
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc57d68e1dcbf2ddd207aa60099d8296d217161b7eda72868f4f366ee5340b33f02e03c1c33e9c1b1df0c997591defa10b472f63078e20819ffa715aab0c3cb1
|
7
|
+
data.tar.gz: 64890a20a0effca5816512184a9750f9636809b67192b5697e38ee7b441dcb78e98d313386c954a64b3c5429b1314cfb4039549d996c3137a8dc4bdd1c195b88
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -24,10 +24,10 @@ hoespec = Hoe.spec 'strelka' do
|
|
24
24
|
self.dependency 'configurability', '~> 2.0'
|
25
25
|
self.dependency 'foreman', '~> 0.61'
|
26
26
|
self.dependency 'highline', '~> 1.6'
|
27
|
-
self.dependency 'inversion', '~> 0.
|
27
|
+
self.dependency 'inversion', '~> 0.12'
|
28
28
|
self.dependency 'loggability', '~> 0.5'
|
29
29
|
self.dependency 'mongrel2', '~> 0.36'
|
30
|
-
self.dependency '
|
30
|
+
self.dependency 'pluggability', '~> 0.0'
|
31
31
|
self.dependency 'sysexits', '~> 1.1'
|
32
32
|
self.dependency 'trollop', '~> 2.0'
|
33
33
|
self.dependency 'uuidtools', '~> 2.1'
|
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.
|
27
|
+
VERSION = '0.3.0'
|
28
28
|
|
29
29
|
# Version-control revision constant
|
30
|
-
REVISION = %q$Revision:
|
30
|
+
REVISION = %q$Revision: 01ab7adefccf $
|
31
31
|
|
32
32
|
require 'strelka/constants'
|
33
33
|
require 'strelka/exceptions'
|
data/lib/strelka/app/auth.rb
CHANGED
@@ -26,6 +26,10 @@ require 'strelka/paramvalidator'
|
|
26
26
|
# param :id, /\d+/, "The user's numeric ID"
|
27
27
|
# param :mode, /^\s*(?<prefix>[A-Z]{2})-(?<sku>\p{Print}+)/
|
28
28
|
#
|
29
|
+
# # ...
|
30
|
+
#
|
31
|
+
# end # class UserManager
|
32
|
+
#
|
29
33
|
# The first item is the parameter _key_, which corresponds to the field 'name' attribute for
|
30
34
|
# a form, or the key for JSON or YAML data.
|
31
35
|
#
|
@@ -53,19 +57,17 @@ require 'strelka/paramvalidator'
|
|
53
57
|
#
|
54
58
|
# The inclusion of this plugin also allows you to use parameters in your routes:
|
55
59
|
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
# req.params.error_messages
|
66
|
-
# end
|
60
|
+
# # :username gets validated and merged into query args; URI parameters
|
61
|
+
# # clobber query params
|
62
|
+
# get '/info/:username' do |req|
|
63
|
+
# req.params.add( :id, /[XRT]\d{4}-\d{8}/ )
|
64
|
+
# req.params.okay?
|
65
|
+
# req.params[:username]
|
66
|
+
# req.params.values_at( :id, :username )
|
67
|
+
# req.params.username
|
67
68
|
#
|
68
|
-
#
|
69
|
+
# req.params.error_messages
|
70
|
+
# end
|
69
71
|
#
|
70
72
|
# [:FIXME:] Add more docs.
|
71
73
|
module Strelka::App::Parameters
|
@@ -100,12 +102,6 @@ module Strelka::App::Parameters
|
|
100
102
|
end
|
101
103
|
|
102
104
|
|
103
|
-
### Add a 'builtin' constraint type with the specified +name+.
|
104
|
-
def add_param_type( name, &block )
|
105
|
-
|
106
|
-
end
|
107
|
-
|
108
|
-
|
109
105
|
### Get/set the untainting flag. If set, all parameters which match their constraints
|
110
106
|
### will also be untainted.
|
111
107
|
def untaint_all_constraints( newval=nil )
|
@@ -51,7 +51,7 @@ require 'strelka/app' unless defined?( Strelka::App )
|
|
51
51
|
# [ ] Means of tailoring responses for requests for which the response
|
52
52
|
# isn't clearly specified in the RFC (DELETE /resource)
|
53
53
|
# [ ] Sequel plugin for adding links to serialized representations
|
54
|
-
#
|
54
|
+
#
|
55
55
|
# == Caveats / Known Problems
|
56
56
|
#
|
57
57
|
# * Dataset methods declared using the 'subset' declaration don't allow the
|
@@ -491,7 +491,7 @@ module Strelka::App::RestResources
|
|
491
491
|
|
492
492
|
route = "%s/%s" % [ route_prefix, methname ]
|
493
493
|
params = []
|
494
|
-
|
494
|
+
|
495
495
|
# Add a route placeholder for each parameter of the dataset method
|
496
496
|
meth.parameters.each do |type, param|
|
497
497
|
self.log.debug " adding parameter placeholder to the route for %s parameter %p" %
|
@@ -619,7 +619,7 @@ module Strelka::App::RestResources
|
|
619
619
|
#######
|
620
620
|
|
621
621
|
### Add parameter validations for the given +columns+ of the specified resource object +rsrcobj+
|
622
|
-
### to the specified +req+uest.
|
622
|
+
### to the specified +req+uest.
|
623
623
|
def add_resource_params( req, rsrcobj, *columns )
|
624
624
|
columns = rsrcobj.allowed_columns || rsrcobj.columns if columns.empty?
|
625
625
|
|
data/lib/strelka/authprovider.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# vim: set nosta noet ts=4 sw=4:
|
3
3
|
# encoding: utf-8
|
4
4
|
|
5
|
-
require '
|
5
|
+
require 'pluggability'
|
6
6
|
|
7
7
|
require 'strelka' unless defined?( Strelka )
|
8
8
|
require 'strelka/mixins'
|
@@ -29,9 +29,9 @@ require 'strelka/mixins'
|
|
29
29
|
#
|
30
30
|
class Strelka::AuthProvider
|
31
31
|
extend Loggability,
|
32
|
+
Pluggability,
|
32
33
|
Strelka::Delegation
|
33
|
-
include
|
34
|
-
Strelka::Constants,
|
34
|
+
include Strelka::Constants,
|
35
35
|
Strelka::AbstractClass,
|
36
36
|
Strelka::ResponseHelpers
|
37
37
|
|
@@ -39,11 +39,8 @@ class Strelka::AuthProvider
|
|
39
39
|
log_to :strelka
|
40
40
|
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
def self::derivative_dirs
|
45
|
-
return ['strelka/authprovider']
|
46
|
-
end
|
42
|
+
# Pluggability API -- Specify the list of prefixes to try when loading plugins
|
43
|
+
plugin_prefixes 'strelka/authprovider'
|
47
44
|
|
48
45
|
|
49
46
|
#################################################################
|
@@ -4,7 +4,7 @@ require 'strelka/constants'
|
|
4
4
|
require 'strelka/httprequest' unless defined?( Strelka::HTTPRequest )
|
5
5
|
|
6
6
|
|
7
|
-
# The mixin that adds methods to Strelka::HTTPRequest for
|
7
|
+
# The mixin that adds methods to Strelka::HTTPRequest for
|
8
8
|
# authentication/authorization.
|
9
9
|
module Strelka::HTTPRequest::Auth
|
10
10
|
include Strelka::Constants
|
data/lib/strelka/httpresponse.rb
CHANGED
@@ -111,7 +111,7 @@ class Strelka::HTTPResponse < Mongrel2::HTTPResponse
|
|
111
111
|
|
112
112
|
### Add a charset to the content-type header in +headers+ if possible.
|
113
113
|
def add_content_type_charset( headers )
|
114
|
-
return unless headers.content_type &&
|
114
|
+
return unless headers.content_type &&
|
115
115
|
headers.content_type.start_with?( 'text' )
|
116
116
|
|
117
117
|
charset = self.find_header_charset
|
@@ -914,7 +914,7 @@ class Strelka::ParamValidator
|
|
914
914
|
end
|
915
915
|
|
916
916
|
|
917
|
-
### Return an Array of error messages, one for each field present in the parameters in the last
|
917
|
+
### Return an Array of error messages, one for each field present in the parameters in the last
|
918
918
|
### validation that didn't have a constraint associated with it.
|
919
919
|
def unknown_param_errors
|
920
920
|
self.log.debug "Fetching unknown param errors for %p." % [ self.unknown ]
|
data/lib/strelka/router.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# encoding: utf-8
|
4
4
|
|
5
5
|
require 'loggability'
|
6
|
-
require '
|
6
|
+
require 'pluggability'
|
7
7
|
|
8
8
|
require 'strelka' unless defined?( Strelka )
|
9
9
|
require 'strelka/app' unless defined?( Strelka::App )
|
@@ -24,18 +24,15 @@ require 'strelka/mixins'
|
|
24
24
|
# <tt>strelka/router/{something}.rb</tt>, and be sure to override the
|
25
25
|
# #add_route and #route_request methods.
|
26
26
|
class Strelka::Router
|
27
|
-
extend Loggability
|
28
|
-
|
29
|
-
|
27
|
+
extend Loggability,
|
28
|
+
Pluggability
|
29
|
+
include Strelka::AbstractClass
|
30
30
|
|
31
31
|
# Loggability API -- set up logging under the 'strelka' log host
|
32
32
|
log_to :strelka
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
def self::derivative_dirs
|
37
|
-
return ['strelka/router']
|
38
|
-
end
|
34
|
+
# Pluggability API -- Specify the list of prefixes to try when loading plugins
|
35
|
+
plugin_prefixes 'strelka/router'
|
39
36
|
|
40
37
|
|
41
38
|
### Create a new router that will route requests according to the specified
|
@@ -64,7 +61,7 @@ class Strelka::Router
|
|
64
61
|
# {RFC 2616}[http://tools.ietf.org/html/rfc2616#section-9] as a Symbol (e.g.,
|
65
62
|
# +:GET+, +:DELETE+). The +path_array+ will be the route path split up by
|
66
63
|
# path separator. The +routing_info+ is a Hash that contains the action
|
67
|
-
|
64
|
+
# that will be run when the route matches, routing options, and any other
|
68
65
|
# routing information associated with the route.
|
69
66
|
pure_virtual :add_route
|
70
67
|
|
data/lib/strelka/session.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# vim: set nosta noet ts=4 sw=4:
|
3
3
|
|
4
4
|
require 'digest/sha1'
|
5
|
-
require '
|
5
|
+
require 'pluggability'
|
6
6
|
require 'loggability'
|
7
7
|
|
8
8
|
require 'strelka' unless defined?( Strelka )
|
@@ -43,19 +43,16 @@ require 'strelka/mixins'
|
|
43
43
|
#
|
44
44
|
#
|
45
45
|
class Strelka::Session
|
46
|
-
extend Loggability
|
47
|
-
|
48
|
-
|
46
|
+
extend Loggability,
|
47
|
+
Pluggability
|
48
|
+
include Strelka::AbstractClass
|
49
|
+
|
49
50
|
|
50
51
|
# Loggability API -- set up logging under the 'strelka' log host
|
51
52
|
log_to :strelka
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
### Session classes.
|
56
|
-
def self::derivative_dirs
|
57
|
-
return ['strelka/session']
|
58
|
-
end
|
54
|
+
# Pluggability API -- Specify the list of prefixes to try when loading plugins
|
55
|
+
plugin_prefixes 'strelka/session'
|
59
56
|
|
60
57
|
|
61
58
|
### Configure the session class with the given +options+, which should be a
|
@@ -363,7 +363,7 @@ describe Strelka::App::Auth do
|
|
363
363
|
@app.no_auth_for( '' ) {|req| req.verb == :GET }
|
364
364
|
@app.require_perms_for %r{.*}, :it_assets_webapp
|
365
365
|
@app.require_perms_for( %r{.*}, :@sysadmin ) {|req, m| req.verb != :GET }
|
366
|
-
|
366
|
+
|
367
367
|
app = @app.new
|
368
368
|
|
369
369
|
req = @request_factory.get( '/api/v1' )
|
@@ -309,7 +309,7 @@ describe Strelka::App::RestResources do
|
|
309
309
|
body.first.should be_a( Hash )
|
310
310
|
body.first['port'].should > 1024
|
311
311
|
end
|
312
|
-
|
312
|
+
|
313
313
|
it "has a GET route for methods declared in a named dataset module" do
|
314
314
|
req = @request_factory.get( '/api/v1/servers/by_name/Step',
|
315
315
|
:accept => 'application/json' )
|
@@ -32,7 +32,7 @@ describe Strelka::AuthProvider do
|
|
32
32
|
|
33
33
|
|
34
34
|
it "looks for plugins under strelka/authprovider" do
|
35
|
-
described_class.
|
35
|
+
described_class.plugin_prefixes.should include( 'strelka/authprovider' )
|
36
36
|
end
|
37
37
|
|
38
38
|
|
data/spec/strelka/router_spec.rb
CHANGED
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Granger
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
6mKCwjpegytE0oifXfF8k75A9105cBnNiMZOe1tXiqYc/exCgWvbggurzDOcRkZu
|
31
31
|
/YSusaiDXHKU2O3Akc3htA==
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2013-03-
|
33
|
+
date: 2013-03-12 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: configurability
|
@@ -80,14 +80,14 @@ dependencies:
|
|
80
80
|
requirements:
|
81
81
|
- - ~>
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '0.
|
83
|
+
version: '0.12'
|
84
84
|
type: :runtime
|
85
85
|
prerelease: false
|
86
86
|
version_requirements: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
88
|
- - ~>
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: '0.
|
90
|
+
version: '0.12'
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: loggability
|
93
93
|
requirement: !ruby/object:Gem::Requirement
|
@@ -117,19 +117,19 @@ dependencies:
|
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: '0.36'
|
119
119
|
- !ruby/object:Gem::Dependency
|
120
|
-
name:
|
120
|
+
name: pluggability
|
121
121
|
requirement: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
123
|
- - ~>
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: '
|
125
|
+
version: '0.0'
|
126
126
|
type: :runtime
|
127
127
|
prerelease: false
|
128
128
|
version_requirements: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
130
|
- - ~>
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: '
|
132
|
+
version: '0.0'
|
133
133
|
- !ruby/object:Gem::Dependency
|
134
134
|
name: sysexits
|
135
135
|
requirement: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
Binary file
|