drb_fileclient 0.5.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e08a226c5a41610e9293150aa3ccc9077db21e19de9444bef56b23e08ca6c90
4
- data.tar.gz: 8cba9bfa3319e7809c26063adb85dc2637d009846e4132bc4bc689bdc4d407b0
3
+ metadata.gz: e1f0a270e1365dcd6dd42f986f4527ef05f0ecd34ade395acd12355cb8078362
4
+ data.tar.gz: b35293345434cc1a18e9ad92d782b8ef18e199ebe6578ea6752010783c349d9a
5
5
  SHA512:
6
- metadata.gz: c7a914a369294bd5ad7c7cc6034a6a2b332fc9abae2801d8359c605d015edead7677b97f4ae7f29667470dc6cc9ec0a44eef99714bcee4dd4c61aa5017177879
7
- data.tar.gz: b1e65e13442dd353acdb30dae87f09fa8fecf71d5b40ad894e19e83c49e79703b1dc63cb748b2b0b6c613756f75a5adfc9c7d1b3f5dc1b50e358f5b0088d1240
6
+ metadata.gz: 6c45a27577fa8a15a8224f1b21d349bfe26c70dd79a6fd824aebd22e591a762e3a721a0eda4e9301dced3a93fb039a3b8798aa8ea7883e0ce2dcc808c2ff4501
7
+ data.tar.gz: 9321992f907fcdceb1022fdb8cfd8b2783b7770cdcf0329d8f5d76da437283043bbf8e7c95e60c45d348d65657fa83a88ed52c36e821276337a60fa5c1760722
checksums.yaml.gz.sig CHANGED
Binary file
@@ -11,85 +11,113 @@ class DRbFileClient
11
11
  using ColouredText
12
12
 
13
13
  def initialize(location=nil, host: nil, port: '61010', debug: false)
14
-
14
+
15
15
  @debug = debug
16
-
16
+
17
17
  if location then
18
-
18
+
19
19
  host = location[/(?<=^dfs:\/\/)[^\/:]+/]
20
20
  port = location[/(?<=^dfs:\/\/)[^:]+:(\d+)/,1] || '61010'
21
21
  @directory = location[/(?<=^dfs:\/\/)[^\/]+\/(.*)/,1]
22
-
22
+
23
23
  end
24
-
24
+
25
25
  DRb.start_service
26
-
26
+
27
27
  end
28
-
28
+
29
29
  def chdir(raw_path)
30
-
30
+
31
31
  return Dir.chdir raw_path unless @directory or raw_path =~ /^dfs:\/\//
32
-
32
+
33
33
  if raw_path[0] == '/' then
34
34
  directory = raw_path[1..-1]
35
35
  elsif raw_path =~ /^dfs:\/\//
36
36
  @file, directory = parse_path(raw_path)
37
- else
37
+ else
38
38
  directory = File.join(@directory, raw_path)
39
- end
40
-
39
+ end
40
+
41
41
  if @file.exists? directory then
42
42
  @directory = directory
43
43
  else
44
44
  'No such file or directory'
45
45
  end
46
-
46
+
47
+ end
48
+
49
+ def chmod(permissions, raw_path)
50
+
51
+ if raw_path =~ /^dfs:\/\// then
52
+
53
+ @file, path = parse_path(raw_path)
54
+ @file.chmod permissions, path
55
+
56
+ else
57
+ return FileUtils.chmod(permissions, raw_path)
58
+ end
47
59
  end
48
60
 
49
61
  def cp(raw_path, raw_path2)
50
-
62
+
51
63
  puts 'inside cp'.info if @debug
52
-
53
- unless @directory or raw_path =~ /^dfs:\/\// then
54
- return FileUtils.cp raw_path, raw_path2
55
- end
56
-
64
+
57
65
  if raw_path =~ /^dfs:\/\// then
58
-
66
+
59
67
  if @debug then
60
68
  puts ('raw_path: ' + raw_path.inspect).debug
61
69
  puts ('raw_path2: ' + raw_path2.inspect).debug
62
70
  end
63
-
71
+
64
72
  if raw_path[/^dfs:\/\/([^\/]+)/] == raw_path2[/^dfs:\/\/([^\/]+)/] then
65
-
73
+
66
74
  _, path = parse_path(raw_path)
67
75
  @file, path2 = parse_path(raw_path2)
68
76
  @file.cp path, path2
69
-
70
- else
71
-
77
+
78
+ elsif raw_path2[/^dfs:\/\//]
79
+
72
80
  @file, path = parse_path(raw_path)
73
81
  file2, path2 = parse_path(raw_path2)
82
+ puts ('path: ' + path.inspect).debug if @debug
83
+ puts ('path2: ' + path.inspect).debug if @debug
74
84
  content = @file.read path
75
-
85
+
76
86
  file2.write path2, content
77
87
 
88
+ else
89
+
90
+ @file, path = parse_path(raw_path)
91
+ #file2, path2 = parse_path(raw_path2)
92
+ puts ('path: ' + path.inspect).debug if @debug
93
+ puts ('path2: ' + path2.inspect).debug if @debug
94
+ content = @file.read path
95
+
96
+ File.write raw_path2, content
97
+
78
98
  end
79
-
99
+
100
+ elsif raw_path2 =~ /dfs:\/\// then
101
+
102
+ puts 'option2'.info if @debug
103
+
104
+ file2, path2 = parse_path(raw_path2)
105
+ puts ('path2: ' + path2.inspect).debug if @debug
106
+ file2.write path2, File.read(raw_path)
107
+
80
108
  else
81
-
82
- @file.cp File.join(@directory, raw_path),
83
- File.join(@directory, raw_path2)
84
-
85
- end
86
-
87
- end
88
-
89
- def directory?(filename=@filename)
90
-
109
+
110
+ puts 'option3'.info if @debug
111
+ FileUtils.cp raw_path, raw_path2
112
+
113
+ end
114
+
115
+ end
116
+
117
+ def directory?(filename=@filename)
118
+
91
119
  return File.directory? filename unless @directory or filename =~ /^dfs:\/\//
92
-
120
+
93
121
  if filename =~ /^dfs:\/\// then
94
122
  @file, filename2 = parse_path(filename)
95
123
  else
@@ -98,13 +126,13 @@ class DRbFileClient
98
126
  end
99
127
 
100
128
  @file.directory?(filename2)
101
-
102
- end
103
-
104
- def exists?(filename=@filename)
105
-
129
+
130
+ end
131
+
132
+ def exists?(filename=@filename)
133
+
106
134
  return File.exists? filename unless @directory or filename =~ /^dfs:\/\//
107
-
135
+
108
136
  if filename =~ /^dfs:\/\// then
109
137
  @file, filename2 = parse_path(filename)
110
138
  else
@@ -113,136 +141,148 @@ class DRbFileClient
113
141
  end
114
142
 
115
143
  @file.exists?(filename2)
116
-
144
+
117
145
  end
118
-
146
+
119
147
  alias exist? exists?
120
-
148
+
149
+ def glob(s)
150
+
151
+ if s =~ /^dfs:\/\// then
152
+ @file, s2 = parse_path(s)
153
+ else
154
+ s2 = File.join(@directory, s)
155
+ end
156
+
157
+ @file.glob s2
158
+
159
+ end
160
+
121
161
  def ls(raw_path)
122
-
162
+
123
163
  return Dir[raw_path] unless @directory or raw_path =~ /^dfs:\/\//
124
-
164
+
125
165
  if raw_path[0] == '/' then
126
166
  path = raw_path[1..-1]
127
167
  elsif raw_path =~ /^dfs:\/\//
128
168
  @file, path = parse_path(raw_path)
129
- else
169
+ else
130
170
  path = File.join(@directory, raw_path)
131
- end
132
-
171
+ end
172
+
133
173
  @file.ls path
134
-
135
- end
136
-
174
+
175
+ end
176
+
137
177
  def mkdir(name)
138
-
178
+
139
179
  return FileUtils.mkdir name unless @directory or name =~ /^dfs:\/\//
140
-
180
+
141
181
  @file, path = parse_path(name)
142
182
  @file.mkdir path
143
183
  end
144
-
184
+
145
185
  def mkdir_p(raw_path)
146
-
186
+
147
187
  unless @directory or raw_path =~ /^dfs:\/\// then
148
- return FileUtils.mkdir_p raw_path
149
- end
150
-
188
+ return FileUtils.mkdir_p raw_path
189
+ end
190
+
151
191
  if raw_path =~ /^dfs:\/\// then
152
192
  @file, filepath = parse_path(raw_path)
153
193
  else
154
194
  filepath = File.join(@directory, raw_path)
155
195
  end
156
-
196
+
157
197
  @file.mkdir_p filepath
158
- end
159
-
198
+ end
199
+
160
200
  def mv(raw_path, raw_path2)
161
-
201
+
162
202
  unless @directory or raw_path =~ /^dfs:\/\// then
163
- return FileUtils.mv raw_path, raw_path2
203
+ return FileUtils.mv raw_path, raw_path2
164
204
  end
165
-
205
+
166
206
  if raw_path =~ /^dfs:\/\// then
167
207
  _, path = parse_path(raw_path)
168
208
  else
169
209
  path = File.join(@directory, raw_path)
170
210
  end
171
-
211
+
172
212
  if raw_path2 =~ /^dfs:\/\// then
173
213
  _, path2 = parse_path(raw_path2)
174
214
  else
175
215
  path2 = File.join(@directory, raw_path2)
176
216
  end
177
-
217
+
178
218
  @file.mv path, path2
179
- end
180
-
219
+ end
220
+
181
221
  def pwd()
182
-
222
+
183
223
  return Dir.pwd unless @directory
184
-
224
+
185
225
  '/' + @directory if @file
186
-
187
- end
226
+
227
+ end
188
228
 
189
229
  def read(filename=@filename)
190
-
230
+
191
231
  return File.read filename, s unless @directory or filename =~ /^dfs:\/\//
192
-
232
+
193
233
  if filename =~ /^dfs:\/\// then
194
234
  @file, path = parse_path(filename)
195
235
  else
196
236
  path = File.join(@directory, filename)
197
237
  end
198
-
238
+
199
239
  @file.read path
200
240
  end
201
-
241
+
202
242
  def rm(path)
203
-
243
+
204
244
  return FileUtils.rm path unless @directory or path =~ /^dfs:\/\//
205
-
245
+
206
246
  if path =~ /^dfs:\/\// then
207
247
  @file, path2 = parse_path( path)
208
248
  else
209
249
  path2 = File.join(@directory, path)
210
250
  end
211
-
251
+
212
252
  @file.rm path2
213
-
214
- end
215
-
253
+
254
+ end
255
+
216
256
  def write(filename=@filename, s)
217
-
257
+
218
258
  return File.write filename, s unless @directory or filename =~ /^dfs:\/\//
219
-
259
+
220
260
  if filename =~ /^dfs:\/\// then
221
261
  @file, path = parse_path(filename)
222
262
  else
223
263
  path = File.join(@directory, filename)
224
264
  end
225
-
226
- @file.write path, s
227
-
265
+
266
+ @file.write path, s
267
+
228
268
  end
229
-
269
+
230
270
  def zip(filename_zip, a)
231
-
271
+
232
272
  puts '@directory: ' + @directory.inspect if @debug
233
-
273
+
234
274
  unless @directory or filename_zip =~ /^dfs:\/\// then
235
-
275
+
236
276
  Zip::File.open(zipfile_zip, Zip::File::CREATE) do |x|
237
277
 
238
- a.each do |filename, buffer|
278
+ a.each do |filename, buffer|
239
279
  x.get_output_stream(filename) {|os| os.write buffer }
240
280
  end
241
281
 
242
282
  end
243
-
283
+
244
284
  end
245
-
285
+
246
286
  if filename_zip =~ /^dfs:\/\// then
247
287
  @file, filepath = parse_path(filename_zip)
248
288
  else
@@ -250,16 +290,16 @@ class DRbFileClient
250
290
  end
251
291
 
252
292
  @file.zip filepath, a
253
-
293
+
254
294
  end
255
295
 
256
296
  private
257
-
297
+
258
298
  def parse_path(filename)
259
299
 
260
300
  host = filename[/(?<=^dfs:\/\/)[^\/:]+/]
261
301
  @host = host if host
262
-
302
+
263
303
  port = filename[/(?<=^dfs:\/\/)[^:]+:(\d+)/,1] || '61010'
264
304
 
265
305
  file_server = DRbObject.new nil, "druby://#{host || @host}:#{port}"
@@ -267,24 +307,26 @@ class DRbFileClient
267
307
 
268
308
  end
269
309
 
270
- end
310
+ end
271
311
 
272
312
  class DfsFile
273
-
313
+
274
314
  @client = DRbFileClient.new
275
-
276
- def self.directory?(filename) @client.directory?(filename) end
277
- def self.exists?(filename) @client.exists?(filename) end
278
- def self.chdir(path) @client.chdir(path) end
279
- def self.cp(path, path2) @client.cp(path, path2) end
280
- def self.ls(path) @client.ls(path) end
281
- def self.mkdir(name) @client.mkdir(name) end
282
- def self.mkdir_p(path) @client.mkdir_p(path) end
283
- def self.mv(path, path2) @client.mv(path, path2) end
284
- def self.pwd() @client.pwd() end
315
+
316
+ def self.directory?(filename) @client.directory?(filename) end
317
+ def self.exists?(filename) @client.exists?(filename) end
318
+ def self.chdir(path) @client.chdir(path) end
319
+ def self.chmod(num, filename) @client.chmod(num, filename) end
320
+ def self.cp(path, path2) @client.cp(path, path2) end
321
+ def self.glob(s) @client.glob(s) end
322
+ def self.ls(path) @client.ls(path) end
323
+ def self.mkdir(name) @client.mkdir(name) end
324
+ def self.mkdir_p(path) @client.mkdir_p(path) end
325
+ def self.mv(path, path2) @client.mv(path, path2) end
326
+ def self.pwd() @client.pwd() end
285
327
  def self.read(filename) @client.read(filename) end
286
- def self.rm(filename) @client.rm(filename) end
328
+ def self.rm(filename) @client.rm(filename) end
287
329
  def self.write(filename, s) @client.write(filename, s) end
288
330
  def self.zip(filename, a) @client.zip(filename, a) end
289
-
331
+
290
332
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drb_fileclient
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -11,31 +11,31 @@ cert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KkuGpHpGu3Pm6sSsoY53RSdOIrUbATq7d9R+nDC
31
- IuHsUhqWu0JHuIcJAt2nFdNhpAM1xI8xmpBB/ZAPmuBgCIGACRUj9zDwCcvQTexg
32
- VpPvUCkhqF2HslhSBvMt0uWior6rx2NF1XjLcaNZ3D/RYODI+c8bzGuG/kiy49T1
33
- GiV9YurS5UW2Pbpy6GnkvDWNOGwV3SuIeVzo0kcGh/O4zRzC0UHWXzfMshQZq+vj
34
- jYmP2hJqU6kqXV8nvKfwDTVov3W49/Nx2NgvhKFga4gMlwRryZCYpWSNJ/2PnKke
35
- Q2NfvYKLI+E2SiA6gvWccHs5PVlVg/BMshm3jnuqHGeuzxtSivRoTcRKfedcs6CL
36
- NlXQCltmwWchk+xRD5gmICCy
28
+ BgkqhkiG9w0BAQsFAAOCAYEAoKkYN6WZurnK5O9oEqj+ugBPm9Gh5I75oLQCUyIw
29
+ sHsBR0clXN+Lta4plvzonH3xKx9ddzX+KWZS0tHxcm072zV6sKEKFYcQiUzQyTwc
30
+ Hyfp6E3950UwJi3KO4o3RPZC1U5/fOvnuZgVAbGqcJQf/t/SfD5M3pBymbK2QszM
31
+ fG8W6bQ2kbkv7JbD3B0Sjb1eCDy3/s/eMmbjl1Wg48al1LWQDUMGAmadqLrnFEs0
32
+ 3arfhEofWPCcGw0u45L6omLCU8VWJFupyvQKDwEmkVAD9MMbnUuIsMWMkW4qFwl4
33
+ 0xIrbpFWN8ZHrlc29DrrNH9IKcgsI6Fmc4jOxrqnlushuHG3uthM1hGChljvOMaB
34
+ rs55jJl1U2ICzKSTmV28mLdtigYtJHOzuXrdZSLICM9FSvRkBWOnBz2YaDCA2NXP
35
+ FGcgjmmz5fOIqq2sBxk6JW1yo2G43yIUzymWOYKT2Jh6RR0Gg3z66wWwYpFpx8yR
36
+ 00JTBNVAgW+s2sLpeBtyMDbb
37
37
  -----END CERTIFICATE-----
38
- date: 2019-04-28 00:00:00.000000000 Z
38
+ date: 2022-01-18 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: zip
@@ -61,24 +61,24 @@ dependencies:
61
61
  name: c32
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements:
64
- - - "~>"
65
- - !ruby/object:Gem::Version
66
- version: '0.1'
67
64
  - - ">="
68
65
  - !ruby/object:Gem::Version
69
- version: 0.1.2
66
+ version: 0.3.0
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '0.3'
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - "~>"
75
- - !ruby/object:Gem::Version
76
- version: '0.1'
77
74
  - - ">="
78
75
  - !ruby/object:Gem::Version
79
- version: 0.1.2
76
+ version: 0.3.0
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '0.3'
80
80
  description:
81
- email: james@jamesrobertson.eu
81
+ email: digital.robertson@gmail.com
82
82
  executables: []
83
83
  extensions: []
84
84
  extra_rdoc_files: []
@@ -103,7 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  requirements: []
106
- rubygems_version: 3.0.1
106
+ rubyforge_project:
107
+ rubygems_version: 2.7.10
107
108
  signing_key:
108
109
  specification_version: 4
109
110
  summary: Reads or writes files from a remote DRb server. Simple as DfsFile.read or
metadata.gz.sig CHANGED
Binary file