rsc 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +3 -1
- data.tar.gz.sig +0 -0
- data/lib/rsc.rb +68 -14
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5515efb4f9945805779a857ce5a1798fe3a52369
|
4
|
+
data.tar.gz: e15a3ef37d4604123de84d78990a1c39a0273a44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d77eac9bee1bde92f22a414abe010a135b2ccef32b7481266a71181300f1adb5d51ae9cbca2b344a09368a8dc5eb5b0d78cbae1204877c7e06d7340cff2857c4
|
7
|
+
data.tar.gz: d8292c1e7e2a6b949e716812a2968a090d5b783e67942ba20d1a96fd562c36781488c30cc578c22766c320b98f8b294c5d50013a69e426bd3c85df5602c74fee
|
checksums.yaml.gz.sig
CHANGED
@@ -1 +1,3 @@
|
|
1
|
-
|
1
|
+
�Ֆ7��!��o��Q3�Z��tR)Q�B�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
metadata.gz.sig
CHANGED
Binary file
|