rscript-server 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/lib/rscript-server.rb +52 -36
  2. data.tar.gz.sig +2 -0
  3. metadata +27 -8
  4. metadata.gz.sig +0 -0
@@ -9,15 +9,16 @@ require 'rexml/document'
9
9
 
10
10
  class RScriptServer
11
11
  include REXML
12
+ include AppRoutes
12
13
 
13
14
  def initialize(raw_opts={})
14
15
 
15
16
  opts = {ip: '0.0.0.0', port: 4446, pkg_src: ''}.merge(raw_opts)
16
17
  @ip, @port, @url_base = opts[:ip], opts[:port], opts[:pkg_src]
17
18
  super()
18
- params = {}
19
- @app = AppRoutes.new(params)
20
- application(params)
19
+
20
+ #@app = AppRoutes.new(params)
21
+ routes(@params)
21
22
  @rscript = RScript.new()
22
23
 
23
24
  @content_type = 'text/html'
@@ -34,7 +35,7 @@ class RScriptServer
34
35
  request = raw_request[/.[^\s]+(?= HTTP\/1\.\d)/].strip
35
36
  puts "%s %s" % [Time.now,request]
36
37
 
37
- result = @app.run(request)
38
+ result = run_route(request)
38
39
 
39
40
  result ||= "404: page not found"
40
41
 
@@ -46,61 +47,76 @@ class RScriptServer
46
47
 
47
48
  private
48
49
 
49
- def application(params)
50
+ def routes(params)
51
+
52
+ get '/do/:package/:job' do |package,job|
50
53
 
51
- @app.routes do
54
+ jobs = "//job:" + job
55
+ url = "%s%s.rsf" % [@url_base, package]
56
+ run(url, jobs, params)
57
+ end
52
58
 
53
- get '/do/:package/:job' do |package,job|
59
+ get '/do/:package/:job/*' do |package, job|
54
60
 
55
- jobs = "//job:" + job
56
- url = "%s%s.rsf" % [@url_base, package]
57
- run(url, jobs, params)
58
- end
61
+ jobs = "//job:" + job
62
+ raw_args = params[:splat]
63
+ args = raw_args.join.split('/')[1..-1]
64
+ url = "%s%s.rsf" % [@url_base, package]
65
+ run(url, jobs, params, args)
66
+ end
59
67
 
60
- get '/do/:package/:job/*' do |package, job|
68
+ get '/source/:package' do |package|
61
69
 
62
- jobs = "//job:" + job
63
- raw_args = params[:splat]
64
- args = raw_args.join.split('/')[1..-1]
65
- url = "%s%s.rsf" % [@url_base, package]
66
- run(url, jobs, params, args)
67
- end
70
+ url = "%s%s.rsf" % [@url_base, package]
71
+ @content_type = 'text/plain'
72
+ open(url, "UserAgent" => 'RscriptServer').read
73
+ end
68
74
 
69
- get '/source/:package' do |package|
75
+ get '/source/:package/:job' do |package, job|
70
76
 
71
- url = "%s%s.rsf" % [@url_base, package]
72
- @content_type = 'text/plain'
73
- open(url, "UserAgent" => 'RscriptServer').read
74
- end
77
+ url = "%s%s.rsf" % [@url_base, package]
78
+ buffer = open(url, "UserAgent" => 'RscriptServer').read
79
+ doc = Document.new(buffer)
75
80
 
76
- get '/source/:package/:job' do |package, job|
81
+ @content_type = 'text/plain'
82
+ XPath.first(doc.root, "//job[@id='#{job}']").to_s
83
+ end
77
84
 
78
- url = "%s%s.rsf" % [@url_base, package]
79
- buffer = open(url, "UserAgent" => 'RscriptServer').read
80
- doc = Document.new(buffer)
85
+ get '/reset' do |package, job|
81
86
 
82
- @content_type = 'text/plain'
83
- XPath.first(doc.root, "//job[@id='#{job}']").to_s
84
- end
87
+ @rscript.reset
85
88
 
89
+ @content_type = 'text/plain'
90
+ "reset done"
86
91
  end
87
- end
88
92
 
89
- def get(arg,&block)
90
- @app.get(arg, &block)
93
+
91
94
  end
92
95
 
93
96
  def run_rcscript(rsf_url, jobs, raw_args=[])
94
97
  @rscript.read([rsf_url, jobs.split(/\s/), raw_args].flatten)
95
98
  end
96
99
 
97
- def run(url, jobs, *qargs)
100
+ def run(url, jobs, params={}, *qargs)
101
+ if params[:splat] and params[:splat].length > 0 then
102
+ h = params[:splat].first[1..-1].split('&').inject({}) do |r,x|
103
+ k, v = x.split('=')
104
+ r.merge(k.to_sym => v)
105
+ end
106
+ params.merge! h
107
+ end
108
+
98
109
  result, args = run_rcscript(url, jobs, qargs)
99
110
 
100
111
  begin
101
112
  eval result
102
- rescue
103
- "rws error: " + ($!).to_s
113
+ #rescue
114
+ # "rws error: " + ($!).to_s
115
+ rescue Exception => e
116
+
117
+ err_label = e.message + " :: \n" + e.backtrace.join("\n")
118
+ puts err_label
119
+ $!
104
120
  end
105
121
  end
106
122
  end
data.tar.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ ���:�n����O�^��A���4�0�����{�r��&�Њi�f(�b�L���y�w�o�!�o^F�qz�=&�9�������?;�e{ >1 ���������/�gV�α������׋�h�u��ztm�3�=WI�>�+Z�}|͆;dx(�p䅈�Ó��'�%U6�����S���'�٧5��j)�s��-�Q��8��pPY
2
+ `{�� ��8��˫D~�?��)�L>U�7���[�W�P�
metadata CHANGED
@@ -2,16 +2,36 @@
2
2
  name: rscript-server
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.3
5
+ version: 0.1.5
6
6
  platform: ruby
7
- authors: []
8
-
7
+ authors:
8
+ - James Robertson
9
9
  autorequire:
10
10
  bindir: bin
11
- cert_chain: []
11
+ cert_chain:
12
+ - |
13
+ -----BEGIN CERTIFICATE-----
14
+ MIIDRDCCAiygAwIBAgIBADANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
15
+ YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
16
+ 8ixkARkWAmV1MB4XDTEzMDIwNjIxMDQ0OFoXDTE0MDIwNjIxMDQ0OFowSDESMBAG
17
+ A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
18
+ EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
19
+ ggEBALlQCMk4cjocTaoNBcPxZaptjjIeLoHRCGTJL4yZhjjMJOL9AIcwgwpzF0Xm
20
+ 7PELDjc1G04YF1B+EWwl4p+DxY7zqW3xTRUcHpl7W0lgjChKGwZVSakocb3uD/O1
21
+ xYy2crwCrfOlTFfvY9/jcvnygvAsvjzyR1T1rX61/JSlTjTFPW+vocaDlM+X1l66
22
+ JzpX7zoRtvPYFQj2h2BqKAwPE7z1dbKXHasN07PzY02hwD0BsAKDN1AMCxgYejns
23
+ Q7LMcRzWrfaJuNay9Q3Rp1IRXJFHuDSO5RWhdVS6p0zYUF6LoMEFC8EZbOnbkkDt
24
+ TyOScM/ATDMxKQBRQCCzYZUVOz0CAwEAAaM5MDcwCQYDVR0TBAIwADAdBgNVHQ4E
25
+ FgQUDFdDeQanOsBnwwLGGobD+r1wIigwCwYDVR0PBAQDAgSwMA0GCSqGSIb3DQEB
26
+ BQUAA4IBAQBOQQ9O1N3KyrSVW5ah7HBwX0QTV4RapEeQLYTRRedB2Ow58EoWTahz
27
+ ztzkADFp7gfmQTTwUfXBEQcjk8hN22+5fj74u0DwYo1+J8qD3/TXoY01nRvZ6SNn
28
+ dgwkb0BVzSuyJUro/k498eXno0M60XtF/ad9AT1J7C2GJ2JXFeXPuApPmmKaCoJz
29
+ ah2XuE7UyeVvKFrtN3ljh6lb+9USdfH5G6mCdsc7XOvcPGK3cu1kwhvRNWCfybX4
30
+ QgYGas6PZ27G/HiJSLLn5lREsGrpTG/7Bm87fwbobAvjai89EpM8vyl1zhGXdCSA
31
+ FmJWaeq1WTfKnVDXvfgJ4Qb5d4WK6JRl
32
+ -----END CERTIFICATE-----
12
33
 
13
- date: 2011-03-14 00:00:00 +00:00
14
- default_executable:
34
+ date: 2013-02-06 00:00:00 Z
15
35
  dependencies:
16
36
  - !ruby/object:Gem::Dependency
17
37
  name: rscript
@@ -45,7 +65,6 @@ extra_rdoc_files: []
45
65
 
46
66
  files:
47
67
  - lib/rscript-server.rb
48
- has_rdoc: true
49
68
  homepage:
50
69
  licenses: []
51
70
 
@@ -69,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
88
  requirements: []
70
89
 
71
90
  rubyforge_project:
72
- rubygems_version: 1.5.2
91
+ rubygems_version: 1.8.23
73
92
  signing_key:
74
93
  specification_version: 3
75
94
  summary: rscript-server
metadata.gz.sig ADDED
Binary file