rxfreadwrite 0.1.1 → 0.1.5

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: be9aed29d79ff21b058ffcc6509a8dbc0fcb157c1c2dd733475e26e0fb9fc6c7
4
- data.tar.gz: e2831bde3a2272fdee7fe727410100104504b8668f5b8aa4a172778bf8a9c5a2
3
+ metadata.gz: e4a5e0be2ab188873e5b66442a41c9323cb2cdc147479a4f345e0bf8f65a5169
4
+ data.tar.gz: 789b30722ba41958c2583339ae81517a6b9e15add206257962e46487cd30fafc
5
5
  SHA512:
6
- metadata.gz: e228cf408ad01f8dcd3feb1512a498467a56b0df57f070569d80877e87c01602ad660098593e6015b51a9d21564a47a97f8d7bfc122f967427546a90bd64fbd3
7
- data.tar.gz: 8c82a289ff13468c05c5a5afc2b763e787efa5913fa820dcabbb4c7a914b9e2f12418eac6ad3f87d96edb0f38260dd01e9f24ff626b2976179b0427065ed818c
6
+ metadata.gz: c4111afd84565a9548023a8986574548332d3f37f3d7fd09da6ac21df8163ff46feb71142694cd45c001878071d945662ebc29a8b7ba4c6f9976db35c3728c89
7
+ data.tar.gz: 401e36e30e4f859afa88ef3087a73299546431adb139bb8aef1b04b885d5d41a364784cfcc5c47708d6aeb79c597881ebdf5c864633006c5a3e7717fb5c57396
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/rxfreadwrite.rb CHANGED
@@ -8,76 +8,133 @@ require 'rxfreader'
8
8
  module RXFReadWriteModule
9
9
  include RXFRead
10
10
 
11
-
12
11
  class DirX
13
12
 
14
- def self.glob(s) RXFileReadWrite.glob(s) end
13
+ def self.glob(s) RXFReadWrite.glob(s) end
14
+ def self.mkdir(s) RXFReadWrite.mkdir(s) end
15
+ def self.mkdir_p(s) RXFReadWrite.mkdir_p(s) end
15
16
 
16
17
  end
17
18
 
18
- def FileX.exists?(filename)
19
+ def FileX.mkdir(s) RXFReadWrite.mkdir(s) end
20
+ def FileX.mkdir_p(s) RXFReadWrite.mkdir_p(s) end
21
+ def FileX.rm(s) RXFReadWrite.rm(s) end
22
+
23
+ def FileX.rm_r(s, force: false)
24
+ RXFReadWrite.rm_r(s, force: force)
25
+ end
19
26
 
20
- type = FileX.filetype(filename)
27
+ def FileX.touch(s, mtime: Time.now)
28
+ RXFReadWrite.touch(s, mtime: mtime)
29
+ end
21
30
 
22
- filex = case type
23
- when :file
24
- File
25
- when :dfs
26
- DfsFile
31
+ def FileX.write(x, s)
32
+ RXFReadWrite.write(x, s)
33
+ end
34
+ end
35
+
36
+
37
+ class RXFReadWriteException < Exception
38
+ end
39
+
40
+ class RXFReadWrite < RXFReader
41
+ using ColouredText
42
+
43
+ def self.glob(s)
44
+
45
+ if s[/^dfs:\/\//] then
46
+ DfsFile.glob(s)
27
47
  else
28
- nil
48
+ Dir.glob(s)
29
49
  end
30
50
 
31
- return nil unless filex
51
+ end
52
+
53
+ def self.mkdir(x)
32
54
 
33
- filex.exists? filename
55
+ if x[/^file:\/\//] or File.exists?(File.dirname(x)) then
56
+ FileUtils.mkdir x
57
+ elsif x[/^dfs:\/\//]
58
+ DfsFile.mkdir x
59
+ end
34
60
 
35
61
  end
36
62
 
63
+ def self.mkdir_p(x)
37
64
 
38
- def FileX.filetype(x)
65
+ if x[/^dfs:\/\//] then
66
+ DfsFile.mkdir_p x
67
+ else
68
+ FileUtils.mkdir_p x
69
+ end
39
70
 
40
- return :string if x.lines.length > 1
71
+ end
41
72
 
42
- case x
43
- when /^https?:\/\//
44
- :http
45
- when /^dfs:\/\//
46
- :dfs
47
- when /^file:\/\//
48
- :file
73
+ def self.rm(filename)
74
+
75
+ case filename[/^\w+(?=:\/\/)/]
76
+ when 'dfs'
77
+ DfsFile.rm filename
49
78
  else
50
79
 
51
- if File.exists?(x) then
52
- :file
80
+ if File.basename(filename) =~ /\*/ then
81
+
82
+ Dir.glob(filename).each do |file|
83
+
84
+ begin
85
+ FileUtils.rm file
86
+ rescue
87
+ puts ('RXFReadWrite#rm: ' + file + ' is a Directory').warning
88
+ end
89
+
90
+ end
91
+
53
92
  else
54
- :text
93
+ FileUtils.rm filename
55
94
  end
56
95
 
57
96
  end
58
- end
59
97
 
60
- def FileX.write(x, s)
61
- RXFReadWrite.write(x, s)
62
98
  end
63
- end
64
99
 
100
+ def self.rm_r(filename, force: false)
65
101
 
66
- class RXFReadWriteException < Exception
67
- end
102
+ case filename[/^\w+(?=:\/\/)/]
103
+ when 'dfs'
104
+ DfsFile.rm_r filename, force: force
105
+ else
68
106
 
69
- class RXFReadWrite < RXFReader
70
- using ColouredText
107
+ if File.basename(filename) =~ /\*/ then
71
108
 
72
- def self.glob(s)
109
+ Dir.glob(filename).each do |file|
73
110
 
74
- if s[/^dfs:\/\//] then
75
- DfsFile.glob(s)
111
+ begin
112
+ FileUtils.rm_r file, force: force
113
+ rescue
114
+ puts ('RXFReadWrite#rm_r: ' + file + ' is a Directory').warning
115
+ end
116
+
117
+ end
118
+
119
+ else
120
+ FileUtils.rm_r filename, force: force
121
+ end
122
+
123
+ end
124
+
125
+ end
126
+
127
+ def self.touch(filename, mtime: Time.now)
128
+
129
+ case filename[/^\w+(?=:\/\/)/]
130
+ when 'dfs'
131
+ DfsFile.touch filename, mtime: mtime
76
132
  else
77
- Dir.glob(s)
133
+ FileUtils.touch filename, mtime: mtime
78
134
  end
79
135
 
80
136
  end
137
+
81
138
  def self.write(location, s=nil)
82
139
 
83
140
  case location
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rxfreadwrite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  gnYmJHVhKvNaFwL4ryulhkA+n8o3Ve6Kzo/AGlO2+Ge6H0bqIUbS8UisqDa7IwlY
36
36
  tvleW582+lzMrpAfWdGb4VFX
37
37
  -----END CERTIFICATE-----
38
- date: 2022-02-20 00:00:00.000000000 Z
38
+ date: 2022-02-21 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rxfreader
metadata.gz.sig CHANGED
Binary file