drb_fileclient-readwrite 0.1.0 → 0.1.1

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: 3e0f345936168e8e3b2cc92f3160b5bebdfaccec295d54bfb9168a7053487956
4
+ data.tar.gz: f58a10be3a0b86cfc7e473d97c891760caa0e0805db39bcf855e3e9e9858c669
5
5
  SHA512:
6
- metadata.gz: 00c5e0522c6229a0704e0919624b124d2ac23083559ac87e2902b43fa01a0aeb43ee5fb6e0641294d076b7a3ac7f312ce42a4244d87e8f256999ef9d663e41e1
7
- data.tar.gz: e53dea186b47578a7e2a047dc4a65d574d5d7c62e85561fe557e6b3ff7f4853eafc66f47dd5de0c4b895955112acd9d7fa76bb12ffcb02481cb13060357a3ab9
6
+ metadata.gz: 3ba4ce2c1df040c36bce549232eebde9fc70e40ef1d607c3243337f8c1b0dd457e2b4c67929265def1d05b2083d104877cffd3b384c8d1f65650618a233e799c
7
+ data.tar.gz: aacb4828d3cf6b2a6855fed502a3731234b0f5f81290ba58610c16dad26563af60bd1d6391fdf0062c2309f2ae6ade904a18606f6b1fd219dadf4b5dff3b3fa3
checksums.yaml.gz.sig CHANGED
Binary file
@@ -8,6 +8,26 @@ 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
+
11
31
  def glob(s)
12
32
 
13
33
  if s =~ /^dfs:\/\// then
@@ -19,43 +39,43 @@ class DRbFileClientReadWrite < DRbFileClientReader
19
39
  @file.glob s2
20
40
 
21
41
  end
22
-
42
+
23
43
  def mkdir(name)
24
-
44
+
25
45
  return FileUtils.mkdir name unless @directory or name =~ /^dfs:\/\//
26
-
46
+
27
47
  @file, path = parse_path(name)
28
48
  @file.mkdir path
29
49
  end
30
-
50
+
31
51
  def mkdir_p(raw_path)
32
-
52
+
33
53
  unless @directory or raw_path =~ /^dfs:\/\// then
34
- return FileUtils.mkdir_p raw_path
35
- end
36
-
54
+ return FileUtils.mkdir_p raw_path
55
+ end
56
+
37
57
  if raw_path =~ /^dfs:\/\// then
38
58
  @file, filepath = parse_path(raw_path)
39
59
  else
40
60
  filepath = File.join(@directory, raw_path)
41
61
  end
42
-
62
+
43
63
  @file.mkdir_p filepath
44
64
  end
45
-
65
+
46
66
  def rm(path)
47
-
67
+
48
68
  return FileUtils.rm path unless @directory or path =~ /^dfs:\/\//
49
-
69
+
50
70
  if path =~ /^dfs:\/\// then
51
71
  @file, path2 = parse_path( path)
52
72
  else
53
73
  path2 = File.join(@directory, path)
54
74
  end
55
-
75
+
56
76
  @file.rm path2
57
-
58
- end
77
+
78
+ end
59
79
 
60
80
  def rm_r(path, force: false)
61
81
 
@@ -88,24 +108,27 @@ class DRbFileClientReadWrite < DRbFileClientReader
88
108
  @file.touch s2, mtime: mtime
89
109
 
90
110
  end
91
-
111
+
92
112
  def write(filename=@filename, s)
93
-
113
+
94
114
  return File.write filename, s unless @directory or filename =~ /^dfs:\/\//
95
-
115
+
96
116
  if filename =~ /^dfs:\/\// then
97
117
  @file, path = parse_path(filename)
98
118
  else
99
119
  path = File.join(@directory, filename)
100
120
  end
101
-
102
- @file.write path, s
103
-
121
+
122
+ @file.write path, s
123
+
104
124
  end
105
125
 
106
- end
126
+ end
127
+
128
+ def DfsFile.chdir(path)
129
+ DRbFileClientReadWrite.new.chdir(path)
130
+ end
107
131
 
108
-
109
132
  def DfsFile.glob(s)
110
133
  DRbFileClientReadWrite.new.glob(s)
111
134
  end
@@ -125,4 +148,3 @@ end
125
148
  def DfsFile.write(filename, s)
126
149
  DRbFileClientReadWrite.new.write(filename, s)
127
150
  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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file