rocketio 0.0.8 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rocketio/controller.rb +40 -20
- data/lib/rocketio/controller/authentication.rb +5 -7
- data/lib/rocketio/controller/authorization.rb +1 -3
- data/lib/rocketio/controller/error_handlers.rb +3 -3
- data/lib/rocketio/controller/filters.rb +3 -3
- data/lib/rocketio/controller/middleware.rb +1 -1
- data/lib/rocketio/controller/render/engine.rb +3 -3
- data/lib/rocketio/controller/render/layout.rb +1 -1
- data/lib/rocketio/controller/render/layouts.rb +8 -8
- data/lib/rocketio/controller/render/template_vars.rb +3 -3
- data/lib/rocketio/controller/render/templates.rb +8 -8
- data/lib/rocketio/controller/sessions.rb +1 -1
- data/lib/rocketio/version.rb +1 -1
- data/rocketio.gemspec +2 -2
- data/test/api_test.rb +155 -0
- data/test/authentication_test.rb +4 -4
- data/test/authorization_test.rb +2 -2
- data/test/filters_test.rb +9 -9
- data/test/middleware_test.rb +2 -2
- data/test/render/engine_test.rb +1 -1
- data/test/render/layout_test.rb +1 -1
- data/test/render/layouts_test.rb +5 -5
- data/test/render/template_vars_test.rb +3 -3
- data/test/render/templates_test.rb +5 -5
- data/test/sessions_test.rb +2 -2
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9540db8ccba375983a890602be457287f31f7e2
|
4
|
+
data.tar.gz: aeeba39bb33341e1c015c099040793df15e1b396
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 135b3a8e35301383adf5b21ae1a3a80aa0639feb1d44d5cd96e82c4c4da453844890cffe4517aceb2b5642d664d9893bd8889c10d7d05a58026a4e7220c1544b
|
7
|
+
data.tar.gz: b526fcf90b86d59f0e1a3cf6cd847c1d752919ef4e27a6c9b4e85a741b06795e1a3b7ed2554dfbfe300d3e5b3014390e224840939008a00b2ebf155d37c31873
|
data/lib/rocketio/controller.rb
CHANGED
@@ -56,6 +56,7 @@ module RocketIO
|
|
56
56
|
}
|
57
57
|
invoke_after_filter
|
58
58
|
}
|
59
|
+
|
59
60
|
response.body ||= RocketIO::EMPTY_ARRAY
|
60
61
|
response.body = [] if head? # dropping body on HEAD requests
|
61
62
|
response.finish
|
@@ -122,32 +123,53 @@ module RocketIO
|
|
122
123
|
|
123
124
|
class << Controller
|
124
125
|
|
125
|
-
|
126
|
-
|
127
|
-
|
126
|
+
# only public non-inherited methods are included in public API directly.
|
127
|
+
def api
|
128
|
+
return [] if self == RocketIO::Controller
|
129
|
+
public_instance_methods(false).concat(inherited_api) - private_api
|
130
|
+
end
|
131
|
+
|
132
|
+
# inherited methods are excluded from public API
|
133
|
+
# but we still need a way to know what API methods was inherited
|
134
|
+
def inherited_api
|
135
|
+
@__inherited_api__
|
136
|
+
end
|
137
|
+
|
138
|
+
# used internally to keep a list of public methods
|
139
|
+
# that should be excluded from public API
|
140
|
+
def private_api
|
141
|
+
@__private_api__
|
142
|
+
end
|
143
|
+
|
144
|
+
# import some config from some controller
|
145
|
+
def import setup, from:
|
146
|
+
__send__(:"define_#{setup}_methods", from)
|
128
147
|
end
|
129
148
|
|
130
149
|
def inherited base
|
131
150
|
# registering new controller
|
132
151
|
RocketIO.controllers.push(base)
|
133
152
|
|
153
|
+
base.instance_variable_set(:@__private_api__, self.private_api.uniq)
|
154
|
+
base.instance_variable_set(:@__inherited_api__, self.api.freeze)
|
155
|
+
|
134
156
|
# new controller inherits all setups from superclass
|
135
|
-
base.
|
136
|
-
base.
|
137
|
-
base.
|
157
|
+
base.import :before, from: self
|
158
|
+
base.import :around, from: self
|
159
|
+
base.import :after, from: self
|
138
160
|
|
139
|
-
base.
|
140
|
-
base.
|
141
|
-
base.
|
161
|
+
base.import :basic_auth, from: self
|
162
|
+
base.import :digest_auth, from: self
|
163
|
+
base.import :token_auth, from: self
|
142
164
|
|
143
|
-
base.
|
144
|
-
base.
|
145
|
-
base.
|
165
|
+
base.import :error_handlers, from: self
|
166
|
+
base.import :middleware, from: self
|
167
|
+
base.import :sessions, from: self
|
146
168
|
|
147
|
-
base.
|
148
|
-
base.
|
149
|
-
base.
|
150
|
-
base.
|
169
|
+
base.import :engine, from: self
|
170
|
+
base.import :layout, from: self
|
171
|
+
base.import :layouts, from: self
|
172
|
+
base.import :templates, from: self
|
151
173
|
|
152
174
|
# removing superclass name from new controller name
|
153
175
|
path = RocketIO.underscore(base.name.to_s.sub(self.name.to_s + '::', '').gsub('::', '/'))
|
@@ -279,11 +301,9 @@ module RocketIO
|
|
279
301
|
def call env
|
280
302
|
initialize_controller.call(env)
|
281
303
|
end
|
282
|
-
|
283
|
-
def api
|
284
|
-
public_instance_methods(false)
|
285
|
-
end
|
286
304
|
end
|
305
|
+
|
306
|
+
Controller.instance_variable_set(:@__private_api__, [])
|
287
307
|
end
|
288
308
|
|
289
309
|
require 'rocketio/controller/authentication'
|
@@ -46,11 +46,11 @@ module RocketIO
|
|
46
46
|
def self.define_basic_auth_methods source = self
|
47
47
|
prompts = (source.instance_variable_get(:@__basic_auth__) || {}).each_with_object(allocate.basic_auth.dup) do |(rm,p),o|
|
48
48
|
method = :"__basic_auth__#{rm}__"
|
49
|
-
define_method(method, &p[:block])
|
49
|
+
private_api << define_method(method, &p[:block])
|
50
50
|
o[rm] = p.merge(method: method).freeze
|
51
51
|
end.freeze
|
52
52
|
return if prompts.empty?
|
53
|
-
define_method(:basic_auth) {prompts}
|
53
|
+
private_api << define_method(:basic_auth) {prompts}
|
54
54
|
end
|
55
55
|
|
56
56
|
def basic_auth; RocketIO::EMPTY_HASH end
|
@@ -109,18 +109,16 @@ module RocketIO
|
|
109
109
|
def self.define_digest_auth_methods source = self
|
110
110
|
prompts = (source.instance_variable_get(:@__digest_auth__) || {}).each_with_object(allocate.digest_auth.dup) do |(rm,p),o|
|
111
111
|
method = :"__digest_auth__#{rm}__"
|
112
|
-
define_method(method, &p[:block])
|
112
|
+
private_api << define_method(method, &p[:block])
|
113
113
|
o[rm] = p.merge(method: method).freeze
|
114
114
|
end.freeze
|
115
115
|
return if prompts.empty?
|
116
|
-
define_method(:digest_auth) {prompts}
|
116
|
+
private_api << define_method(:digest_auth) {prompts}
|
117
117
|
end
|
118
118
|
|
119
119
|
def digest_auth; RocketIO::EMPTY_HASH end
|
120
120
|
|
121
|
-
def user
|
122
|
-
env[RocketIO::REMOTE_USER]
|
123
|
-
end
|
121
|
+
def user?; env[RocketIO::REMOTE_USER] end
|
124
122
|
|
125
123
|
# checks whether authentication is required and
|
126
124
|
# send an authorization request if credentials not present or invalid
|
@@ -25,7 +25,7 @@ module RocketIO
|
|
25
25
|
def self.define_token_auth_methods source = self
|
26
26
|
prompts = allocate.token_auth.merge(source.instance_variable_get(:@__token_auth__) || {}).freeze
|
27
27
|
return if prompts.empty?
|
28
|
-
define_method(:token_auth) {prompts}
|
28
|
+
private_api << define_method(:token_auth) {prompts}
|
29
29
|
end
|
30
30
|
|
31
31
|
def token_auth; RocketIO::EMPTY_HASH end
|
@@ -43,11 +43,9 @@ module RocketIO
|
|
43
43
|
def validate_token_auth &block
|
44
44
|
RocketIO::TokenAuth.authenticate(env, &block)
|
45
45
|
end
|
46
|
-
alias valid_token_auth? validate_token_auth
|
47
46
|
|
48
47
|
def request_token_auth realm = RocketIO::DEFAULT_TOKEN_AUTH_REALM
|
49
48
|
RocketIO::TokenAuth.authentication_request(realm)
|
50
49
|
end
|
51
|
-
alias request_token_auth! request_token_auth
|
52
50
|
end
|
53
51
|
end
|
@@ -36,14 +36,14 @@ module RocketIO
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def self.define_error_handlers_methods source = self
|
39
|
-
handlers = (source.instance_variable_get(:@__error_handlers__) || {}).each_with_object({}) do |(code,
|
39
|
+
handlers = (source.instance_variable_get(:@__error_handlers__) || {}).each_with_object({}) do |(code,block),o|
|
40
40
|
o[code] = :"__#{code}_error_handler__"
|
41
|
-
define_method(o[code], &
|
41
|
+
private_api << define_method(o[code], &block)
|
42
42
|
end
|
43
43
|
handlers.update(allocate.error_handlers)
|
44
44
|
return if handlers.empty?
|
45
45
|
handlers.freeze
|
46
|
-
define_method(:error_handlers) {handlers}
|
46
|
+
private_api << define_method(:error_handlers) {handlers}
|
47
47
|
end
|
48
48
|
|
49
49
|
def error_handlers; RocketIO::EMPTY_HASH end
|
@@ -73,14 +73,14 @@ module RocketIO
|
|
73
73
|
end
|
74
74
|
|
75
75
|
define_singleton_method define_methods do |source = self|
|
76
|
-
filters = (source.instance_variable_get(var) || {}).each_with_object({}) do |(meth,
|
76
|
+
filters = (source.instance_variable_get(var) || {}).each_with_object({}) do |(meth,block),o|
|
77
77
|
o[meth] = :"__#{filter}_#{meth}__"
|
78
|
-
define_method(o[meth], &
|
78
|
+
private_api << define_method(o[meth], &block)
|
79
79
|
end
|
80
80
|
filters.update(allocate.__send__(filter))
|
81
81
|
return unless filters.any?
|
82
82
|
filters.freeze
|
83
|
-
define_method(filter) {filters}
|
83
|
+
private_api << define_method(filter) {filters}
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
@@ -24,7 +24,7 @@ module RocketIO
|
|
24
24
|
def self.define_middleware_methods source = self
|
25
25
|
middleware = ((source.instance_variable_get(:@__middleware__) || []) + allocate.middleware).uniq.freeze
|
26
26
|
return if middleware.empty?
|
27
|
-
define_method(:middleware) {middleware}
|
27
|
+
private_api << define_method(:middleware) {middleware}
|
28
28
|
end
|
29
29
|
|
30
30
|
def middleware; RocketIO::EMPTY_ARRAY end
|
@@ -60,14 +60,14 @@ module RocketIO
|
|
60
60
|
return unless engine = source.instance_variable_get(:@__engine__)
|
61
61
|
if Proc === engine
|
62
62
|
selfengine = allocate.engine
|
63
|
-
define_method(:__rocketio_engine__, &engine)
|
64
|
-
define_method(:engine) {
|
63
|
+
private_api << define_method(:__rocketio_engine__, &engine)
|
64
|
+
private_api << define_method(:engine) {
|
65
65
|
engine, *engine_options = __rocketio_engine__
|
66
66
|
return selfengine unless engine
|
67
67
|
[RocketIO.engine_class(engine), engine_options.freeze].freeze
|
68
68
|
}
|
69
69
|
else
|
70
|
-
define_method(:engine) {engine}
|
70
|
+
private_api << define_method(:engine) {engine}
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
@@ -17,7 +17,7 @@ module RocketIO
|
|
17
17
|
def self.define_layout_methods source = self
|
18
18
|
return unless source.instance_variables.include?(:@__layout__)
|
19
19
|
layout = source.instance_variable_get(:@__layout__)
|
20
|
-
define_method(:layout) {layout}
|
20
|
+
private_api << define_method(:layout) {layout}
|
21
21
|
end
|
22
22
|
|
23
23
|
# by default no layout used, so this method returns nil.
|
@@ -59,25 +59,25 @@ module RocketIO
|
|
59
59
|
o[name] = :"__#{name}_layout__"
|
60
60
|
if setup[:block]
|
61
61
|
# block given, do not search for file, use returned value instead
|
62
|
-
define_method(o[name], &setup[:block])
|
62
|
+
private_api << define_method(o[name], &setup[:block])
|
63
63
|
elsif setup[:file]
|
64
64
|
# file given, search the file in original controller dirname
|
65
|
-
meth_name = :"__#{name}_layout_file__"
|
65
|
+
private_api << meth_name = :"__#{name}_layout_file__"
|
66
66
|
meth_proc = setup[:file].is_a?(::Proc) ? setup[:file] : -> {setup[:file]}
|
67
|
-
define_method(meth_name, &meth_proc)
|
68
|
-
define_method
|
67
|
+
private_api << define_method(meth_name, &meth_proc)
|
68
|
+
private_api << define_method(o[name]) {
|
69
69
|
engine, * = resolve_engine
|
70
70
|
read_template(find_template(setup[:root], __send__(meth_name), engine))
|
71
|
-
|
71
|
+
}
|
72
72
|
else
|
73
73
|
# only name given, search for a file with same name in controller's dirname
|
74
|
-
define_method
|
74
|
+
private_api << define_method(o[name]) {
|
75
75
|
engine, * = resolve_engine
|
76
76
|
read_template(find_template(self.dirname, setup[:name], engine))
|
77
|
-
|
77
|
+
}
|
78
78
|
end
|
79
79
|
end.freeze
|
80
|
-
define_method(:layouts) {layouts}
|
80
|
+
private_api << define_method(:layouts) {layouts}
|
81
81
|
end
|
82
82
|
|
83
83
|
def layouts; RocketIO::EMPTY_HASH end
|
@@ -17,12 +17,12 @@ module RocketIO
|
|
17
17
|
vars = source.instance_variable_get(:@__template_vars__).each_with_object(allocate.__template_vars__.dup) do |(name,value),o|
|
18
18
|
o[name] = :"__#{name}_template_var__"
|
19
19
|
if value.is_a?(Proc)
|
20
|
-
define_method(o[name], &value)
|
20
|
+
private_api << define_method(o[name], &value)
|
21
21
|
else
|
22
|
-
define_method(o[name]) {value}
|
22
|
+
private_api << define_method(o[name]) {value}
|
23
23
|
end
|
24
24
|
end.freeze
|
25
|
-
define_method(:__template_vars__) {vars}
|
25
|
+
private_api << define_method(:__template_vars__) {vars}
|
26
26
|
end
|
27
27
|
|
28
28
|
def __template_vars__; RocketIO::EMPTY_HASH end
|
@@ -57,25 +57,25 @@ module RocketIO
|
|
57
57
|
o[name] = :"__#{name}_template__"
|
58
58
|
if setup[:block]
|
59
59
|
# block given, do not search for file, use returned value instead
|
60
|
-
define_method(o[name], &setup[:block])
|
60
|
+
private_api << define_method(o[name], &setup[:block])
|
61
61
|
elsif setup[:file]
|
62
62
|
# file given, search the file in original controller dirname
|
63
|
-
meth_name = :"__#{name}_template_file__"
|
63
|
+
private_api << meth_name = :"__#{name}_template_file__"
|
64
64
|
meth_proc = setup[:file].is_a?(Proc) ? setup[:file] : -> {setup[:file]}
|
65
|
-
define_method(meth_name, &meth_proc)
|
66
|
-
define_method
|
65
|
+
private_api << define_method(meth_name, &meth_proc)
|
66
|
+
private_api << define_method(o[name]) {
|
67
67
|
engine, * = resolve_engine
|
68
68
|
read_template(find_template(setup[:root], __send__(meth_name), engine))
|
69
|
-
|
69
|
+
}
|
70
70
|
else
|
71
71
|
# only name given, search for a file with same name in controller's dirname
|
72
|
-
define_method
|
72
|
+
private_api << define_method(o[name]) {
|
73
73
|
engine, * = resolve_engine
|
74
74
|
read_template(find_template(self.dirname, setup[:name], engine))
|
75
|
-
|
75
|
+
}
|
76
76
|
end
|
77
77
|
end.freeze
|
78
|
-
define_method(:templates) {templates}
|
78
|
+
private_api << define_method(:templates) {templates}
|
79
79
|
end
|
80
80
|
|
81
81
|
def templates; RocketIO::EMPTY_HASH end
|
@@ -56,7 +56,7 @@ module RocketIO
|
|
56
56
|
def self.define_sessions_methods source = self
|
57
57
|
return unless source.instance_variables.include?(:@__sessions__)
|
58
58
|
sessions = source.instance_variable_get(:@__sessions__)
|
59
|
-
define_method(:sessions) {sessions}
|
59
|
+
private_api << define_method(:sessions) {sessions}
|
60
60
|
end
|
61
61
|
|
62
62
|
def sessions; end
|
data/lib/rocketio/version.rb
CHANGED
data/rocketio.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.files = Dir['**/{*,.[a-z]*}'].reject {|e| e =~ /(gem|lock)\z/}
|
15
15
|
spec.require_paths = ['lib']
|
16
16
|
|
17
|
-
spec.required_ruby_version = '~> 2.
|
17
|
+
spec.required_ruby_version = '~> 2.2'
|
18
18
|
|
19
19
|
spec.add_runtime_dependency 'rack', '~> 1.5'
|
20
20
|
spec.add_runtime_dependency 'mustache', '~> 1'
|
@@ -23,5 +23,5 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency 'bundler', '~> 1.7'
|
24
24
|
spec.add_development_dependency 'rake', '~> 10.0'
|
25
25
|
spec.add_development_dependency 'tokyo', '~> 0'
|
26
|
-
spec.add_development_dependency 'rack-radar'
|
26
|
+
spec.add_development_dependency 'rack-radar', '~> 0'
|
27
27
|
end
|
data/test/api_test.rb
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
require 'setup'
|
2
|
+
|
3
|
+
spec :api do
|
4
|
+
|
5
|
+
it 'should contain only public non-inherited methods' do
|
6
|
+
c = mock_controller {
|
7
|
+
basic_auth {}
|
8
|
+
digest_auth {}
|
9
|
+
token_auth {}
|
10
|
+
error(500) {}
|
11
|
+
before {}
|
12
|
+
around {}
|
13
|
+
after {}
|
14
|
+
use proc {}
|
15
|
+
sessions :cookies
|
16
|
+
engine :ERB
|
17
|
+
layout :main
|
18
|
+
define_layout(:main) {}
|
19
|
+
define_layout(:file, file: :file)
|
20
|
+
define_template(:main) {}
|
21
|
+
define_template(:file, file: :file)
|
22
|
+
define_template_var(:var) {}
|
23
|
+
}
|
24
|
+
assert(c.api).empty?
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
it 'should inherit api methods' do
|
29
|
+
a = mock_controller {
|
30
|
+
def x; end
|
31
|
+
}
|
32
|
+
|
33
|
+
b = mock_controller(a) {
|
34
|
+
def y; end
|
35
|
+
}
|
36
|
+
|
37
|
+
assert(b.api).include?(:x)
|
38
|
+
assert(b.api).include?(:y)
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
context :private_api do
|
43
|
+
|
44
|
+
it 'should contain auth methods' do
|
45
|
+
c = mock_controller {
|
46
|
+
basic_auth {}
|
47
|
+
digest_auth {}
|
48
|
+
token_auth {}
|
49
|
+
}
|
50
|
+
assert(c.private_api).include?(:basic_auth)
|
51
|
+
assert(c.private_api).include?(:__basic_auth__get__)
|
52
|
+
|
53
|
+
assert(c.private_api).include?(:digest_auth)
|
54
|
+
assert(c.private_api).include?(:__digest_auth__get__)
|
55
|
+
|
56
|
+
assert(c.private_api).include?(:token_auth)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should contain error handler methods' do
|
60
|
+
c = mock_controller {
|
61
|
+
error(500) {}
|
62
|
+
}
|
63
|
+
assert(c.private_api).include?(:error_handlers)
|
64
|
+
assert(c.private_api).include?(:__404_error_handler__)
|
65
|
+
assert(c.private_api).include?(:__409_error_handler__)
|
66
|
+
assert(c.private_api).include?(:__501_error_handler__)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should contain filters methods' do
|
70
|
+
c = mock_controller {
|
71
|
+
before {}
|
72
|
+
around {}
|
73
|
+
after {}
|
74
|
+
}
|
75
|
+
assert(c.private_api).include?(:before)
|
76
|
+
assert(c.private_api).include?(:'__before_*__')
|
77
|
+
|
78
|
+
assert(c.private_api).include?(:around)
|
79
|
+
assert(c.private_api).include?(:'__around_*__')
|
80
|
+
|
81
|
+
assert(c.private_api).include?(:after)
|
82
|
+
assert(c.private_api).include?(:'__after_*__')
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should contain middleware methods' do
|
87
|
+
c = mock_controller {
|
88
|
+
use proc {}
|
89
|
+
}
|
90
|
+
assert(c.private_api).include?(:middleware)
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'should contain session methods' do
|
94
|
+
c = mock_controller {
|
95
|
+
sessions :cookies
|
96
|
+
}
|
97
|
+
assert(c.private_api).include?(:sessions)
|
98
|
+
end
|
99
|
+
|
100
|
+
context :render do
|
101
|
+
|
102
|
+
it 'should contain engine methods' do
|
103
|
+
c = mock_controller {
|
104
|
+
engine :ERB
|
105
|
+
}
|
106
|
+
|
107
|
+
assert(c.private_api).include?(:engine)
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'should contain engine methods when engine defined as block' do
|
111
|
+
c = mock_controller {
|
112
|
+
engine {:ERB}
|
113
|
+
}
|
114
|
+
|
115
|
+
assert(c.private_api).include?(:engine)
|
116
|
+
assert(c.private_api).include?(:__rocketio_engine__)
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'should contain layout methods' do
|
120
|
+
c = mock_controller {
|
121
|
+
layout :main
|
122
|
+
define_layout(:main) {}
|
123
|
+
define_layout(:file, file: :file)
|
124
|
+
}
|
125
|
+
|
126
|
+
assert(c.private_api).include?(:layout)
|
127
|
+
assert(c.private_api).include?(:layouts)
|
128
|
+
assert(c.private_api).include?(:__file_layout_file__)
|
129
|
+
assert(c.private_api).include?(:__file_layout__)
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'should contain template methods' do
|
133
|
+
c = mock_controller {
|
134
|
+
define_template(:main) {}
|
135
|
+
define_template(:file, file: :file)
|
136
|
+
}
|
137
|
+
|
138
|
+
assert(c.private_api).include?(:templates)
|
139
|
+
assert(c.private_api).include?(:__file_template_file__)
|
140
|
+
assert(c.private_api).include?(:__file_template__)
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'should contain template_var methods' do
|
144
|
+
c = mock_controller {
|
145
|
+
define_template_var(:var) {}
|
146
|
+
}
|
147
|
+
|
148
|
+
assert(c.private_api).include?(:__template_vars__)
|
149
|
+
assert(c.private_api).include?(:__var_template_var__)
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
end
|
data/test/authentication_test.rb
CHANGED
@@ -38,7 +38,7 @@ spec :AuthenticationTest do
|
|
38
38
|
basic_auth {|u,p| [u,p] == %w[x y]}
|
39
39
|
}
|
40
40
|
c = mock_controller(a) {
|
41
|
-
|
41
|
+
import :basic_auth, from: b
|
42
42
|
}
|
43
43
|
app(c)
|
44
44
|
get
|
@@ -53,7 +53,7 @@ spec :AuthenticationTest do
|
|
53
53
|
basic_auth {|u,p| [u,p] == %w[u p]}
|
54
54
|
}
|
55
55
|
b = mock_controller {
|
56
|
-
|
56
|
+
import :basic_auth, from: a
|
57
57
|
}
|
58
58
|
app(b)
|
59
59
|
get
|
@@ -99,7 +99,7 @@ spec :AuthenticationTest do
|
|
99
99
|
digest_auth {|u| {'x' => 'y'}[u]}
|
100
100
|
}
|
101
101
|
c = mock_controller(a) {
|
102
|
-
|
102
|
+
import :digest_auth, from: b
|
103
103
|
}
|
104
104
|
app(b)
|
105
105
|
get
|
@@ -114,7 +114,7 @@ spec :AuthenticationTest do
|
|
114
114
|
digest_auth {|u| {'u' => 'p'}[u]}
|
115
115
|
}
|
116
116
|
b = mock_controller {
|
117
|
-
|
117
|
+
import :digest_auth, from: a
|
118
118
|
}
|
119
119
|
app(b)
|
120
120
|
get
|
data/test/authorization_test.rb
CHANGED
@@ -38,7 +38,7 @@ spec :AuthorizationTest do
|
|
38
38
|
token_auth {|t| t == 'y'}
|
39
39
|
}
|
40
40
|
c = mock_controller(a) {
|
41
|
-
|
41
|
+
import :token_auth, from: b
|
42
42
|
}
|
43
43
|
app(c)
|
44
44
|
get
|
@@ -53,7 +53,7 @@ spec :AuthorizationTest do
|
|
53
53
|
token_auth {|t| t == 'x'}
|
54
54
|
}
|
55
55
|
b = mock_controller {
|
56
|
-
|
56
|
+
import :token_auth, from: a
|
57
57
|
}
|
58
58
|
app(b)
|
59
59
|
get
|
data/test/filters_test.rb
CHANGED
@@ -26,9 +26,9 @@ spec :Filters do
|
|
26
26
|
def get; end
|
27
27
|
}
|
28
28
|
b = mock_controller {
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
import :before, from: a
|
30
|
+
import :around, from: a
|
31
|
+
import :after, from: a
|
32
32
|
}
|
33
33
|
app(b)
|
34
34
|
get
|
@@ -49,9 +49,9 @@ spec :Filters do
|
|
49
49
|
after(:get) {after << :b}
|
50
50
|
}
|
51
51
|
c = mock_controller(a) {
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
import :before, from: b
|
53
|
+
import :around, from: b
|
54
|
+
import :after, from: b
|
55
55
|
}
|
56
56
|
app(c)
|
57
57
|
get
|
@@ -73,9 +73,9 @@ spec :Filters do
|
|
73
73
|
after(:post) {after_post << :b}
|
74
74
|
}
|
75
75
|
c = mock_controller(a) {
|
76
|
-
|
77
|
-
|
78
|
-
|
76
|
+
import :before, from: b
|
77
|
+
import :around, from: b
|
78
|
+
import :after, from: b
|
79
79
|
}
|
80
80
|
app(c)
|
81
81
|
get
|
data/test/middleware_test.rb
CHANGED
@@ -29,7 +29,7 @@ spec :Middleware do
|
|
29
29
|
}
|
30
30
|
b = mock_controller {
|
31
31
|
use(ware) { buff << 3 }
|
32
|
-
|
32
|
+
import :middleware, from: a
|
33
33
|
def get; end
|
34
34
|
}
|
35
35
|
app mock_app(b)
|
@@ -47,7 +47,7 @@ spec :Middleware do
|
|
47
47
|
def get; end
|
48
48
|
}
|
49
49
|
c = mock_controller(a) {
|
50
|
-
|
50
|
+
import :middleware, from: b
|
51
51
|
def get; end
|
52
52
|
}
|
53
53
|
app mock_app(c)
|
data/test/render/engine_test.rb
CHANGED
data/test/render/layout_test.rb
CHANGED
data/test/render/layouts_test.rb
CHANGED
@@ -40,7 +40,7 @@ spec :layouts do
|
|
40
40
|
define_layout(:x) {'b'}
|
41
41
|
}
|
42
42
|
c = mock_controller(a) {
|
43
|
-
|
43
|
+
import :layouts, from: b
|
44
44
|
}.initialize_controller
|
45
45
|
assert(c.__send__ c.layouts[:x]) == 'b'
|
46
46
|
end
|
@@ -53,7 +53,7 @@ spec :layouts do
|
|
53
53
|
define_layout(:b) {'b'}
|
54
54
|
}
|
55
55
|
c = mock_controller(a) {
|
56
|
-
|
56
|
+
import :layouts, from: b
|
57
57
|
}.initialize_controller
|
58
58
|
assert(c.__send__ c.layouts[:a]) == 'a'
|
59
59
|
assert(c.__send__ c.layouts[:b]) == 'b'
|
@@ -65,7 +65,7 @@ spec :layouts do
|
|
65
65
|
}
|
66
66
|
b = mock_controller {
|
67
67
|
define_layout(:x) {'b'}
|
68
|
-
|
68
|
+
import :layouts, from: a
|
69
69
|
}.initialize_controller
|
70
70
|
assert(b.__send__ b.layouts[:x]) == 'a'
|
71
71
|
end
|
@@ -76,7 +76,7 @@ spec :layouts do
|
|
76
76
|
}
|
77
77
|
b = mock_controller {
|
78
78
|
define_layout(:b) {'b'}
|
79
|
-
|
79
|
+
import :layouts, from: a
|
80
80
|
}.initialize_controller
|
81
81
|
assert(b.__send__ b.layouts[:a]) == 'a'
|
82
82
|
assert(b.__send__ b.layouts[:b]) == 'b'
|
@@ -87,7 +87,7 @@ spec :layouts do
|
|
87
87
|
define_layout(:x) {'a'}
|
88
88
|
}
|
89
89
|
b = mock_controller {
|
90
|
-
|
90
|
+
import :layouts, from: a
|
91
91
|
define_layout(:x) {'b'}
|
92
92
|
}.initialize_controller
|
93
93
|
assert(b.__send__ b.layouts[:x]) == 'b'
|
@@ -39,7 +39,7 @@ spec :template_vars do
|
|
39
39
|
define_template_var(:a, 'b')
|
40
40
|
}
|
41
41
|
c = mock_controller(a) {
|
42
|
-
|
42
|
+
import :template_vars, from: b
|
43
43
|
}.initialize_controller
|
44
44
|
assert(c.template_vars[:a]) == 'b'
|
45
45
|
end
|
@@ -52,7 +52,7 @@ spec :template_vars do
|
|
52
52
|
define_template_var(:b, 'b')
|
53
53
|
}
|
54
54
|
c = mock_controller(a) {
|
55
|
-
|
55
|
+
import :template_vars, from: b
|
56
56
|
}.initialize_controller
|
57
57
|
assert(c.template_vars[:a]) == 'a'
|
58
58
|
assert(c.template_vars[:b]) == 'b'
|
@@ -64,7 +64,7 @@ spec :template_vars do
|
|
64
64
|
}
|
65
65
|
b = mock_controller {
|
66
66
|
define_template_var(:a, 'b')
|
67
|
-
|
67
|
+
import :template_vars, from: a
|
68
68
|
}.initialize_controller
|
69
69
|
assert(b.template_vars[:a]) == 'a'
|
70
70
|
end
|
@@ -40,7 +40,7 @@ spec :templates do
|
|
40
40
|
define_template(:x) {'b'}
|
41
41
|
}
|
42
42
|
c = mock_controller(a) {
|
43
|
-
|
43
|
+
import :templates, from: b
|
44
44
|
}.initialize_controller
|
45
45
|
assert(c.__send__ c.templates[:x]) == 'b'
|
46
46
|
end
|
@@ -53,7 +53,7 @@ spec :templates do
|
|
53
53
|
define_template(:b) {'b'}
|
54
54
|
}
|
55
55
|
c = mock_controller(a) {
|
56
|
-
|
56
|
+
import :templates, from: b
|
57
57
|
}.initialize_controller
|
58
58
|
assert(c.__send__ c.templates[:a]) == 'a'
|
59
59
|
assert(c.__send__ c.templates[:b]) == 'b'
|
@@ -65,7 +65,7 @@ spec :templates do
|
|
65
65
|
}
|
66
66
|
b = mock_controller {
|
67
67
|
define_template(:x) {'b'}
|
68
|
-
|
68
|
+
import :templates, from: a
|
69
69
|
}.initialize_controller
|
70
70
|
assert(b.__send__ b.templates[:x]) == 'a'
|
71
71
|
end
|
@@ -76,7 +76,7 @@ spec :templates do
|
|
76
76
|
}
|
77
77
|
b = mock_controller {
|
78
78
|
define_template(:b) {'b'}
|
79
|
-
|
79
|
+
import :templates, from: a
|
80
80
|
}.initialize_controller
|
81
81
|
assert(b.__send__ b.templates[:a]) == 'a'
|
82
82
|
assert(b.__send__ b.templates[:b]) == 'b'
|
@@ -87,7 +87,7 @@ spec :templates do
|
|
87
87
|
define_template(:x) {'a'}
|
88
88
|
}
|
89
89
|
b = mock_controller {
|
90
|
-
|
90
|
+
import :templates, from: a
|
91
91
|
define_template(:x) {'b'}
|
92
92
|
}.initialize_controller
|
93
93
|
assert(b.__send__ b.templates[:x]) == 'b'
|
data/test/sessions_test.rb
CHANGED
@@ -49,7 +49,7 @@ spec :Sessions do
|
|
49
49
|
sessions :cookies
|
50
50
|
}
|
51
51
|
b = mock_controller(:b) {
|
52
|
-
|
52
|
+
import :sessions, from: a
|
53
53
|
def get(y); session[:x] = y end
|
54
54
|
def post; session[:x] end
|
55
55
|
}
|
@@ -84,7 +84,7 @@ spec :Sessions do
|
|
84
84
|
def post; session[:x] end
|
85
85
|
}
|
86
86
|
c = mock_controller(a) {
|
87
|
-
|
87
|
+
import :sessions, from: b
|
88
88
|
def get(y); session[:x] = y end
|
89
89
|
def post; session[:x] end
|
90
90
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rocketio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Slee Woo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -98,14 +98,14 @@ dependencies:
|
|
98
98
|
name: rack-radar
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
description: Simple, fast, scalable web framework for Ruby
|
@@ -155,6 +155,7 @@ files:
|
|
155
155
|
- lib/rocketio/version.rb
|
156
156
|
- rocketio.gemspec
|
157
157
|
- test/aliases_test.rb
|
158
|
+
- test/api_test.rb
|
158
159
|
- test/authentication_test.rb
|
159
160
|
- test/authorization_test.rb
|
160
161
|
- test/cache_control_test.rb
|
@@ -201,7 +202,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
201
202
|
requirements:
|
202
203
|
- - "~>"
|
203
204
|
- !ruby/object:Gem::Version
|
204
|
-
version: '2.
|
205
|
+
version: '2.2'
|
205
206
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
206
207
|
requirements:
|
207
208
|
- - ">="
|
@@ -212,5 +213,5 @@ rubyforge_project:
|
|
212
213
|
rubygems_version: 2.5.1
|
213
214
|
signing_key:
|
214
215
|
specification_version: 4
|
215
|
-
summary: '["rocketio-0.0
|
216
|
+
summary: '["rocketio-0.1.0", "Simple, fast, scalable web framework for Ruby"]'
|
216
217
|
test_files: []
|