rxfhelper 1.3.2 → 1.4.1

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