drb_fileclient 0.5.1 → 0.6.2

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: 1899af13205ad2ea11a359b2f073e471838d9dc8a36eb348c248f5d5b377fc39
4
- data.tar.gz: a9b543548e0e1ff671e6b5a80691a53d02da0e0a84495e51a70165bc8b0fc064
3
+ metadata.gz: 999b420d751011626f3ed98cdca573242b85e1935f7dd6e79e2d359ed288d180
4
+ data.tar.gz: 261480c5b9e8b66685fbbfa308dc429120abdb3421c028c822f0e9ec9e732368
5
5
  SHA512:
6
- metadata.gz: 73727dfaaa2ba5f61b4fa6d82e7480c020288ab4634ae725f84de280e52960bd260777c3a170a01cc9995d5dde36dccb207034af9e6d40b92a3044c6d296ed5a
7
- data.tar.gz: 33005e5f9c0d522c0eb6d8255e0f082d35ddd85fdebb56db7356a15706675333fd2eb3acc77f19461a962280b24a96ca8067dd7326306327831c32a22a717c4a
6
+ metadata.gz: b04b95f16e439987d441508da786bbe556652ea65a368d0a84428885f0b3fd4889cdfebb42ee97687f054c9f8d24ff0a2f1f48595054a0a19411201faa4a814a
7
+ data.tar.gz: 87ef8faaabd5bd8b8196bc76d0a6eb8c2857c4a60d9795d244652ed619c3e00c5eca45ec507da3bf9e4c1ae5ffbe494e748d1495d225dd8e1cc0b05d55799a83
checksums.yaml.gz.sig CHANGED
Binary file
@@ -11,90 +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
- else
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
- @file.cp File.join(@directory, raw_path),
88
- File.join(@directory, raw_path2)
89
-
90
- end
91
-
92
- end
93
-
94
- def directory?(filename=@filename)
95
-
111
+ FileUtils.cp raw_path, raw_path2
112
+
113
+ end
114
+
115
+ end
116
+
117
+ def directory?(filename=@filename)
118
+
96
119
  return File.directory? filename unless @directory or filename =~ /^dfs:\/\//
97
-
120
+
98
121
  if filename =~ /^dfs:\/\// then
99
122
  @file, filename2 = parse_path(filename)
100
123
  else
@@ -103,13 +126,13 @@ class DRbFileClient
103
126
  end
104
127
 
105
128
  @file.directory?(filename2)
106
-
107
- end
108
-
109
- def exists?(filename=@filename)
110
-
129
+
130
+ end
131
+
132
+ def exists?(filename=@filename)
133
+
111
134
  return File.exists? filename unless @directory or filename =~ /^dfs:\/\//
112
-
135
+
113
136
  if filename =~ /^dfs:\/\// then
114
137
  @file, filename2 = parse_path(filename)
115
138
  else
@@ -118,136 +141,164 @@ class DRbFileClient
118
141
  end
119
142
 
120
143
  @file.exists?(filename2)
121
-
144
+
122
145
  end
123
-
146
+
124
147
  alias exist? exists?
125
-
148
+
149
+ def glob(s)
150
+
151
+ if s =~ /^dfs:\/\// then
152
+ @file, s2 = parse_path(s)
153
+ else
154
+ s2 = File.join(@directory, s)
155
+ end
156
+
157
+ @file.glob s2
158
+
159
+ end
160
+
126
161
  def ls(raw_path)
127
-
162
+
128
163
  return Dir[raw_path] unless @directory or raw_path =~ /^dfs:\/\//
129
-
164
+
130
165
  if raw_path[0] == '/' then
131
166
  path = raw_path[1..-1]
132
167
  elsif raw_path =~ /^dfs:\/\//
133
168
  @file, path = parse_path(raw_path)
134
- else
169
+ else
135
170
  path = File.join(@directory, raw_path)
136
- end
137
-
171
+ end
172
+
138
173
  @file.ls path
139
-
140
- end
141
-
174
+
175
+ end
176
+
142
177
  def mkdir(name)
143
-
178
+
144
179
  return FileUtils.mkdir name unless @directory or name =~ /^dfs:\/\//
145
-
180
+
146
181
  @file, path = parse_path(name)
147
182
  @file.mkdir path
148
183
  end
149
-
184
+
150
185
  def mkdir_p(raw_path)
151
-
186
+
152
187
  unless @directory or raw_path =~ /^dfs:\/\// then
153
- return FileUtils.mkdir_p raw_path
154
- end
155
-
188
+ return FileUtils.mkdir_p raw_path
189
+ end
190
+
156
191
  if raw_path =~ /^dfs:\/\// then
157
192
  @file, filepath = parse_path(raw_path)
158
193
  else
159
194
  filepath = File.join(@directory, raw_path)
160
195
  end
161
-
196
+
162
197
  @file.mkdir_p filepath
163
- end
164
-
198
+ end
199
+
165
200
  def mv(raw_path, raw_path2)
166
-
201
+
167
202
  unless @directory or raw_path =~ /^dfs:\/\// then
168
- return FileUtils.mv raw_path, raw_path2
203
+ return FileUtils.mv raw_path, raw_path2
169
204
  end
170
-
205
+
171
206
  if raw_path =~ /^dfs:\/\// then
172
207
  _, path = parse_path(raw_path)
173
208
  else
174
209
  path = File.join(@directory, raw_path)
175
210
  end
176
-
211
+
177
212
  if raw_path2 =~ /^dfs:\/\// then
178
213
  _, path2 = parse_path(raw_path2)
179
214
  else
180
215
  path2 = File.join(@directory, raw_path2)
181
216
  end
182
-
217
+
183
218
  @file.mv path, path2
184
- end
185
-
219
+ end
220
+
186
221
  def pwd()
187
-
222
+
188
223
  return Dir.pwd unless @directory
189
-
224
+
190
225
  '/' + @directory if @file
191
-
192
- end
226
+
227
+ end
193
228
 
194
229
  def read(filename=@filename)
195
-
230
+
196
231
  return File.read filename, s unless @directory or filename =~ /^dfs:\/\//
197
-
232
+
198
233
  if filename =~ /^dfs:\/\// then
199
234
  @file, path = parse_path(filename)
200
235
  else
201
236
  path = File.join(@directory, filename)
202
237
  end
203
-
238
+
204
239
  @file.read path
205
240
  end
206
-
241
+
207
242
  def rm(path)
208
-
243
+
209
244
  return FileUtils.rm path unless @directory or path =~ /^dfs:\/\//
210
-
245
+
211
246
  if path =~ /^dfs:\/\// then
212
247
  @file, path2 = parse_path( path)
213
248
  else
214
249
  path2 = File.join(@directory, path)
215
250
  end
216
-
251
+
217
252
  @file.rm path2
218
-
219
- end
220
-
253
+
254
+ end
255
+
256
+ def touch(s, mtime: Time.now)
257
+
258
+ unless @directory or s =~ /^dfs:\/\// then
259
+ return FileUtils.touch(s, mtime: mtime)
260
+ end
261
+
262
+ if s =~ /^dfs:\/\// then
263
+ @file, s2 = parse_path(s)
264
+ else
265
+ s2 = File.join(@directory, s)
266
+ end
267
+
268
+ @file.touch s2, mtime: mtime
269
+
270
+ end
271
+
221
272
  def write(filename=@filename, s)
222
-
273
+
223
274
  return File.write filename, s unless @directory or filename =~ /^dfs:\/\//
224
-
275
+
225
276
  if filename =~ /^dfs:\/\// then
226
277
  @file, path = parse_path(filename)
227
278
  else
228
279
  path = File.join(@directory, filename)
229
280
  end
230
-
231
- @file.write path, s
232
-
281
+
282
+ @file.write path, s
283
+
233
284
  end
234
-
285
+
235
286
  def zip(filename_zip, a)
236
-
287
+
237
288
  puts '@directory: ' + @directory.inspect if @debug
238
-
289
+
239
290
  unless @directory or filename_zip =~ /^dfs:\/\// then
240
-
291
+
241
292
  Zip::File.open(zipfile_zip, Zip::File::CREATE) do |x|
242
293
 
243
- a.each do |filename, buffer|
294
+ a.each do |filename, buffer|
244
295
  x.get_output_stream(filename) {|os| os.write buffer }
245
296
  end
246
297
 
247
298
  end
248
-
299
+
249
300
  end
250
-
301
+
251
302
  if filename_zip =~ /^dfs:\/\// then
252
303
  @file, filepath = parse_path(filename_zip)
253
304
  else
@@ -255,16 +306,16 @@ class DRbFileClient
255
306
  end
256
307
 
257
308
  @file.zip filepath, a
258
-
309
+
259
310
  end
260
311
 
261
312
  private
262
-
313
+
263
314
  def parse_path(filename)
264
315
 
265
316
  host = filename[/(?<=^dfs:\/\/)[^\/:]+/]
266
317
  @host = host if host
267
-
318
+
268
319
  port = filename[/(?<=^dfs:\/\/)[^:]+:(\d+)/,1] || '61010'
269
320
 
270
321
  file_server = DRbObject.new nil, "druby://#{host || @host}:#{port}"
@@ -272,24 +323,31 @@ class DRbFileClient
272
323
 
273
324
  end
274
325
 
275
- end
326
+ end
276
327
 
277
328
  class DfsFile
278
-
329
+
279
330
  @client = DRbFileClient.new
280
-
281
- def self.directory?(filename) @client.directory?(filename) end
282
- def self.exists?(filename) @client.exists?(filename) end
283
- def self.chdir(path) @client.chdir(path) end
284
- def self.cp(path, path2) @client.cp(path, path2) end
285
- def self.ls(path) @client.ls(path) end
286
- def self.mkdir(name) @client.mkdir(name) end
287
- def self.mkdir_p(path) @client.mkdir_p(path) end
288
- def self.mv(path, path2) @client.mv(path, path2) end
289
- def self.pwd() @client.pwd() end
331
+
332
+ def self.directory?(filename) @client.directory?(filename) end
333
+ def self.exists?(filename) @client.exists?(filename) end
334
+ def self.chdir(path) @client.chdir(path) end
335
+ def self.chmod(num, filename) @client.chmod(num, filename) end
336
+ def self.cp(path, path2) @client.cp(path, path2) end
337
+ def self.glob(s) @client.glob(s) end
338
+ def self.ls(path) @client.ls(path) end
339
+ def self.mkdir(name) @client.mkdir(name) end
340
+ def self.mkdir_p(path) @client.mkdir_p(path) end
341
+ def self.mv(path, path2) @client.mv(path, path2) end
342
+ def self.pwd() @client.pwd() end
290
343
  def self.read(filename) @client.read(filename) end
291
- def self.rm(filename) @client.rm(filename) end
344
+ def self.rm(filename) @client.rm(filename) end
345
+
346
+ def self.touch(filename, mtime: Time.now)
347
+ @client.touch(filename, mtime: mtime)
348
+ end
349
+
292
350
  def self.write(filename, s) @client.write(filename, s) end
293
351
  def self.zip(filename, a) @client.zip(filename, a) end
294
-
352
+
295
353
  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.5.1
4
+ version: 0.6.2
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
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTkwMjE4MTMyMjE4WhcN
15
- MjAwMjE4MTMyMjE4WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
- cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDPLIWE
17
- 1LxL0Rs9thm/+dEKOLimLGMrg805TqNbDMVg3zSxx/hu5DDgZw+kZxHBrhdAOGgL
18
- N9q1wHikBL3KRBlfpZn6DLL1J6RxsJmTEdhEY0IGT1sVlNYnW3IYK9nfaeJccSAA
19
- Siqt1Wg2T7O6UOTq3jg4qWSp7jT8W/CYeN+drJNvTPXf5mlBcgWhzbCJLjAMdMoG
20
- tEiBzlAGs5ys/6jk9JDVK/ll3QGq5ldzVmW+eV6z54MIXJTBRZKf43Eb5h28BNa5
21
- MoWLdj2T0nKApQDnJjwbsKdb0qq5wOAbvz49NgGfEt+azogI2DFst3JC6tt62E1C
22
- i1/6+xD70d5NpiQQlui027F8JdQbyk+3k8JMDKEI/mx+SWw41wvy1+wjiGm18X2y
23
- PC2h2eGzDdS1Rf+RwYnmw4hwmsMysEnuJyy3odhmiuYL64Uj7GKGmFuigkff2pui
24
- FSuSFUAZVcaFpqjozYvREn1iQiYCsbTs/zu1Hwyz5oZHsLlpI+J5iF6IsxkCAwEA
25
- AaOBijCBhzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVH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qq2sBxk6JW1yo2G43yIUzymWOYKT2Jh6RR0Gg3z66wWwYpFpx8yR
36
+ 00JTBNVAgW+s2sLpeBtyMDbb
37
37
  -----END CERTIFICATE-----
38
- date: 2019-04-28 00:00:00.000000000 Z
38
+ date: 2022-02-08 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.1.2
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.1.2
76
+ version: 0.3.0
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '0.3'
80
80
  description:
81
- email: james@jamesrobertson.eu
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
- rubygems_version: 3.0.1
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