drb_fileclient 0.7.2 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ee3feb5166347679ba7107067598c719cf15663fa6a872c07fe6a53742bb727
4
- data.tar.gz: 9ccfc67edaa513985ce97b6f81e94733bb4f7b637403b1c713cc273255c973f5
3
+ metadata.gz: 07a2cbcbbc70f014fa750685abf3a553e1d904873aba2c58b979b9178c1ab8e8
4
+ data.tar.gz: 0c6ea77a2ce0c463a4ecc39a1c735f5b91645e917b1208d7e43258c9db096fd0
5
5
  SHA512:
6
- metadata.gz: 3584d15b675099e548d8c1943523db7705afcd0aaf4261dd6af957c98fe0bff876eaa26ed99a41bb62749c05200da07e34d7a5ecd3db1e5f0950b81f9d263894
7
- data.tar.gz: 902a9ac523608de39170beab7004f1335e5100dabac8e7cb9f46bac0bee5682647a78988ea4ed2719e273bf908c85f92adb563cb5ed6993cd89254f6102f4dd0
6
+ metadata.gz: 33d3c8869c4228aa4bfd05e2b488d1606110bd3db7634f995d978cc132b3189124b13c5d301064a1f8844e9243c12685183456d12e87bd335eec5da8ee1a7105
7
+ data.tar.gz: b75e6e463ed540df983fd10d655fa8bfeea7ad2072701c688b4278e224aa87fb74a1e242f2e87ff698a68f9a2393094ac7722620858862e434a4ae6ebb1d03dd
checksums.yaml.gz.sig CHANGED
Binary file
@@ -2,58 +2,21 @@
2
2
 
3
3
  # file: drb_fileclient.rb
4
4
 
5
- require 'drb'
6
5
  require 'zip'
7
- require 'c32'
8
- # Commented out to avoid bug with RXFHelper constants
9
- #require 'dir-to-xml'
6
+ require 'dir-to-xml'
7
+ require 'drb_fileclient-readwrite'
10
8
 
11
9
 
12
- class DRbFileClient
10
+ class DRbFileClient < DRbFileClientReadWrite
13
11
  using ColouredText
14
12
 
15
- def initialize(location=nil, host: nil, port: '61010', debug: false)
16
-
17
- @debug = debug
18
-
19
- if location then
20
-
21
- host = location[/(?<=^dfs:\/\/)[^\/:]+/]
22
- port = location[/(?<=^dfs:\/\/)[^:]+:(\d+)/,1] || '61010'
23
- @directory = location[/(?<=^dfs:\/\/)[^\/]+\/(.*)/,1]
24
-
25
- end
26
-
27
- DRb.start_service
28
-
29
- end
30
-
31
- def chdir(raw_path)
32
-
33
- return Dir.chdir raw_path unless @directory or raw_path =~ /^dfs:\/\//
34
-
35
- if raw_path[0] == '/' then
36
- directory = raw_path[1..-1]
37
- elsif raw_path =~ /^dfs:\/\//
38
- @file, directory = parse_path(raw_path)
39
- else
40
- directory = File.join(@directory, raw_path)
41
- end
42
-
43
- if @file.exists? directory then
44
- @directory = directory
45
- else
46
- 'No such file or directory'
47
- end
48
-
49
- end
50
13
 
51
14
  def chmod(permissions, raw_path)
52
15
 
53
16
  if raw_path =~ /^dfs:\/\// then
54
17
 
55
- @file, path = parse_path(raw_path)
56
- @file.chmod permissions, path
18
+ @@file, path = parse_path(raw_path)
19
+ @@file.chmod permissions, path
57
20
 
58
21
  else
59
22
  return FileUtils.chmod(permissions, raw_path)
@@ -74,26 +37,26 @@ class DRbFileClient
74
37
  if raw_path[/^dfs:\/\/([^\/]+)/] == raw_path2[/^dfs:\/\/([^\/]+)/] then
75
38
 
76
39
  _, path = parse_path(raw_path)
77
- @file, path2 = parse_path(raw_path2)
78
- @file.cp path, path2
40
+ @@file, path2 = parse_path(raw_path2)
41
+ @@file.cp path, path2
79
42
 
80
43
  elsif raw_path2[/^dfs:\/\//]
81
44
 
82
- @file, path = parse_path(raw_path)
45
+ @@file, path = parse_path(raw_path)
83
46
  file2, path2 = parse_path(raw_path2)
84
47
  puts ('path: ' + path.inspect).debug if @debug
85
48
  puts ('path2: ' + path.inspect).debug if @debug
86
- content = @file.read path
49
+ content = @@file.read path
87
50
 
88
51
  file2.write path2, content
89
52
 
90
53
  else
91
54
 
92
- @file, path = parse_path(raw_path)
55
+ @@file, path = parse_path(raw_path)
93
56
  #file2, path2 = parse_path(raw_path2)
94
57
  puts ('path: ' + path.inspect).debug if @debug
95
58
  puts ('path2: ' + path2.inspect).debug if @debug
96
- content = @file.read path
59
+ content = @@file.read path
97
60
 
98
61
  File.write raw_path2, content
99
62
 
@@ -116,227 +79,83 @@ class DRbFileClient
116
79
 
117
80
  end
118
81
 
119
- def directory?(filename=@filename)
120
-
121
- return File.directory? filename unless @directory or filename =~ /^dfs:\/\//
122
-
123
- if filename =~ /^dfs:\/\// then
124
- @file, filename2 = parse_path(filename)
125
- else
126
-
127
- filename2 = File.join(@directory, filename)
128
- end
129
-
130
- @file.directory?(filename2)
131
-
132
- end
133
-
134
- def exists?(filename=@filename)
135
-
136
- return File.exists? filename unless @directory or filename =~ /^dfs:\/\//
137
-
138
- if filename =~ /^dfs:\/\// then
139
- @file, filename2 = parse_path(filename)
140
- else
141
-
142
- filename2 = File.join(@directory, filename)
143
- end
144
-
145
- @file.exists?(filename2)
146
-
147
- end
148
-
149
- alias exist? exists?
150
-
151
- def glob(s)
152
-
153
- if s =~ /^dfs:\/\// then
154
- @file, s2 = parse_path(s)
155
- else
156
- s2 = File.join(@directory, s)
157
- end
158
-
159
- @file.glob s2
160
-
161
- end
162
-
163
82
  def ls(raw_path)
164
83
 
165
- return Dir[raw_path] unless @directory or raw_path =~ /^dfs:\/\//
84
+ return Dir[raw_path] unless @@directory or raw_path =~ /^dfs:\/\//
166
85
 
167
86
  if raw_path[0] == '/' then
168
87
  path = raw_path[1..-1]
169
88
  elsif raw_path =~ /^dfs:\/\//
170
- @file, path = parse_path(raw_path)
89
+ @@file, path = parse_path(raw_path)
171
90
  else
172
- path = File.join(@directory, raw_path)
173
- end
174
-
175
- @file.ls path
176
-
177
- end
178
-
179
- def mkdir(name)
180
-
181
- return FileUtils.mkdir name unless @directory or name =~ /^dfs:\/\//
182
-
183
- @file, path = parse_path(name)
184
- @file.mkdir path
185
- end
186
-
187
- def mkdir_p(raw_path)
188
-
189
- unless @directory or raw_path =~ /^dfs:\/\// then
190
- return FileUtils.mkdir_p raw_path
91
+ path = File.join(@@directory, raw_path)
191
92
  end
192
93
 
193
- if raw_path =~ /^dfs:\/\// then
194
- @file, filepath = parse_path(raw_path)
195
- else
196
- filepath = File.join(@directory, raw_path)
197
- end
94
+ @@file.ls path
198
95
 
199
- @file.mkdir_p filepath
200
96
  end
201
97
 
202
98
  def mv(raw_path, raw_path2)
203
99
 
204
- unless @directory or raw_path =~ /^dfs:\/\// then
100
+ unless @@directory or raw_path =~ /^dfs:\/\// then
205
101
  return FileUtils.mv raw_path, raw_path2
206
102
  end
207
103
 
208
104
  if raw_path =~ /^dfs:\/\// then
209
105
  _, path = parse_path(raw_path)
210
106
  else
211
- path = File.join(@directory, raw_path)
107
+ path = File.join(@@directory, raw_path)
212
108
  end
213
109
 
214
110
  if raw_path2 =~ /^dfs:\/\// then
215
111
  _, path2 = parse_path(raw_path2)
216
112
  else
217
- path2 = File.join(@directory, raw_path2)
113
+ path2 = File.join(@@directory, raw_path2)
218
114
  end
219
115
 
220
- @file.mv path, path2
116
+ @@file.mv path, path2
221
117
  end
222
118
 
223
- def pwd()
224
119
 
225
- return Dir.pwd unless @directory
226
-
227
- '/' + @directory if @file
228
-
229
- end
230
-
231
- def read(filename=@filename)
232
-
233
- return File.read filename, s unless @directory or filename =~ /^dfs:\/\//
234
-
235
- if filename =~ /^dfs:\/\// then
236
- @file, path = parse_path(filename)
237
- else
238
- path = File.join(@directory, filename)
239
- end
240
-
241
- @file.read path
242
- end
243
-
244
- def rm(path)
245
-
246
- return FileUtils.rm path unless @directory or path =~ /^dfs:\/\//
247
-
248
- if path =~ /^dfs:\/\// then
249
- @file, path2 = parse_path( path)
250
- else
251
- path2 = File.join(@directory, path)
252
- end
253
-
254
- @file.rm path2
255
-
256
- end
257
-
258
- def rm_r(path, force: false)
259
-
260
- unless @directory or path =~ /^dfs:\/\// then
261
- return FileUtils.rm_r(path, force: force)
262
- end
263
-
264
- if path =~ /^dfs:\/\// then
265
- @file, path2 = parse_path( path)
266
- else
267
- path2 = File.join(@directory, path)
268
- end
269
-
270
- @file.rm_r(path2, force: force)
271
-
272
- end
273
120
 
274
121
  def ru(path)
275
122
 
276
- return DirToXML.new(path, verbose: false).latest unless @directory \
123
+ return DirToXML.new(path, verbose: false).latest unless @@directory \
277
124
  or path =~ /^dfs:\/\//
278
125
 
279
126
  if path =~ /^dfs:\/\// then
280
- @file, path2 = parse_path( path)
127
+ @@file, path2, addr = parse_path(path)
281
128
  else
282
- path2 = File.join(@directory, path)
129
+ path2 = File.join(@@directory, path)
283
130
  end
284
131
 
285
- @file.ru path2
132
+ found = @@file.ru path2
133
+ return (addr + found) if found and addr
286
134
 
287
135
  end
288
136
 
289
137
  def ru_r(path)
290
138
 
291
- unless @directory or path =~ /^dfs:\/\// then
139
+ unless @@directory or path =~ /^dfs:\/\// then
292
140
  return DirToXML.new(path, recursive: true, verbose: false).latest
293
141
  end
294
142
 
295
143
  if path =~ /^dfs:\/\// then
296
- @file, path2 = parse_path( path)
144
+ @@file, path2, addr = parse_path(path)
297
145
  else
298
- path2 = File.join(@directory, path)
146
+ path2 = File.join(@@directory, path)
299
147
  end
300
148
 
301
- @file.ru_r path2
302
-
303
- end
304
-
305
- def touch(s, mtime: Time.now)
306
-
307
- unless @directory or s =~ /^dfs:\/\// then
308
- return FileUtils.touch(s, mtime: mtime)
309
- end
310
-
311
- if s =~ /^dfs:\/\// then
312
- @file, s2 = parse_path(s)
313
- else
314
- s2 = File.join(@directory, s)
315
- end
316
-
317
- @file.touch s2, mtime: mtime
318
-
319
- end
320
-
321
- def write(filename=@filename, s)
322
-
323
- return File.write filename, s unless @directory or filename =~ /^dfs:\/\//
324
-
325
- if filename =~ /^dfs:\/\// then
326
- @file, path = parse_path(filename)
327
- else
328
- path = File.join(@directory, filename)
329
- end
330
-
331
- @file.write path, s
149
+ found = @@file.ru_r path2
150
+ return (addr + found) if found and addr
332
151
 
333
152
  end
334
153
 
335
154
  def zip(filename_zip, a)
336
155
 
337
- puts '@directory: ' + @directory.inspect if @debug
156
+ puts '@@directory: ' + @@directory.inspect if @debug
338
157
 
339
- unless @directory or filename_zip =~ /^dfs:\/\// then
158
+ unless @@directory or filename_zip =~ /^dfs:\/\// then
340
159
 
341
160
  Zip::File.open(zipfile_zip, Zip::File::CREATE) do |x|
342
161
 
@@ -349,61 +168,42 @@ class DRbFileClient
349
168
  end
350
169
 
351
170
  if filename_zip =~ /^dfs:\/\// then
352
- @file, filepath = parse_path(filename_zip)
171
+ @@file, filepath = parse_path(filename_zip)
353
172
  else
354
- filepath = File.join(@directory, filename_zip)
173
+ filepath = File.join(@@directory, filename_zip)
355
174
  end
356
175
 
357
- @file.zip filepath, a
176
+ @@file.zip filepath, a
358
177
 
359
178
  end
360
179
 
361
- private
362
-
363
- def parse_path(filename)
364
-
365
- host = filename[/(?<=^dfs:\/\/)[^\/:]+/]
366
- @host = host if host
367
-
368
- port = filename[/(?<=^dfs:\/\/)[^:]+:(\d+)/,1] || '61010'
180
+ end
369
181
 
370
- file_server = DRbObject.new nil, "druby://#{host || @host}:#{port}"
371
- [file_server, filename[/(?<=^dfs:\/\/)[^\/]+\/(.*)/,1]]
372
182
 
373
- end
183
+ def DfsFile.chmod(num, filename)
184
+ DRbFileClient.new.chmod(num, filename)
185
+ end
374
186
 
187
+ def DfsFile.cp(path, path2)
188
+ DRbFileClient.new.cp(path, path2)
375
189
  end
376
190
 
377
- class DfsFile
378
-
379
- @client = DRbFileClient.new
380
-
381
- def self.directory?(filename) @client.directory?(filename) end
382
- def self.exists?(filename) @client.exists?(filename) end
383
- def self.chdir(path) @client.chdir(path) end
384
- def self.chmod(num, filename) @client.chmod(num, filename) end
385
- def self.cp(path, path2) @client.cp(path, path2) end
386
- def self.glob(s) @client.glob(s) end
387
- def self.ls(path) @client.ls(path) end
388
- def self.mkdir(name) @client.mkdir(name) end
389
- def self.mkdir_p(path) @client.mkdir_p(path) end
390
- def self.mv(path, path2) @client.mv(path, path2) end
391
- def self.pwd() @client.pwd() end
392
- def self.read(filename) @client.read(filename) end
393
- def self.rm(filename) @client.rm(filename) end
394
-
395
- def self.rm_r(filename, force: false)
396
- @client.rm_r(filename, force: force)
397
- end
191
+ def DfsFile.ls(path)
192
+ DRbFileClient.new.ls(path)
193
+ end
398
194
 
399
- def self.ru(path) @client.ru(path) end
400
- def self.ru_r(path) @client.ru_r(path) end
195
+ def DfsFile.mv(path, path2)
196
+ DRbFileClient.new.mv(path, path2)
197
+ end
401
198
 
402
- def self.touch(filename, mtime: Time.now)
403
- @client.touch(filename, mtime: mtime)
404
- end
199
+ def DfsFile.ru(path)
200
+ DRbFileClient.new.ru(path)
201
+ end
405
202
 
406
- def self.write(filename, s) @client.write(filename, s) end
407
- def self.zip(filename, a) @client.zip(filename, a) end
203
+ def DfsFile.ru_r(path)
204
+ DRbFileClient.new.ru_r(path)
205
+ end
408
206
 
207
+ def DfsFile.zip(filename, a)
208
+ DRbFileClient.new.zip(filename, a)
409
209
  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.7.2
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  FGcgjmmz5fOIqq2sBxk6JW1yo2G43yIUzymWOYKT2Jh6RR0Gg3z66wWwYpFpx8yR
36
36
  00JTBNVAgW+s2sLpeBtyMDbb
37
37
  -----END CERTIFICATE-----
38
- date: 2022-02-11 00:00:00.000000000 Z
38
+ date: 2022-02-23 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: zip
@@ -58,25 +58,45 @@ dependencies:
58
58
  - !ruby/object:Gem::Version
59
59
  version: 2.0.2
60
60
  - !ruby/object:Gem::Dependency
61
- name: c32
61
+ name: dir-to-xml
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: 0.3.0
67
64
  - - "~>"
68
65
  - !ruby/object:Gem::Version
69
- version: '0.3'
66
+ version: '1.2'
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 1.2.1
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: '1.2'
74
77
  - - ">="
75
78
  - !ruby/object:Gem::Version
76
- version: 0.3.0
79
+ version: 1.2.1
80
+ - !ruby/object:Gem::Dependency
81
+ name: drb_fileclient-readwrite
82
+ requirement: !ruby/object:Gem::Requirement
83
+ requirements:
77
84
  - - "~>"
78
85
  - !ruby/object:Gem::Version
79
- version: '0.3'
86
+ version: '0.1'
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 0.1.5
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.1'
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: 0.1.5
80
100
  description:
81
101
  email: digital.robertson@gmail.com
82
102
  executables: []
@@ -103,8 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
123
  - !ruby/object:Gem::Version
104
124
  version: '0'
105
125
  requirements: []
106
- rubyforge_project:
107
- rubygems_version: 2.7.10
126
+ rubygems_version: 3.2.22
108
127
  signing_key:
109
128
  specification_version: 4
110
129
  summary: Reads or writes files from a remote DRb server. Simple as DfsFile.read or
metadata.gz.sig CHANGED
Binary file