rsc 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/rsc.rb +93 -53
  4. data.tar.gz.sig +0 -0
  5. metadata +31 -31
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 115749bd16f1af955ea0e43418bba405759717e0c79dd01fad8949d6a347d919
4
- data.tar.gz: e69fdafceb96dccd9e5cd28293bbc34945d434c0dbcebfdf42372e9eed9b8b79
3
+ metadata.gz: a468303e494872289c8abae2d4423708d53a524321889572d708318a732bf6e3
4
+ data.tar.gz: cd6be7b4404608866702a991f629a454cc47ff4d0cc50171aa85a8e6178d85ef
5
5
  SHA512:
6
- metadata.gz: d79d6a669490acf00d80fda396a921aa8999f17e37210ba479085aa0592c05221479475d165eae3b2b27ce60d684261bf141f3d3446b18f5aee59e1545b360ba
7
- data.tar.gz: a9da5d5628a9241ae958294122ea5ab24bd2cedb0f2bfb3710a1612fb13ee761dd2249ae0792dbe1a5f3b54f488e7238378bab5feb7d7c6565907f0413bd2f3a
6
+ metadata.gz: 3c11bb62a6631816aae637fd3e48b95c98cc9e9d4bf08dedb3b9e5525026804a463557643f8008e7ddc3339b152d8b6358d41c4087cbdc3d7040319ae752d218
7
+ data.tar.gz: 8fe6c91c8b2e0c4fc99866ff613c8b9c0c580708e94d15ebab00c1ebdc88e9a2ae366fd9824391838456a3e512ea67ece0934412ece6c5de5e32abcf3bda1301
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/rsc.rb CHANGED
@@ -7,59 +7,97 @@ require 'drb'
7
7
  require 'rexle'
8
8
 
9
9
 
10
- class Rse
11
-
12
- def self.call(x) RSC.new.get(x) end
10
+ class RseClient
11
+
12
+ def self.call(x) RSC.new.get(x) end
13
13
  def self.get(x) RSC.new.get(x) end
14
- def self.post(x, val) RSC.new.post(x, val) end
14
+ def self.post(x, val) RSC.new.post(x, val) end
15
15
  def self.delete(x) RSC.new.delete(x) end
16
- def self.put(x, val) RSC.new.put(x, val) end
17
-
16
+ def self.put(x, val) RSC.new.put(x, val) end
17
+
18
18
  end
19
19
 
20
20
  class RSC
21
21
  using ColouredText
22
-
22
+
23
23
  class Package
24
24
  using ColouredText
25
-
25
+
26
26
  def initialize(drb_obj, package, debug: false)
27
-
27
+
28
28
  @debug = debug
29
29
 
30
30
  @obj = drb_obj
31
31
  drb_obj.package_methods(package).each do |method_name|
32
-
32
+
33
33
  puts ('creating method ' + method_name).info if @debug
34
34
 
35
35
  methodx = "
36
- def %s(*args)
37
- @obj.run_job('%s','%s', args)
36
+ def %s(*args, params: {})
37
+ @obj.run_job('%s','%s', params, args)
38
38
  end" % [method_name, package, method_name]
39
- self.instance_eval(methodx)
40
-
39
+ self.instance_eval(methodx)
40
+
41
41
  end
42
42
 
43
43
  end
44
44
 
45
45
  end
46
46
 
47
- def initialize(drb_hostname='rse', port: '61000', debug: false)
48
-
49
- @port, @debug = port, debug
50
-
51
- drb_start(drb_hostname)
52
-
47
+ def initialize(drb_hostname='rse', port: '61000', odrb2: false, debug: false)
48
+
49
+ @debug = debug
50
+ DRb.start_service
51
+
52
+
53
+ if odrb2 or port == '57844' then
54
+ @port = port =~ /^610[0-9]{2}/ ? '57844' : port
55
+
56
+ @obj = DRbObject.new(nil, "druby://#{drb_hostname}:#{@port}")
57
+ parent = @obj
58
+ @obj&.services.each do |name, methods|
59
+
60
+ class_name = name.capitalize
61
+ klass = Object.const_set(class_name,Class.new)
62
+
63
+ klass.class_eval do
64
+ methods.each do |method_name|
65
+ define_method method_name do |*args|
66
+ parent.call name, method_name, *args
67
+ end
68
+ end
69
+ end
70
+
71
+ define_singleton_method name do
72
+ klass.new
73
+ end
74
+
75
+ end
76
+
77
+ @odrb2 = true
78
+
79
+ else
80
+
81
+ @port = port
82
+ @obj = DRbObject.new(nil, "druby://#{drb_hostname}:#{@port}")
83
+
84
+ end
85
+
86
+
87
+
53
88
  end
54
89
 
90
+ # jr: 2022-04-23 the following public methods should be conditionally
91
+ # created since they are specific to classic RSC and not odrb2
92
+
55
93
  def delete(s=nil)
56
94
  s ? run_uri(s, :delete) : @obj.delete
57
95
  end
58
-
96
+
59
97
  def get(s=nil)
60
98
  s ? run_uri(s, :get) : @obj.get
61
99
  end
62
-
100
+
63
101
  def post(s=nil, val=nil)
64
102
  s ? run_uri(s, :post, value: val) : @obj.post
65
103
  end
@@ -67,40 +105,42 @@ class RSC
67
105
  def put(s=nil, val=nil)
68
106
  s ? run_uri(s, :put, value: val) : @obj.put
69
107
  end
70
-
71
-
108
+
109
+
72
110
  def run_job(package, job, params={}, *qargs, package_path: nil)
73
111
  @obj.run_job(package, job, params, qargs, package_path)
74
112
  end
75
113
 
76
114
  private
77
-
115
+
78
116
  def drb_start(host)
79
117
  DRb.start_service
80
- @obj = DRbObject.new(nil, "druby://#{host}:#{@port}")
118
+ @obj = DRbObject.new(nil, "druby://#{host}:#{@port}")
81
119
  end
82
-
120
+
83
121
  def method_missing(method_name, *args)
84
122
 
85
123
  if @debug then
86
- puts 'method_missing'.info
124
+ puts 'method_missing'.info
87
125
  puts ('method_name: ' + method_name.inspect).debug
88
126
  end
89
-
90
- begin
91
- Package.new @obj, method_name.to_s, debug: @debug
92
- rescue
93
- # nil will be returned if there is no package by that name
127
+
128
+ if not @odrb2 then
129
+
130
+ begin
131
+ Package.new @obj, method_name.to_s, debug: @debug
132
+ rescue
133
+ # nil will be returned if there is no package by that name
134
+ end
94
135
  end
95
-
96
136
  end
97
-
137
+
98
138
  def parse_uri(s)
99
-
139
+
100
140
  protocol, _, host, package, raw_job, remaining = s.split('/',6)
101
-
141
+
102
142
  if remaining then
103
-
143
+
104
144
  job = raw_job
105
145
  # split on the 1st question mark
106
146
  raw_args, raw_params = if remaining =~ /\?/ then
@@ -108,40 +148,40 @@ class RSC
108
148
  else
109
149
  remaining
110
150
  end
111
-
151
+
112
152
  elsif raw_job =~ /\?/
113
153
  job, raw_params = raw_job.split('?',2)
114
154
  else
115
155
  job = raw_job
116
156
  end
117
-
157
+
118
158
  if raw_args or raw_params then
119
159
  args = raw_args.split('/') if raw_args
120
-
160
+
121
161
  if raw_params then
122
- params = raw_params.split('&').inject({}) do |r,x|
162
+ params = raw_params.split('&').inject({}) do |r,x|
123
163
  k, v = x.split('=')
124
164
  v ? r.merge(k[/\w+$/].to_sym => URI.unescape(v)) : r
125
- end
165
+ end
126
166
  end
127
167
 
128
- end
129
-
168
+ end
169
+
130
170
  [host, package, job, args, params]
131
171
  end
132
-
172
+
133
173
  def run_uri(s, type=:get, value: nil)
134
-
174
+
135
175
  host, package, job, args, params = parse_uri(s)
136
176
  drb_start host
137
177
  @obj.type = type
138
-
178
+
139
179
  if value then
140
- params ||= {}
141
- params.merge!(value.is_a?(Hash) ? value : {value: value})
180
+ params ||= {}
181
+ params.merge!(value.is_a?(Hash) ? value : {value: value})
142
182
  end
143
-
144
- @obj.run_job(package, job, params, args)
145
-
183
+
184
+ @obj.run_job(package, job, params, args)
185
+
146
186
  end
147
187
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.0
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
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTkwMzI2MjA1NjMxWhcN
15
- MjAwMzI1MjA1NjMxWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
- cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGK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b3A1f4f/mOq6BoLjgtZ/BQcF6skvI7i
35
- ErJFIoeyeVsFvSBnm5kPCZAp6NFkohs59rEEMVKkj4ZlAkFLyOHJ3sUyedByJwqE
36
- zW8gffb/eYXJOnj754Mmtpb4
28
+ BgkqhkiG9w0BAQsFAAOCAYEAm8KCfzZeyU4a0kDPMxcb8iOTVIoJ8limkG/lYyuo
29
+ Hz8C9jH6Xwnf4vXCrlgws61KSzK5jgMOq6Kp0pT7cbzo/Q18610THO20z/4/LEe+
30
+ sIhzxr4qxQP7TJpMmJq4LID//QYT7OY92fj3fkoDkggm85OcVFRPGtTyWpa0dkYL
31
+ P3O/v5tkIffwiO1gY66UFT0dlPAAkeqhSCGqGiwJ76bPysM0hqOQ71FYPZo9VczD
32
+ HqSj7ZJVUDPW1iKYvB880LA2xuo8/EIxOwiIBKh/TSS9tfS+cMPuLo2wDN01RJTC
33
+ 02kbvdTC2ZBSjLt1fo5+JWfFJ5yfwoxSsw0MmxXYVqBNlF4CkZU+s9ngXa/sXXZi
34
+ vB6UTVioVZH0DMsCmInZK1EbAAv3q27SbTyAtG8f3yRjfb9kAGo6zDotHy1oGAiA
35
+ aXZYTu0wdZCcurVbkjN+dC+imsA1+dCLcoS6yn0qWDfFBE/IJCWIQKNT0YDW0sTw
36
+ yQTpQzKRnLzRe2Mu66QO3dN3
37
37
  -----END CERTIFICATE-----
38
- date: 2019-03-26 00:00:00.000000000 Z
38
+ date: 2022-04-23 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rexle
@@ -46,7 +46,7 @@ dependencies:
46
46
  version: '1.5'
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 1.5.1
49
+ version: 1.5.14
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
@@ -56,9 +56,9 @@ dependencies:
56
56
  version: '1.5'
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 1.5.1
60
- description: formerly known as rcscript-client
61
- email: james@jamesrobertson.eu
59
+ version: 1.5.14
60
+ description: formerly known as rcscript-client; Now supports OneDRb version2.
61
+ email: digital.robertson@gmail.com
62
62
  executables: []
63
63
  extensions: []
64
64
  extra_rdoc_files: []
@@ -83,9 +83,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
85
  requirements: []
86
- rubygems_version: 3.0.1
86
+ rubygems_version: 3.2.22
87
87
  signing_key:
88
88
  specification_version: 4
89
- summary: Objectifies remote calls to RSF packages and jobs which are run through a
90
- DRb server
89
+ summary: Primarily objectifies remote calls to RSF packages and jobs which are run
90
+ through a DRb server
91
91
  test_files: []
metadata.gz.sig CHANGED
Binary file