rack-rscript 1.2.1 → 1.3.1

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: eb8f81937a9057df995fed0866db887efb7d3b51821c94fd8981be81443fc0fb
4
- data.tar.gz: 4145e73c58a2ae1de7e636b576e33a51ac08a021b631e54aef864bc8e1753352
3
+ metadata.gz: 35d6d0eead7c09e461f0a012e4bbde41a6d0caed9407cb5c3084f296cee53109
4
+ data.tar.gz: de258189650cfcce899fe6595a3a7d25a98a1ff8d39faf72cd7fc7c79219e143
5
5
  SHA512:
6
- metadata.gz: b0775bf1401dc6bd0cb792065b9db9347254693e50934dd8ebe7c960692d4153935ebecb671d930994bb521fb2b194f76c2865c7dd498b0c7149fa283b9e9904
7
- data.tar.gz: ca86b8dcc16acf51140b9e8ad375df2cb1949a35ef83ce871c62aa7b22dc5af6851f8e34c48956a0fda564c87f20f117751bad799ca64ca82889bcbb59faa25f
6
+ metadata.gz: 852ddfd534c199308c7973544a918d6cecbbfaeac935739b952e57551765f8f739fac509991b603f9151f9d5df27e59a62dccf93afd7b92cc872399d14e52c24
7
+ data.tar.gz: 9f1d6a104adbfa437ffe5aff658e9c16cff42fd9f499e3d036fa3cb75de5ed69d2393b428a80dc55e2432c4599e6901df95384dbafe487dab9be7b1d9c1ac6cf
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/rack-rscript.rb CHANGED
@@ -13,6 +13,7 @@ require 'rscript'
13
13
  require 'app-routes'
14
14
  require 'uri'
15
15
  require 'polyrex-links'
16
+ require 'nthrut'
16
17
 
17
18
 
18
19
  class Redirect
@@ -42,14 +43,15 @@ class RackRscript
42
43
  pxlinks: nil, debug: false, root: '', static: {})
43
44
 
44
45
  @log, @debug, @static = log, debug, static
45
- #=begin
46
- puts '@app_root: ' + @app_root.inspect if @debug
46
+
47
47
  puts 'root: ' + root.inspect if @debug
48
+ puts 'pkg_Src: ' + pkg_src.inspect if @debug
48
49
 
49
50
  @params = {}
50
51
 
51
52
  @templates = {}
52
53
 
54
+ @log.debug 'pkg_src: ' + pkg_src.inspect if @log
53
55
  @rscript = RScriptRW.new log: log, pkg_src: pkg_src, cache: cache, debug: true
54
56
  @render = NThrut.new(self)
55
57
 
@@ -88,7 +90,7 @@ class RackRscript
88
90
 
89
91
  @root, @static = root, static
90
92
  @initialized = {}
91
- #=end
93
+
92
94
  end
93
95
 
94
96
  def call(env, testmode: false)
@@ -190,7 +192,6 @@ class RackRscript
190
192
  @initialized[url] = true
191
193
  end
192
194
 
193
-
194
195
  r = eval result
195
196
 
196
197
  return r
@@ -235,19 +236,24 @@ class RackRscript
235
236
  run_job("%s%s.rsf" % [@url_base, package], job, params)
236
237
  end
237
238
 
238
- get /\/(.*)\/do\/(\w+)\/(\w+)$/ do |d, package,job|
239
- run_job(("%s%s/%s.rsf" % [@url_base, d, package]), job, params)
239
+ get '/:dir/do/:package/:job' do |dir, package, job|
240
+ run_job(("%s%s/%s.rsf" % [@url_base, dir, package]), job, params)
240
241
  end
241
242
 
242
- get /\/(.*)\/do\/(\w+)\/(\w+)\/(.*)/ do |d, package, job, raw_args|
243
- args = raw_args.split('/')
244
- run_job(("%s%s/%s.rsf" % [@url_base, d, package]), job, params, :get, args)
243
+ get '/:dir/do/:package/:job/*' do |dir, package, job|
244
+ raw_args = params[:splat]
245
+ args = raw_args.first[/[^\s\?]+/].to_s.split('/')[1..-1]
246
+ run_job(("%s%s/%s.rsf" % [@url_base, dir, package]), job, params, :get, args)
245
247
  end
246
248
 
247
249
  post '/do/:package/:job' do |package,job|
248
250
  run_job("%s%s.rsf" % [@url_base, package], job, params, :post)
249
251
  end
250
252
 
253
+ post '/:dir/do/:package/:job' do |dir, package,job|
254
+ run_job(("%s%s/%s.rsf" % [@url_base, dir, package]), job, params, :post)
255
+ end
256
+
251
257
  get '/do/:package/:job/*' do |package, job|
252
258
  raw_args = params[:splat]
253
259
  args = raw_args.first[/[^\s\?]+/].to_s.split('/')[1..-1]
@@ -260,6 +266,12 @@ class RackRscript
260
266
  run_job("%s%s.rsf" % [@url_base, package], job, params, :post, args)
261
267
  end
262
268
 
269
+ post '/:dir/do/:package/:job/*' do |package, job|
270
+ raw_args = params[:splat]
271
+ args = raw_args.first[/[^\s\?]+/].to_s.split('/')[1..-1]
272
+ run_job("%s%s/%s.rsf" % [@url_base, dir, package], job, params, :post, args)
273
+ end
274
+
263
275
  get '/source/:package/:job' do |package,job|
264
276
  url = "%s%s.rsf" % [@url_base, package]
265
277
  [@rscript.read([url, job]).first, 'text/plain']
@@ -286,7 +298,7 @@ class RackRscript
286
298
  FileX.exists? @url_base
287
299
  filepath = @url_base
288
300
 
289
- [Dir.glob(filepath + '/*.rsf').map{|x| x[/([^\/]+)\.rsf$/,1]}.to_json,\
301
+ [DirX.glob(filepath + '/*.rsf').map{|x| x[/([^\/]+)\.rsf$/,1]}.to_json,\
290
302
  'application/json']
291
303
 
292
304
  end
@@ -301,7 +313,7 @@ class RackRscript
301
313
 
302
314
  path = raw_path
303
315
  puts 'path: ' + path.inspect if @debug
304
- filepath = File.join(@app_root, @root, path )
316
+ filepath = File.join(@root, path )
305
317
 
306
318
  else
307
319
 
@@ -331,30 +343,20 @@ class RackRscript
331
343
  end
332
344
 
333
345
  end
346
+
334
347
  end
335
348
 
336
349
  get /^\/$/ do
337
350
 
338
351
  if @root.length > 0 then
339
352
  file = File.join(@root, 'index.html')
340
- File.read file
353
+ FileX.read file
341
354
  else
342
355
  Time.now.inspect
343
356
  end
344
357
 
345
358
  end
346
359
 
347
- # file exists?
348
- a = Dir.glob( File.join(@root.to_s, '*')).select do |x|
349
- File::ftype(x) == 'directory'
350
- end
351
-
352
- get /^\/#{a.join('|')}/ do
353
-
354
- 'found' + a.inspect
355
-
356
- end
357
-
358
360
  end
359
361
 
360
362
  def run_request(request)
data.tar.gz.sig CHANGED
Binary file
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.2.1
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  uQ8ts8x2DfuJYY/PmLbqwXkzMzb1EgnUBWZ3mZCdlL0UBst5ypPAFTn1b2qRUC92
36
36
  UtKkOrrEmCXrBnFtpv6a1ULk
37
37
  -----END CERTIFICATE-----
38
- date: 2021-12-29 00:00:00.000000000 Z
38
+ date: 2022-01-20 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rack
@@ -197,6 +197,26 @@ dependencies:
197
197
  - - ">="
198
198
  - !ruby/object:Gem::Version
199
199
  version: 0.4.3
200
+ - !ruby/object:Gem::Dependency
201
+ name: nthrut
202
+ requirement: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - ">="
205
+ - !ruby/object:Gem::Version
206
+ version: 0.1.0
207
+ - - "~>"
208
+ - !ruby/object:Gem::Version
209
+ version: '0.1'
210
+ type: :runtime
211
+ prerelease: false
212
+ version_requirements: !ruby/object:Gem::Requirement
213
+ requirements:
214
+ - - ">="
215
+ - !ruby/object:Gem::Version
216
+ version: 0.1.0
217
+ - - "~>"
218
+ - !ruby/object:Gem::Version
219
+ version: '0.1'
200
220
  description:
201
221
  email: digital.robertson@gmail.com
202
222
  executables: []
metadata.gz.sig CHANGED
Binary file