bfs-s3 0.6.2 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bfs-s3.gemspec +1 -1
- data/lib/bfs/bucket/s3.rb +13 -24
- data/spec/bfs/bucket/s3_spec.rb +2 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e49f967d04b05a36711b1c2b858347af451e6c6aa9690739c524b21249137aee
|
4
|
+
data.tar.gz: dfe6415867f0e4af1a8b2106123972aa12f3531729b65bf0806081076cd1b903
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f29025c22ba7bb6bb72c0a7c517da339de233964ced69e6aae02dba86f2a69a54d80a6eb7d3915808b303159c6a864fe498703583932de1368314458ef414b4e
|
7
|
+
data.tar.gz: 4fd3e4ebac13f4f7f21698f8e193e977319c906902d1510e6879fdae74eecc51c41cfe3f7b1d24994511d1a8beaa2484fadde2d145a5e332c80508d3749412f2
|
data/bfs-s3.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.files = `git ls-files`.split("\n")
|
16
16
|
s.test_files = `git ls-files -- spec/*`.split("\n")
|
17
17
|
s.require_paths = ['lib']
|
18
|
-
s.required_ruby_version = '>= 2.
|
18
|
+
s.required_ruby_version = '>= 2.6.0'
|
19
19
|
|
20
20
|
s.add_dependency 'aws-sdk-s3', '~> 1.38'
|
21
21
|
s.add_dependency 'bfs', s.version
|
data/lib/bfs/bucket/s3.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'bfs'
|
2
2
|
require 'aws-sdk-s3'
|
3
|
-
require 'cgi'
|
4
3
|
|
5
4
|
module BFS
|
6
5
|
module Bucket
|
@@ -21,7 +20,6 @@ module BFS
|
|
21
20
|
# @option opts [Symbol] :acl canned ACL
|
22
21
|
# @option opts [String] :storage_class storage class
|
23
22
|
# @option opts [Aws::S3::Client] :client custom client, uses default_client by default
|
24
|
-
# @option opts [String] :encoding Custom encoding.
|
25
23
|
def initialize(name, **opts)
|
26
24
|
super(**opts)
|
27
25
|
|
@@ -35,7 +33,7 @@ module BFS
|
|
35
33
|
|
36
34
|
# Lists the contents of a bucket using a glob pattern
|
37
35
|
def ls(pattern = '**/*', **opts)
|
38
|
-
prefix = pattern[%r{^[
|
36
|
+
prefix = pattern[%r{^[^*?\{\}\[\]]+/}]
|
39
37
|
prefix = File.join(*[@prefix, prefix].compact) if @prefix
|
40
38
|
|
41
39
|
opts = opts.merge(bucket: name, prefix: @prefix)
|
@@ -74,9 +72,8 @@ module BFS
|
|
74
72
|
# @option opts [String] :acl custom ACL override
|
75
73
|
# @option opts [String] :server_side_encryption SSE override
|
76
74
|
# @option opts [String] :storage_class storage class override
|
77
|
-
def create(path, encoding:
|
75
|
+
def create(path, encoding: self.encoding, perm: self.perm, **opts, &block)
|
78
76
|
path = full_path(path)
|
79
|
-
enc = encoding || @encoding
|
80
77
|
opts = opts.merge(
|
81
78
|
bucket: name,
|
82
79
|
key: path,
|
@@ -85,8 +82,8 @@ module BFS
|
|
85
82
|
opts[:server_side_encryption] ||= @sse if @sse
|
86
83
|
opts[:storage_class] ||= @storage_class if @storage_class
|
87
84
|
|
88
|
-
temp = BFS::TempWriter.new(path, encoding:
|
89
|
-
File.open(t, encoding:
|
85
|
+
temp = BFS::TempWriter.new(path, encoding: encoding, perm: perm) do |t|
|
86
|
+
File.open(t, encoding: encoding) do |file|
|
90
87
|
@client.put_object(opts.merge(body: file))
|
91
88
|
end
|
92
89
|
end
|
@@ -104,10 +101,9 @@ module BFS
|
|
104
101
|
# @param [Hash] opts options
|
105
102
|
# @option opts [String] :encoding Custom encoding.
|
106
103
|
# @option opts [String] :tempdir Custom temp dir.
|
107
|
-
def open(path, encoding:
|
104
|
+
def open(path, encoding: self.encoding, tempdir: nil, **opts, &block)
|
108
105
|
path = full_path(path)
|
109
|
-
|
110
|
-
temp = Tempfile.new(File.basename(path), tempdir, encoding: enc)
|
106
|
+
temp = Tempfile.new(File.basename(path), tempdir, encoding: encoding)
|
111
107
|
temp.close
|
112
108
|
|
113
109
|
opts = opts.merge(
|
@@ -117,7 +113,7 @@ module BFS
|
|
117
113
|
)
|
118
114
|
@client.get_object(**opts)
|
119
115
|
|
120
|
-
File.open(temp.path, encoding:
|
116
|
+
File.open(temp.path, encoding: encoding, &block)
|
121
117
|
rescue Aws::S3::Errors::NoSuchKey, Aws::S3::Errors::NoSuchBucket, Aws::S3::Errors::NotFound
|
122
118
|
raise BFS::FileNotFound, trim_prefix(path)
|
123
119
|
end
|
@@ -162,17 +158,10 @@ module BFS
|
|
162
158
|
end
|
163
159
|
end
|
164
160
|
|
165
|
-
BFS.register('s3') do |url|
|
166
|
-
|
167
|
-
prefix =
|
168
|
-
|
169
|
-
|
170
|
-
BFS::Bucket::S3.
|
171
|
-
prefix: prefix,
|
172
|
-
region: params.key?('region') ? params['region'].first : nil,
|
173
|
-
sse: params.key?('sse') ? params['sse'].first : nil,
|
174
|
-
access_key_id: params.key?('access_key_id') ? params['access_key_id'].first : nil,
|
175
|
-
secret_access_key: params.key?('secret_access_key') ? params['secret_access_key'].first : nil,
|
176
|
-
acl: params.key?('acl') ? params['acl'].first : nil,
|
177
|
-
storage_class: params.key?('storage_class') ? params['storage_class'].first : nil
|
161
|
+
BFS.register('s3') do |url, opts, block|
|
162
|
+
prefix = BFS.norm_path(opts[:prefix] || url.path)
|
163
|
+
opts[:prefix] = prefix.empty? ? nil : prefix
|
164
|
+
opts = opts.slice(:prefix, :region, :sse, :access_key_id, :secret_access_key, :acl, :storage_class, :encoding)
|
165
|
+
|
166
|
+
BFS::Bucket::S3.open url.host, **opts, &block
|
178
167
|
end
|
data/spec/bfs/bucket/s3_spec.rb
CHANGED
@@ -25,10 +25,11 @@ RSpec.describe BFS::Bucket::S3, if: run_spec do
|
|
25
25
|
it_behaves_like 'a bucket'
|
26
26
|
|
27
27
|
it 'should resolve from URL' do
|
28
|
-
bucket = BFS.resolve("s3://#{sandbox[:bucket]}/?acl=private")
|
28
|
+
bucket = BFS.resolve("s3://#{sandbox[:bucket]}/?acl=private&encoding=binary")
|
29
29
|
expect(bucket).to be_instance_of(described_class)
|
30
30
|
expect(bucket.name).to eq(sandbox[:bucket])
|
31
31
|
expect(bucket.acl).to eq(:private)
|
32
|
+
expect(bucket.encoding).to eq('binary')
|
32
33
|
expect(bucket.instance_variable_get(:@prefix)).to be_nil
|
33
34
|
|
34
35
|
bucket = BFS.resolve("s3://#{sandbox[:bucket]}/a/b/")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bfs-s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.1
|
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-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-s3
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.7.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.7.1
|
41
41
|
description: https://github.com/bsm/bfs.rb
|
42
42
|
email: dimitrij@blacksquaremedia.com
|
43
43
|
executables: []
|
@@ -60,14 +60,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
60
60
|
requirements:
|
61
61
|
- - ">="
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: 2.
|
63
|
+
version: 2.6.0
|
64
64
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
requirements: []
|
70
|
-
rubygems_version: 3.
|
70
|
+
rubygems_version: 3.1.4
|
71
71
|
signing_key:
|
72
72
|
specification_version: 4
|
73
73
|
summary: S3 bucket adapter for bfs
|