rsf_services 0.9.3 → 0.9.6

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: 86fb1a368503749f11101ebc687aaf588fd0af90ebf6687ca90f5a67f67036e5
4
- data.tar.gz: 6abdb89a27223598d3c82e65b63d38c326de50503f83727d8dac29985df8c3c7
3
+ metadata.gz: 2f526110312deb79dfeec5348890b9062075de464c7eae75a3fddd4ca4fdfbb1
4
+ data.tar.gz: 45b4961f92c1891897511881fa21c5add3de8ef80f31f57514c56c0e3265a684
5
5
  SHA512:
6
- metadata.gz: 8ab2aec2be43819469b9cacea29e19fa41218e61b571c325138e0c486dcf69f0c025c9daad929e8039678df1d61ccbb3a504d500f970821abbfcebfb404137f6
7
- data.tar.gz: 191df149e75687e22308c912e2e9acc43d91bd00c998bba54edaad468dfc87e1c0b8c82620a12bb83a1d5c1ca60c70e3f8c35936ccb13d123dd2de0e18a9dace
6
+ metadata.gz: b03f92dd48e67fd465016fbd1c4e5ae10c518743eade8bd81bfa20615571f001d90f1cedab58424d96a30dc4372606d5dcbcd64303eea6915e31c26eb34d5124
7
+ data.tar.gz: 7d6bab11e70fceada0addf02c312c3afd8ce7c1b745af38429135568322e860c39ab96079cd577a2ad4d8a0dc22c67864fea5c3eda09fb0372a8bb439c4963ef
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/rsf_services.rb CHANGED
@@ -5,41 +5,52 @@
5
5
  #require 'rscript'
6
6
  require 'app-mgr'
7
7
  require 'dws-registry'
8
-
8
+ require 'rxfreader'
9
9
 
10
10
 
11
11
  class RSFServices < RScriptRW
12
-
12
+
13
13
  class PackageMethod
14
-
15
- def initialize(parent, type: :get)
14
+
15
+ def initialize(parent, type: :get)
16
16
  @parent = parent
17
17
  @parent.type = type
18
18
  end
19
-
19
+
20
20
  private
21
-
21
+
22
22
  def method_missing(method_name, *args)
23
23
  Package.new @parent, method_name.to_s
24
- end
25
-
26
- end
27
-
28
-
24
+ end
25
+
26
+ end
27
+
28
+
29
29
  class Package
30
-
30
+
31
31
  def initialize(obj, package, debug: false)
32
32
 
33
+
34
+ puts 'inside Package#initialize' if debug
35
+
33
36
  @obj, @package, @debug = obj, package, debug
34
37
 
35
38
  @url = File.join(@obj.package_basepath, package + '.rsf')
36
- doc = Rexle.new open(@url,
37
- 'UserAgent' => 'RSFServices::Package reader').read
39
+
40
+ puts 'before Rexle' if @debug
41
+ puts '@url: ' + @url.inspect if @debug
42
+
43
+ s, _ = RXFReader.read(@url)
44
+ puts 's: ' + s.inspect if @debug
45
+
46
+ doc = Rexle.new s
47
+ puts 'before xpath' if @debug
48
+
38
49
  a = doc.root.xpath 'job/attribute::id'
39
-
50
+
40
51
  a.each do |attr|
41
-
42
- method_name = attr.value.gsub('-','_')
52
+
53
+ method_name = attr.value.gsub('-','_')
43
54
 
44
55
  define_singleton_method method_name.to_sym do |*args|
45
56
  run_job method_name, args
@@ -50,39 +61,39 @@ class RSFServices < RScriptRW
50
61
  end
51
62
 
52
63
  private
53
-
64
+
54
65
  def run_job(method_name, *args)
55
-
66
+
56
67
  puts 'inside Package::run_job: args: ' + args.inspect if @debug
57
-
68
+
58
69
  args.flatten!(1)
59
70
  params = args.find {|x| x.is_a? Hash} ? args.pop : {}
60
71
  a = ['//job:' + method_name, @url, args].flatten(1)
61
-
72
+
62
73
  if @debug then
63
74
  puts 'a: ' + a.inspect
64
75
  puts 'params: ' + params.inspect
65
76
  end
66
-
77
+
67
78
  @obj.run a, params
68
79
  end
69
-
70
80
 
71
- end
81
+
82
+ end
72
83
 
73
84
  attr_reader :services, :package_basepath, :registry
74
85
 
75
- def initialize(reg=nil, package_basepath: '', log: nil, debug: false,
86
+ def initialize(reg=nil, package_basepath: '', log: nil, debug: false,
76
87
  app_rsf: nil)
77
-
88
+
78
89
  @log, @debug = log, debug
79
-
90
+
80
91
  puts 'inside RSF_services' if @debug
81
92
 
82
93
  super(log: log, debug: debug)
83
94
 
84
95
  @package_basepath, @services = package_basepath, {}
85
-
96
+
86
97
  @initialized = {}
87
98
 
88
99
  if reg then
@@ -92,62 +103,63 @@ class RSFServices < RScriptRW
92
103
  else
93
104
  reg
94
105
  end
95
-
106
+
96
107
  # load the system/startup RSF jobs
97
108
 
98
109
  startup = reg.get_key('system/startup')
99
-
110
+
100
111
  jobs = startup.xpath('*[load="1"]').inject({}) do |r, job|
101
112
  settings = reg.get_keys("system/packages/#{job.name}/*")\
102
113
  .inject({}){|r,x| r.merge(x.name.to_sym => x.text) }
103
114
  r.merge(job.name => settings)
104
115
  end
105
-
106
- jobs.each do |package, settings|
107
- r = run_job(package.to_s, 'load', settings,
116
+
117
+ jobs.each do |package, settings|
118
+ r = run_job(package.to_s, 'load', settings,
108
119
  package_path: settings[:url])
109
120
  end
110
121
  end
111
-
122
+
112
123
  @app = AppMgr.new(rsf: app_rsf, reg: reg, rsc: self) if app_rsf
113
124
 
114
125
  end
115
-
116
-
126
+
127
+
117
128
  def delete()
118
129
  PackageMethod.new self, type: :delete
119
- end
120
-
130
+ end
131
+
121
132
  def get()
122
133
  PackageMethod.new self
123
- end
124
-
134
+ end
135
+
125
136
  def put()
126
137
  PackageMethod.new self, type: :put
127
- end
128
-
138
+ end
139
+
129
140
  def post()
130
141
  PackageMethod.new self, type: :post
131
142
  end
132
143
 
133
144
  def run_job(package, jobs, params={}, *qargs)
134
-
145
+
135
146
  puts 'inside run_job' #if @debug
136
147
 
137
148
  package_path = "%s/%s.rsf" % [@package_basepath, package]
138
-
149
+
139
150
  if @log or @debug then
140
- msg = 'RSFServices/run job: ' +
151
+ msg = 'RSFServices/run job: ' +
141
152
  ("package: %s jobs: %s params: %s qargs: %s " + \
142
153
  " package_path: %s" % [package, jobs, params, qargs, package_path])
143
154
  @log.info msg if @log
144
155
  puts msg if @debug
145
156
  end
146
-
147
- yield(params) if block_given?
148
-
157
+
158
+ yield(params) if block_given?
159
+
149
160
  a = [package_path, jobs.split(/\s/).map{|x| "//job:%s" % x} ,qargs].flatten(2)
150
-
161
+ @log.info 'RSFServices/run job: a: ' + a.inspect if @log
162
+
151
163
  puts 'a: ' + a.inspect if @debug
152
164
 
153
165
  c, args, _ = read(a)
@@ -155,51 +167,53 @@ class RSFServices < RScriptRW
155
167
  rws, reg, app = self, @registry, @app
156
168
 
157
169
  begin
158
-
170
+
159
171
  @log.info 'RSFServices/run job: code: ' + c if @log and c.is_a? String
160
172
 
161
- # if there is a job id called *initialize* then execute if it hasn't
173
+ # if there is a job id called *initialize* then execute if it hasn't
162
174
  # already been executed
163
175
 
164
- if self.jobs(package_path).include? :initialize and
176
+ if self.jobs(package_path).include? :initialize and
165
177
  !@initialized[package_path] and jobs != 'initialize' then
166
178
  run_job(package, 'initialize')
167
179
  @initialized[package_path] = true
168
180
  end
169
181
 
170
- r = eval c
182
+ r = instance_eval c
171
183
  puts 'r: ' + r.inspect if @debug
172
184
  #thread = Thread.new {Thread.current[:v] = eval c}
173
185
  #thread.join
174
- #r = thread[:v]
175
-
186
+ #r = thread[:v]
187
+
176
188
  @log.info 'RSFServices/run job: result: ' + r if @log and r.is_a? String
177
-
189
+
178
190
  return r
179
191
 
180
- rescue Exception => e
181
-
192
+ rescue Exception => e
193
+
182
194
  params = {}
183
- err_label = e.message.to_s + " :: \n" + e.backtrace.join("\n")
195
+ err_label = e.message.to_s + " :: \n" + e.backtrace.join("\n")
184
196
  @log.debug 'RSFServices/run_job/error: ' + err_label if @log
185
197
 
186
198
  end
187
-
199
+
188
200
  end
189
-
201
+
190
202
  def package_methods(package)
191
-
192
- url = File.join(@package_basepath, package + '.rsf')
193
- doc = Rexle.new open(url, 'UserAgent' => 'ClientRscript').read
203
+
204
+ url = File.join(@package_basepath, package + '.rsf')
205
+ doc = Rexle.new URI.open(url, 'UserAgent' => 'ClientRscript').read
194
206
  doc.root.xpath('job/attribute::id').map {|x| x.value.to_s.gsub('-','_') }
195
207
 
196
208
  end
197
-
209
+
198
210
  private
199
-
200
- def method_missing2(method_name, *args)
211
+
212
+ def method_missing(method_name, *args)
213
+
214
+ puts 'inside method_missing' if @debug
201
215
  self.type = :get
202
216
  Package.new self, method_name.to_s, debug: @debug
203
- end
204
-
217
+ end
218
+
205
219
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsf_services
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -11,52 +11,52 @@ cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
13
  MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjAwNjI4MTAzODExWhcN
15
- MjEwNjI4MTAzODExWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
- cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDihlal
17
- S7Ayw88OOfbgDNcfYFIBkwJsw1K7lnTkQ33d3CjfHjkHpwue+BPZrqNDDkzkq72C
18
- GH24K4vhz9xeQ+sc+eAiSk0iARvNxFUXe/4JpZmo1A9u3fLCNbA7bL2IQIQqyBWY
19
- /KgltVLGWau1X4rxuIS00TXrpUeG5pUeol/kUeDhmS8XmdU4rTbB62cz5RH/J2Zb
20
- cDMx8jiap1BqyxU0qcJLoe0yJzwCNqrX3UmakhaFjv+5IHH0z+GP3evQ1Z/toY+G
21
- MYrAFJ3cGjnk0s712KOa4W+tIW+q5FKjEwY5cGE/mbPh6cjZ+BYuYeSVqDrCY98d
22
- a0I7JVRG6V/h+K8++OlSQ8dT4V0Yl7S6Nj21Yd9hmS/BXKbkq81J2zEF3mxHJZN7
23
- AMKJE8m7jz+TLFX1f7+wIUrslfIJXqwXbThIGAqhFUb8+Ec0AuKs2F4l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FA/uTvD77A8MgCYQa5llIZEx0Bd7ExPDPZn
34
+ e86Mje12aZQAyilVfeqbv5u3EZlw6kLbigLmw7BlUk7Zi2X84+iz7W8EdU3GSv8a
35
+ y347QSdvzPRHMpmi1wAJh+koAo4s8Noi64GU5+4xUDRUh02AV/sXFxRdJne2WDW0
36
+ 4wvjYJ8JEXo2AHNQSXG3FQmn
37
37
  -----END CERTIFICATE-----
38
- date: 2020-06-28 00:00:00.000000000 Z
38
+ date: 2022-02-22 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: dws-registry
42
42
  requirement: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: 0.5.0
47
44
  - - "~>"
48
45
  - !ruby/object:Gem::Version
49
46
  version: '0.5'
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 0.5.0
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: 0.5.0
57
54
  - - "~>"
58
55
  - !ruby/object:Gem::Version
59
56
  version: '0.5'
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 0.5.0
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: app-mgr
62
62
  requirement: !ruby/object:Gem::Requirement
@@ -78,7 +78,7 @@ dependencies:
78
78
  - !ruby/object:Gem::Version
79
79
  version: 0.3.1
80
80
  description:
81
- email: james@jamesrobertson.eu
81
+ email: digital.robertson@gmail.com
82
82
  executables: []
83
83
  extensions: []
84
84
  extra_rdoc_files: []
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  requirements: []
106
- rubygems_version: 3.0.3
106
+ rubygems_version: 3.2.22
107
107
  signing_key:
108
108
  specification_version: 4
109
109
  summary: Runs within a DRb server to run RSF jobs, as well as other services.
metadata.gz.sig CHANGED
Binary file