incline 0.2.17 → 0.2.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/models/incline/action_security.rb +1 -35
- data/lib/incline/version.rb +1 -1
- data/lib/incline.rb +60 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d480afc97f1235565c6a453fc357d1a3055b3b0
|
4
|
+
data.tar.gz: 439acc31750a1a618f1255f3fcf6d4efaea31492
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dd29096c66f7cf8678dee49f828fc9f0dfa79aa014837068fc1194ba031dc48ab915bf211344934e20cc495954a9267c9cea8837c609733d7b4d2b6ca16eddf
|
7
|
+
data.tar.gz: 2e9f293bdd559bf718ea385031de52c15683f3978613df97370712dd518c76e8bc1899347edd3cfc0cc33ae5d1b99d3f1968124d16a1b99ca38d3a2e5c183e96
|
data/Gemfile.lock
CHANGED
@@ -31,41 +31,7 @@ module Incline
|
|
31
31
|
self.allow_anon = self.require_anon = self.require_admin = self.unknown_controller = self.non_standard = false
|
32
32
|
|
33
33
|
self.unknown_controller = true
|
34
|
-
klass =
|
35
|
-
begin
|
36
|
-
(controller_name + '_controller').classify.constantize
|
37
|
-
rescue NameError
|
38
|
-
nil
|
39
|
-
end
|
40
|
-
|
41
|
-
unless klass
|
42
|
-
options =
|
43
|
-
if controller_name.include?('/')
|
44
|
-
ns = controller_name.rpartition('/')[0]
|
45
|
-
ctrl = controller_name.rpartition('/')[2]
|
46
|
-
options = [
|
47
|
-
"#{ns}/app/controllers/#{ns}/#{ctrl}_controller",
|
48
|
-
"app/controllers/#{ns}/#{ctrl}_controller",
|
49
|
-
"#{ns}/app/controllers/#{ctrl}_controller",
|
50
|
-
"#{ns}/#{ctrl}_controller"
|
51
|
-
]
|
52
|
-
else
|
53
|
-
options = [
|
54
|
-
"app/controllers/#{controller_name}_controller",
|
55
|
-
"#{controller_name}_controller"
|
56
|
-
]
|
57
|
-
end
|
58
|
-
|
59
|
-
while (file = options.shift)
|
60
|
-
begin
|
61
|
-
require file
|
62
|
-
klass = (controller_name + '_controller').classify.constantize
|
63
|
-
break
|
64
|
-
rescue LoadError, NameError
|
65
|
-
# just preventing the error from bubbling up.
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
34
|
+
klass = ::Incline.get_controller_class(controller_name)
|
69
35
|
|
70
36
|
if klass
|
71
37
|
self.unknown_controller = false
|
data/lib/incline/version.rb
CHANGED
data/lib/incline.rb
CHANGED
@@ -146,6 +146,66 @@ module Incline
|
|
146
146
|
def self.migrate!
|
147
147
|
ActiveRecord::Migrator.migrate File.expand_path('../../db/migrate', __FILE__), nil
|
148
148
|
end
|
149
|
+
|
150
|
+
##
|
151
|
+
# Locates and loads a controller's class definition.
|
152
|
+
#
|
153
|
+
# If found, returns the controller class, otherwise nil.
|
154
|
+
def self.get_controller_class(controller_name)
|
155
|
+
controller_name += '_controller' unless controller_name =~ /_controller$/
|
156
|
+
class_name = controller_name.classify
|
157
|
+
|
158
|
+
klass =
|
159
|
+
begin
|
160
|
+
class_name.constantize
|
161
|
+
rescue NameError
|
162
|
+
nil
|
163
|
+
end
|
164
|
+
|
165
|
+
if klass
|
166
|
+
unless klass <= ::ActionController::Base
|
167
|
+
::Incline::Log::warn "The '#{class_name}' class does not inherit from 'ActionController::Base'."
|
168
|
+
return nil
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
unless klass
|
173
|
+
file_options =
|
174
|
+
if controller_name.include?('/')
|
175
|
+
ns,_,ctrl = controller_name.rpartition('/')
|
176
|
+
[
|
177
|
+
"#{ns}/app/controllers/#{ns}/#{ctrl}_controller",
|
178
|
+
"app/controllers/#{ns}/#{ctrl}_controller",
|
179
|
+
"#{ns}/app/controllers/#{ctrl}_controller",
|
180
|
+
"#{ns}/#{ctrl}_controller"
|
181
|
+
]
|
182
|
+
else
|
183
|
+
[
|
184
|
+
"app/controllers/#{controller_name}_controller",
|
185
|
+
"#{controller_name}_controller"
|
186
|
+
]
|
187
|
+
end
|
188
|
+
|
189
|
+
while (file = file_options.shift)
|
190
|
+
begin
|
191
|
+
require file
|
192
|
+
klass = class_name.constantize
|
193
|
+
if klass <= ::ActionController::Base
|
194
|
+
::Incline::Log::debug "Found '#{class_name}' in '#{file}'."
|
195
|
+
else
|
196
|
+
::Incline::Log::warn "Found '#{class_name}' in '#{file}', but it does not inherit from 'ActionController::Base'."
|
197
|
+
klass = nil
|
198
|
+
end
|
199
|
+
break
|
200
|
+
rescue LoadError, NameError
|
201
|
+
# don't bubble up these errors.
|
202
|
+
klass = nil
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
klass
|
208
|
+
end
|
149
209
|
|
150
210
|
private
|
151
211
|
|