Class: BFS::Bucket::Abstract
- Inherits:
-
Object
- Object
- BFS::Bucket::Abstract
- Defined in:
- lib/bfs/bucket/abstract.rb
Instance Method Summary collapse
-
#cp(src, dst, opts = {}) ⇒ Object
Copies src to dst.
-
#create(_path, _opts = {}) ⇒ Object
Creates a new file and opens it for writing.
-
#info(_path, _opts = {}) ⇒ Object
Info returns the info for a single file.
-
#ls(_pattern = '**', _opts = {}) ⇒ Object
Lists the contents of a bucket using a glob pattern.
-
#mv(src, dst, _opts = {}) ⇒ Object
Moves src to dst.
-
#open(_path, _opts = {}) ⇒ Object
Opens an existing file for reading May raise BFS::FileNotFound.
-
#read(path, opts = {}) ⇒ Object
Shortcut method to read the contents of a file into memory.
-
#rm(_path, _opts = {}) ⇒ Object
Deletes a file.
-
#write(path, data, opts = {}) ⇒ Object
Shortcut method to write data to path.
Instance Method Details
#cp(src, dst, opts = {}) ⇒ Object
Copies src to dst
43 44 45 46 47 48 49 |
# File 'lib/bfs/bucket/abstract.rb', line 43 def cp(src, dst, opts={}) open(src, opts) do |r| create(dst, opts) do |w| IO.copy_stream(r, w) end end end |
#create(_path, _opts = {}) ⇒ Object
Creates a new file and opens it for writing
17 18 19 |
# File 'lib/bfs/bucket/abstract.rb', line 17 def create(_path, _opts={}) raise 'not implemented' end |
#info(_path, _opts = {}) ⇒ Object
Info returns the info for a single file
12 13 14 |
# File 'lib/bfs/bucket/abstract.rb', line 12 def info(_path, _opts={}) raise 'not implemented' end |
#ls(_pattern = '**', _opts = {}) ⇒ Object
Lists the contents of a bucket using a glob pattern
7 8 9 |
# File 'lib/bfs/bucket/abstract.rb', line 7 def ls(_pattern='**', _opts={}) raise 'not implemented' end |
#mv(src, dst, _opts = {}) ⇒ Object
Moves src to dst
52 53 54 55 |
# File 'lib/bfs/bucket/abstract.rb', line 52 def mv(src, dst, _opts={}) cp(src, dst) rm(src) end |
#open(_path, _opts = {}) ⇒ Object
Opens an existing file for reading May raise BFS::FileNotFound
23 24 25 |
# File 'lib/bfs/bucket/abstract.rb', line 23 def open(_path, _opts={}) raise 'not implemented' end |
#read(path, opts = {}) ⇒ Object
Shortcut method to read the contents of a file into memory
33 34 35 |
# File 'lib/bfs/bucket/abstract.rb', line 33 def read(path, opts={}) open(path, opts, &:read) end |
#rm(_path, _opts = {}) ⇒ Object
Deletes a file.
28 29 30 |
# File 'lib/bfs/bucket/abstract.rb', line 28 def rm(_path, _opts={}) raise 'not implemented' end |
#write(path, data, opts = {}) ⇒ Object
Shortcut method to write data to path
38 39 40 |
# File 'lib/bfs/bucket/abstract.rb', line 38 def write(path, data, opts={}) create(path, opts) {|f| f.write data } end |