rxfhelper 1.2.2 → 1.2.6

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: 8b138d1576463c9bba8e0d18b64e7be0734f2df074854f94fbb4f0efa109d768
4
- data.tar.gz: 8b66c19d007599ef84ba0dc2a361e92d93565625c5b1608b10c84d2abc204291
3
+ metadata.gz: cc08e94405728b8ce7bcd30f2c33736b9f209131caac7d6fded3faf7a5488985
4
+ data.tar.gz: d1625899121690c01ccb348f42ea31e04445a3177c2841b510222f8f8dd04414
5
5
  SHA512:
6
- metadata.gz: 75e3dc8373f2571a4222a7992c1490f9fbdfa41ceb920aeb57d12fa5f501f438991ee685316ecab6b31766a7db7d5f102e2d74c7dabb7c9406a3bf41cbbc02ab
7
- data.tar.gz: 55b81edb3b58deba0e3148cc2ce314fc45825fed75f5e79951aee77f80593b3eab82552b898fac3e334f9ff69ac5996a65da6e9d78d5cb6d38b86987be063c4b
6
+ metadata.gz: ed7fd7c023ec9fd526bfa6e6b7347980240ade785bf2dde4f80d0a4ddf5bd6238961e1dc549c0eba773d36dfdaed3f173b71412bb766d62c0e7a0581bb655e2f
7
+ data.tar.gz: 1c80069ebddf99533700fe872f9b65dc324b2f78481fac3ffe7299ea764eb306e14d053f74c51005b4da22ed3d75e74d1bfe0aa8d069f78fa15def4402d3429a
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/rxfhelper.rb CHANGED
@@ -110,6 +110,15 @@ module RXFHelperModule
110
110
  def self.pwd() RXFHelper.pwd() end
111
111
  def self.read(x) RXFHelper.read(x).first end
112
112
  def self.rm(s) RXFHelper.rm(s) end
113
+
114
+ def self.rm_r(s, force: false)
115
+ RXFHelper.rm_r(s, force: force)
116
+ end
117
+
118
+ def self.touch(s, mtime: Time.now)
119
+ RXFHelper.touch(s, mtime: mtime)
120
+ end
121
+
113
122
  def self.write(x, s) RXFHelper.write(x, s) end
114
123
  def self.zip(s, a) RXFHelper.zip(s, a) end
115
124
 
@@ -154,7 +163,7 @@ class RXFHelper
154
163
  return unless permissions.is_a? Integer
155
164
  return unless s.is_a? String
156
165
 
157
- if s[/^dfs:\/\//] or @fs == :dfs then
166
+ if s[/^dfs:\/\//] or @fs[0..2] == 'dfs' then
158
167
  DfsFile.chmod permissions, s
159
168
  else
160
169
  FileUtils.chmod permissions, s
@@ -171,11 +180,11 @@ class RXFHelper
171
180
 
172
181
  if found.any? then
173
182
 
174
- case found.first[/^\w+(?=:\/\/)/].to_sym
183
+ case found.first[/^\w+(?=:\/\/)/]
175
184
 
176
- when :dfs
185
+ when 'dfs'
177
186
  DfsFile.cp(s1, s2)
178
- when :ftp
187
+ when 'ftp'
179
188
  MyMediaFTP.cp s1, s2
180
189
  else
181
190
 
@@ -190,12 +199,22 @@ class RXFHelper
190
199
 
191
200
  def self.chdir(x)
192
201
 
202
+ # We can use @fs within chdir() to flag the current file system.
203
+ # Allowing us to use relative paths with FileX operations instead
204
+ # of explicitly stating the path each time. e.g. touch 'foo.txt'
205
+ #
206
+
193
207
  if x[/^file:\/\//] or File.exists?(File.dirname(x)) then
208
+
194
209
  @fs = :local
195
210
  FileUtils.chdir x
211
+
196
212
  elsif x[/^dfs:\/\//]
197
- @fs = :dfs
213
+
214
+ host = x[/(?<=dfs:\/\/)[^\/]+/]
215
+ @fs = 'dfs://' + host
198
216
  DfsFile.chdir x
217
+
199
218
  end
200
219
 
201
220
  end
@@ -233,12 +252,12 @@ class RXFHelper
233
252
 
234
253
  return Dir[x] if File.exists?(File.dirname(x))
235
254
 
236
- case x[/^\w+(?=:\/\/)/].to_sym
237
- when :file
255
+ case x[/^\w+(?=:\/\/)/]
256
+ when 'file'
238
257
  Dir[x]
239
- when :dfs
258
+ when 'dfs'
240
259
  DfsFile.ls x
241
- when :ftp
260
+ when 'ftp'
242
261
  MyMediaFTP.ls x
243
262
  else
244
263
 
@@ -258,7 +277,7 @@ class RXFHelper
258
277
 
259
278
  def self.mkdir_p(x)
260
279
 
261
- if x[/^dfs:\/\//] or @fs == :dfs then
280
+ if x[/^dfs:\/\//] or @fs[0..2] == 'dfs' then
262
281
  DfsFile.mkdir_p x
263
282
  else
264
283
  FileUtils.mkdir_p x
@@ -382,13 +401,75 @@ class RXFHelper
382
401
 
383
402
  def self.rm(filename)
384
403
 
385
- case filename[/^\w+(?=:\/\/)/].to_sym
386
- when :dfs
404
+ case filename[/^\w+(?=:\/\/)/]
405
+ when 'dfs'
387
406
  DfsFile.rm filename
388
- when :ftp
407
+ when 'ftp'
389
408
  MyMediaFTP.rm filename
390
409
  else
391
410
 
411
+ if File.basename(filename) =~ /\*/ then
412
+
413
+ Dir.glob(filename).each do |file|
414
+
415
+ begin
416
+ FileUtils.rm file
417
+ rescue
418
+ puts ('RXFHelper#rm: ' + file + ' is a Directory').warning
419
+ end
420
+
421
+ end
422
+
423
+ else
424
+ FileUtils.rm filename
425
+ end
426
+
427
+ end
428
+
429
+ end
430
+
431
+ def self.rm_r(filename, force: false)
432
+
433
+ case filename[/^\w+(?=:\/\/)/]
434
+ when 'dfs'
435
+ DfsFile.rm_r filename, force: force
436
+ #when 'ftp'
437
+ # MyMediaFTP.rm filename
438
+ else
439
+
440
+ if File.basename(filename) =~ /\*/ then
441
+
442
+ Dir.glob(filename).each do |file|
443
+
444
+ begin
445
+ FileUtils.rm_r file, force: force
446
+ rescue
447
+ puts ('RXFHelper#rm: ' + file + ' is a Directory').warning
448
+ end
449
+
450
+ end
451
+
452
+ else
453
+ FileUtils.rm_r filename, force: force
454
+ end
455
+
456
+ end
457
+
458
+ end
459
+
460
+ def self.touch(filename, mtime: Time.now)
461
+
462
+ if @fs[0..2] == 'dfs' then
463
+ return DfsFile.touch(@fs + pwd + '/' + filename, mtime: mtime)
464
+ end
465
+
466
+ case filename[/^\w+(?=:\/\/)/]
467
+ when 'dfs'
468
+ DfsFile.touch filename, mtime: mtime
469
+ #when 'ftp'
470
+ # MyMediaFTP.touch filename
471
+ else
472
+ FileUtils.touch filename, mtime: mtime
392
473
  end
393
474
 
394
475
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rxfhelper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  MrrH8cS6bqJRPQqEL1FsPmXfQpp86RvPSr0WqNSRnYEUCmqL0l2pYrXdPAyBLcji
36
36
  X1jPyhH0sl/QdPdaUnsigze+
37
37
  -----END CERTIFICATE-----
38
- date: 2022-02-04 00:00:00.000000000 Z
38
+ date: 2022-02-09 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rsc
metadata.gz.sig CHANGED
Binary file