strelka 0.15.0 → 0.16.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/ChangeLog +3293 -3058
- data/History.rdoc +17 -0
- data/Manifest.txt +3 -0
- data/Rakefile +2 -2
- data/contrib/hoetemplate/lib/file_name.rb.erb +3 -2
- data/contrib/hoetemplate/spec/file_name_spec.rb.erb +1 -1
- data/examples/apps/auth-demo +1 -2
- data/examples/apps/auth-demo2 +1 -2
- data/examples/apps/sessions-demo +1 -2
- data/examples/gen-config.rb +1 -2
- data/lib/strelka.rb +92 -17
- data/lib/strelka/app.rb +7 -6
- data/lib/strelka/app/auth.rb +5 -5
- data/lib/strelka/app/errors.rb +1 -1
- data/lib/strelka/app/filters.rb +1 -1
- data/lib/strelka/app/negotiation.rb +1 -1
- data/lib/strelka/app/parameters.rb +1 -1
- data/lib/strelka/app/restresources.rb +14 -21
- data/lib/strelka/app/routing.rb +5 -6
- data/lib/strelka/app/sessions.rb +3 -1
- data/lib/strelka/app/templating.rb +1 -1
- data/lib/strelka/authprovider.rb +1 -1
- data/lib/strelka/authprovider/basic.rb +1 -0
- data/lib/strelka/authprovider/hostaccess.rb +1 -0
- data/lib/strelka/behavior/plugin.rb +2 -2
- data/lib/strelka/cli.rb +2 -1
- data/lib/strelka/command/config.rb +2 -1
- data/lib/strelka/command/discover.rb +2 -1
- data/lib/strelka/command/start.rb +2 -1
- data/lib/strelka/constants.rb +1 -1
- data/lib/strelka/cookie.rb +1 -1
- data/lib/strelka/cookieset.rb +1 -1
- data/lib/strelka/discovery.rb +1 -1
- data/lib/strelka/httprequest.rb +4 -4
- data/lib/strelka/httprequest/acceptparams.rb +1 -1
- data/lib/strelka/httprequest/auth.rb +3 -1
- data/lib/strelka/httprequest/negotiation.rb +1 -1
- data/lib/strelka/httprequest/session.rb +3 -1
- data/lib/strelka/httpresponse.rb +2 -3
- data/lib/strelka/httpresponse/negotiation.rb +1 -1
- data/lib/strelka/httpresponse/session.rb +1 -1
- data/lib/strelka/mixins.rb +26 -5
- data/lib/strelka/multipartparser.rb +3 -3
- data/lib/strelka/paramvalidator.rb +4 -4
- data/lib/strelka/plugins.rb +14 -5
- data/lib/strelka/router.rb +1 -1
- data/lib/strelka/router/default.rb +1 -1
- data/lib/strelka/router/exclusive.rb +1 -1
- data/lib/strelka/session.rb +1 -0
- data/lib/strelka/session/db.rb +1 -0
- data/lib/strelka/session/default.rb +1 -0
- data/lib/strelka/testing.rb +454 -14
- data/lib/strelka/websocketserver.rb +150 -36
- data/lib/strelka/websocketserver/heartbeat.rb +163 -0
- data/lib/strelka/websocketserver/routing.rb +46 -19
- data/spec/constants.rb +1 -1
- data/spec/helpers.rb +15 -6
- data/spec/strelka/app/auth_spec.rb +5 -3
- data/spec/strelka/app/errors_spec.rb +2 -2
- data/spec/strelka/app/filters_spec.rb +2 -2
- data/spec/strelka/app/negotiation_spec.rb +2 -2
- data/spec/strelka/app/parameters_spec.rb +5 -5
- data/spec/strelka/app/restresources_spec.rb +8 -6
- data/spec/strelka/app/routing_spec.rb +3 -3
- data/spec/strelka/app/sessions_spec.rb +4 -2
- data/spec/strelka/app/templating_spec.rb +2 -2
- data/spec/strelka/app_spec.rb +5 -24
- data/spec/strelka/authprovider/basic_spec.rb +3 -2
- data/spec/strelka/authprovider/hostaccess_spec.rb +3 -2
- data/spec/strelka/authprovider_spec.rb +3 -2
- data/spec/strelka/cli_spec.rb +7 -4
- data/spec/strelka/cookie_spec.rb +2 -2
- data/spec/strelka/cookieset_spec.rb +2 -2
- data/spec/strelka/discovery_spec.rb +2 -2
- data/spec/strelka/exceptions_spec.rb +2 -2
- data/spec/strelka/httprequest/acceptparams_spec.rb +2 -2
- data/spec/strelka/httprequest/auth_spec.rb +3 -2
- data/spec/strelka/httprequest/negotiation_spec.rb +2 -2
- data/spec/strelka/httprequest/session_spec.rb +3 -2
- data/spec/strelka/httprequest_spec.rb +7 -2
- data/spec/strelka/httpresponse/negotiation_spec.rb +6 -5
- data/spec/strelka/httpresponse/session_spec.rb +3 -2
- data/spec/strelka/httpresponse_spec.rb +4 -3
- data/spec/strelka/mixins_spec.rb +85 -2
- data/spec/strelka/multipartparser_spec.rb +5 -4
- data/spec/strelka/paramvalidator_spec.rb +15 -10
- data/spec/strelka/plugins_spec.rb +24 -2
- data/spec/strelka/router/default_spec.rb +2 -2
- data/spec/strelka/router/exclusive_spec.rb +2 -2
- data/spec/strelka/router_spec.rb +2 -2
- data/spec/strelka/session/db_spec.rb +3 -2
- data/spec/strelka/session/default_spec.rb +3 -2
- data/spec/strelka/session_spec.rb +3 -2
- data/spec/strelka/testing_spec.rb +772 -0
- data/spec/strelka/websocketserver/heartbeat_spec.rb +19 -0
- data/spec/strelka/websocketserver/routing_spec.rb +31 -29
- data/spec/strelka/websocketserver_spec.rb +210 -75
- data/spec/strelka_spec.rb +172 -2
- metadata +43 -36
- metadata.gz.sig +0 -0
data/History.rdoc
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
== v0.16.0 [2019-08-10] Michael Granger <ged@FaerieMUD.org>
|
2
|
+
|
3
|
+
Enhancements:
|
4
|
+
|
5
|
+
- Add spec matchers for matching JSON entity bodies
|
6
|
+
- Allow a block to be passed when loading a plugin
|
7
|
+
- Fix up to work under frozen-string-literals mode
|
8
|
+
- Add setup subcommand to bin/strelka
|
9
|
+
- Rewrite the WebSocketServer to be easier to use and offer some common facilities
|
10
|
+
for managing connections, broadcasting to them, etc.
|
11
|
+
- Update the restresources plugin for Sequel 5.0
|
12
|
+
|
13
|
+
Bugfixes:
|
14
|
+
|
15
|
+
- Fix some unintended argument mutation
|
16
|
+
|
17
|
+
|
1
18
|
== v0.15.0 [2017-06-14] Michael Granger <ged@FaerieMUD.org>
|
2
19
|
|
3
20
|
Enhancements:
|
data/Manifest.txt
CHANGED
@@ -83,6 +83,7 @@ lib/strelka/session/db.rb
|
|
83
83
|
lib/strelka/session/default.rb
|
84
84
|
lib/strelka/testing.rb
|
85
85
|
lib/strelka/websocketserver.rb
|
86
|
+
lib/strelka/websocketserver/heartbeat.rb
|
86
87
|
lib/strelka/websocketserver/routing.rb
|
87
88
|
spec/constants.rb
|
88
89
|
spec/data/error.tmpl
|
@@ -134,6 +135,8 @@ spec/strelka/router_spec.rb
|
|
134
135
|
spec/strelka/session/db_spec.rb
|
135
136
|
spec/strelka/session/default_spec.rb
|
136
137
|
spec/strelka/session_spec.rb
|
138
|
+
spec/strelka/testing_spec.rb
|
139
|
+
spec/strelka/websocketserver/heartbeat_spec.rb
|
137
140
|
spec/strelka/websocketserver/routing_spec.rb
|
138
141
|
spec/strelka/websocketserver_spec.rb
|
139
142
|
spec/strelka_spec.rb
|
data/Rakefile
CHANGED
@@ -16,7 +16,7 @@ Hoe.plugin :deveiate
|
|
16
16
|
|
17
17
|
Hoe.plugins.delete :rubyforge
|
18
18
|
|
19
|
-
hoespec = Hoe.spec 'strelka' do
|
19
|
+
hoespec = Hoe.spec( 'strelka' ) do
|
20
20
|
self.readme_file = 'README.rdoc'
|
21
21
|
self.history_file = 'History.rdoc'
|
22
22
|
self.extra_rdoc_files = FileList[ '*.rdoc' ]
|
@@ -30,7 +30,7 @@ hoespec = Hoe.spec 'strelka' do
|
|
30
30
|
self.dependency 'highline', '~> 1.6'
|
31
31
|
self.dependency 'inversion', '~> 1.0'
|
32
32
|
self.dependency 'loggability', '~> 0.9'
|
33
|
-
self.dependency 'mongrel2', '~> 0.
|
33
|
+
self.dependency 'mongrel2', '~> 0.53'
|
34
34
|
self.dependency 'pluggability', '~> 0.4'
|
35
35
|
self.dependency 'sysexits', '~> 1.1'
|
36
36
|
self.dependency 'uuidtools', '~> 2.1'
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- ruby -*-
|
2
|
-
#
|
2
|
+
# vim: set nosta noet ts=4 sw=4:
|
3
|
+
# frozen-string-literal: true
|
3
4
|
|
4
5
|
# <%= XIF %> (top-level documentation)
|
5
6
|
module <%= klass %>
|
@@ -8,7 +9,7 @@ module <%= klass %>
|
|
8
9
|
VERS<%# this is just here so Hoe doesn't see this constant %>ION = '0.0.1'
|
9
10
|
|
10
11
|
# Version-control revision constant
|
11
|
-
REVISION = %q$Revision
|
12
|
+
REVISION = %q$Revision$
|
12
13
|
|
13
14
|
end # module <%= klass %>
|
14
15
|
|
data/examples/apps/auth-demo
CHANGED
data/examples/apps/auth-demo2
CHANGED
data/examples/apps/sessions-demo
CHANGED
data/examples/gen-config.rb
CHANGED
data/lib/strelka.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
# vim: set nosta noet ts=4 sw=4:
|
3
|
-
#
|
3
|
+
# frozen-string-literal: true
|
4
4
|
|
5
5
|
require 'mongrel2'
|
6
6
|
require 'loggability'
|
@@ -21,19 +21,32 @@ require 'configurability/config'
|
|
21
21
|
module Strelka
|
22
22
|
extend Loggability
|
23
23
|
|
24
|
-
# Loggability API -- Set up this module as a log host.
|
25
|
-
log_as :strelka
|
26
|
-
|
27
24
|
# Library version constant
|
28
|
-
VERSION = '0.
|
25
|
+
VERSION = '0.16.0'
|
29
26
|
|
30
27
|
# Version-control revision constant
|
31
|
-
REVISION = %q$Revision
|
28
|
+
REVISION = %q$Revision$
|
29
|
+
|
30
|
+
# The name of the environment variable that can be used to specify a configfile
|
31
|
+
# to load.
|
32
|
+
CONFIG_ENV = 'STRELKA_CONFIG'
|
33
|
+
|
34
|
+
# The name of the config file for local overrides.
|
35
|
+
LOCAL_CONFIG_FILE = Pathname( '~/.strelka.yml' ).expand_path
|
36
|
+
|
37
|
+
# The name of the config file that's loaded if none is specified.
|
38
|
+
DEFAULT_CONFIG_FILE = Pathname( 'config.yml' ).expand_path
|
39
|
+
|
40
|
+
|
41
|
+
# Loggability API -- set up a logger for this namespace.
|
42
|
+
log_as :strelka
|
43
|
+
|
32
44
|
|
33
45
|
require 'strelka/mixins'
|
34
46
|
require 'strelka/constants'
|
35
47
|
require 'strelka/exceptions'
|
36
48
|
include Strelka::Constants
|
49
|
+
extend Strelka::MethodUtilities
|
37
50
|
|
38
51
|
require 'strelka/app'
|
39
52
|
require 'strelka/httprequest'
|
@@ -50,19 +63,81 @@ module Strelka
|
|
50
63
|
end
|
51
64
|
|
52
65
|
|
53
|
-
|
54
|
-
|
55
|
-
|
66
|
+
### Get the library version. If +include_buildnum+ is true, the version string will
|
67
|
+
### include the VCS rev ID.
|
68
|
+
def self::version_string( include_buildnum=false )
|
69
|
+
vstring = "%s %s" % [ self.name, VERSION ]
|
70
|
+
vstring << " (build %s)" % [ REVISION[/: ([[:xdigit:]]+)/, 1] || '0' ] if include_buildnum
|
71
|
+
return vstring
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
##
|
76
|
+
# An Array of callbacks to be run after the config is loaded
|
77
|
+
singleton_attr_reader :after_configure_hooks
|
78
|
+
@after_configure_hooks = Set.new
|
79
|
+
|
80
|
+
##
|
81
|
+
# True if the after_configure hooks have already (started to) run.
|
82
|
+
singleton_predicate_reader :after_configure_hooks_run
|
83
|
+
@after_configure_hooks_run = false
|
84
|
+
|
85
|
+
|
86
|
+
#
|
87
|
+
# :section: Configuration API
|
88
|
+
#
|
89
|
+
|
90
|
+
### Get the loaded config (a Configurability::Config object)
|
91
|
+
def self::config
|
92
|
+
Configurability.loaded_config
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
### Returns +true+ if the configuration has been loaded at least once.
|
97
|
+
def self::config_loaded?
|
98
|
+
return self.config ? true : false
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
### Register a callback to be run after the config is loaded.
|
103
|
+
def self::after_configure( &block )
|
104
|
+
raise LocalJumpError, "no block given" unless block
|
105
|
+
self.after_configure_hooks << block
|
106
|
+
|
107
|
+
# Call the block immediately if the hooks have already been called or are in
|
108
|
+
# the process of being called.
|
109
|
+
block.call if self.after_configure_hooks_run?
|
110
|
+
end
|
111
|
+
singleton_method_alias :after_configuration, :after_configure
|
112
|
+
|
113
|
+
|
114
|
+
### Call the post-configuration callbacks.
|
115
|
+
def self::call_after_configure_hooks
|
116
|
+
self.log.debug " calling %d post-config hooks" % [ self.after_configure_hooks.length ]
|
117
|
+
@after_configure_hooks_run = true
|
118
|
+
|
119
|
+
self.after_configure_hooks.to_a.each do |hook|
|
120
|
+
self.log.debug " %s line %s..." % hook.source_location
|
121
|
+
hook.call
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
### Load the specified +config_file+, install the config in all objects with
|
127
|
+
### Configurability, and call any callbacks registered via #after_configure.
|
128
|
+
def self::load_config( config_file=nil, defaults=nil )
|
129
|
+
config_file ||= ENV[ CONFIG_ENV ]
|
130
|
+
config_file ||= LOCAL_CONFIG_FILE if LOCAL_CONFIG_FILE.exist?
|
131
|
+
config_file ||= DEFAULT_CONFIG_FILE
|
132
|
+
|
133
|
+
defaults ||= Configurability.gather_defaults
|
56
134
|
|
135
|
+
self.log.warn "Loading config from %p with defaults for sections: %p." %
|
136
|
+
[ config_file, defaults.keys ]
|
137
|
+
config = Configurability::Config.load( config_file, defaults )
|
138
|
+
config.install
|
57
139
|
|
58
|
-
|
59
|
-
### and install it.
|
60
|
-
def self::load_config( configfile, defaults=nil )
|
61
|
-
defaults ||= Configurability.gather_defaults
|
62
|
-
self.log.info "Loading universal config from %p with defaults for sections: %p." %
|
63
|
-
[ configfile, defaults.keys ]
|
64
|
-
self.config = Configurability::Config.load( configfile, defaults )
|
65
|
-
self.config.install
|
140
|
+
self.call_after_configure_hooks
|
66
141
|
end
|
67
142
|
|
68
143
|
|
data/lib/strelka/app.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
# vim: set nosta noet ts=4 sw=4:
|
3
|
-
#
|
3
|
+
# frozen-string-literal: true
|
4
4
|
|
5
5
|
require 'rubygems' # For the Rubygems API
|
6
6
|
|
@@ -175,13 +175,14 @@ class Strelka::App < Mongrel2::Handler
|
|
175
175
|
response.headers.connection = 'close'
|
176
176
|
self.conn.reply( response )
|
177
177
|
|
178
|
-
explanation =
|
179
|
-
|
180
|
-
|
181
|
-
|
178
|
+
explanation = <<~END_OF_MESSAGE
|
179
|
+
If you wish to handle requests like this, either set your server's
|
180
|
+
'limits.content_length' setting to a higher value than %{content_length}, or override
|
181
|
+
#handle_async_upload_start.
|
182
|
+
END_OF_MESSAGE
|
182
183
|
|
183
184
|
self.log.warn "Async upload from %s dropped." % [ request.remote_ip ]
|
184
|
-
self.log.info( explanation )
|
185
|
+
self.log.info( explanation % {content_length: request.content_length} )
|
185
186
|
|
186
187
|
self.conn.reply_close( request )
|
187
188
|
|
data/lib/strelka/app/auth.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
# vim: set nosta noet ts=4 sw=4:
|
3
|
-
#
|
3
|
+
# frozen-string-literal: true
|
4
4
|
|
5
5
|
require 'loggability'
|
6
6
|
|
@@ -370,7 +370,7 @@ module Strelka::App::Auth
|
|
370
370
|
block ||= Proc.new { true }
|
371
371
|
|
372
372
|
criteria.each do |pattern|
|
373
|
-
pattern.gsub
|
373
|
+
pattern = pattern.gsub( %r{^/+|/+$}, '' ) if pattern.respond_to?( :gsub )
|
374
374
|
self.log.debug " adding require_auth for %p" % [ pattern ]
|
375
375
|
self.positive_auth_criteria[ pattern ] = block
|
376
376
|
end
|
@@ -398,7 +398,7 @@ module Strelka::App::Auth
|
|
398
398
|
block ||= Proc.new { true }
|
399
399
|
|
400
400
|
criteria.each do |pattern|
|
401
|
-
pattern.gsub
|
401
|
+
pattern = pattern.gsub( %r{^/+|/+$}, '' ) if pattern.respond_to?( :gsub )
|
402
402
|
self.log.debug " adding no_auth for %p" % [ pattern ]
|
403
403
|
self.negative_auth_criteria[ pattern ] = block
|
404
404
|
end
|
@@ -419,7 +419,7 @@ module Strelka::App::Auth
|
|
419
419
|
true
|
420
420
|
}
|
421
421
|
|
422
|
-
pattern.gsub
|
422
|
+
pattern = pattern.gsub( %r{^/+|/+$}, '' ) if pattern.respond_to?( :gsub )
|
423
423
|
self.log.debug " adding require_perms (%p) for %p" % [ perms, pattern ]
|
424
424
|
self.positive_perms_criteria << [ pattern, block, perms.freeze ]
|
425
425
|
end
|
@@ -435,7 +435,7 @@ module Strelka::App::Auth
|
|
435
435
|
block ||= Proc.new { true }
|
436
436
|
pattern ||= /(?##{block.object_id})/
|
437
437
|
|
438
|
-
pattern.gsub
|
438
|
+
pattern = pattern.gsub( %r{^/+|/+$}, '' ) if pattern.respond_to?( :gsub )
|
439
439
|
self.log.debug " adding no_auth for %p" % [ pattern ]
|
440
440
|
self.negative_perms_criteria << [ pattern, block ]
|
441
441
|
end
|
data/lib/strelka/app/errors.rb
CHANGED
data/lib/strelka/app/filters.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
# vim: set nosta noet ts=4 sw=4:
|
3
|
-
#
|
3
|
+
# frozen-string-literal: true
|
4
4
|
|
5
5
|
require 'set'
|
6
6
|
require 'sequel'
|
@@ -55,19 +55,6 @@ require 'strelka/app' unless defined?( Strelka::App )
|
|
55
55
|
# isn't clearly specified in the RFC (DELETE /resource)
|
56
56
|
# [ ] Sequel plugin for adding links to serialized representations
|
57
57
|
#
|
58
|
-
# == Caveats / Known Problems
|
59
|
-
#
|
60
|
-
# * Dataset methods declared using the 'subset' declaration don't allow the
|
61
|
-
# introspection necessary for automatically building routes, so you have
|
62
|
-
# to declare them as normal methods in a dataset module:
|
63
|
-
#
|
64
|
-
# dataset_module do
|
65
|
-
# def by_name( string )
|
66
|
-
# filter(:name => string)
|
67
|
-
# end
|
68
|
-
# end
|
69
|
-
#
|
70
|
-
#
|
71
58
|
# == Supported/Planned Options
|
72
59
|
#
|
73
60
|
# The 'resource' directive accepts options that control which methods it
|
@@ -76,18 +63,20 @@ require 'strelka/app' unless defined?( Strelka::App )
|
|
76
63
|
# [√] :readonly => false
|
77
64
|
# [ ] :include => <array of verbs>
|
78
65
|
# [ ] :exclude => <array of verbs>
|
79
|
-
# [ ] :
|
66
|
+
# [ ] :filters => <boolean or array>
|
80
67
|
# [ ] :associations => <boolean or array>
|
68
|
+
# [ ] :composite =< <boolean or array>
|
81
69
|
#
|
82
70
|
module Strelka::App::RestResources
|
83
71
|
extend Strelka::Plugin
|
84
72
|
|
85
73
|
# Resource route option defaults
|
86
74
|
DEFAULTS = {
|
87
|
-
prefix:
|
75
|
+
prefix: nil,
|
88
76
|
name: nil,
|
89
77
|
readonly: false,
|
90
78
|
use_transactions: true,
|
79
|
+
composite: true
|
91
80
|
}.freeze
|
92
81
|
|
93
82
|
|
@@ -148,6 +137,7 @@ module Strelka::App::RestResources
|
|
148
137
|
def resource( rsrcobj, options={} )
|
149
138
|
self.log.debug "Adding REST resource for %p" % [ rsrcobj ]
|
150
139
|
options = self.service_options.merge( options )
|
140
|
+
self.log.warn "Options = %p" % [ options ]
|
151
141
|
|
152
142
|
# Add a parameter for the primary key
|
153
143
|
pkey = rsrcobj.primary_key
|
@@ -160,6 +150,7 @@ module Strelka::App::RestResources
|
|
160
150
|
# Figure out what the resource name is, and make the route from it
|
161
151
|
name = options[:name] || rsrcobj.implicit_table_name
|
162
152
|
route = [ options[:prefix], name ].compact.join( '/' )
|
153
|
+
self.log.warn "Route is: %p" % [[ options[:prefix], name ]]
|
163
154
|
|
164
155
|
# Ensure validated parameters are untainted
|
165
156
|
self.untaint_all_constraints
|
@@ -184,7 +175,7 @@ module Strelka::App::RestResources
|
|
184
175
|
end
|
185
176
|
|
186
177
|
# Add any composite resources based on the +rsrcobj+'s associations
|
187
|
-
self.add_composite_resource_handlers( route, rsrcobj, options )
|
178
|
+
self.add_composite_resource_handlers( route, rsrcobj, options ) if options[:composite]
|
188
179
|
end
|
189
180
|
|
190
181
|
|
@@ -199,7 +190,7 @@ module Strelka::App::RestResources
|
|
199
190
|
|
200
191
|
# Gather up metadata describing the resource
|
201
192
|
verbs = self.class.resource_verbs[ route ].sort
|
202
|
-
columns = rsrcobj.
|
193
|
+
columns = rsrcobj.columns
|
203
194
|
attributes = columns.each_with_object({}) do |col, hash|
|
204
195
|
hash[ col ] = rsrcobj.db_schema[ col ][:type]
|
205
196
|
end
|
@@ -259,7 +250,7 @@ module Strelka::App::RestResources
|
|
259
250
|
[ rsrcobj, route ]
|
260
251
|
|
261
252
|
# Make a column regexp for validating the order field
|
262
|
-
colunion = Regexp.union(
|
253
|
+
colunion = Regexp.union( rsrcobj.columns.map(&:to_s) )
|
263
254
|
colre = /^(?<column>#{colunion})$/
|
264
255
|
|
265
256
|
self.add_route( :GET, route, options ) do |req|
|
@@ -522,6 +513,8 @@ module Strelka::App::RestResources
|
|
522
513
|
|
523
514
|
### Add routes for any associations +rsrcobj+ has as composite resources.
|
524
515
|
def add_composite_resource_handlers( route_prefix, rsrcobj, options )
|
516
|
+
self.log.debug "Adding composite resource handlers for %p to %s (%p)" %
|
517
|
+
[ rsrcobj, route_prefix, options ]
|
525
518
|
|
526
519
|
# Add methods declared by (user-declared) dataset modules.
|
527
520
|
ds_mods = rsrcobj.dataset_method_modules.select do |mod|
|
@@ -621,7 +614,7 @@ module Strelka::App::RestResources
|
|
621
614
|
self.log.debug "Adding composite read handler for association: %s" % [ association ]
|
622
615
|
|
623
616
|
pkey = rsrcobj.primary_key
|
624
|
-
colunion = Regexp.union(
|
617
|
+
colunion = Regexp.union( rsrcobj.columns.map(&:to_s) )
|
625
618
|
colre = /^(?<column>#{colunion})$/
|
626
619
|
|
627
620
|
self.add_route( :GET, path, options ) do |req|
|
@@ -686,7 +679,7 @@ module Strelka::App::RestResources
|
|
686
679
|
### Add parameter validations for the given +columns+ of the specified resource object +rsrcobj+
|
687
680
|
### to the specified parameter +validator+.
|
688
681
|
def add_resource_params( validator, rsrcobj, *columns )
|
689
|
-
columns = rsrcobj.
|
682
|
+
columns = rsrcobj.columns if columns.empty?
|
690
683
|
|
691
684
|
columns.each do |col|
|
692
685
|
config = rsrcobj.db_schema[ col ] or
|