drb_fileclient 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/drb_fileclient.rb +82 -27
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b2a277d060d30cdf5174b0d76f89a0cec60e6ff399f183165022b584e4ec1fbe
|
4
|
+
data.tar.gz: 4393a67153df3e323ae422f6d9acac44aed1cc6f32a9037571fb0a735191cd49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16593a3b669406cb2b2ee8f6d6ed53240110ef8fc51ee7cd0ecbc88f079b6273b77901add42949d8ec9aa60d5975fa3d6140bec222d03e331a948cdc3f0a5991
|
7
|
+
data.tar.gz: 33b4810bfbbb01403fd8153ea9af854e806f2196822b27a687230b1861c52c59073f67ff8593ff966e90283f520df6710b655f49fac7370ab77673bc58ed8fe4
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/drb_fileclient.rb
CHANGED
@@ -13,72 +13,127 @@ class DRbFileClient
|
|
13
13
|
|
14
14
|
host = location[/(?<=^dfs:\/\/)[^\/:]+/]
|
15
15
|
port = location[/(?<=^dfs:\/\/)[^:]+:(\d+)/,1] || '61010'
|
16
|
-
@
|
16
|
+
@directory = location[/(?<=^dfs:\/\/)[^\/]+\/(.*)/,1]
|
17
17
|
|
18
18
|
end
|
19
19
|
|
20
20
|
DRb.start_service
|
21
|
-
|
22
|
-
# attach to the DRb server via a URI given on the command line
|
23
|
-
@file = DRbObject.new nil, "druby://#{host}:#{port}" if host
|
24
21
|
|
25
22
|
end
|
26
23
|
|
24
|
+
def chdir(raw_path)
|
25
|
+
|
26
|
+
directory = if raw_path[0] == '/' then
|
27
|
+
raw_path[1..-1]
|
28
|
+
elsif raw_path =~ /^dfs:\/\//
|
29
|
+
parse_path(raw_path)
|
30
|
+
else
|
31
|
+
File.join(@directory, raw_path)
|
32
|
+
end
|
33
|
+
|
34
|
+
if @file.exists? directory then
|
35
|
+
@directory = directory
|
36
|
+
else
|
37
|
+
'No such file or directory'
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
27
42
|
def exists?(filename=@filename)
|
28
43
|
|
29
|
-
filename2 =
|
30
|
-
|
44
|
+
filename2 = if filename =~ /^dfs:\/\// then
|
45
|
+
parse_path(filename)
|
46
|
+
else
|
47
|
+
filename
|
48
|
+
end
|
49
|
+
|
50
|
+
@file.exists? File.join(@directory, filename2)
|
31
51
|
|
32
52
|
end
|
53
|
+
|
54
|
+
def mkdir(name)
|
55
|
+
path = parse_path(name)
|
56
|
+
@file.mkdir path
|
57
|
+
end
|
58
|
+
|
59
|
+
def mkdir_p(raw_path)
|
60
|
+
path = parse_path(raw_path)
|
61
|
+
@file.mkdir_p path
|
62
|
+
end
|
63
|
+
|
64
|
+
def pwd()
|
65
|
+
|
66
|
+
'/' + @directory if @file
|
67
|
+
|
68
|
+
end
|
33
69
|
|
34
70
|
def read(filename=@filename)
|
35
71
|
|
36
|
-
|
37
|
-
|
72
|
+
path = if filename =~ /^dfs:\/\// then
|
73
|
+
parse_path(filename)
|
74
|
+
else
|
75
|
+
File.join(@directory, filename)
|
76
|
+
end
|
38
77
|
|
78
|
+
@file.read path
|
39
79
|
end
|
40
80
|
|
41
81
|
def write(filename=@filename, s)
|
82
|
+
|
83
|
+
path = if filename =~ /^dfs:\/\// then
|
84
|
+
parse_path(filename)
|
85
|
+
else
|
86
|
+
File.join(@directory, filename)
|
87
|
+
end
|
42
88
|
|
43
|
-
|
44
|
-
@file.write filename2, s
|
89
|
+
@file.write path, s
|
45
90
|
|
46
91
|
end
|
47
92
|
|
48
93
|
private
|
49
94
|
|
50
95
|
def parse_path(filename)
|
51
|
-
|
52
|
-
if @file then
|
53
|
-
|
54
|
-
filename
|
55
|
-
|
56
|
-
else
|
57
|
-
|
58
|
-
host = filename[/(?<=^dfs:\/\/)[^\/:]+/]
|
59
|
-
port = filename[/(?<=^dfs:\/\/)[^:]+:(\d+)/,1] || '61010'
|
60
96
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
97
|
+
host = filename[/(?<=^dfs:\/\/)[^\/:]+/]
|
98
|
+
port = filename[/(?<=^dfs:\/\/)[^:]+:(\d+)/,1] || '61010'
|
99
|
+
|
100
|
+
@file = DRbObject.new nil, "druby://#{host}:#{port}"
|
101
|
+
filename[/(?<=^dfs:\/\/)[^\/]+\/(.*)/,1]
|
102
|
+
|
66
103
|
end
|
67
104
|
|
68
105
|
end
|
69
106
|
|
70
107
|
class DfsFile
|
71
108
|
|
109
|
+
@client = DRbFileClient.new
|
110
|
+
|
72
111
|
def self.exists?(filename)
|
73
|
-
|
112
|
+
@client.exists?(filename)
|
74
113
|
end
|
75
114
|
|
115
|
+
def self.chdir(path)
|
116
|
+
@client.chdir(path)
|
117
|
+
end
|
118
|
+
|
119
|
+
def self.mkdir(name)
|
120
|
+
@client.mkdir(name)
|
121
|
+
end
|
122
|
+
|
123
|
+
def self.mkdir_p(path)
|
124
|
+
@client.mkdir_p(path)
|
125
|
+
end
|
126
|
+
|
127
|
+
def self.pwd()
|
128
|
+
@client.pwd()
|
129
|
+
end
|
130
|
+
|
76
131
|
def self.read(filename)
|
77
|
-
|
132
|
+
@client.read(filename)
|
78
133
|
end
|
79
134
|
|
80
135
|
def self.write(filename, s)
|
81
|
-
|
136
|
+
@client.write(filename, s)
|
82
137
|
end
|
83
138
|
|
84
139
|
end
|
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.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
2aIZ9lf6/AT4LP07t9jB5oYLHlr2nBLIqtPXdJvg5RKKr79CQVmpJ5LCTjwTg9h+
|
31
31
|
g1Q=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2018-
|
33
|
+
date: 2018-08-11 00:00:00.000000000 Z
|
34
34
|
dependencies: []
|
35
35
|
description:
|
36
36
|
email: james@jamesrobertson.eu
|
@@ -59,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
59
|
version: '0'
|
60
60
|
requirements: []
|
61
61
|
rubyforge_project:
|
62
|
-
rubygems_version: 2.6
|
62
|
+
rubygems_version: 2.7.6
|
63
63
|
signing_key:
|
64
64
|
specification_version: 4
|
65
65
|
summary: Reads or writes files from a remote DRb server. Simple as DfsFile.read or
|
metadata.gz.sig
CHANGED
Binary file
|