bfs 0.3.7 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bfs.gemspec +1 -1
- data/lib/bfs/bucket/abstract.rb +7 -0
- data/lib/bfs/bucket/fs.rb +5 -2
- data/lib/bfs/bucket/in_mem.rb +3 -2
- data/lib/bfs/helpers.rb +1 -3
- data/lib/bfs.rb +1 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6a37891cce4971bd933f31f0539a551ed03bb730a348363db854e944ca4befe
|
4
|
+
data.tar.gz: 3c47f220dfd7a45f2e59eb2f73493eb7724137021c2f7770231282e823aa318b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77d82c55b279127518da424b440edb550b0b07956d33698c0547aa88e4884cf374b4cd2baa1d9608fcf8cf9b13bdbe7347c3a635ece334c89639832c978031c9
|
7
|
+
data.tar.gz: c85adb1bb78c2ea5b822ef8839d2943b2c32281f9e3b40bbd039d08987f2ff0e4156baee58df7dfd85adb2eaaa526d95c453ae67bef16716712db01037480c3a
|
data/bfs.gemspec
CHANGED
data/lib/bfs/bucket/abstract.rb
CHANGED
@@ -3,6 +3,13 @@ require 'bfs'
|
|
3
3
|
module BFS
|
4
4
|
module Bucket
|
5
5
|
class Abstract
|
6
|
+
# Initializes a new bucket
|
7
|
+
# @param [Hash] opts options
|
8
|
+
# @option opts [String] :encoding default encoding, default: binary.
|
9
|
+
def initialize(opts={})
|
10
|
+
@encoding = opts.delete(:encoding) || Encoding::BINARY
|
11
|
+
end
|
12
|
+
|
6
13
|
# Lists the contents of a bucket using a glob pattern
|
7
14
|
def ls(_pattern='**', _opts={})
|
8
15
|
raise 'not implemented'
|
data/lib/bfs/bucket/fs.rb
CHANGED
@@ -6,7 +6,9 @@ module BFS
|
|
6
6
|
module Bucket
|
7
7
|
# FS buckets are operating on the file system
|
8
8
|
class FS < Abstract
|
9
|
-
def initialize(root,
|
9
|
+
def initialize(root, opts={})
|
10
|
+
super(opts.dup)
|
11
|
+
|
10
12
|
@root = Pathname.new(root.to_s)
|
11
13
|
@prefix = "#{@root.to_s.chomp('/')}/"
|
12
14
|
end
|
@@ -38,7 +40,8 @@ module BFS
|
|
38
40
|
full = @root.join(norm_path(path))
|
39
41
|
FileUtils.mkdir_p(full.dirname.to_s)
|
40
42
|
|
41
|
-
|
43
|
+
enc = opts[:encoding] || @encoding
|
44
|
+
temp = BFS::TempWriter.new(full, encoding: enc) {|t| FileUtils.mv t, full.to_s }
|
42
45
|
return temp unless block
|
43
46
|
|
44
47
|
begin
|
data/lib/bfs/bucket/in_mem.rb
CHANGED
@@ -7,7 +7,8 @@ module BFS
|
|
7
7
|
class InMem < Abstract
|
8
8
|
Entry = Struct.new(:io, :mtime, :content_type, :metadata)
|
9
9
|
|
10
|
-
def initialize
|
10
|
+
def initialize(opts={})
|
11
|
+
super(opts.dup)
|
11
12
|
@files = {}
|
12
13
|
end
|
13
14
|
|
@@ -43,7 +44,7 @@ module BFS
|
|
43
44
|
# @option opts [Hash] :metadata Metadata key-value pairs.
|
44
45
|
def create(path, opts={}, &block)
|
45
46
|
io = StringIO.new
|
46
|
-
|
47
|
+
io.set_encoding(opts[:encoding] || @encoding)
|
47
48
|
|
48
49
|
@files[norm_path(path)] = Entry.new(io, Time.now, opts[:content_type], opts[:metadata] || {})
|
49
50
|
return io unless block
|
data/lib/bfs/helpers.rb
CHANGED
@@ -3,8 +3,6 @@ require 'tempfile'
|
|
3
3
|
module BFS
|
4
4
|
class TempWriter
|
5
5
|
def initialize(name, opts={}, &closer)
|
6
|
-
opts = opts.merge(binmode: true) unless opts[:encoding]
|
7
|
-
|
8
6
|
@closer = closer
|
9
7
|
@tempfile = ::Tempfile.new(File.basename(name.to_s), opts)
|
10
8
|
end
|
@@ -26,7 +24,7 @@ module BFS
|
|
26
24
|
|
27
25
|
path = @tempfile.path
|
28
26
|
@tempfile.close
|
29
|
-
@closer
|
27
|
+
@closer&.call(path)
|
30
28
|
@tempfile.unlink
|
31
29
|
end
|
32
30
|
end
|
data/lib/bfs.rb
CHANGED
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.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitrij Denissenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Minimalist abstraction for bucket storage
|
14
14
|
email: dimitrij@blacksquaremedia.com
|
@@ -40,14 +40,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 2.
|
43
|
+
version: 2.4.0
|
44
44
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
requirements: []
|
50
|
-
rubygems_version: 3.0.
|
50
|
+
rubygems_version: 3.0.3
|
51
51
|
signing_key:
|
52
52
|
specification_version: 4
|
53
53
|
summary: Multi-platform cloud bucket adapter
|