rsf_services 0.9.1 → 0.9.5

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: e88296fc206a405c9481936297b10d651cc20bde62ffa5da5d1c9cb0bd7a01ce
4
- data.tar.gz: 22ffe21c8ee86214ffadb6682d3dbcbafaca674fd7b8f1bb72da43f0a0b985d1
3
+ metadata.gz: 43feef11d6b29d948bffbd0b15dbb6ffc0824ccc300710c2c00a53cbcbddddd7
4
+ data.tar.gz: 960d006b9687bd9c11ef998750b83555b0a065f4348983c882b9ba41d5c9779b
5
5
  SHA512:
6
- metadata.gz: 2c92e3c7e898f340b8050f67cd10904ba5f02ae908af9ffcbee1e39e8499776e8d6693f29788774d49a3e59d3eda6478b614dc327e546705ba626219f6d2fc6b
7
- data.tar.gz: a4585d138ce856bc2ed457c07dc3addf77a4138cfc70edc9ad6f811fea5db1dc8de34d3b8baf4d2c03626cf3a4768108efe1223855dd000db7948ffd0fa8b7e9
6
+ metadata.gz: 32c7760f8ddb53a3f81f54dba12dbe742502ab80de5d241391a7123474667d64f928a7751068f9ba63d195e4290429500ebf515e04a3f135a7d1874e9bc30a52
7
+ data.tar.gz: fb07b09dd1db29349bdf876528b9b143b4f0265c9c872607dc9db26a3002f2a28943ff28e9ea6860d12ae2d401694134a0eaf5407cb235aee827ea3213028b04
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/rsf_services.rb CHANGED
@@ -7,39 +7,49 @@ require 'app-mgr'
7
7
  require 'dws-registry'
8
8
 
9
9
 
10
-
11
10
  class RSFServices < RScriptRW
12
-
11
+
13
12
  class PackageMethod
14
-
15
- def initialize(parent, type: :get)
13
+
14
+ def initialize(parent, type: :get)
16
15
  @parent = parent
17
16
  @parent.type = type
18
17
  end
19
-
18
+
20
19
  private
21
-
20
+
22
21
  def method_missing(method_name, *args)
23
22
  Package.new @parent, method_name.to_s
24
- end
25
-
26
- end
27
-
28
-
23
+ end
24
+
25
+ end
26
+
27
+
29
28
  class Package
30
-
31
- def initialize(obj, package, debug: debug)
29
+
30
+ def initialize(obj, package, debug: false)
31
+
32
+
33
+ puts 'inside Package#initialize' if debug
32
34
 
33
35
  @obj, @package, @debug = obj, package, debug
34
36
 
35
37
  @url = File.join(@obj.package_basepath, package + '.rsf')
36
- doc = Rexle.new open(@url,
37
- 'UserAgent' => 'RSFServices::Package reader').read
38
+
39
+ puts 'before Rexle' if @debug
40
+ puts '@url: ' + @url.inspect if @debug
41
+
42
+ s, _ = RXFHelper.read(@url)
43
+ puts 's: ' + s.inspect if @debug
44
+
45
+ doc = Rexle.new s
46
+ puts 'before xpath' if @debug
47
+
38
48
  a = doc.root.xpath 'job/attribute::id'
39
-
49
+
40
50
  a.each do |attr|
41
-
42
- method_name = attr.value.gsub('-','_')
51
+
52
+ method_name = attr.value.gsub('-','_')
43
53
 
44
54
  define_singleton_method method_name.to_sym do |*args|
45
55
  run_job method_name, args
@@ -50,39 +60,41 @@ class RSFServices < RScriptRW
50
60
  end
51
61
 
52
62
  private
53
-
63
+
54
64
  def run_job(method_name, *args)
55
-
65
+
56
66
  puts 'inside Package::run_job: args: ' + args.inspect if @debug
57
-
67
+
58
68
  args.flatten!(1)
59
69
  params = args.find {|x| x.is_a? Hash} ? args.pop : {}
60
70
  a = ['//job:' + method_name, @url, args].flatten(1)
61
-
71
+
62
72
  if @debug then
63
73
  puts 'a: ' + a.inspect
64
74
  puts 'params: ' + params.inspect
65
75
  end
66
-
76
+
67
77
  @obj.run a, params
68
78
  end
69
-
70
79
 
71
- end
80
+
81
+ end
72
82
 
73
83
  attr_reader :services, :package_basepath, :registry
74
84
 
75
- def initialize(reg=nil, package_basepath: '', log: nil, debug: false,
85
+ def initialize(reg=nil, package_basepath: '', log: nil, debug: false,
76
86
  app_rsf: nil)
77
-
87
+
78
88
  @log, @debug = log, debug
79
-
89
+
80
90
  puts 'inside RSF_services' if @debug
81
91
 
82
- super(log: log)
92
+ super(log: log, debug: debug)
83
93
 
84
94
  @package_basepath, @services = package_basepath, {}
85
95
 
96
+ @initialized = {}
97
+
86
98
  if reg then
87
99
 
88
100
  @registry = @services['registry'] = if reg.is_a? String then
@@ -90,98 +102,117 @@ class RSFServices < RScriptRW
90
102
  else
91
103
  reg
92
104
  end
93
-
105
+
94
106
  # load the system/startup RSF jobs
95
107
 
96
108
  startup = reg.get_key('system/startup')
97
-
109
+
98
110
  jobs = startup.xpath('*[load="1"]').inject({}) do |r, job|
99
111
  settings = reg.get_keys("system/packages/#{job.name}/*")\
100
112
  .inject({}){|r,x| r.merge(x.name.to_sym => x.text) }
101
113
  r.merge(job.name => settings)
102
114
  end
103
-
104
- jobs.each do |package, settings|
105
- r = run_job(package.to_s, 'load', settings,
115
+
116
+ jobs.each do |package, settings|
117
+ r = run_job(package.to_s, 'load', settings,
106
118
  package_path: settings[:url])
107
119
  end
108
120
  end
109
-
121
+
110
122
  @app = AppMgr.new(rsf: app_rsf, reg: reg, rsc: self) if app_rsf
111
123
 
112
124
  end
113
-
114
-
125
+
126
+
115
127
  def delete()
116
128
  PackageMethod.new self, type: :delete
117
- end
118
-
129
+ end
130
+
119
131
  def get()
120
132
  PackageMethod.new self
121
- end
122
-
133
+ end
134
+
123
135
  def put()
124
136
  PackageMethod.new self, type: :put
125
- end
126
-
137
+ end
138
+
127
139
  def post()
128
140
  PackageMethod.new self, type: :post
129
141
  end
130
142
 
131
143
  def run_job(package, jobs, params={}, *qargs)
132
144
 
145
+ puts 'inside run_job' #if @debug
146
+
133
147
  package_path = "%s/%s.rsf" % [@package_basepath, package]
134
-
135
- if @log then
136
- @log.info 'RSFServices/run job: ' +
148
+
149
+ if @log or @debug then
150
+ msg = 'RSFServices/run job: ' +
137
151
  ("package: %s jobs: %s params: %s qargs: %s " + \
138
152
  " package_path: %s" % [package, jobs, params, qargs, package_path])
153
+ @log.info msg if @log
154
+ puts msg if @debug
139
155
  end
140
-
141
- yield(params) if block_given?
142
-
156
+
157
+ yield(params) if block_given?
158
+
143
159
  a = [package_path, jobs.split(/\s/).map{|x| "//job:%s" % x} ,qargs].flatten(2)
160
+ @log.info 'RSFServices/run job: a: ' + a.inspect if @log
144
161
 
145
- c, args, _ = read(a)
162
+ puts 'a: ' + a.inspect if @debug
146
163
 
164
+ c, args, _ = read(a)
165
+ puts 'c: ' + c.inspect if @debug
147
166
  rws, reg, app = self, @registry, @app
148
167
 
149
168
  begin
150
-
169
+
151
170
  @log.info 'RSFServices/run job: code: ' + c if @log and c.is_a? String
152
171
 
153
- r = eval c
172
+ # if there is a job id called *initialize* then execute if it hasn't
173
+ # already been executed
174
+
175
+ if self.jobs(package_path).include? :initialize and
176
+ !@initialized[package_path] and jobs != 'initialize' then
177
+ run_job(package, 'initialize')
178
+ @initialized[package_path] = true
179
+ end
180
+
181
+ r = instance_eval c
182
+ puts 'r: ' + r.inspect if @debug
154
183
  #thread = Thread.new {Thread.current[:v] = eval c}
155
184
  #thread.join
156
- #r = thread[:v]
157
-
185
+ #r = thread[:v]
186
+
158
187
  @log.info 'RSFServices/run job: result: ' + r if @log and r.is_a? String
159
-
188
+
160
189
  return r
161
190
 
162
- rescue Exception => e
163
-
191
+ rescue Exception => e
192
+
164
193
  params = {}
165
- err_label = e.message.to_s + " :: \n" + e.backtrace.join("\n")
194
+ err_label = e.message.to_s + " :: \n" + e.backtrace.join("\n")
166
195
  @log.debug 'RSFServices/run_job/error: ' + err_label if @log
167
196
 
168
197
  end
169
-
198
+
170
199
  end
171
-
200
+
172
201
  def package_methods(package)
173
-
174
- url = File.join(@package_basepath, package + '.rsf')
175
- doc = Rexle.new open(url, 'UserAgent' => 'ClientRscript').read
202
+
203
+ url = File.join(@package_basepath, package + '.rsf')
204
+ doc = Rexle.new URI.open(url, 'UserAgent' => 'ClientRscript').read
176
205
  doc.root.xpath('job/attribute::id').map {|x| x.value.to_s.gsub('-','_') }
177
206
 
178
207
  end
179
-
208
+
180
209
  private
181
-
210
+
182
211
  def method_missing(method_name, *args)
212
+
213
+ puts 'inside method_missing' if @debug
183
214
  self.type = :get
184
215
  Package.new self, method_name.to_s, debug: @debug
185
- end
186
-
216
+ end
217
+
187
218
  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.1
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -11,31 +11,31 @@ cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
13
  MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTkwMzA1MTU1MzUxWhcN
15
- MjAwMzA0MTU1MzUxWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
- cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDlYGvg
17
- qZvJhIVpFp3bf26jf3rf4pDQBpTzGZu9M99OZHuVFBaMDm3ogTSe8DTlEPmgNMkB
18
- pguoBZn18Xp+v/XXNHBKtQc/YVj/jdhfwpMvXRsM8kqkPYMne8CK1HMKaIi0xgRC
19
- 5FWiTc04g10M04CES0Eh14zq1bbsXZqSTNN950+vvKq0th7i/pySEZHqXWu5Q0lz
20
- cKtHW5o3BUJoVOKMVO6p2dUk0LjFx5uXHc5Bbxl4uQ2jCTV5tdxYHeP7qXAZI/FE
21
- 2dzF4zb8lWxKt/99C+grAhySE+JOz8WWE4hGU7754nBX0wOT1jrjAKQ+m11FcKBb
22
- TuCw0BR9ZOGqz9KX96NBAfVcH4ooNy7tHYXWg2OwpkSKbmtBblFzwwKYIOSChe82
23
- uygIU3vpoKQs15QWqh+4kMKaZx1i8CXQ9B4d2x/f0sOWSC+yk7jYoXPOTnKlHwXG
24
- gipDR3kb6u5B1wYcbT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yilVfeqbv5u3EZlw6kLbigLmw7BlUk7Zi2X84+iz7W8EdU3GSv8a
35
+ y347QSdvzPRHMpmi1wAJh+koAo4s8Noi64GU5+4xUDRUh02AV/sXFxRdJne2WDW0
36
+ 4wvjYJ8JEXo2AHNQSXG3FQmn
37
37
  -----END CERTIFICATE-----
38
- date: 2019-09-17 00:00:00.000000000 Z
38
+ date: 2021-11-18 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: dws-registry
@@ -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,8 @@ 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
+ rubyforge_project:
107
+ rubygems_version: 2.7.10
107
108
  signing_key:
108
109
  specification_version: 4
109
110
  summary: Runs within a DRb server to run RSF jobs, as well as other services.
metadata.gz.sig CHANGED
Binary file