rxfreadwrite 0.2.1 → 0.2.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: ce12d520fd0882b7a49194ef341ff80d14551b9d3a32773605f74a3203a0bdda
4
- data.tar.gz: 60579f92af1b9bd7e430521d22de70be7ae40f1d646e878decc0e66b56fe1ca8
3
+ metadata.gz: a413b0dff84c4e2bcbad1dd82fc0050ee3528a90c8ec47cd0cc5c80dec1d61cb
4
+ data.tar.gz: 8a348a14dcafca0f419327e67ffe4a2bdbfc684125778726805c45dd64f75cba
5
5
  SHA512:
6
- metadata.gz: 26a3ac804405987b43ca015325c8b24e8d03db18713905e381f3631152f0c3f370e4ed9b372affea51106d222beafefd410f2f654690193e4c17c60507afd864
7
- data.tar.gz: e6759d75ea0ec5009d0662ab46007cd4cc0c3a8f53d0c827f3f9aa160478b2c0e70ec4828b70c14ac35e59433533f095d685385aecc56339a566809de67a91b7
6
+ metadata.gz: 2f13199d4ac7d9cde364173b822281c80f73445806413c7fd6d2172de1a1bbe2ea5f3e4ce3981305b55f5ee266e397267ca04e0f66b397e5bbb1580275fc4884
7
+ data.tar.gz: ecfc56805572a2dd2571c4bdf866effb587b0f85583579ae99a5a7f2009f11b7acfd6572f87255d6b4bbe9b9a1273a72f5b99619b6ddc0efba0bb31fb6396a3a
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/rxfreadwrite.rb CHANGED
@@ -15,12 +15,35 @@ module RXFReadWriteModule
15
15
  def self.glob(s) RXFReadWrite.glob(s) end
16
16
  def self.mkdir(s) RXFReadWrite.mkdir(s) end
17
17
  def self.mkdir_p(s) RXFReadWrite.mkdir_p(s) end
18
+ def self.pwd() RXFReadWrite.pwd() end
18
19
 
19
20
  end
20
21
 
21
22
  def FileX.chdir(s) RXFReadWrite.chdir(s) end
23
+
24
+ def FileX.directory?(filename)
25
+
26
+ type = FileX.filetype(filename)
27
+
28
+ filex = case type
29
+ when :file
30
+ File
31
+ when :dfs
32
+ DfsFile
33
+ else
34
+ nil
35
+ end
36
+
37
+ return nil unless filex
38
+
39
+ filex.directory? filename
40
+
41
+ end
42
+
43
+ def FileX.exists?(s) RXFReadWrite.exists?(s) end
22
44
  def FileX.mkdir(s) RXFReadWrite.mkdir(s) end
23
45
  def FileX.mkdir_p(s) RXFReadWrite.mkdir_p(s) end
46
+ def FileX.pwd() RXFReadWrite.pwd() end
24
47
  def FileX.rm(s) RXFReadWrite.rm(s) end
25
48
 
26
49
  def FileX.rm_r(s, force: false)
@@ -45,29 +68,62 @@ end
45
68
  class RXFReadWrite < RXFReader
46
69
  using ColouredText
47
70
 
71
+ @@fs = :local
72
+
73
+ # identifies the working file system
74
+ def self.fs()
75
+ @@fs
76
+ end
48
77
 
49
78
  def self.chdir(x)
50
79
 
51
- # We can use @fs within chdir() to flag the current file system.
80
+ # We can use @@fs within chdir() to flag the current file system.
52
81
  # Allowing us to use relative paths with FileX operations instead
53
82
  # of explicitly stating the path each time. e.g. touch 'foo.txt'
54
83
  #
55
84
 
56
85
  if x[/^file:\/\//] or File.exists?(File.dirname(x)) then
57
86
 
58
- @fs = :local
87
+ @@fs = :local
59
88
  FileUtils.chdir x
60
89
 
61
90
  elsif x[/^dfs:\/\//]
62
91
 
63
92
  host = x[/(?<=dfs:\/\/)[^\/]+/]
64
- @fs = 'dfs://' + host
93
+ @@fs = 'dfs://' + host
65
94
  DfsFile.chdir x
66
95
 
67
96
  end
68
97
 
69
98
  end
70
99
 
100
+ def self.exists?(filename)
101
+
102
+ type = self.filetype(filename)
103
+
104
+ filex = case type
105
+ when :file
106
+ File
107
+ when :dfs
108
+ DfsFile
109
+ else
110
+ nil
111
+ end
112
+
113
+ return nil unless filex
114
+
115
+ filex.exists? filename
116
+
117
+ end
118
+
119
+ def self.filetype(x)
120
+
121
+ return :string if x.lines.length > 1
122
+ return :dfs if @@fs[0..2] == 'dfs'
123
+ RXFReader.filetype(x)
124
+
125
+ end
126
+
71
127
  def self.glob(s)
72
128
 
73
129
  if s[/^dfs:\/\//] then
@@ -98,6 +154,10 @@ class RXFReadWrite < RXFReader
98
154
 
99
155
  end
100
156
 
157
+ def self.pwd()
158
+ DfsFile.pwd
159
+ end
160
+
101
161
  def self.rm(filename)
102
162
 
103
163
  case filename[/^\w+(?=:\/\/)/]
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.2.1
4
+ version: 0.2.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-22 00:00:00.000000000 Z
38
+ date: 2022-02-28 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rxfreader
@@ -66,7 +66,7 @@ dependencies:
66
66
  version: '0.1'
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: 0.1.0
69
+ version: 0.1.4
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0.1'
77
77
  - - ">="
78
78
  - !ruby/object:Gem::Version
79
- version: 0.1.0
79
+ version: 0.1.4
80
80
  description:
81
81
  email: digital.robertson@gmail.com
82
82
  executables: []
metadata.gz.sig CHANGED
Binary file