rack-rscript 1.1.9 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a2d9082990c984616d9a1e5df565d4691931b996646569380500cfef752ff0af
4
- data.tar.gz: 851c3dcf2920516de03778abda5bcbee715e846a419431758fb8756992319023
3
+ metadata.gz: 35ab3661aa2c2f191b140e28dbda3805f32a97e6a3eaf6c1f410e30f411d6b6c
4
+ data.tar.gz: b6d2ba9fd30c7ae71571f69918583c8206cd0d5dbebd89dd796e4f35d44662d0
5
5
  SHA512:
6
- metadata.gz: e97d68f52d58c1fe00e019a51a8579b2aab3046dc4c82602f5857a88e91821542fc608f0e2f99a599a8becb9388599645911ea0c0ef46966abfa4aa553464e60
7
- data.tar.gz: f25c004d25a0c65fc94900a1fcd3342e6f47849daf5a0ffab8f989ef172aceb5d69c0369459e2772c41928ceb9bcae74758d65d04a1380eee1a3e72422a1fe12
6
+ metadata.gz: 216dc0e7c0e24231bf0e0fbb7d6cd5550cf9bf027a37b860102f909a378c608c78c806f51ab1b170a4b5880d0fc021311cd23d2d42782b56dc200ffa15eacde4
7
+ data.tar.gz: da45f89a5e37161bf83a9c63cdc8830e69ed949241f004990db59e67e7d21d33d9533932df96de08f5136339d1d61b81589d73fa9814149a0fe20997a93f0845
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -34,7 +34,7 @@ class RackRscript
34
34
  include RXFHelperModule
35
35
  using ColouredText
36
36
 
37
- attr_reader :req
37
+ attr_reader :req, :rsc
38
38
 
39
39
 
40
40
  def initialize(log: nil, pkg_src: '', cache: 5, rsc_host: nil,
@@ -73,7 +73,7 @@ class RackRscript
73
73
  end
74
74
 
75
75
  super() # required for app-routes initialize method to exectue
76
- default_routes(@env, @params)
76
+ default_routes(@env, @params || {})
77
77
 
78
78
  @rsc = nil
79
79
 
@@ -88,7 +88,7 @@ class RackRscript
88
88
  #=end
89
89
  end
90
90
 
91
- def call(env)
91
+ def call(env, testmode: false)
92
92
 
93
93
 
94
94
  @env = env
@@ -96,9 +96,14 @@ class RackRscript
96
96
  #raw_request = env['REQUEST_PATH']
97
97
 
98
98
  @log.info 'RackRscript/call: ' + env.inspect if @log
99
- @req = Rack::Request.new(env)
100
-
101
- @req_params = @req.params
99
+
100
+ if testmode == false then
101
+
102
+ @req = Rack::Request.new(env)
103
+ @req_params = @req.params
104
+
105
+ end
106
+
102
107
  default_routes(env,@params)
103
108
 
104
109
  request = if @pxlinks then
@@ -110,6 +115,7 @@ class RackRscript
110
115
 
111
116
  @log.info 'RackRscript/call/request: ' + request.inspect if @log
112
117
  #=begin
118
+ puts 'request: ' + request.inspect if @debug
113
119
  run_request(request)
114
120
  #=end
115
121
  # [200, {"Content-Type" => "text/plain"}, [env.inspect]]
@@ -119,8 +125,9 @@ class RackRscript
119
125
  @rscript.reset
120
126
  end
121
127
 
122
- def run_job(url, jobs, params={}, type=:get, *qargs)
128
+ def run_job(url, job, params={}, type=:get, *qargs)
123
129
 
130
+ puts 'inside run_job' if @debug
124
131
  @log.debug 'RackRscript/run_job/params: ' + params.inspect if @log
125
132
  @log.debug 'RackRscript/run_job/qargs: ' + qargs.inspect if @log
126
133
 
@@ -139,9 +146,20 @@ class RackRscript
139
146
  @params.merge! h
140
147
  end
141
148
 
142
- @params.merge! @req.params
149
+ @params.merge! @req.params if @req
143
150
  @rscript.type = type
144
- result, args = @rscript.read([url, jobs.split(/\s/), \
151
+
152
+ if not @rscript.jobs(url).include?(job.to_sym) then
153
+
154
+ if @rscript.jobs(url).include?(:job_missing) then
155
+ job = 'job_missing'
156
+ else
157
+ [404, 'job not found']
158
+ end
159
+
160
+ end
161
+
162
+ result, args = @rscript.read([url, '//job:' + job, \
145
163
  qargs].flatten)
146
164
 
147
165
  rws = self
@@ -149,14 +167,29 @@ class RackRscript
149
167
  req = @req if @req
150
168
 
151
169
  begin
170
+
171
+ if @debug then
172
+ puts @rscript.jobs(url).inspect
173
+ puts 'job: ' + job.inspect
174
+ puts 'url: ' + url.inspect
175
+ puts '@initialized: ' + @initialized.inspect
176
+ bflag = @rscript.jobs(url).include?(:initialize) and \
177
+ !@initialized[url] and job != 'initialize'
178
+ puts 'bflag: ' + bflag.inspect
179
+ end
152
180
 
153
- if @rscript.jobs(url).include? :initialize and
154
- !@initialized[url] and jobs != 'initialize' then
155
- @rscript.run([url, '//job:initialize'])
181
+ if @rscript.jobs(url).include?(:initialize) and
182
+ !@initialized[url] and job != 'initialize' then
183
+ puts 'before run initialize' if @debug
184
+ r2 = @rscript.read([url, '//job:initialize'])
185
+ puts 'r2: ' + r2.inspect if @debug
186
+ eval r2.join
156
187
  @initialized[url] = true
157
188
  end
158
189
 
190
+
159
191
  r = eval result
192
+
160
193
  return r
161
194
 
162
195
  rescue Exception => e
@@ -196,33 +229,37 @@ class RackRscript
196
229
 
197
230
  get '/do/:package/:job' do |package,job|
198
231
  @log.info 'RackRscript/route/do/package/job: ' + [package, job].inspect if @log
199
- run_job("%s%s.rsf" % [@url_base, package], "//job:" + job, params)
232
+ run_job("%s%s.rsf" % [@url_base, package], job, params)
200
233
  end
201
234
 
202
- get /\/(.*)\/do\/(\w+)\/(\w+)/ do |d, package,job|
203
- run_job(("%s%s/%s.rsf" % [@url_base, d, package]),
204
- "//job:" + job, params)
235
+ get /\/(.*)\/do\/(\w+)\/(\w+)$/ do |d, package,job|
236
+ run_job(("%s%s/%s.rsf" % [@url_base, d, package]), job, params)
205
237
  end
238
+
239
+ get /\/(.*)\/do\/(\w+)\/(\w+)\/(.*)/ do |d, package, job, raw_args|
240
+ args = raw_args.split('/')
241
+ run_job(("%s%s/%s.rsf" % [@url_base, d, package]), job, params, :get, args)
242
+ end
206
243
 
207
244
  post '/do/:package/:job' do |package,job|
208
- run_job("%s%s.rsf" % [@url_base, package], "//job:" + job, params, :post)
245
+ run_job("%s%s.rsf" % [@url_base, package], job, params, :post)
209
246
  end
210
247
 
211
248
  get '/do/:package/:job/*' do |package, job|
212
249
  raw_args = params[:splat]
213
250
  args = raw_args.first[/[^\s\?]+/].to_s.split('/')[1..-1]
214
- run_job("%s%s.rsf" % [@url_base, package], "//job:" + job, params, :get, args)
251
+ run_job("%s%s.rsf" % [@url_base, package], job, params, :get, args)
215
252
  end
216
253
 
217
254
  post '/do/:package/:job/*' do |package, job|
218
255
  raw_args = params[:splat]
219
256
  args = raw_args.first[/[^\s\?]+/].to_s.split('/')[1..-1]
220
- run_job("%s%s.rsf" % [@url_base, package], "//job:" + job, params, :post, args)
257
+ run_job("%s%s.rsf" % [@url_base, package], job, params, :post, args)
221
258
  end
222
259
 
223
260
  get '/source/:package/:job' do |package,job|
224
261
  url = "%s%s.rsf" % [@url_base, package]
225
- [@rscript.read([url, '//job:' + job]).first, 'text/plain']
262
+ [@rscript.read([url, job]).first, 'text/plain']
226
263
  end
227
264
 
228
265
  get '/source/:package' do |package,job|
@@ -313,7 +350,8 @@ class RackRscript
313
350
  method_type = @env ? @env['REQUEST_METHOD'] : 'GET'
314
351
  content, content_type, status_code = run_route(request, method_type)
315
352
  @log.info 'RackRscript/run_request/content: ' + content.inspect if @log
316
-
353
+ #puts 'content: ' + content.inspect if @debug
354
+
317
355
  #@log.debug 'inside run_request' if @log
318
356
  if content.is_a? Redirect then
319
357
 
@@ -372,45 +410,9 @@ class RackRscript
372
410
  alias jumpto run_request
373
411
 
374
412
  private
375
-
376
- def render99(name, type, opt={})
377
-
378
- options = {locals: {}}.merge!(opt)
379
- locals = options.delete :locals
380
-
381
- unless @templates[:layout] then
382
- template(:layout, type) { File.read('views/layout.' + type.to_s) }
383
- end
384
-
385
- layout = Tilt[type.to_s].new(options) {|x| @templates[:layout][:content]}
386
-
387
- unless @templates[name] then
388
- template(name, type) { File.read("views/%s.%s" % [name.to_s, type.to_s])}
389
- end
390
-
391
- template = Tilt[type.to_s].new(options) {|x| @templates[name][:content]}
392
- layout.render{ template.render(self, locals)}
393
- end
394
-
413
+
395
414
  def template(name, type=nil, &blk)
396
415
  @render.template name, type, &blk
397
- end
398
-
399
- def template99(name, type=nil, &blk)
400
- @templates.merge!({name => {content: blk.call, type: type}})
401
- @templates[name]
402
- end
403
-
404
- def tilt99(name, options={})
405
-
406
- options = {locals: {}}.merge!(opt)
407
- locals = options.delete :locals
408
- layout = Tilt[@templates[:layout][:type].to_s].new(options)\
409
- {|x| @templates[:layout][:content]}
410
- template = Tilt[@templates[name][:type].to_s].new(options) \
411
- {|x| @templates[name][:content]}
412
- layout.render{ template.render(self, locals)}
413
-
414
- end
416
+ end
415
417
 
416
418
  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.9
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  tilHf4Ok7vnZYPnxQk5PY3q28lYoflnB47YIc0pdkJHI1M3YXL/HxrcZCEIHAU3W
36
36
  aTCBK3Pk2/LQtqaW3yaSg73t
37
37
  -----END CERTIFICATE-----
38
- date: 2020-07-04 00:00:00.000000000 Z
38
+ date: 2021-01-18 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rack
@@ -166,7 +166,7 @@ dependencies:
166
166
  version: '0.4'
167
167
  - - ">="
168
168
  - !ruby/object:Gem::Version
169
- version: 0.4.4
169
+ version: 0.4.5
170
170
  type: :runtime
171
171
  prerelease: false
172
172
  version_requirements: !ruby/object:Gem::Requirement
@@ -176,7 +176,7 @@ dependencies:
176
176
  version: '0.4'
177
177
  - - ">="
178
178
  - !ruby/object:Gem::Version
179
- version: 0.4.4
179
+ version: 0.4.5
180
180
  - !ruby/object:Gem::Dependency
181
181
  name: polyrex-links
182
182
  requirement: !ruby/object:Gem::Requirement
@@ -223,7 +223,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
223
  - !ruby/object:Gem::Version
224
224
  version: '0'
225
225
  requirements: []
226
- rubygems_version: 3.0.3
226
+ rubyforge_project:
227
+ rubygems_version: 2.7.10
227
228
  signing_key:
228
229
  specification_version: 4
229
230
  summary: Rack-Rscript is a light-weight alternative to Sinatra-Rscript.
metadata.gz.sig CHANGED
Binary file