rack-rscript 1.1.2 → 1.1.3
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/lib/rack-rscript.rb +75 -61
- metadata +2 -2
- metadata.gz.sig +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6bf34f921036c9bb60b380fb41e64280db27289
|
4
|
+
data.tar.gz: 52f2d2b76ee05e29c1575d876b601c1ff2225a9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7a072f5034d81ab1ec3afeb2b803822f8c674f94784443e2fd068c6a85db5146c4363682619c8edbf07a200b796a8419eb89d22f9b519351031a6b80402f4bd
|
7
|
+
data.tar.gz: d8913dcf856a2e1b08c2c04352cdcb95a70d2745b146771c547bdcfe4abc2d8934f0ce6d7ca23489170ef76b0155afdd4d39cca0b79956aef3ed2bc00c22d205
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/rack-rscript.rb
CHANGED
@@ -97,61 +97,7 @@ class RackRscript
|
|
97
97
|
raw_request
|
98
98
|
end
|
99
99
|
|
100
|
-
|
101
|
-
|
102
|
-
if content.is_a? Redirect then
|
103
|
-
|
104
|
-
redirectx = content
|
105
|
-
res = Rack::Response.new
|
106
|
-
res.redirect(redirectx.to_url)
|
107
|
-
res.finish
|
108
|
-
|
109
|
-
else
|
110
|
-
|
111
|
-
e = $!
|
112
|
-
|
113
|
-
if e then
|
114
|
-
content, status_code = e, 500
|
115
|
-
@log.debug 'RackRscript/call/error: ' + e if @log
|
116
|
-
elsif content.nil? then
|
117
|
-
content, status_code = "404: page not found", 404
|
118
|
-
end
|
119
|
-
|
120
|
-
tilt_proc = lambda do |s, content_type|
|
121
|
-
type = content_type[/[^\/]+$/]
|
122
|
-
s = [s,{}] unless s.is_a? Array
|
123
|
-
content, options = s
|
124
|
-
[Tilt[type].new() {|x| content}.render(self, options), 'text/html']
|
125
|
-
end
|
126
|
-
|
127
|
-
passthru_proc = lambda{|c, ct| [c,ct]}
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
ct_list = {
|
132
|
-
'text/html' => passthru_proc,
|
133
|
-
'text/haml' => tilt_proc,
|
134
|
-
'text/slim' => tilt_proc,
|
135
|
-
'text/plain' => passthru_proc,
|
136
|
-
'text/xml' => passthru_proc,
|
137
|
-
'text/css' => passthru_proc,
|
138
|
-
'text/markdown' => passthru_proc,
|
139
|
-
'application/xml' => passthru_proc,
|
140
|
-
'application/xhtml' => passthru_proc,
|
141
|
-
'application/json' => passthru_proc,
|
142
|
-
'image/png' => passthru_proc,
|
143
|
-
'image/jpeg' => passthru_proc,
|
144
|
-
'image/svg+xml' => passthru_proc
|
145
|
-
}
|
146
|
-
|
147
|
-
content_type ||= 'text/html'
|
148
|
-
status_code ||= 200
|
149
|
-
proc = ct_list[content_type]
|
150
|
-
proc ||= passthru_proc
|
151
|
-
content, content_type = proc.call(content, content_type)
|
152
|
-
|
153
|
-
[status_code, {"Content-Type" => content_type}, [content]]
|
154
|
-
end
|
100
|
+
run_request(request)
|
155
101
|
end
|
156
102
|
|
157
103
|
def clear_cache()
|
@@ -162,7 +108,8 @@ class RackRscript
|
|
162
108
|
|
163
109
|
if @params[:splat] then
|
164
110
|
@params.each do |k,v|
|
165
|
-
@params.delete k unless k == :splat or k == :package
|
111
|
+
@params.delete k unless k == :splat or k == :package \
|
112
|
+
or k == :job or k == :captures
|
166
113
|
end
|
167
114
|
end
|
168
115
|
|
@@ -174,7 +121,7 @@ class RackRscript
|
|
174
121
|
@params.merge! h
|
175
122
|
end
|
176
123
|
|
177
|
-
@params.merge! @
|
124
|
+
@params.merge! @req.params
|
178
125
|
result, args = @rrscript.read([url, jobs.split(/\s/), \
|
179
126
|
qargs].flatten)
|
180
127
|
|
@@ -225,7 +172,8 @@ class RackRscript
|
|
225
172
|
end
|
226
173
|
|
227
174
|
get /\/(.*)\/do\/(\w+)\/(\w+)/ do |d, package,job|
|
228
|
-
run_job(("%s%s/%s.rsf" % [@url_base, d, package]),
|
175
|
+
run_job(("%s%s/%s.rsf" % [@url_base, d, package]),
|
176
|
+
"//job:" + job, params)
|
229
177
|
end
|
230
178
|
|
231
179
|
post '/do/:package/:job' do |package,job|
|
@@ -307,6 +255,67 @@ class RackRscript
|
|
307
255
|
end
|
308
256
|
|
309
257
|
end
|
258
|
+
|
259
|
+
def run_request(request)
|
260
|
+
|
261
|
+
content, content_type, status_code = run_route(request,
|
262
|
+
@env['REQUEST_METHOD'])
|
263
|
+
|
264
|
+
if content.is_a? Redirect then
|
265
|
+
|
266
|
+
redirectx = content
|
267
|
+
res = Rack::Response.new
|
268
|
+
res.redirect(redirectx.to_url)
|
269
|
+
res.finish
|
270
|
+
|
271
|
+
else
|
272
|
+
|
273
|
+
e = $!
|
274
|
+
|
275
|
+
if e then
|
276
|
+
content, status_code = e, 500
|
277
|
+
@log.debug 'RackRscript/call/error: ' + e if @log
|
278
|
+
elsif content.nil? then
|
279
|
+
content, status_code = "404: page not found", 404
|
280
|
+
end
|
281
|
+
|
282
|
+
tilt_proc = lambda do |s, content_type|
|
283
|
+
type = content_type[/[^\/]+$/]
|
284
|
+
s = [s,{}] unless s.is_a? Array
|
285
|
+
content, options = s
|
286
|
+
[Tilt[type].new() {|x| content}.render(self, options), 'text/html']
|
287
|
+
end
|
288
|
+
|
289
|
+
passthru_proc = lambda{|c, ct| [c,ct]}
|
290
|
+
|
291
|
+
ct_list = {
|
292
|
+
'text/html' => passthru_proc,
|
293
|
+
'text/haml' => tilt_proc,
|
294
|
+
'text/slim' => tilt_proc,
|
295
|
+
'text/plain' => passthru_proc,
|
296
|
+
'text/xml' => passthru_proc,
|
297
|
+
'text/css' => passthru_proc,
|
298
|
+
'text/markdown' => passthru_proc,
|
299
|
+
'application/xml' => passthru_proc,
|
300
|
+
'application/xhtml' => passthru_proc,
|
301
|
+
'application/json' => passthru_proc,
|
302
|
+
'image/png' => passthru_proc,
|
303
|
+
'image/jpeg' => passthru_proc,
|
304
|
+
'image/svg+xml' => passthru_proc
|
305
|
+
}
|
306
|
+
|
307
|
+
content_type ||= 'text/html'
|
308
|
+
status_code ||= 200
|
309
|
+
proc = ct_list[content_type]
|
310
|
+
proc ||= passthru_proc
|
311
|
+
content, content_type = proc.call(content, content_type)
|
312
|
+
|
313
|
+
[status_code, {"Content-Type" => content_type}, [content]]
|
314
|
+
end
|
315
|
+
|
316
|
+
end
|
317
|
+
|
318
|
+
alias jumpto run_request
|
310
319
|
|
311
320
|
private
|
312
321
|
|
@@ -322,7 +331,7 @@ class RackRscript
|
|
322
331
|
layout = Tilt[type.to_s].new(options) {|x| @templates[:layout][:content]}
|
323
332
|
|
324
333
|
unless @templates[name] then
|
325
|
-
template(name, type) { File.read("views/%s.%s" % [name.to_s, type.to_s])
|
334
|
+
template(name, type) { File.read("views/%s.%s" % [name.to_s, type.to_s])}
|
326
335
|
end
|
327
336
|
|
328
337
|
template = Tilt[type.to_s].new(options) {|x| @templates[name][:content]}
|
@@ -335,10 +344,15 @@ class RackRscript
|
|
335
344
|
end
|
336
345
|
|
337
346
|
def tilt(name, options={})
|
347
|
+
|
338
348
|
options = {locals: {}}.merge!(opt)
|
339
349
|
locals = options.delete :locals
|
340
|
-
layout = Tilt[@templates[:layout][:type].to_s].new(options)
|
341
|
-
|
350
|
+
layout = Tilt[@templates[:layout][:type].to_s].new(options)\
|
351
|
+
{|x| @templates[:layout][:content]}
|
352
|
+
template = Tilt[@templates[name][:type].to_s].new(options) \
|
353
|
+
{|x| @templates[name][:content]}
|
342
354
|
layout.render{ template.render(self, locals)}
|
355
|
+
|
343
356
|
end
|
357
|
+
|
344
358
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-rscript
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
vvLi4Y0qQy/Uz/kHVXzfeLcG657aNIu8ogA1I3Xnlz0sqlNoDhk5sSBd2BsfkVFS
|
32
32
|
sTo/69YTrLx1zw==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2018-07-
|
34
|
+
date: 2018-07-23 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rack
|
metadata.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
^��1��+�G��!/�h�2�+����V��r�o�b*p%���ל:�K��<�Zݠ�C���E�7O�QT�� 3㥲ĺg��JF����� ��C�,�J���NKt�{D�p��ʋ���c�D�xƿ.>��H@�)3$�L� 6^��v[r�D�.8��q�C���Vu�#U�E$�+ƛ���5fi;���锷���ݽw���-�������]� 9�h;���y�.@�ƾo%!�g�p��}���
|