drb_fileclient 0.5.2 → 0.6.0
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 +0 -0
- data/lib/drb_fileclient.rb +137 -112
- data.tar.gz.sig +0 -0
- metadata +35 -34
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ec57e89e0d0588cc4ab855a9fb3047a950e57b53497b585e658593668660146
|
4
|
+
data.tar.gz: e26f60db52598b80752b173d08d1113bd1ffdfd155b6d5a9bdb3bbf835346b76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2ceaa76749231d9a4b2c5670ba91d70db4c395c52f41d0871a51bc6430a2259dd426496fc0bca426154937174cfe088179ffbcd18500590936b556f25d2a73b
|
7
|
+
data.tar.gz: 6d6f2121e40ac1a2c536421745d1f038b7cd03e2ab9a83cd0489b2d7e7ebbe59469160705a4bdb5800c6454e7690233c731a1b5b1786f0beea1008e21cc3579f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/drb_fileclient.rb
CHANGED
@@ -11,89 +11,113 @@ class DRbFileClient
|
|
11
11
|
using ColouredText
|
12
12
|
|
13
13
|
def initialize(location=nil, host: nil, port: '61010', debug: false)
|
14
|
-
|
14
|
+
|
15
15
|
@debug = debug
|
16
|
-
|
16
|
+
|
17
17
|
if location then
|
18
|
-
|
18
|
+
|
19
19
|
host = location[/(?<=^dfs:\/\/)[^\/:]+/]
|
20
20
|
port = location[/(?<=^dfs:\/\/)[^:]+:(\d+)/,1] || '61010'
|
21
21
|
@directory = location[/(?<=^dfs:\/\/)[^\/]+\/(.*)/,1]
|
22
|
-
|
22
|
+
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
DRb.start_service
|
26
|
-
|
26
|
+
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def chdir(raw_path)
|
30
|
-
|
30
|
+
|
31
31
|
return Dir.chdir raw_path unless @directory or raw_path =~ /^dfs:\/\//
|
32
|
-
|
32
|
+
|
33
33
|
if raw_path[0] == '/' then
|
34
34
|
directory = raw_path[1..-1]
|
35
35
|
elsif raw_path =~ /^dfs:\/\//
|
36
36
|
@file, directory = parse_path(raw_path)
|
37
|
-
else
|
37
|
+
else
|
38
38
|
directory = File.join(@directory, raw_path)
|
39
|
-
end
|
40
|
-
|
39
|
+
end
|
40
|
+
|
41
41
|
if @file.exists? directory then
|
42
42
|
@directory = directory
|
43
43
|
else
|
44
44
|
'No such file or directory'
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
def chmod(permissions, raw_path)
|
50
|
+
|
51
|
+
if raw_path =~ /^dfs:\/\// then
|
52
|
+
|
53
|
+
@file, path = parse_path(raw_path)
|
54
|
+
@file.chmod permissions, path
|
55
|
+
|
56
|
+
else
|
57
|
+
return FileUtils.chmod(permissions, raw_path)
|
58
|
+
end
|
47
59
|
end
|
48
60
|
|
49
61
|
def cp(raw_path, raw_path2)
|
50
|
-
|
62
|
+
|
51
63
|
puts 'inside cp'.info if @debug
|
52
|
-
|
64
|
+
|
53
65
|
if raw_path =~ /^dfs:\/\// then
|
54
|
-
|
66
|
+
|
55
67
|
if @debug then
|
56
68
|
puts ('raw_path: ' + raw_path.inspect).debug
|
57
69
|
puts ('raw_path2: ' + raw_path2.inspect).debug
|
58
70
|
end
|
59
|
-
|
71
|
+
|
60
72
|
if raw_path[/^dfs:\/\/([^\/]+)/] == raw_path2[/^dfs:\/\/([^\/]+)/] then
|
61
|
-
|
73
|
+
|
62
74
|
_, path = parse_path(raw_path)
|
63
75
|
@file, path2 = parse_path(raw_path2)
|
64
76
|
@file.cp path, path2
|
65
|
-
|
66
|
-
|
67
|
-
|
77
|
+
|
78
|
+
elsif raw_path2[/^dfs:\/\//]
|
79
|
+
|
68
80
|
@file, path = parse_path(raw_path)
|
69
81
|
file2, path2 = parse_path(raw_path2)
|
82
|
+
puts ('path: ' + path.inspect).debug if @debug
|
83
|
+
puts ('path2: ' + path.inspect).debug if @debug
|
70
84
|
content = @file.read path
|
71
|
-
|
85
|
+
|
72
86
|
file2.write path2, content
|
73
87
|
|
88
|
+
else
|
89
|
+
|
90
|
+
@file, path = parse_path(raw_path)
|
91
|
+
#file2, path2 = parse_path(raw_path2)
|
92
|
+
puts ('path: ' + path.inspect).debug if @debug
|
93
|
+
puts ('path2: ' + path2.inspect).debug if @debug
|
94
|
+
content = @file.read path
|
95
|
+
|
96
|
+
File.write raw_path2, content
|
97
|
+
|
74
98
|
end
|
75
|
-
|
99
|
+
|
76
100
|
elsif raw_path2 =~ /dfs:\/\// then
|
77
|
-
|
101
|
+
|
78
102
|
puts 'option2'.info if @debug
|
79
|
-
|
103
|
+
|
80
104
|
file2, path2 = parse_path(raw_path2)
|
81
105
|
puts ('path2: ' + path2.inspect).debug if @debug
|
82
106
|
file2.write path2, File.read(raw_path)
|
83
|
-
|
107
|
+
|
84
108
|
else
|
85
|
-
|
109
|
+
|
86
110
|
puts 'option3'.info if @debug
|
87
111
|
FileUtils.cp raw_path, raw_path2
|
88
|
-
|
89
|
-
end
|
90
|
-
|
91
|
-
end
|
92
|
-
|
93
|
-
def directory?(filename=@filename)
|
94
|
-
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
def directory?(filename=@filename)
|
118
|
+
|
95
119
|
return File.directory? filename unless @directory or filename =~ /^dfs:\/\//
|
96
|
-
|
120
|
+
|
97
121
|
if filename =~ /^dfs:\/\// then
|
98
122
|
@file, filename2 = parse_path(filename)
|
99
123
|
else
|
@@ -102,13 +126,13 @@ class DRbFileClient
|
|
102
126
|
end
|
103
127
|
|
104
128
|
@file.directory?(filename2)
|
105
|
-
|
106
|
-
end
|
107
|
-
|
108
|
-
def exists?(filename=@filename)
|
109
|
-
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
def exists?(filename=@filename)
|
133
|
+
|
110
134
|
return File.exists? filename unless @directory or filename =~ /^dfs:\/\//
|
111
|
-
|
135
|
+
|
112
136
|
if filename =~ /^dfs:\/\// then
|
113
137
|
@file, filename2 = parse_path(filename)
|
114
138
|
else
|
@@ -117,136 +141,136 @@ class DRbFileClient
|
|
117
141
|
end
|
118
142
|
|
119
143
|
@file.exists?(filename2)
|
120
|
-
|
144
|
+
|
121
145
|
end
|
122
|
-
|
146
|
+
|
123
147
|
alias exist? exists?
|
124
|
-
|
148
|
+
|
125
149
|
def ls(raw_path)
|
126
|
-
|
150
|
+
|
127
151
|
return Dir[raw_path] unless @directory or raw_path =~ /^dfs:\/\//
|
128
|
-
|
152
|
+
|
129
153
|
if raw_path[0] == '/' then
|
130
154
|
path = raw_path[1..-1]
|
131
155
|
elsif raw_path =~ /^dfs:\/\//
|
132
156
|
@file, path = parse_path(raw_path)
|
133
|
-
else
|
157
|
+
else
|
134
158
|
path = File.join(@directory, raw_path)
|
135
|
-
end
|
136
|
-
|
159
|
+
end
|
160
|
+
|
137
161
|
@file.ls path
|
138
|
-
|
139
|
-
end
|
140
|
-
|
162
|
+
|
163
|
+
end
|
164
|
+
|
141
165
|
def mkdir(name)
|
142
|
-
|
166
|
+
|
143
167
|
return FileUtils.mkdir name unless @directory or name =~ /^dfs:\/\//
|
144
|
-
|
168
|
+
|
145
169
|
@file, path = parse_path(name)
|
146
170
|
@file.mkdir path
|
147
171
|
end
|
148
|
-
|
172
|
+
|
149
173
|
def mkdir_p(raw_path)
|
150
|
-
|
174
|
+
|
151
175
|
unless @directory or raw_path =~ /^dfs:\/\// then
|
152
|
-
return FileUtils.mkdir_p raw_path
|
153
|
-
end
|
154
|
-
|
176
|
+
return FileUtils.mkdir_p raw_path
|
177
|
+
end
|
178
|
+
|
155
179
|
if raw_path =~ /^dfs:\/\// then
|
156
180
|
@file, filepath = parse_path(raw_path)
|
157
181
|
else
|
158
182
|
filepath = File.join(@directory, raw_path)
|
159
183
|
end
|
160
|
-
|
184
|
+
|
161
185
|
@file.mkdir_p filepath
|
162
|
-
end
|
163
|
-
|
186
|
+
end
|
187
|
+
|
164
188
|
def mv(raw_path, raw_path2)
|
165
|
-
|
189
|
+
|
166
190
|
unless @directory or raw_path =~ /^dfs:\/\// then
|
167
|
-
return FileUtils.mv raw_path, raw_path2
|
191
|
+
return FileUtils.mv raw_path, raw_path2
|
168
192
|
end
|
169
|
-
|
193
|
+
|
170
194
|
if raw_path =~ /^dfs:\/\// then
|
171
195
|
_, path = parse_path(raw_path)
|
172
196
|
else
|
173
197
|
path = File.join(@directory, raw_path)
|
174
198
|
end
|
175
|
-
|
199
|
+
|
176
200
|
if raw_path2 =~ /^dfs:\/\// then
|
177
201
|
_, path2 = parse_path(raw_path2)
|
178
202
|
else
|
179
203
|
path2 = File.join(@directory, raw_path2)
|
180
204
|
end
|
181
|
-
|
205
|
+
|
182
206
|
@file.mv path, path2
|
183
|
-
end
|
184
|
-
|
207
|
+
end
|
208
|
+
|
185
209
|
def pwd()
|
186
|
-
|
210
|
+
|
187
211
|
return Dir.pwd unless @directory
|
188
|
-
|
212
|
+
|
189
213
|
'/' + @directory if @file
|
190
|
-
|
191
|
-
end
|
214
|
+
|
215
|
+
end
|
192
216
|
|
193
217
|
def read(filename=@filename)
|
194
|
-
|
218
|
+
|
195
219
|
return File.read filename, s unless @directory or filename =~ /^dfs:\/\//
|
196
|
-
|
220
|
+
|
197
221
|
if filename =~ /^dfs:\/\// then
|
198
222
|
@file, path = parse_path(filename)
|
199
223
|
else
|
200
224
|
path = File.join(@directory, filename)
|
201
225
|
end
|
202
|
-
|
226
|
+
|
203
227
|
@file.read path
|
204
228
|
end
|
205
|
-
|
229
|
+
|
206
230
|
def rm(path)
|
207
|
-
|
231
|
+
|
208
232
|
return FileUtils.rm path unless @directory or path =~ /^dfs:\/\//
|
209
|
-
|
233
|
+
|
210
234
|
if path =~ /^dfs:\/\// then
|
211
235
|
@file, path2 = parse_path( path)
|
212
236
|
else
|
213
237
|
path2 = File.join(@directory, path)
|
214
238
|
end
|
215
|
-
|
239
|
+
|
216
240
|
@file.rm path2
|
217
|
-
|
218
|
-
end
|
219
|
-
|
241
|
+
|
242
|
+
end
|
243
|
+
|
220
244
|
def write(filename=@filename, s)
|
221
|
-
|
245
|
+
|
222
246
|
return File.write filename, s unless @directory or filename =~ /^dfs:\/\//
|
223
|
-
|
247
|
+
|
224
248
|
if filename =~ /^dfs:\/\// then
|
225
249
|
@file, path = parse_path(filename)
|
226
250
|
else
|
227
251
|
path = File.join(@directory, filename)
|
228
252
|
end
|
229
|
-
|
230
|
-
@file.write path, s
|
231
|
-
|
253
|
+
|
254
|
+
@file.write path, s
|
255
|
+
|
232
256
|
end
|
233
|
-
|
257
|
+
|
234
258
|
def zip(filename_zip, a)
|
235
|
-
|
259
|
+
|
236
260
|
puts '@directory: ' + @directory.inspect if @debug
|
237
|
-
|
261
|
+
|
238
262
|
unless @directory or filename_zip =~ /^dfs:\/\// then
|
239
|
-
|
263
|
+
|
240
264
|
Zip::File.open(zipfile_zip, Zip::File::CREATE) do |x|
|
241
265
|
|
242
|
-
a.each do |filename, buffer|
|
266
|
+
a.each do |filename, buffer|
|
243
267
|
x.get_output_stream(filename) {|os| os.write buffer }
|
244
268
|
end
|
245
269
|
|
246
270
|
end
|
247
|
-
|
271
|
+
|
248
272
|
end
|
249
|
-
|
273
|
+
|
250
274
|
if filename_zip =~ /^dfs:\/\// then
|
251
275
|
@file, filepath = parse_path(filename_zip)
|
252
276
|
else
|
@@ -254,16 +278,16 @@ class DRbFileClient
|
|
254
278
|
end
|
255
279
|
|
256
280
|
@file.zip filepath, a
|
257
|
-
|
281
|
+
|
258
282
|
end
|
259
283
|
|
260
284
|
private
|
261
|
-
|
285
|
+
|
262
286
|
def parse_path(filename)
|
263
287
|
|
264
288
|
host = filename[/(?<=^dfs:\/\/)[^\/:]+/]
|
265
289
|
@host = host if host
|
266
|
-
|
290
|
+
|
267
291
|
port = filename[/(?<=^dfs:\/\/)[^:]+:(\d+)/,1] || '61010'
|
268
292
|
|
269
293
|
file_server = DRbObject.new nil, "druby://#{host || @host}:#{port}"
|
@@ -271,24 +295,25 @@ class DRbFileClient
|
|
271
295
|
|
272
296
|
end
|
273
297
|
|
274
|
-
end
|
298
|
+
end
|
275
299
|
|
276
300
|
class DfsFile
|
277
|
-
|
301
|
+
|
278
302
|
@client = DRbFileClient.new
|
279
|
-
|
280
|
-
def self.directory?(filename) @client.directory?(filename) end
|
281
|
-
def self.exists?(filename) @client.exists?(filename) end
|
282
|
-
def self.chdir(path) @client.chdir(path) end
|
283
|
-
def self.
|
284
|
-
def self.
|
285
|
-
def self.
|
286
|
-
def self.
|
287
|
-
def self.
|
288
|
-
def self.
|
303
|
+
|
304
|
+
def self.directory?(filename) @client.directory?(filename) end
|
305
|
+
def self.exists?(filename) @client.exists?(filename) end
|
306
|
+
def self.chdir(path) @client.chdir(path) end
|
307
|
+
def self.chmod(num, filename) @client.chmod(num, filename) end
|
308
|
+
def self.cp(path, path2) @client.cp(path, path2) end
|
309
|
+
def self.ls(path) @client.ls(path) end
|
310
|
+
def self.mkdir(name) @client.mkdir(name) end
|
311
|
+
def self.mkdir_p(path) @client.mkdir_p(path) end
|
312
|
+
def self.mv(path, path2) @client.mv(path, path2) end
|
313
|
+
def self.pwd() @client.pwd() end
|
289
314
|
def self.read(filename) @client.read(filename) end
|
290
|
-
def self.rm(filename) @client.rm(filename) end
|
315
|
+
def self.rm(filename) @client.rm(filename) end
|
291
316
|
def self.write(filename, s) @client.write(filename, s) end
|
292
317
|
def self.zip(filename, a) @client.zip(filename, a) end
|
293
|
-
|
318
|
+
|
294
319
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drb_fileclient
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjIwMTE3MjExMTUxWhcN
|
15
|
+
MjMwMTE3MjExMTUxWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQC1sfsT
|
17
|
+
Jfjs0K5yhTPZsHAcniDvpZsgsTzASYu0IbH63AZ1o3dBV7IzF6KrziLoJ4LZ7UQK
|
18
|
+
yJ6PnHUSTKBZJccpxIErNb3YlU3wYhF4aFqVxZBjt/IWVyGk62GtgbkuFGcsC2DP
|
19
|
+
sxL4/WYtZvSrDCnY/XDEK8LUO6/MQ6cF2aT3OHmXSz3zuDW83yuIWrTXbKJnjuKn
|
20
|
+
V7zM0prSGfLGNM+DlIgAGrspj+D+aofhVZ1vcsy7tHHSazErTtp88ONCoJrBv8UZ
|
21
|
+
Zw+fZV14rwhqftK7jYH0XL7kBZYILVkpehNXRFOwojnkg/Z6IECYxz2alNYwDWUB
|
22
|
+
lPzxgCPJsHoQCtustc2UHE/Ik+8QVJIHimpwquzhwECGq9MSUlYau48XlB8nBHlN
|
23
|
+
3YckYd3CjdbB/4UkCjlQOBrb0UT7HQHm+f5uCa2hXKkpWFKJNO99FBR75FAJWbQt
|
24
|
+
JfYUJzGrp2z95pc6cDvaqzXPVA48JVVWF6uUqCeoVOCcz3rISfZT5X6Y+I8CAwEA
|
25
|
+
AaOBijCBhzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUWpxb19+x
|
26
|
+
FM42Y6G5h22m4V4WOQ8wJgYDVR0RBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
|
27
27
|
c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
28
|
+
BgkqhkiG9w0BAQsFAAOCAYEAoKkYN6WZurnK5O9oEqj+ugBPm9Gh5I75oLQCUyIw
|
29
|
+
sHsBR0clXN+Lta4plvzonH3xKx9ddzX+KWZS0tHxcm072zV6sKEKFYcQiUzQyTwc
|
30
|
+
Hyfp6E3950UwJi3KO4o3RPZC1U5/fOvnuZgVAbGqcJQf/t/SfD5M3pBymbK2QszM
|
31
|
+
fG8W6bQ2kbkv7JbD3B0Sjb1eCDy3/s/eMmbjl1Wg48al1LWQDUMGAmadqLrnFEs0
|
32
|
+
3arfhEofWPCcGw0u45L6omLCU8VWJFupyvQKDwEmkVAD9MMbnUuIsMWMkW4qFwl4
|
33
|
+
0xIrbpFWN8ZHrlc29DrrNH9IKcgsI6Fmc4jOxrqnlushuHG3uthM1hGChljvOMaB
|
34
|
+
rs55jJl1U2ICzKSTmV28mLdtigYtJHOzuXrdZSLICM9FSvRkBWOnBz2YaDCA2NXP
|
35
|
+
FGcgjmmz5fOIqq2sBxk6JW1yo2G43yIUzymWOYKT2Jh6RR0Gg3z66wWwYpFpx8yR
|
36
|
+
00JTBNVAgW+s2sLpeBtyMDbb
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2022-01-17 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: zip
|
@@ -61,24 +61,24 @@ dependencies:
|
|
61
61
|
name: c32
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
|
-
- - "~>"
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: '0.1'
|
67
64
|
- - ">="
|
68
65
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0.
|
66
|
+
version: 0.3.0
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.3'
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- - "~>"
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: '0.1'
|
77
74
|
- - ">="
|
78
75
|
- !ruby/object:Gem::Version
|
79
|
-
version: 0.
|
76
|
+
version: 0.3.0
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0.3'
|
80
80
|
description:
|
81
|
-
email:
|
81
|
+
email: digital.robertson@gmail.com
|
82
82
|
executables: []
|
83
83
|
extensions: []
|
84
84
|
extra_rdoc_files: []
|
@@ -103,7 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
|
-
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.7.10
|
107
108
|
signing_key:
|
108
109
|
specification_version: 4
|
109
110
|
summary: Reads or writes files from a remote DRb server. Simple as DfsFile.read or
|
metadata.gz.sig
CHANGED
Binary file
|