drb_fileclient 0.5.2 → 0.6.0

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: 4bb18a2fe46c0d601bbfffee7c7cbd1ebed33586abe3241ca821fbbb2ac680c1
4
- data.tar.gz: e8812a2688db89ff2ecf0bd8d7ca8161cea0fe005592146239d66ae9c0c6bf69
3
+ metadata.gz: 9ec57e89e0d0588cc4ab855a9fb3047a950e57b53497b585e658593668660146
4
+ data.tar.gz: e26f60db52598b80752b173d08d1113bd1ffdfd155b6d5a9bdb3bbf835346b76
5
5
  SHA512:
6
- metadata.gz: 9cbb3e0ed60f00426e83f31f10fd0c2962ffa2da2c1ea5043ee0f5c7cc98d1f9f53e2a17a8598e4e5a616e78c6a6d3bc052b20657d112c8b8d04d61bc115ae9b
7
- data.tar.gz: a6847f771d944cb5c2c0ac904b8bc889b4ed2cca762489fa126b9d3cb84ed6dd5b6250d4aa3c9e296e469cd5ce4ca6cb7891ded0bb4099933585b5ad2833220a
6
+ metadata.gz: d2ceaa76749231d9a4b2c5670ba91d70db4c395c52f41d0871a51bc6430a2259dd426496fc0bca426154937174cfe088179ffbcd18500590936b556f25d2a73b
7
+ data.tar.gz: 6d6f2121e40ac1a2c536421745d1f038b7cd03e2ab9a83cd0489b2d7e7ebbe59469160705a4bdb5800c6454e7690233c731a1b5b1786f0beea1008e21cc3579f
checksums.yaml.gz.sig CHANGED
Binary file
@@ -11,89 +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
-
64
+
53
65
  if raw_path =~ /^dfs:\/\// then
54
-
66
+
55
67
  if @debug then
56
68
  puts ('raw_path: ' + raw_path.inspect).debug
57
69
  puts ('raw_path2: ' + raw_path2.inspect).debug
58
70
  end
59
-
71
+
60
72
  if raw_path[/^dfs:\/\/([^\/]+)/] == raw_path2[/^dfs:\/\/([^\/]+)/] then
61
-
73
+
62
74
  _, path = parse_path(raw_path)
63
75
  @file, path2 = parse_path(raw_path2)
64
76
  @file.cp path, path2
65
-
66
- else
67
-
77
+
78
+ elsif raw_path2[/^dfs:\/\//]
79
+
68
80
  @file, path = parse_path(raw_path)
69
81
  file2, path2 = parse_path(raw_path2)
82
+ puts ('path: ' + path.inspect).debug if @debug
83
+ puts ('path2: ' + path.inspect).debug if @debug
70
84
  content = @file.read path
71
-
85
+
72
86
  file2.write path2, content
73
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
+
74
98
  end
75
-
99
+
76
100
  elsif raw_path2 =~ /dfs:\/\// then
77
-
101
+
78
102
  puts 'option2'.info if @debug
79
-
103
+
80
104
  file2, path2 = parse_path(raw_path2)
81
105
  puts ('path2: ' + path2.inspect).debug if @debug
82
106
  file2.write path2, File.read(raw_path)
83
-
107
+
84
108
  else
85
-
109
+
86
110
  puts 'option3'.info if @debug
87
111
  FileUtils.cp raw_path, raw_path2
88
-
89
- end
90
-
91
- end
92
-
93
- def directory?(filename=@filename)
94
-
112
+
113
+ end
114
+
115
+ end
116
+
117
+ def directory?(filename=@filename)
118
+
95
119
  return File.directory? filename unless @directory or filename =~ /^dfs:\/\//
96
-
120
+
97
121
  if filename =~ /^dfs:\/\// then
98
122
  @file, filename2 = parse_path(filename)
99
123
  else
@@ -102,13 +126,13 @@ class DRbFileClient
102
126
  end
103
127
 
104
128
  @file.directory?(filename2)
105
-
106
- end
107
-
108
- def exists?(filename=@filename)
109
-
129
+
130
+ end
131
+
132
+ def exists?(filename=@filename)
133
+
110
134
  return File.exists? filename unless @directory or filename =~ /^dfs:\/\//
111
-
135
+
112
136
  if filename =~ /^dfs:\/\// then
113
137
  @file, filename2 = parse_path(filename)
114
138
  else
@@ -117,136 +141,136 @@ class DRbFileClient
117
141
  end
118
142
 
119
143
  @file.exists?(filename2)
120
-
144
+
121
145
  end
122
-
146
+
123
147
  alias exist? exists?
124
-
148
+
125
149
  def ls(raw_path)
126
-
150
+
127
151
  return Dir[raw_path] unless @directory or raw_path =~ /^dfs:\/\//
128
-
152
+
129
153
  if raw_path[0] == '/' then
130
154
  path = raw_path[1..-1]
131
155
  elsif raw_path =~ /^dfs:\/\//
132
156
  @file, path = parse_path(raw_path)
133
- else
157
+ else
134
158
  path = File.join(@directory, raw_path)
135
- end
136
-
159
+ end
160
+
137
161
  @file.ls path
138
-
139
- end
140
-
162
+
163
+ end
164
+
141
165
  def mkdir(name)
142
-
166
+
143
167
  return FileUtils.mkdir name unless @directory or name =~ /^dfs:\/\//
144
-
168
+
145
169
  @file, path = parse_path(name)
146
170
  @file.mkdir path
147
171
  end
148
-
172
+
149
173
  def mkdir_p(raw_path)
150
-
174
+
151
175
  unless @directory or raw_path =~ /^dfs:\/\// then
152
- return FileUtils.mkdir_p raw_path
153
- end
154
-
176
+ return FileUtils.mkdir_p raw_path
177
+ end
178
+
155
179
  if raw_path =~ /^dfs:\/\// then
156
180
  @file, filepath = parse_path(raw_path)
157
181
  else
158
182
  filepath = File.join(@directory, raw_path)
159
183
  end
160
-
184
+
161
185
  @file.mkdir_p filepath
162
- end
163
-
186
+ end
187
+
164
188
  def mv(raw_path, raw_path2)
165
-
189
+
166
190
  unless @directory or raw_path =~ /^dfs:\/\// then
167
- return FileUtils.mv raw_path, raw_path2
191
+ return FileUtils.mv raw_path, raw_path2
168
192
  end
169
-
193
+
170
194
  if raw_path =~ /^dfs:\/\// then
171
195
  _, path = parse_path(raw_path)
172
196
  else
173
197
  path = File.join(@directory, raw_path)
174
198
  end
175
-
199
+
176
200
  if raw_path2 =~ /^dfs:\/\// then
177
201
  _, path2 = parse_path(raw_path2)
178
202
  else
179
203
  path2 = File.join(@directory, raw_path2)
180
204
  end
181
-
205
+
182
206
  @file.mv path, path2
183
- end
184
-
207
+ end
208
+
185
209
  def pwd()
186
-
210
+
187
211
  return Dir.pwd unless @directory
188
-
212
+
189
213
  '/' + @directory if @file
190
-
191
- end
214
+
215
+ end
192
216
 
193
217
  def read(filename=@filename)
194
-
218
+
195
219
  return File.read filename, s unless @directory or filename =~ /^dfs:\/\//
196
-
220
+
197
221
  if filename =~ /^dfs:\/\// then
198
222
  @file, path = parse_path(filename)
199
223
  else
200
224
  path = File.join(@directory, filename)
201
225
  end
202
-
226
+
203
227
  @file.read path
204
228
  end
205
-
229
+
206
230
  def rm(path)
207
-
231
+
208
232
  return FileUtils.rm path unless @directory or path =~ /^dfs:\/\//
209
-
233
+
210
234
  if path =~ /^dfs:\/\// then
211
235
  @file, path2 = parse_path( path)
212
236
  else
213
237
  path2 = File.join(@directory, path)
214
238
  end
215
-
239
+
216
240
  @file.rm path2
217
-
218
- end
219
-
241
+
242
+ end
243
+
220
244
  def write(filename=@filename, s)
221
-
245
+
222
246
  return File.write filename, s unless @directory or filename =~ /^dfs:\/\//
223
-
247
+
224
248
  if filename =~ /^dfs:\/\// then
225
249
  @file, path = parse_path(filename)
226
250
  else
227
251
  path = File.join(@directory, filename)
228
252
  end
229
-
230
- @file.write path, s
231
-
253
+
254
+ @file.write path, s
255
+
232
256
  end
233
-
257
+
234
258
  def zip(filename_zip, a)
235
-
259
+
236
260
  puts '@directory: ' + @directory.inspect if @debug
237
-
261
+
238
262
  unless @directory or filename_zip =~ /^dfs:\/\// then
239
-
263
+
240
264
  Zip::File.open(zipfile_zip, Zip::File::CREATE) do |x|
241
265
 
242
- a.each do |filename, buffer|
266
+ a.each do |filename, buffer|
243
267
  x.get_output_stream(filename) {|os| os.write buffer }
244
268
  end
245
269
 
246
270
  end
247
-
271
+
248
272
  end
249
-
273
+
250
274
  if filename_zip =~ /^dfs:\/\// then
251
275
  @file, filepath = parse_path(filename_zip)
252
276
  else
@@ -254,16 +278,16 @@ class DRbFileClient
254
278
  end
255
279
 
256
280
  @file.zip filepath, a
257
-
281
+
258
282
  end
259
283
 
260
284
  private
261
-
285
+
262
286
  def parse_path(filename)
263
287
 
264
288
  host = filename[/(?<=^dfs:\/\/)[^\/:]+/]
265
289
  @host = host if host
266
-
290
+
267
291
  port = filename[/(?<=^dfs:\/\/)[^:]+:(\d+)/,1] || '61010'
268
292
 
269
293
  file_server = DRbObject.new nil, "druby://#{host || @host}:#{port}"
@@ -271,24 +295,25 @@ class DRbFileClient
271
295
 
272
296
  end
273
297
 
274
- end
298
+ end
275
299
 
276
300
  class DfsFile
277
-
301
+
278
302
  @client = DRbFileClient.new
279
-
280
- def self.directory?(filename) @client.directory?(filename) end
281
- def self.exists?(filename) @client.exists?(filename) end
282
- def self.chdir(path) @client.chdir(path) end
283
- def self.cp(path, path2) @client.cp(path, path2) end
284
- def self.ls(path) @client.ls(path) end
285
- def self.mkdir(name) @client.mkdir(name) end
286
- def self.mkdir_p(path) @client.mkdir_p(path) end
287
- def self.mv(path, path2) @client.mv(path, path2) end
288
- def self.pwd() @client.pwd() end
303
+
304
+ def self.directory?(filename) @client.directory?(filename) end
305
+ def self.exists?(filename) @client.exists?(filename) end
306
+ def self.chdir(path) @client.chdir(path) end
307
+ def self.chmod(num, filename) @client.chmod(num, filename) end
308
+ def self.cp(path, path2) @client.cp(path, path2) end
309
+ def self.ls(path) @client.ls(path) end
310
+ def self.mkdir(name) @client.mkdir(name) end
311
+ def self.mkdir_p(path) @client.mkdir_p(path) end
312
+ def self.mv(path, path2) @client.mv(path, path2) end
313
+ def self.pwd() @client.pwd() end
289
314
  def self.read(filename) @client.read(filename) end
290
- def self.rm(filename) @client.rm(filename) end
315
+ def self.rm(filename) @client.rm(filename) end
291
316
  def self.write(filename, s) @client.write(filename, s) end
292
317
  def self.zip(filename, a) @client.zip(filename, a) end
293
-
318
+
294
319
  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.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -11,31 +11,31 @@ cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
13
  MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTkwMjE4MTMyMjE4WhcN
15
- MjAwMjE4MTMyMjE4WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
- cnRzb24vREM9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U6kqXV8nvKfwDTVov3W49/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-29 00:00:00.000000000 Z
38
+ date: 2022-01-17 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