rsc 0.3.0 → 0.3.1

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 +3 -1
  3. data.tar.gz.sig +0 -0
  4. data/lib/rsc.rb +68 -14
  5. metadata +1 -1
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87bb396af79207dc02df1dba6d3db3c8f1cd677d
4
- data.tar.gz: 3e7bb33b85c71d06c43410480544178aac3151d7
3
+ metadata.gz: 5515efb4f9945805779a857ce5a1798fe3a52369
4
+ data.tar.gz: e15a3ef37d4604123de84d78990a1c39a0273a44
5
5
  SHA512:
6
- metadata.gz: 9731c275bf0348bea2f1bb3efe111abd3d7edb9a97bd209f87e0217f4618781186edde4101b04ac1a7f58ede90675c187182ff021bf31b9b9ef8186e868882ac
7
- data.tar.gz: 7b93d9ba504d31a8477f772f910bbab7fb734bea2d6e6e2effe997d6ab38ce34a24ebdea46f010eafd31aaa9e1b96667e33a356cba73ac8e554c558af48897fa
6
+ metadata.gz: d77eac9bee1bde92f22a414abe010a135b2ccef32b7481266a71181300f1adb5d51ae9cbca2b344a09368a8dc5eb5b0d78cbae1204877c7e06d7340cff2857c4
7
+ data.tar.gz: d8292c1e7e2a6b949e716812a2968a090d5b783e67942ba20d1a96fd562c36781488c30cc578c22766c320b98f8b294c5d50013a69e426bd3c85df5602c74fee
@@ -1 +1,3 @@
1
- �^a�Ӵ~���l a�>�cD���~�-��$vݨA/����D���X�D����9���?�v�L��������rh`��1���d�m���\��`6��ެSrN>�|�7H����d~�@�)gП�����񳦡|<~T2e۫��/���-z|�<��<����6Z��K�Ԑ�Ɍ���W�?ٖ$��@fkK�"��O'��iw����/:0��"���� �fB�+��c,��<${0������bpL]��
1
+ �Ֆ7��!��o��Q3Z��tR)QB�z�+�1?�@��o
2
+ >!�vw�5fC���A;��$a�b�
3
+ �.�5`�\��Z6းU��I�f��y��͠�?�(�������y�&�.4�7�Y��h��Aq��B})�%Zq!�]�H���x�W�W䢡���!�/L��Q�]Jı�ސ���I�ELB�<@I"5F<C�W��7�
data.tar.gz.sig CHANGED
Binary file
data/lib/rsc.rb CHANGED
@@ -40,37 +40,91 @@ class RSC
40
40
 
41
41
  end
42
42
 
43
- def initialize(drb_hostname='rse', parent_url)
43
+ def initialize(drb_hostname='rse', parent_url=nil, port: '61000')
44
+
45
+ @port = port
46
+
47
+ if parent_url then
48
+ @parent_url = parent_url
49
+ drb_start(drb_hostname)
50
+ end
44
51
 
45
- @parent_url = parent_url
46
- DRb.start_service
47
- @obj = DRbObject.new(nil, "druby://#{drb_hostname}:61000")
48
52
  end
49
53
 
50
54
  def delete()
51
- @obj.delete
52
- end
55
+ s ? run_uri(s, :delete) : @obj.delete
56
+ end
53
57
 
54
- def get()
55
- @obj.get
58
+ def get(s=nil)
59
+ s ? run_uri(s, :get) : @obj.get
56
60
  end
57
-
58
- def put()
59
- @obj.put
60
- end
61
61
 
62
- def post()
63
- @obj.post
62
+ def post(s=nil)
63
+ s ? run_uri(s, :post) : @obj.post
64
+ end
65
+
66
+ def put(s)
67
+ s ? run_uri(s, :put) : @obj.put
64
68
  end
65
69
 
70
+
66
71
  def run_job(package, job, params={}, *qargs, package_path: nil)
67
72
  @obj.run_job(package, job, params, qargs, package_path)
68
73
  end
69
74
 
70
75
  private
71
76
 
77
+ def drb_start(host)
78
+ DRb.start_service
79
+ @obj = DRbObject.new(nil, "druby://#{host}:#{@port}")
80
+ end
81
+
72
82
  def method_missing(method_name, *args)
73
83
  Package.new @obj, @parent_url, method_name.to_s
74
84
  end
75
85
 
86
+ def parse_uri(s)
87
+
88
+ protocol, _, host, package, raw_job, remaining = s.split('/',6)
89
+
90
+ if remaining then
91
+
92
+ job = raw_job
93
+ # split on the 1st question mark
94
+ raw_args, raw_params = if remaining =~ /\?/ then
95
+ remaining.split('?',2)
96
+ else
97
+ remaining
98
+ end
99
+
100
+ elsif raw_job =~ /\?/
101
+ job, raw_params = raw_job.split('?',2)
102
+ else
103
+ job = raw_job
104
+ end
105
+
106
+ if raw_args or raw_params then
107
+ args = raw_args.split('/') if raw_args
108
+
109
+ if raw_params then
110
+ params = raw_params.split('&').inject({}) do |r,x|
111
+ k, v = x.split('=')
112
+ v ? r.merge(k[/\w+$/].to_sym => URI.unescape(v)) : r
113
+ end
114
+ end
115
+
116
+ end
117
+
118
+ [host, package, job, args, params]
119
+ end
120
+
121
+ def run_uri(s, type=:get)
122
+
123
+ host, package, job, args, params = parse_uri(s)
124
+ drb_start host
125
+ @obj.type = type
126
+
127
+ @obj.run_job(package, job, params, args)
128
+
129
+ end
76
130
  end
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.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file