rxfreadwrite 0.2.3 → 0.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: '0568a7bd949343da576434a90ace51dc73726e21576d5219ba7be4c00487bdcc'
4
- data.tar.gz: 27b26cb4c0b15e42724b97be4d77df4487479684a7e60a0605385370eb5eba45
3
+ metadata.gz: 2f072cce5e865d662597df89db26a0ad9fce1ceed1458c1c9ca8a40125d44fb6
4
+ data.tar.gz: 82f22f143b6010841cd1078d2f5e926968bc6be0f6b4ccd0f97b5b8b36e83a3b
5
5
  SHA512:
6
- metadata.gz: a6145972b5042a8c8d93be494ffbf300e51ee3e0490b6caa240fee03a85384ba31e1cd9e61ea540d668026ff0a5f2089ffeb20ab5139c1bc7cd802f0fb9be828
7
- data.tar.gz: d7d50e11a221b906ed746ed3087c73e692c967f25abe0559c9d9a035cd4afd75df447353083be94f0e5f628b9cbbf7421f3c5a6514286be8bd88cc1502c1d901
6
+ metadata.gz: fc7863e1530a609729b92d7df0ad2f3d4515398ba4bf0f755100b077b393c746c36303f29dfe462dedc8d585095fd26ecb4e73b8c09eeb3915879e52b4225b55
7
+ data.tar.gz: c27d5699d06c1c86dc611a9537c06b64b8fc1a216f7d060c483407b7075739ad70fa32df0b05f85bdca6d4838095693119ff8b2791d62bff07a3541698f1a225
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/rxfreadwrite.rb CHANGED
@@ -15,6 +15,7 @@ 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
 
@@ -39,8 +40,10 @@ module RXFReadWriteModule
39
40
 
40
41
  end
41
42
 
43
+ def FileX.exists?(s) RXFReadWrite.exists?(s) end
42
44
  def FileX.mkdir(s) RXFReadWrite.mkdir(s) end
43
45
  def FileX.mkdir_p(s) RXFReadWrite.mkdir_p(s) end
46
+ def FileX.pwd() RXFReadWrite.pwd() end
44
47
  def FileX.rm(s) RXFReadWrite.rm(s) end
45
48
 
46
49
  def FileX.rm_r(s, force: false)
@@ -65,33 +68,74 @@ end
65
68
  class RXFReadWrite < RXFReader
66
69
  using ColouredText
67
70
 
71
+ @@fs = :local
72
+
73
+ # identifies the working file system
74
+ def self.fs()
75
+ @@fs
76
+ end
68
77
 
69
78
  def self.chdir(x)
70
79
 
71
- # 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.
72
81
  # Allowing us to use relative paths with FileX operations instead
73
82
  # of explicitly stating the path each time. e.g. touch 'foo.txt'
74
83
  #
75
84
 
76
85
  if x[/^file:\/\//] or File.exists?(File.dirname(x)) then
77
86
 
78
- @fs = :local
87
+ @@fs = :local
79
88
  FileUtils.chdir x
80
89
 
81
90
  elsif x[/^dfs:\/\//]
82
91
 
83
92
  host = x[/(?<=dfs:\/\/)[^\/]+/]
84
- @fs = 'dfs://' + host
93
+ @@fs = 'dfs://' + host
85
94
  DfsFile.chdir x
86
95
 
87
96
  end
88
97
 
89
98
  end
90
99
 
100
+ def self.exists?(filename)
101
+ puts 'inside readwrite exists?'
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
+
91
127
  def self.glob(s)
92
128
 
93
129
  if s[/^dfs:\/\//] then
94
- DfsFile.glob(s)
130
+
131
+ basepath = s[/^(dfs:\/\/[^\/]+)/,1]
132
+ pos = s.length - basepath.length
133
+
134
+ DfsFile.glob(s).map do |x|
135
+ pos2 = x =~ /#{s[pos..-1]}/
136
+ basepath + x[pos2..-1]
137
+ end
138
+
95
139
  else
96
140
  Dir.glob(s)
97
141
  end
@@ -118,6 +162,10 @@ class RXFReadWrite < RXFReader
118
162
 
119
163
  end
120
164
 
165
+ def self.pwd()
166
+ DfsFile.pwd
167
+ end
168
+
121
169
  def self.rm(filename)
122
170
 
123
171
  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.3
4
+ version: 0.2.6
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-23 00:00:00.000000000 Z
38
+ date: 2022-04-11 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rxfreader
@@ -43,20 +43,20 @@ dependencies:
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0.2'
46
+ version: '0.3'
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 0.2.1
49
+ version: 0.3.3
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: '0.2'
56
+ version: '0.3'
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 0.2.1
59
+ version: 0.3.3
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: drb_fileclient-readwrite
62
62
  requirement: !ruby/object:Gem::Requirement
@@ -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.6
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.6
80
80
  description:
81
81
  email: digital.robertson@gmail.com
82
82
  executables: []
metadata.gz.sig CHANGED
Binary file