bfs 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bfs.rb +1 -1
- data/lib/bfs/bucket/fs.rb +1 -1
- data/lib/bfs/bucket/in_mem.rb +9 -4
- data/spec/bfs/blob_spec.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ed077904a46a574dd780eaa9ce2ca804ebe4a11eac9b744dff1389bd9a34169
|
4
|
+
data.tar.gz: 1ae5d64274163768624e28b6d7cd5cba63b2237dffbd88dc8c481a0515c7b353
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d60da76feb312e7bef9c0d796e33e9161830ce59ef9a5f60bb2d3e5a697b7d3a55b6820ebc5defe8601b5c34db2ee19850f6998195ea8088f9e3fb1dafa69a6
|
7
|
+
data.tar.gz: 151543a8a0f1b48ce925c261a580b06960db41ceab7f3fd83cac8ad9479fa7ffa0d29338eb6b2518cf9110bba52afaf80830451b843e3ad2f337d53271fe75f7
|
data/lib/bfs.rb
CHANGED
data/lib/bfs/bucket/fs.rb
CHANGED
@@ -24,7 +24,7 @@ module BFS
|
|
24
24
|
def info(path, _opts={})
|
25
25
|
full = @root.join(norm_path(path))
|
26
26
|
path = trim_prefix(full.to_s)
|
27
|
-
BFS::FileInfo.new(path, full.size, full.mtime)
|
27
|
+
BFS::FileInfo.new(path, full.size, full.mtime, nil, {})
|
28
28
|
rescue Errno::ENOENT
|
29
29
|
raise BFS::FileNotFound, path
|
30
30
|
end
|
data/lib/bfs/bucket/in_mem.rb
CHANGED
@@ -5,12 +5,17 @@ module BFS
|
|
5
5
|
module Bucket
|
6
6
|
# InMem buckets are useful for tests
|
7
7
|
class InMem < Abstract
|
8
|
-
Entry = Struct.new(:io, :mtime)
|
8
|
+
Entry = Struct.new(:io, :mtime, :content_type, :metadata)
|
9
9
|
|
10
10
|
def initialize
|
11
11
|
@files = {}
|
12
12
|
end
|
13
13
|
|
14
|
+
# Reset bucket and clear all files.
|
15
|
+
def clear
|
16
|
+
@files.clear
|
17
|
+
end
|
18
|
+
|
14
19
|
# Lists the contents of a bucket using a glob pattern
|
15
20
|
def ls(pattern='**/*', _opts={})
|
16
21
|
Enumerator.new do |y|
|
@@ -26,13 +31,13 @@ module BFS
|
|
26
31
|
raise BFS::FileNotFound, path unless @files.key?(path)
|
27
32
|
|
28
33
|
entry = @files[path]
|
29
|
-
BFS::FileInfo.new(path, entry.io.size, entry.mtime)
|
34
|
+
BFS::FileInfo.new(path, entry.io.size, entry.mtime, entry.content_type, entry.metadata)
|
30
35
|
end
|
31
36
|
|
32
37
|
# Creates a new file and opens it for writing
|
33
|
-
def create(path,
|
38
|
+
def create(path, opts={}, &block)
|
34
39
|
io = StringIO.new
|
35
|
-
@files[norm_path(path)] = Entry.new(io, Time.now)
|
40
|
+
@files[norm_path(path)] = Entry.new(io, Time.now, opts[:content_type], opts[:metadata] || {})
|
36
41
|
return io unless block
|
37
42
|
|
38
43
|
begin
|
data/spec/bfs/blob_spec.rb
CHANGED
@@ -17,10 +17,10 @@ RSpec.describe BFS::Blob do
|
|
17
17
|
|
18
18
|
it 'should write/read' do
|
19
19
|
expect { subject.read }.to raise_error(BFS::FileNotFound)
|
20
|
-
subject.write('TESTDATA')
|
20
|
+
subject.write('TESTDATA', content_type: 'text/plain', metadata: { 'key' => 'val' })
|
21
21
|
|
22
22
|
info = subject.info
|
23
|
-
expect(info).to eq(BFS::FileInfo.new('path/to/file.txt', 8, info.mtime))
|
23
|
+
expect(info).to eq(BFS::FileInfo.new('path/to/file.txt', 8, info.mtime, 'text/plain', 'key' => 'val'))
|
24
24
|
expect(info.mtime).to be_within(1).of(Time.now)
|
25
25
|
|
26
26
|
expect(subject.read).to eq('TESTDATA')
|
@@ -49,11 +49,11 @@ RSpec.describe BFS::Blob do
|
|
49
49
|
it 'should write/read' do
|
50
50
|
expect { subject.read }.to raise_error(BFS::FileNotFound)
|
51
51
|
|
52
|
-
subject.write('TESTDATA')
|
52
|
+
subject.write('TESTDATA', content_type: 'text/plain', metadata: { 'key' => 'val' })
|
53
53
|
expect(subject.read).to eq('TESTDATA')
|
54
54
|
|
55
55
|
info = subject.info
|
56
|
-
expect(info).to eq(BFS::FileInfo.new(path, 8, info.mtime))
|
56
|
+
expect(info).to eq(BFS::FileInfo.new(path, 8, info.mtime, nil, {}))
|
57
57
|
expect(info.mtime).to be_within(1).of(Time.now)
|
58
58
|
|
59
59
|
expect(Pathname.glob("#{tmpdir}/**/*").select(&:file?).map(&:to_s)).to eq [
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bfs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitrij Denissenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Minimalist abstraction for bucket storage
|
14
14
|
email: dimitrij@blacksquaremedia.com
|