drb_fileclient-readwrite 0.1.0 → 0.1.3

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: 3e4060c863053e5bbc2fcbdb93448e88a9fcc456aca86d449e292a1f6eafed80
4
- data.tar.gz: 7f9bc1de7c42157df9317cebbaf7d25dc84e89fa2d99a839dc722c2d4ffbac64
3
+ metadata.gz: b75b32f3dacb08f9e07f4e372e8fdefdd593f5091c79a9eea168d92d75e859d4
4
+ data.tar.gz: fa8f294001ea716daeacac43a9c27ecbd66b30ad9bbb4ecd53968c9eeb8eaebd
5
5
  SHA512:
6
- metadata.gz: 00c5e0522c6229a0704e0919624b124d2ac23083559ac87e2902b43fa01a0aeb43ee5fb6e0641294d076b7a3ac7f312ce42a4244d87e8f256999ef9d663e41e1
7
- data.tar.gz: e53dea186b47578a7e2a047dc4a65d574d5d7c62e85561fe557e6b3ff7f4853eafc66f47dd5de0c4b895955112acd9d7fa76bb12ffcb02481cb13060357a3ab9
6
+ metadata.gz: b935abfca5cb54d65bc2fecf8fc4545b6e1c185276d44c9fe517d798b675cd34494aac872098d79710c6489cacd65eab186ef60f84506e1c470961b780694a60
7
+ data.tar.gz: 21edf6b3edc0a65fb5aee6252a3de64097bfa7d34265b3ceae181ceb0b2255f1e4dacaea425e307503d4906a501263299533298236299fb3377b13115dc2afac
checksums.yaml.gz.sig CHANGED
Binary file
@@ -8,6 +8,41 @@ require 'drb_fileclient-reader'
8
8
  class DRbFileClientReadWrite < DRbFileClientReader
9
9
  using ColouredText
10
10
 
11
+ def chdir(raw_path)
12
+
13
+ return Dir.chdir raw_path unless @directory or raw_path =~ /^dfs:\/\//
14
+
15
+ if raw_path[0] == '/' then
16
+ directory = raw_path[1..-1]
17
+ elsif raw_path =~ /^dfs:\/\//
18
+ @file, directory = parse_path(raw_path)
19
+ else
20
+ directory = File.join(@directory, raw_path)
21
+ end
22
+
23
+ if @file.exists? directory then
24
+ @directory = directory
25
+ else
26
+ 'No such file or directory'
27
+ end
28
+
29
+ end
30
+
31
+ def directory?(filename=@filename)
32
+
33
+ return File.directory? filename unless @directory or filename =~ /^dfs:\/\//
34
+
35
+ if filename =~ /^dfs:\/\// then
36
+ @file, filename2 = parse_path(filename)
37
+ else
38
+
39
+ filename2 = File.join(@directory, filename)
40
+ end
41
+
42
+ @file.directory?(filename2)
43
+
44
+ end
45
+
11
46
  def glob(s)
12
47
 
13
48
  if s =~ /^dfs:\/\// then
@@ -19,43 +54,43 @@ class DRbFileClientReadWrite < DRbFileClientReader
19
54
  @file.glob s2
20
55
 
21
56
  end
22
-
57
+
23
58
  def mkdir(name)
24
-
59
+
25
60
  return FileUtils.mkdir name unless @directory or name =~ /^dfs:\/\//
26
-
61
+
27
62
  @file, path = parse_path(name)
28
63
  @file.mkdir path
29
64
  end
30
-
65
+
31
66
  def mkdir_p(raw_path)
32
-
67
+
33
68
  unless @directory or raw_path =~ /^dfs:\/\// then
34
- return FileUtils.mkdir_p raw_path
35
- end
36
-
69
+ return FileUtils.mkdir_p raw_path
70
+ end
71
+
37
72
  if raw_path =~ /^dfs:\/\// then
38
73
  @file, filepath = parse_path(raw_path)
39
74
  else
40
75
  filepath = File.join(@directory, raw_path)
41
76
  end
42
-
77
+
43
78
  @file.mkdir_p filepath
44
79
  end
45
-
80
+
46
81
  def rm(path)
47
-
82
+
48
83
  return FileUtils.rm path unless @directory or path =~ /^dfs:\/\//
49
-
84
+
50
85
  if path =~ /^dfs:\/\// then
51
86
  @file, path2 = parse_path( path)
52
87
  else
53
88
  path2 = File.join(@directory, path)
54
89
  end
55
-
90
+
56
91
  @file.rm path2
57
-
58
- end
92
+
93
+ end
59
94
 
60
95
  def rm_r(path, force: false)
61
96
 
@@ -88,28 +123,43 @@ class DRbFileClientReadWrite < DRbFileClientReader
88
123
  @file.touch s2, mtime: mtime
89
124
 
90
125
  end
91
-
126
+
92
127
  def write(filename=@filename, s)
93
-
128
+
94
129
  return File.write filename, s unless @directory or filename =~ /^dfs:\/\//
95
-
130
+
96
131
  if filename =~ /^dfs:\/\// then
97
132
  @file, path = parse_path(filename)
98
133
  else
99
134
  path = File.join(@directory, filename)
100
135
  end
101
-
102
- @file.write path, s
103
-
136
+
137
+ @file.write path, s
138
+
104
139
  end
105
140
 
106
- end
141
+ end
142
+
143
+ def DfsFile.chdir(path)
144
+ DRbFileClientReadWrite.new.chdir(path)
145
+ end
146
+
147
+ def DfsFile.directory?(filename)
148
+ DRbFileClient.new.directory?(filename)
149
+ end
107
150
 
108
-
109
151
  def DfsFile.glob(s)
110
152
  DRbFileClientReadWrite.new.glob(s)
111
153
  end
112
154
 
155
+ def DfsFile.mkdir(filename)
156
+ DRbFileClientReadWrite.new.mkdir(filename)
157
+ end
158
+
159
+ def DfsFile.mkdir_p(filename)
160
+ DRbFileClientReadWrite.new.mkdir_p(filename)
161
+ end
162
+
113
163
  def DfsFile.rm(filename)
114
164
  DRbFileClientReadWrite.new.rm(filename)
115
165
  end
@@ -125,4 +175,3 @@ end
125
175
  def DfsFile.write(filename, s)
126
176
  DRbFileClientReadWrite.new.write(filename, s)
127
177
  end
128
-
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drb_fileclient-readwrite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  ILzVBTpjvSiaWCjFvxvVJFct97WGSbaR2jPvZ03xyAONtWdKkv2yceiyfAMaldSQ
36
36
  eftJvciSPh0DHzyI46OGIkLX
37
37
  -----END CERTIFICATE-----
38
- date: 2022-02-22 00:00:00.000000000 Z
38
+ date: 2022-02-23 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: drb_fileclient-reader
metadata.gz.sig CHANGED
Binary file