rsc 0.4.5 → 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 +90 -50
  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: b01f72dfa760e286914b6c423cbf9724deb0eb47edcf7fcb3ad110eb12a67922
4
- data.tar.gz: bf1e28da451ab37f4708a7d1a96c02739752fdf8d2475a0c3c3674e9e03a53f4
3
+ metadata.gz: a468303e494872289c8abae2d4423708d53a524321889572d708318a732bf6e3
4
+ data.tar.gz: cd6be7b4404608866702a991f629a454cc47ff4d0cc50171aa85a8e6178d85ef
5
5
  SHA512:
6
- metadata.gz: 1edee6d3f54ad895aaf0a6a87b0e078b6dc68f3ba5d9f31dc00e946d66878304af643c2acba4229cd8f9483002dabb3e59080e53032d838efc4dd32a5c380dc1
7
- data.tar.gz: 18ca4264549c16234606ad3772c4fbfefe94baceb9b9b5a0f8e47a05c699277f883c63fbfdda5250d4fc3968b82cb8c4ae1b17261c8226dff48176bff4ab0751
6
+ metadata.gz: 3c11bb62a6631816aae637fd3e48b95c98cc9e9d4bf08dedb3b9e5525026804a463557643f8008e7ddc3339b152d8b6358d41c4087cbdc3d7040319ae752d218
7
+ data.tar.gz: 8fe6c91c8b2e0c4fc99866ff613c8b9c0c580708e94d15ebab00c1ebdc88e9a2ae366fd9824391838456a3e512ea67ece0934412ece6c5de5e32abcf3bda1301
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/rsc.rb CHANGED
@@ -8,58 +8,96 @@ require 'rexle'
8
8
 
9
9
 
10
10
  class RseClient
11
-
12
- def self.call(x) RSC.new.get(x) end
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
36
  def %s(*args, params: {})
37
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.5
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
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjAxMTIyMjExMDI0WhcN
15
- MjExMTIyMjExMDI0WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
- cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDj/1eB
17
- V/C3L3qsRlMSobUmyRpRU6H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2RVS09pLv4ZwZ9VG6pxhnhbGZhRvgwfpH8yzFxyix3K8FwNQcSUw+Qzs
36
- sq6tf27j+XsE4ORGUcdVfJFm
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: 2020-11-22 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.3
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