Class: DRbFileServer
- Inherits:
-
Object
- Object
- DRbFileServer
- Defined in:
- lib/drb_fileserver_plus.rb
Instance Attribute Summary collapse
-
#nodes ⇒ Object
Returns the value of attribute nodes.
Instance Method Summary collapse
- #chmod(permissions, fname) ⇒ Object
- #cp(path, path2) ⇒ Object
- #directory?(fname) ⇒ Boolean
- #exists?(fname) ⇒ Boolean
- #glob(path) ⇒ Object
-
#initialize(nodes, sps: nil, topic: 'file') ⇒ DRbFileServer
constructor
A new instance of DRbFileServer.
- #ls(path) ⇒ Object
- #mkdir(path) ⇒ Object
- #mkdir_p(path) ⇒ Object
- #mv(path, path2) ⇒ Object
- #read(fname) ⇒ Object
- #rm(fname) ⇒ Object
- #rm_r(fname, force: false) ⇒ Object
- #touch(fname, mtime: Time.now) ⇒ Object
- #write(fname, content) ⇒ Object
- #zip(fname, a) ⇒ Object
Constructor Details
#initialize(nodes, sps: nil, topic: 'file') ⇒ DRbFileServer
Returns a new instance of DRbFileServer.
16 17 18 19 20 21 22 |
# File 'lib/drb_fileserver_plus.rb', line 16 def initialize(nodes, sps: nil, topic: 'file') @nodes = nodes @failcount = 0 @sps, @topic = sps, topic end |
Instance Attribute Details
#nodes ⇒ Object
Returns the value of attribute nodes.
14 15 16 |
# File 'lib/drb_fileserver_plus.rb', line 14 def nodes @nodes end |
Instance Method Details
#chmod(permissions, fname) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/drb_fileserver_plus.rb', line 24 def chmod(, fname) node = '' file_op do |f| node = 'dfs://' + @nodes.first f.chmod , File.join(node, fname) end if @sps then @sps.notice "%s/chmod: %d %s" % [@topic, , File.join(node, fname)] end end |
#cp(path, path2) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/drb_fileserver_plus.rb', line 41 def cp(path, path2) node = '' file_op do |f| node = 'dfs://' + @nodes.first f.cp File.join(node, path), File.join(node, path2) end if @sps then @sps.notice "%s/copy: %s %s" % [@topic, File.join(node, path), File.join(node, path2)] end end |
#directory?(fname) ⇒ Boolean
57 58 59 60 61 62 63 64 |
# File 'lib/drb_fileserver_plus.rb', line 57 def directory?(fname) file_op do |f| node = 'dfs://' + @nodes.first f.directory? File.join(node, fname) end end |
#exists?(fname) ⇒ Boolean
66 67 68 69 70 71 72 73 |
# File 'lib/drb_fileserver_plus.rb', line 66 def exists?(fname) file_op do |f| node = 'dfs://' + @nodes.first f.exists? File.join(node, fname) end end |
#glob(path) ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/drb_fileserver_plus.rb', line 75 def glob(path) file_op do |f| node = 'dfs://' + @nodes.first f.glob File.join(node, path) end end |
#ls(path) ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/drb_fileserver_plus.rb', line 85 def ls(path) file_op do |f| node = 'dfs://' + @nodes.first f.ls File.join(node, path) end end |
#mkdir(path) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/drb_fileserver_plus.rb', line 94 def mkdir(path) node = '' file_op do |f| node = 'dfs://' + @nodes.first f.mkdir File.join(node, path) end if @sps then @sps.notice "%s/mkdir: %s" % [@topic, File.join(node, path)] end end |
#mkdir_p(path) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/drb_fileserver_plus.rb', line 109 def mkdir_p(path) node = '' file_op do |f| node = 'dfs://' + @nodes.first f.mkdir_p File.join(node, path) end if @sps then @sps.notice "%s/mkdir_p: %s" % [@topic, File.join(node, path)] end end |
#mv(path, path2) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/drb_fileserver_plus.rb', line 124 def mv(path, path2) node = '' file_op do |f| node = 'dfs://' + @nodes.first f.mv File.join(node, path), File.join(node, path2) end if @sps then @sps.notice "%s/mv: %s %s" % [@topic, File.join(node, path), File.join(node, path2)] end end |
#read(fname) ⇒ Object
140 141 142 143 144 145 146 147 |
# File 'lib/drb_fileserver_plus.rb', line 140 def read(fname) file_op do |f| node = 'dfs://' + @nodes.first f.read File.join(node, fname) end end |
#rm(fname) ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/drb_fileserver_plus.rb', line 149 def rm(fname) node = '' file_op do |f| node = 'dfs://' + @nodes.first f.rm File.join(node, fname) end if @sps then @sps.notice "%s/rm: %s" % [@topic, File.join(node, fname)] end end |
#rm_r(fname, force: false) ⇒ Object
164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/drb_fileserver_plus.rb', line 164 def rm_r(fname, force: false) node = '' file_op do |f| node = 'dfs://' + @nodes.first f.rm_r File.join(node, fname), force: force end if @sps then @sps.notice "%s/rm_r: %s" % [@topic, File.join(node, fname)] end end |
#touch(fname, mtime: Time.now) ⇒ Object
179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/drb_fileserver_plus.rb', line 179 def touch(fname, mtime: Time.now) node = '' file_op do |f| node = 'dfs://' + @nodes.first f.touch File.join(node, fname), mtime: mtime end if @sps then @sps.notice "%s/touch: %s" % [@topic, File.join(node, fname)] end end |
#write(fname, content) ⇒ Object
194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/drb_fileserver_plus.rb', line 194 def write(fname, content) node = '' file_op do |f| node = 'dfs://' + @nodes.first f.write File.join(node, fname), content end if @sps then @sps.notice("%s/write: %s" % [@topic, File.join(node, fname)]) end end |
#zip(fname, a) ⇒ Object
209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/drb_fileserver_plus.rb', line 209 def zip(fname, a) node = '' file_op do |f| node = 'dfs://' + @nodes.first f.zip File.join(node, fname), a end if @sps then @sps.notice "%s/zip: %s" % [@topic, File.join(node, fname)] end end |