onedrb 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e1dea351f77a02d587369c3d60ee375e608c1e10c42598012403c101c54cff6
4
- data.tar.gz: 31e34ab07655ab42669955f8a02dcf68c0afa3989797e6b8cd6765f0b9bff61d
3
+ metadata.gz: 1715575559f96238261a54678e475a056223491a3ff7c610a5df823001fe454c
4
+ data.tar.gz: 66acb7de842732715d02c287c753d1221d2963631b6bc2edd3ca842eecd88665
5
5
  SHA512:
6
- metadata.gz: 2abc2da0df0795521dd76c3e610ccdfa7e6f7b3bbac546e4c167364e7b1797786749326b235bbe9487f54c19087ac2033cab8b89a287d6e4efe1093e74c6db8b
7
- data.tar.gz: fc4a215efd2142d0852ef91b2f6fa8749599a20fe8cb923430c1e04aace1177139293613d7f3a4cfb5996d536800140d95ff77e5dc989a5156de1e5586e689d1
6
+ metadata.gz: befc1ab68c1a9ede94f24415faeeb3fbbfcfc044edd3e73cdda361f3fa8cf77d309158804aecc5c2b1f995ee81b7bd382dbe359f798c24bfa222f9422479cff3
7
+ data.tar.gz: a83d5eb21b2270e5e51c1c8918fffe1b510c43237076f137dbe8d788a5e6394f964bbd10db08d3be4abde3f8e0551766b280c3ba27e6cb94b03fcb579cb03723
checksums.yaml.gz.sig CHANGED
@@ -1,4 +1,2 @@
1
- ��;���ad��2̀���Z5$�G-w��'�Y��w��L �����6��uu e�`P|�!8���w'�@�^��R.�׶���Zd{PG}�>ը-�W��;�ќ���v�x׽��1�X9R�ӱ?�*��VT4s��]�𰣇1As[K䄔���7+��8Ǝ
2
- �Xx��S1�@�R�f�
3
- Fg�P�u���{K��L $b�Ie����B���KA\���U��'���;#_;5�k��L�kk�%��
4
- X�?�_BtR����\\�P)����B�nR�7��캥:�X��.���Oy��&6}c�0��B�]c���[0�TM��)u�E.W��{�ٳs�ZUE!��9ѻ�OE�u� ��c����+�NƼ)vS�xU���&d
1
+ y��I�G<��V�%Ӫ�w�E���������QԬ}�M�ܔC,���5j&�Nkv>$����o���!���J�� �B�w�`�J��`��Q�U�0/u��"^��b�4J�b��^�:�zA���O��h�X��K.�N��+�s^��Β-�x���F�|Ҽi��>A%����9Q�,�-�|sa7wqՓU'����4: Q��%FF2��P%��NIMh �x\�[��a[]r\ލȲ��P9) �&� ���> ټp��9fv���d=��ҲV"�
2
+ ?���n,���
data/lib/onedrb.rb CHANGED
@@ -7,9 +7,48 @@
7
7
  require 'drb'
8
8
  require 'c32'
9
9
 
10
- # Note: The Server object can also use a default Hash object.
11
- # Which allows the Client object to define what user-defined objects the server
12
- # should host dynamically.
10
+ # Note: The Server object can also use a default ServiceMgr object.
11
+ # Which allows multiple services (user-defined objects) to be
12
+ # hosted dynamically.
13
+
14
+
15
+ class ServiceMgr
16
+
17
+ def initialize()
18
+ @services = {}
19
+ end
20
+
21
+
22
+ def call(service, methodname, *a)
23
+
24
+ proc1 = @services[service.to_sym].method(methodname.to_sym)
25
+ a.last.is_a?(Hash) ? proc1.call(*a[0..-2], **a.last) : proc1.call(*a)
26
+
27
+ end
28
+
29
+ def [](key)
30
+ @services[key]
31
+ end
32
+
33
+ def []=(key, value)
34
+ @services[key] = value
35
+
36
+ define_singleton_method key do
37
+ @services[key]
38
+ end
39
+ end
40
+
41
+ def services()
42
+ @services.map do |key, object|
43
+ [key, object.public_methods - Object.public_methods]
44
+ end
45
+ end
46
+
47
+ def method_missing(sym, *args)
48
+ puts 'servicemgr sym: ' + sym.inspect
49
+ puts 'args: ' + args.inspect
50
+ end
51
+ end
13
52
 
14
53
 
15
54
  class OneDrbError < Exception
@@ -22,7 +61,7 @@ module OneDrb
22
61
  using ColouredText
23
62
 
24
63
  def initialize(host: '127.0.0.1', port: (49152..65535).to_a.sample.to_s,
25
- obj: Hash.new, log: nil)
64
+ obj: ServiceMgr.new, log: nil)
26
65
 
27
66
  log.info self.class.to_s + '/initialize: active' if log
28
67
 
@@ -63,6 +102,25 @@ module OneDrb
63
102
 
64
103
  puts ('client connecting to port ' + port).info
65
104
  @obj = DRbObject.new_with_uri("druby://#{host}:#{port}")
105
+ parent = self
106
+ @obj&.services.each do |name, methods|
107
+
108
+ class_name = name.capitalize
109
+ klass = Object.const_set(class_name,Class.new)
110
+
111
+ klass.class_eval do
112
+ methods.each do |method_name|
113
+ define_method method_name do |*args|
114
+ parent.call name, method_name, *args
115
+ end
116
+ end
117
+ end
118
+
119
+ define_singleton_method name do
120
+ klass.new
121
+ end
122
+
123
+ end
66
124
 
67
125
  end
68
126
 
@@ -87,9 +145,24 @@ module OneDrb
87
145
  a = a1.map(&:last)
88
146
 
89
147
  client = OneDrb::Client.new host: hostname, port: port
90
- proc1 = client[service].method(methodname.to_sym)
91
148
 
92
- h.any? ? proc1.call(*a, **h) : proc1.call(*a)
149
+ if h.any? then
150
+
151
+ if a.any? then
152
+ client.call service.to_sym, methodname.to_sym, *a, **h
153
+ else
154
+ client.call service.to_sym, methodname.to_sym, **h
155
+ end
156
+
157
+ elsif a.any?
158
+
159
+ client.call service.to_sym, methodname.to_sym, *a
160
+
161
+ else
162
+
163
+ client.call service.to_sym, methodname.to_sym
164
+
165
+ end
93
166
 
94
167
  end
95
168
 
@@ -99,6 +172,8 @@ module OneDrb
99
172
 
100
173
  def method_missing(sym, *args)
101
174
 
175
+ puts '@obj.class: ' + @obj.class.inspect
176
+
102
177
  if args.last.is_a?(Hash) then
103
178
  @obj.send(sym, *args[0..-2], **args.last)
104
179
  else
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onedrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  lK7OtCGPauDHVuIWDW0EnHb+MMBt6F5SqC+PSy9iOzs4zAWkJMFp86MOEK2yrfnO
36
36
  /ghrVtneK08DqmYOaive8I6P
37
37
  -----END CERTIFICATE-----
38
- date: 2022-04-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: c32
metadata.gz.sig CHANGED
Binary file