Class: Fluffy::File
- Inherits:
-
Object
- Object
- Fluffy::File
- Defined in:
- lib/fluffy.rb
Overview
def method_missing(meth, *args, &block)
RealFileUtils.send(meth, *args, &block)
end
end
Constant Summary collapse
- PATH_SEPARATOR =
'/'
- @@s3_paths =
[]
Class Method Summary collapse
- .basename(*args) ⇒ Object
- .chmod(mode, *files) ⇒ Object
- .const_missing(name) ⇒ Object
- .directory?(path) ⇒ Boolean
- .dirname(path) ⇒ Object
- .exist?(path) ⇒ Boolean (also: exists?)
- .expand_path(*args) ⇒ Object
- .file?(path) ⇒ Boolean
- .join(*parts) ⇒ Object
- .method_missing(meth, *args, &block) ⇒ Object
- .new(path, mode = nil) ⇒ Object
- .open(path, mode = 'r', &block) ⇒ Object
- .read(path) ⇒ Object
- .readlines(path) ⇒ Object
- .readlink(path) ⇒ Object
- .register_s3(file_path, access_key_id, secret_access_key, bucket, start_path = '') ⇒ Object
- .s3_paths ⇒ Object
- .symlink?(path) ⇒ Boolean
- .unlink(*filepaths) ⇒ Object
Class Method Details
.basename(*args) ⇒ Object
187 188 189 |
# File 'lib/fluffy.rb', line 187 def self.basename(*args) RealFile.basename(*args) end |
.chmod(mode, *files) ⇒ Object
235 236 237 |
# File 'lib/fluffy.rb', line 235 def self.chmod(mode, *files) #FIXME: Make it work end |
.const_missing(name) ⇒ Object
161 162 163 |
# File 'lib/fluffy.rb', line 161 def self.const_missing(name) RealFile.const_get(name) end |
.directory?(path) ⇒ Boolean
169 170 171 172 173 |
# File 'lib/fluffy.rb', line 169 def self.directory?(path) Fluffy.cloud_runner(RealFile, :directory?, path) do |s3_path, key| s3_path.bucket.keys('prefix' => key).map{|k| k.name}.any?{|keyname| keyname[key.length] && keyname[key.length].chr == '/'} end end |
.dirname(path) ⇒ Object
191 192 193 |
# File 'lib/fluffy.rb', line 191 def self.dirname(path) RealFile.dirname(path) end |
.exist?(path) ⇒ Boolean Also known as: exists?
155 156 157 158 159 |
# File 'lib/fluffy.rb', line 155 def self.exist?(path) Fluffy.cloud_runner(RealFile, :exist?, path) do |s3_path, key| s3_path.bucket.key(key).exists? or self.directory?(path) end end |
.expand_path(*args) ⇒ Object
183 184 185 |
# File 'lib/fluffy.rb', line 183 def self.(*args) RealFile.(*args) end |
.file?(path) ⇒ Boolean
179 180 181 |
# File 'lib/fluffy.rb', line 179 def self.file?(path) RealFile.file?(path) end |
.join(*parts) ⇒ Object
151 152 153 |
# File 'lib/fluffy.rb', line 151 def self.join(*parts) RealFile.join(parts) end |
.method_missing(meth, *args, &block) ⇒ Object
239 240 241 |
# File 'lib/fluffy.rb', line 239 def self.method_missing(meth, *args, &block) RealFile.send(meth, *args, &block) end |
.new(path, mode = nil) ⇒ Object
229 230 231 232 233 |
# File 'lib/fluffy.rb', line 229 def self.new(path, mode = nil) Fluffy.cloud_runner(RealFile, :new, path) do |s3_path, key| open(path, mode) end end |
.open(path, mode = 'r', &block) ⇒ Object
199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/fluffy.rb', line 199 def self.open(path, mode='r', &block) Fluffy.cloud_runner(RealFile, :open, path, block) do |s3_path, key| s3io = Fluffy::S3Io.new(s3_path, key, mode) if block_given? block_val = yield(s3io) s3io.close return block_val end return s3io end end |
.read(path) ⇒ Object
213 214 215 |
# File 'lib/fluffy.rb', line 213 def self.read(path) open(path).read end |
.readlines(path) ⇒ Object
217 218 219 |
# File 'lib/fluffy.rb', line 217 def self.readlines(path) open(path).readlines end |
.readlink(path) ⇒ Object
195 196 197 |
# File 'lib/fluffy.rb', line 195 def self.readlink(path) RealFile.readlink(path) end |
.register_s3(file_path, access_key_id, secret_access_key, bucket, start_path = '') ⇒ Object
143 144 145 |
# File 'lib/fluffy.rb', line 143 def self.register_s3(file_path, access_key_id, secret_access_key, bucket, start_path = '') File.s3_paths << Fluffy::S3Path.new(File.(file_path), access_key_id, secret_access_key, bucket, start_path) end |
.s3_paths ⇒ Object
147 148 149 |
# File 'lib/fluffy.rb', line 147 def self.s3_paths return @@s3_paths end |
.symlink?(path) ⇒ Boolean
175 176 177 |
# File 'lib/fluffy.rb', line 175 def self.symlink?(path) RealFile.symlink?(path) end |
.unlink(*filepaths) ⇒ Object
221 222 223 224 225 226 227 |
# File 'lib/fluffy.rb', line 221 def self.unlink(*filepaths) filepaths.each do |filename| Fluffy.cloud_runner(RealFile, :unlink, filename) do |s3_path, key| s3_path.bucket.key(key).delete end end end |