bfs 0.6.2 → 0.6.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 +6 -1
- data/lib/bfs/bucket/abstract.rb +4 -0
- data/lib/bfs/bucket/fs.rb +4 -5
- data/lib/bfs/bucket/in_mem.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05234e0a245f3801e31976aff2304846bcab16d3e36caada95ab89ee00e2b139
|
4
|
+
data.tar.gz: 57d254f1a9016b9ca82071d7b31a37b2e8995d5da0c9506ab7c46131a1f9eb26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cff604f7d5458f3ebf8d6a5407a1d3b74cf1c41d1b81d88158f9d234047ff2bcc633d66ad99a2db44fce9597db7b227f55d21f8b2f6f3083532e03bd7d846503
|
7
|
+
data.tar.gz: 195835e3ae17c544d9c4f947e6021fc2239e54081c725a638f885aef32c700b841309d23b2cc9e7c22e059b8b262882167464f5f2557465bf2d0ebb2c9825065
|
data/lib/bfs.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'uri'
|
2
|
+
require 'cgi'
|
2
3
|
|
3
4
|
module BFS
|
4
5
|
class FileInfo < Hash
|
@@ -44,7 +45,11 @@ module BFS
|
|
44
45
|
rsl = @registry[url.scheme]
|
45
46
|
raise ArgumentError, "Unable to resolve #{url}, scheme #{url.scheme} is not registered" unless rsl
|
46
47
|
|
47
|
-
|
48
|
+
opts = {}
|
49
|
+
CGI.parse(url.query.to_s).each do |key, values|
|
50
|
+
opts[key.to_sym] = values.first
|
51
|
+
end
|
52
|
+
rsl.call(url, opts)
|
48
53
|
end
|
49
54
|
|
50
55
|
def self.norm_path(path)
|
data/lib/bfs/bucket/abstract.rb
CHANGED
@@ -3,11 +3,15 @@ require 'bfs'
|
|
3
3
|
module BFS
|
4
4
|
module Bucket
|
5
5
|
class Abstract
|
6
|
+
attr_reader :encoding, :perm
|
7
|
+
|
6
8
|
# Initializes a new bucket
|
7
9
|
# @param [Hash] opts options
|
8
10
|
# @option opts [String] :encoding Custom encoding. Default: Encoding.default_external.
|
11
|
+
# @option opts [Integer] :perm optional file permissions. Default: 0600.
|
9
12
|
def initialize(encoding: Encoding.default_external, **_opts)
|
10
13
|
@encoding = encoding
|
14
|
+
@perm = perm
|
11
15
|
end
|
12
16
|
|
13
17
|
# Lists the contents of a bucket using a glob pattern
|
data/lib/bfs/bucket/fs.rb
CHANGED
@@ -38,12 +38,11 @@ module BFS
|
|
38
38
|
# @param [Hash] opts Additional options.
|
39
39
|
# @option opts [String] :encoding Custom encoding.
|
40
40
|
# @option opts [Integer] :perm Custom file permission, default: 0600.
|
41
|
-
def create(path, encoding:
|
41
|
+
def create(path, encoding: self.encoding, perm: self.perm, **_opts, &block)
|
42
42
|
full = @root.join(norm_path(path))
|
43
43
|
FileUtils.mkdir_p(full.dirname.to_s)
|
44
44
|
|
45
|
-
|
46
|
-
temp = BFS::TempWriter.new(full, encoding: enc, perm: perm) {|t| FileUtils.mv t, full.to_s }
|
45
|
+
temp = BFS::TempWriter.new(full, encoding: encoding, perm: perm) {|t| FileUtils.mv t, full.to_s }
|
47
46
|
return temp unless block
|
48
47
|
|
49
48
|
begin
|
@@ -103,7 +102,7 @@ module BFS
|
|
103
102
|
end
|
104
103
|
end
|
105
104
|
|
106
|
-
BFS.register('file') do |url|
|
105
|
+
BFS.register('file') do |url, opts|
|
107
106
|
parts = [url.host, url.path].compact
|
108
|
-
BFS::Bucket::FS.new File.join(*parts)
|
107
|
+
BFS::Bucket::FS.new File.join(*parts), **opts
|
109
108
|
end
|
data/lib/bfs/bucket/in_mem.rb
CHANGED
@@ -42,11 +42,11 @@ module BFS
|
|
42
42
|
# @option opts [String] :encoding Custom encoding.
|
43
43
|
# @option opts [String] :content_type Custom content type.
|
44
44
|
# @option opts [Hash] :metadata Metadata key-value pairs.
|
45
|
-
def create(path, **
|
45
|
+
def create(path, encoding: self.encoding, content_type: nil, metadata: nil, **_opts, &block)
|
46
46
|
io = StringIO.new
|
47
|
-
io.set_encoding(
|
47
|
+
io.set_encoding(encoding)
|
48
48
|
|
49
|
-
entry = Entry.new(io, Time.now,
|
49
|
+
entry = Entry.new(io, Time.now, content_type, norm_meta(metadata))
|
50
50
|
@files[norm_path(path)] = entry
|
51
51
|
return io unless block
|
52
52
|
|
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.6.
|
4
|
+
version: 0.6.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: 2020-02-
|
11
|
+
date: 2020-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Minimalist abstraction for bucket storage
|
14
14
|
email: dimitrij@blacksquaremedia.com
|
@@ -48,7 +48,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: '0'
|
50
50
|
requirements: []
|
51
|
-
rubygems_version: 3.
|
51
|
+
rubygems_version: 3.1.2
|
52
52
|
signing_key:
|
53
53
|
specification_version: 4
|
54
54
|
summary: Multi-platform cloud bucket adapter
|