rxfhelper 1.3.3 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/rxfhelper.rb +45 -345
  4. data.tar.gz.sig +0 -0
  5. metadata +16 -57
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a2f7f9d0e410726761dbe92f6c6010e21341141239a6678dba24165479af459
4
- data.tar.gz: 285b66a4741ccb039cd8cb9e3fc7b9943d1f88c4897354b01112adc0b4d706c0
3
+ metadata.gz: ebb8a8524b0128715988cb60a6cbf51349bc00accaed990a9bd6b9b149762d27
4
+ data.tar.gz: 90b21fc2c3b3f13fed66d03a0092e5142502bf474fce7aea4a6b7d35275fa440
5
5
  SHA512:
6
- metadata.gz: 965182721f1b4da5d03947ea3edd0ef180dd2932332a81ad68e4c6a6b06aa2c7a46776b574ccebb263a41fa3500502573432d1cbd907f98c72389eb7b2688d05
7
- data.tar.gz: e3a455cc808d22150233455273523accd214eec38318339b27fbd98a61db3559caa002b17c387d5f660fde27b0d4788e3eff319630703283cda12bd25d3b24d8
6
+ metadata.gz: c83ff90aea8d4c98f27e8c7f4c8f33a9492d0421d1c932f858a6b39b1016c886b47cc60570e253ede91c4a9b7632e2c14b637e2072a02bb3e40803662e29e761
7
+ data.tar.gz: 347421d92512c46f4313489b36fd76e30befcefbdf541759592f5f65d4e4840f3da627baec4640eefcd7eeba361fe303df73a6dd6d9859b1886164dbf0a2364e
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/rxfhelper.rb CHANGED
@@ -3,15 +3,9 @@
3
3
  # file: rxfhelper.rb
4
4
 
5
5
  require 'rsc'
6
- #require 'gpd-request'
7
- require 'rest-client'
8
- require 'mymedia_ftp'
9
6
  require 'drb_reg_client'
10
7
  require 'remote_dwsregistry'
11
- # Commented the following out to resolve the *uninitialized constant
12
- # Kvx::RXFHelperModule (NameError)*
13
- #require 'drb_fileclient'
14
- #require 'dir-to-xml'
8
+ require 'rxfileio'
15
9
 
16
10
 
17
11
 
@@ -19,135 +13,79 @@ require 'remote_dwsregistry'
19
13
  # using the Registry feaure to look up objects automatically.
20
14
 
21
15
  module RXFHelperModule
16
+ include RXFileIOModule
22
17
 
23
- class DirX
24
18
 
25
- def self.chdir(s) RXFHelper.chdir(s) end
26
- def self.glob(s) RXFHelper.glob(s) end
27
- def self.mkdir(s) RXFHelper.mkdir(s) end
28
- def self.pwd() RXFHelper.pwd() end
19
+ def FileX.exists?(filename)
29
20
 
30
- end
31
-
32
- class FileX
33
-
34
- def self.chdir(s) RXFHelper.chdir(s) end
35
-
36
- def self.directory?(filename)
37
-
38
- type = self.filetype(filename)
39
-
40
- filex = case type
41
- when :file
42
- File
43
- when :dfs
44
- DfsFile
45
- else
46
- nil
47
- end
48
-
49
- return nil unless filex
50
-
51
- filex.directory? filename
21
+ type = FileX.filetype(filename)
52
22
 
23
+ filex = case type
24
+ when :file
25
+ File
26
+ when :dfs
27
+ DfsFile
28
+ when :sqlite
29
+ host = filename[/(?<=^sqlite:\/\/)[^\/]+/]
30
+ DRbObject.new nil, "druby://#{host}:57000"
31
+ else
32
+ nil
53
33
  end
54
34
 
55
- def self.exists?(filename)
35
+ return nil unless filex
56
36
 
57
- type = self.filetype(filename)
37
+ filex.exists? filename
58
38
 
59
- filex = case type
60
- when :file
61
- File
62
- when :dfs
63
- DfsFile
64
- when :sqlite
65
- host = filename[/(?<=^sqlite:\/\/)[^\/]+/]
66
- DRbObject.new nil, "druby://#{host}:57000"
67
- else
68
- nil
69
- end
70
-
71
- return nil unless filex
72
-
73
- filex.exists? filename
39
+ end
74
40
 
75
- end
76
41
 
77
- def self.exist?(filename)
78
- exists? filename
79
- end
42
+ def FileX.filetype(x)
80
43
 
81
- def self.filetype(x)
44
+ return :string if x.lines.length > 1
82
45
 
83
- return :string if x.lines.length > 1
46
+ case x
47
+ when /^rse:\/\//
48
+ :rse
49
+ when /^https?:\/\//
50
+ :http
51
+ when /^dfs:\/\//
52
+ :dfs
53
+ when /^sqlite:\/\//
54
+ :sqlite
55
+ when /^file:\/\//
56
+ :file
57
+ else
84
58
 
85
- case x
86
- when /^rse:\/\//
87
- :rse
88
- when /^https?:\/\//
89
- :http
90
- when /^dfs:\/\//
91
- :dfs
92
- when /^sqlite:\/\//
93
- :sqlite
94
- when /^file:\/\//
59
+ if File.exists?(x) then
95
60
  :file
96
61
  else
97
-
98
- if File.exists?(x) then
99
- :file
100
- else
101
- :text
102
- end
103
-
62
+ :text
104
63
  end
105
- end
106
64
 
107
- def self.chmod(num, s) RXFHelper.chmod(num, s) end
108
- def self.cp(s, s2) RXFHelper.cp(s, s2) end
109
- def self.ls(s) RXFHelper.ls(s) end
110
- def self.mkdir(s) RXFHelper.mkdir(s) end
111
- def self.mkdir_p(s) RXFHelper.mkdir_p(s) end
112
- def self.mv(s, s2) RXFHelper.mv(s, s2) end
113
- def self.pwd() RXFHelper.pwd() end
114
- def self.read(x) RXFHelper.read(x).first end
115
- def self.rm(s) RXFHelper.rm(s) end
116
-
117
- def self.rm_r(s, force: false)
118
- RXFHelper.rm_r(s, force: force)
119
65
  end
120
-
121
- def self.ru(s) RXFHelper.ru(s) end
122
- def self.ru_r(s) RXFHelper.ru_r(s) end
123
-
124
- def self.touch(s, mtime: Time.now)
125
- RXFHelper.touch(s, mtime: mtime)
126
- end
127
-
128
- def self.write(x, s) RXFHelper.write(x, s) end
129
- def self.zip(s, a) RXFHelper.zip(s, a) end
130
-
131
66
  end
67
+
132
68
  end
133
69
 
70
+ =begin
71
+ # 20th February 2022 # JR
72
+ # the following code has been commented out because it appears to be redundant
134
73
  class URL
135
74
 
136
75
  def self.join(*a)
137
76
  a.map {|x| x.sub(/(?:^\/|\/$)/,'') }.join '/'
138
77
  end
139
78
  end
140
-
79
+ =end
141
80
 
142
81
  class RXFHelperException < Exception
143
82
  end
144
83
 
145
84
  # Read XML File Helper
146
85
  #
147
- class RXFHelper
86
+ class RXFHelper < RXFileIO
148
87
  using ColouredText
149
88
 
150
- @fs = :local
151
89
 
152
90
  def self.call(s)
153
91
 
@@ -164,66 +102,6 @@ class RXFHelper
164
102
 
165
103
  end
166
104
 
167
- def self.chmod(permissions, s)
168
-
169
- return unless permissions.is_a? Integer
170
- return unless s.is_a? String
171
-
172
- if s[/^dfs:\/\//] or @fs[0..2] == 'dfs' then
173
- DfsFile.chmod permissions, s
174
- else
175
- FileUtils.chmod permissions, s
176
- end
177
-
178
- end
179
-
180
- def self.cp(s1, s2, debug: false)
181
-
182
- puts 'inside RXFHelper.cp' if debug
183
-
184
- found = [s1,s2].grep /^\w+:\/\//
185
- puts 'found: ' + found.inspect if debug
186
-
187
- if found.any? then
188
-
189
- case found.first[/^\w+(?=:\/\/)/]
190
-
191
- when 'dfs'
192
- DfsFile.cp(s1, s2)
193
- when 'ftp'
194
- MyMediaFTP.cp s1, s2
195
- else
196
-
197
- end
198
-
199
- else
200
-
201
- FileUtils.cp s1, s2
202
-
203
- end
204
- end
205
-
206
- def self.chdir(x)
207
-
208
- # We can use @fs within chdir() to flag the current file system.
209
- # Allowing us to use relative paths with FileX operations instead
210
- # of explicitly stating the path each time. e.g. touch 'foo.txt'
211
- #
212
-
213
- if x[/^file:\/\//] or File.exists?(File.dirname(x)) then
214
-
215
- @fs = :local
216
- FileUtils.chdir x
217
-
218
- elsif x[/^dfs:\/\//]
219
-
220
- host = x[/(?<=dfs:\/\/)[^\/]+/]
221
- @fs = 'dfs://' + host
222
- DfsFile.chdir x
223
-
224
- end
225
-
226
- end
227
105
 
228
106
  def self.get(x)
229
107
 
@@ -244,57 +122,6 @@ class RXFHelper
244
122
 
245
123
  end
246
124
 
247
- def self.glob(s)
248
-
249
- if s[/^dfs:\/\//] then
250
- DfsFile.glob(s)
251
- else
252
- Dir.glob(s)
253
- end
254
-
255
- end
256
-
257
- def self.ls(x='*')
258
-
259
- return Dir[x] if File.exists?(File.dirname(x))
260
-
261
- case x[/^\w+(?=:\/\/)/]
262
- when 'file'
263
- Dir[x]
264
- when 'dfs'
265
- DfsFile.ls x
266
- when 'ftp'
267
- MyMediaFTP.ls x
268
- else
269
-
270
- end
271
-
272
- end
273
-
274
- def self.mkdir(x)
275
-
276
- if x[/^file:\/\//] or File.exists?(File.dirname(x)) then
277
- FileUtils.mkdir x
278
- elsif x[/^dfs:\/\//]
279
- DfsFile.mkdir x
280
- end
281
-
282
- end
283
-
284
- def self.mkdir_p(x)
285
-
286
- if x[/^dfs:\/\//] or @fs[0..2] == 'dfs' then
287
- DfsFile.mkdir_p x
288
- else
289
- FileUtils.mkdir_p x
290
- end
291
-
292
- end
293
-
294
- def self.mv(s1, s2)
295
- DfsFile.mv(s1, s2)
296
- end
297
-
298
125
  # used by self.read
299
126
  #
300
127
  def self.objectize(contents)
@@ -312,11 +139,6 @@ class RXFHelper
312
139
  obj
313
140
  end
314
141
 
315
- def self.pwd()
316
-
317
- DfsFile.pwd
318
-
319
- end
320
142
 
321
143
  def self.read(x, h={})
322
144
 
@@ -362,7 +184,7 @@ class RXFHelper
362
184
 
363
185
  elsif x[/^dfs:\/\//] then
364
186
 
365
- r = DfsFile.read(x)
187
+ r = DfsFile.read(x).force_encoding('UTF-8')
366
188
  [opt[:auto] ? objectize(r) : r, :dfs]
367
189
 
368
190
  elsif x[/^ftp:\/\//] then
@@ -394,7 +216,7 @@ class RXFHelper
394
216
  elsif x =~ /\s/
395
217
  [x, :text]
396
218
  elsif DfsFile.exists?(x)
397
- [DfsFile.read(x), :dfs]
219
+ [DfsFile.read(x).force_encoding('UTF-8'), :dfs]
398
220
  else
399
221
  [x, :unknown]
400
222
  end
@@ -405,113 +227,6 @@ class RXFHelper
405
227
  end
406
228
  end
407
229
 
408
- def self.rm(filename)
409
-
410
- case filename[/^\w+(?=:\/\/)/]
411
- when 'dfs'
412
- DfsFile.rm filename
413
- when 'ftp'
414
- MyMediaFTP.rm filename
415
- else
416
-
417
- if File.basename(filename) =~ /\*/ then
418
-
419
- Dir.glob(filename).each do |file|
420
-
421
- begin
422
- FileUtils.rm file
423
- rescue
424
- puts ('RXFHelper#rm: ' + file + ' is a Directory').warning
425
- end
426
-
427
- end
428
-
429
- else
430
- FileUtils.rm filename
431
- end
432
-
433
- end
434
-
435
- end
436
-
437
- def self.rm_r(filename, force: false)
438
-
439
- case filename[/^\w+(?=:\/\/)/]
440
- when 'dfs'
441
- DfsFile.rm_r filename, force: force
442
- #when 'ftp'
443
- # MyMediaFTP.rm filename
444
- else
445
-
446
- if File.basename(filename) =~ /\*/ then
447
-
448
- Dir.glob(filename).each do |file|
449
-
450
- begin
451
- FileUtils.rm_r file, force: force
452
- rescue
453
- puts ('RXFHelper#rm: ' + file + ' is a Directory').warning
454
- end
455
-
456
- end
457
-
458
- else
459
- FileUtils.rm_r filename, force: force
460
- end
461
-
462
- end
463
-
464
- end
465
-
466
- # recently_updated
467
- #
468
- def self.ru(path='.')
469
-
470
- case path[/^\w+(?=:\/\/)/]
471
- when 'dfs'
472
- DfsFile.ru path
473
-
474
- else
475
-
476
- DirToXML.new(path, recursive: false, verbose: false).latest
477
-
478
- end
479
-
480
- end
481
-
482
- # recently updated recursively check directories
483
- #
484
- def self.ru_r(path='.')
485
-
486
- case path[/^\w+(?=:\/\/)/]
487
- when 'dfs'
488
- DfsFile.ru_r path
489
-
490
- else
491
-
492
- DirToXML.new(path, recursive: true, verbose: false).latest
493
-
494
- end
495
-
496
- end
497
-
498
- def self.touch(filename, mtime: Time.now)
499
-
500
- if @fs[0..2] == 'dfs' then
501
- return DfsFile.touch(@fs + pwd + '/' + filename, mtime: mtime)
502
- end
503
-
504
- case filename[/^\w+(?=:\/\/)/]
505
- when 'dfs'
506
- DfsFile.touch filename, mtime: mtime
507
- #when 'ftp'
508
- # MyMediaFTP.touch filename
509
- else
510
- FileUtils.touch filename, mtime: mtime
511
- end
512
-
513
- end
514
-
515
230
  def self.write(location, s=nil)
516
231
 
517
232
  case location
@@ -543,22 +258,9 @@ class RXFHelper
543
258
 
544
259
  end
545
260
 
546
- def self.writeable?(source)
547
-
548
- return false if source.lines.length > 1
549
-
550
- if not source =~ /:\/\// then
551
-
552
- return true if File.exists? source
553
-
554
- else
555
-
556
- return true if source =~ /^dfs:/
557
-
558
- end
559
-
560
- return false
561
- end
261
+ =begin
262
+ # 20th February 2022 # JR
263
+ # the following code has been commented out because it appears to be redundant
562
264
 
563
265
  def self.absolute_url(page_url, item_location)
564
266
 
@@ -574,6 +276,7 @@ class RXFHelper
574
276
  File.join page_url[/.*\//], item_location
575
277
  end
576
278
  end
279
+ =end
577
280
 
578
281
  def self.post(uri, x=nil)
579
282
 
@@ -608,7 +311,4 @@ class RXFHelper
608
311
 
609
312
  end
610
313
 
611
- def self.zip(filename, a)
612
- DfsFile.zip(filename, a)
613
- end
614
314
  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.3.3
4
+ version: 1.4.0
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-11 00:00:00.000000000 Z
38
+ date: 2022-02-22 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rsc
@@ -58,105 +58,65 @@ dependencies:
58
58
  - !ruby/object:Gem::Version
59
59
  version: 0.4.5
60
60
  - !ruby/object:Gem::Dependency
61
- name: drb_fileclient
61
+ name: remote_dwsregistry
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
- version: '0.7'
66
+ version: '0.4'
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: 0.7.1
69
+ version: 0.4.1
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '0.7'
76
+ version: '0.4'
77
77
  - - ">="
78
78
  - !ruby/object:Gem::Version
79
- version: 0.7.1
79
+ version: 0.4.1
80
80
  - !ruby/object:Gem::Dependency
81
- name: mymedia_ftp
81
+ name: drb_reg_client
82
82
  requirement: !ruby/object:Gem::Requirement
83
83
  requirements:
84
84
  - - "~>"
85
85
  - !ruby/object:Gem::Version
86
- version: '0.3'
86
+ version: '0.2'
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 0.3.3
89
+ version: 0.2.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0.3'
96
+ version: '0.2'
97
97
  - - ">="
98
98
  - !ruby/object:Gem::Version
99
- version: 0.3.3
99
+ version: 0.2.0
100
100
  - !ruby/object:Gem::Dependency
101
- name: remote_dwsregistry
101
+ name: rxfileio
102
102
  requirement: !ruby/object:Gem::Requirement
103
103
  requirements:
104
104
  - - "~>"
105
105
  - !ruby/object:Gem::Version
106
- version: '0.4'
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- version: 0.4.1
110
- type: :runtime
111
- prerelease: false
112
- version_requirements: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - "~>"
115
- - !ruby/object:Gem::Version
116
- version: '0.4'
117
- - - ">="
118
- - !ruby/object:Gem::Version
119
- version: 0.4.1
120
- - !ruby/object:Gem::Dependency
121
- name: drb_reg_client
122
- requirement: !ruby/object:Gem::Requirement
123
- requirements:
106
+ version: '0.2'
124
107
  - - ">="
125
108
  - !ruby/object:Gem::Version
126
109
  version: 0.2.0
127
- - - "~>"
128
- - !ruby/object:Gem::Version
129
- version: '0.2'
130
110
  type: :runtime
131
111
  prerelease: false
132
112
  version_requirements: !ruby/object:Gem::Requirement
133
113
  requirements:
134
- - - ">="
135
- - !ruby/object:Gem::Version
136
- version: 0.2.0
137
114
  - - "~>"
138
115
  - !ruby/object:Gem::Version
139
116
  version: '0.2'
140
- - !ruby/object:Gem::Dependency
141
- name: rest-client
142
- requirement: !ruby/object:Gem::Requirement
143
- requirements:
144
- - - ">="
145
- - !ruby/object:Gem::Version
146
- version: 2.1.0
147
- - - "~>"
148
- - !ruby/object:Gem::Version
149
- version: '2.1'
150
- type: :runtime
151
- prerelease: false
152
- version_requirements: !ruby/object:Gem::Requirement
153
- requirements:
154
117
  - - ">="
155
118
  - !ruby/object:Gem::Version
156
- version: 2.1.0
157
- - - "~>"
158
- - !ruby/object:Gem::Version
159
- version: '2.1'
119
+ version: 0.2.0
160
120
  description:
161
121
  email: digital.robertson@gmail.com
162
122
  executables: []
@@ -183,8 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
143
  - !ruby/object:Gem::Version
184
144
  version: '0'
185
145
  requirements: []
186
- rubyforge_project:
187
- rubygems_version: 2.7.10
146
+ rubygems_version: 3.2.22
188
147
  signing_key:
189
148
  specification_version: 4
190
149
  summary: Helpful library for primarily reading the contents of a file either from
metadata.gz.sig CHANGED
Binary file