bfs-s3 0.6.0 → 0.6.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 +21 -21
- 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: d45908f3dcc0517ee7beab0c08841a516c140069f2a4e3a6166ae0333ca2c5f0
|
4
|
+
data.tar.gz: 2c845b22f0fb5776ba1e8be311f1de7cd0ff9caf5cd88d61f8b0782712810dc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64de3e661d1bf09aa264ad045eaeeff4c5a86320ab90be4b96e4c46fb9675379babd0ebe24cf98c56552db05fa7dec2ae7530283b7f65fdb27c1819d929199ca
|
7
|
+
data.tar.gz: 7a4707fbfed527b5e3f3ebd48887cbdd759c78bd28951647579a213d49ab418fb9db2e37584c28964a292c0dd180c9f3f73e3a5d6c6de1f087da0a4a63d6aadc
|
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.5.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
@@ -22,24 +22,24 @@ module BFS
|
|
22
22
|
# @option opts [String] :storage_class storage class
|
23
23
|
# @option opts [Aws::S3::Client] :client custom client, uses default_client by default
|
24
24
|
# @option opts [String] :encoding Custom encoding.
|
25
|
-
def initialize(name, opts
|
25
|
+
def initialize(name, **opts)
|
26
26
|
opts = opts.dup
|
27
27
|
opts.keys.each do |key|
|
28
28
|
val = opts.delete(key)
|
29
29
|
opts[key.to_sym] = val unless val.nil?
|
30
30
|
end
|
31
|
-
super(opts)
|
31
|
+
super(**opts)
|
32
32
|
|
33
33
|
@name = name
|
34
34
|
@sse = opts[:sse] || opts[:server_side_encryption]
|
35
35
|
@prefix = opts[:prefix]
|
36
36
|
@acl = opts[:acl].to_sym if opts[:acl]
|
37
37
|
@storage_class = opts[:storage_class]
|
38
|
-
@client = opts[:client] || init_client(opts)
|
38
|
+
@client = opts[:client] || init_client(**opts)
|
39
39
|
end
|
40
40
|
|
41
41
|
# Lists the contents of a bucket using a glob pattern
|
42
|
-
def ls(pattern='**/*', opts
|
42
|
+
def ls(pattern = '**/*', **opts)
|
43
43
|
prefix = pattern[%r{^[^\*\?\{\}\[\]]+/}]
|
44
44
|
prefix = File.join(*[@prefix, prefix].compact) if @prefix
|
45
45
|
|
@@ -61,10 +61,10 @@ module BFS
|
|
61
61
|
end
|
62
62
|
|
63
63
|
# Info returns the object info
|
64
|
-
def info(path, opts
|
64
|
+
def info(path, **opts)
|
65
65
|
path = norm_path(path)
|
66
66
|
opts = opts.merge(bucket: name, key: full_path(path))
|
67
|
-
info = @client.head_object(opts)
|
67
|
+
info = @client.head_object(**opts)
|
68
68
|
raise BFS::FileNotFound, path unless info
|
69
69
|
|
70
70
|
BFS::FileInfo.new(path, info.content_length, info.last_modified, info.content_type, norm_meta(info.metadata))
|
@@ -79,7 +79,7 @@ module BFS
|
|
79
79
|
# @option opts [String] :acl custom ACL override
|
80
80
|
# @option opts [String] :server_side_encryption SSE override
|
81
81
|
# @option opts [String] :storage_class storage class override
|
82
|
-
def create(path, opts
|
82
|
+
def create(path, **opts, &block)
|
83
83
|
path = full_path(path)
|
84
84
|
enc = opts.delete(:encoding) || @encoding
|
85
85
|
opts = opts.merge(
|
@@ -108,7 +108,7 @@ module BFS
|
|
108
108
|
# @param [String] path
|
109
109
|
# @param [Hash] opts options
|
110
110
|
# @option opts [String] :encoding Custom encoding.
|
111
|
-
def open(path, opts
|
111
|
+
def open(path, **opts, &block)
|
112
112
|
path = full_path(path)
|
113
113
|
enc = opts.delete(:encoding) || @encoding
|
114
114
|
temp = Tempfile.new(File.basename(path), encoding: enc)
|
@@ -119,7 +119,7 @@ module BFS
|
|
119
119
|
bucket: name,
|
120
120
|
key: path,
|
121
121
|
)
|
122
|
-
@client.get_object(opts)
|
122
|
+
@client.get_object(**opts)
|
123
123
|
|
124
124
|
File.open(temp.path, encoding: enc, &block)
|
125
125
|
rescue Aws::S3::Errors::NoSuchKey, Aws::S3::Errors::NoSuchBucket, Aws::S3::Errors::NotFound
|
@@ -127,18 +127,18 @@ module BFS
|
|
127
127
|
end
|
128
128
|
|
129
129
|
# Deletes a file.
|
130
|
-
def rm(path, opts
|
130
|
+
def rm(path, **opts)
|
131
131
|
path = full_path(path)
|
132
132
|
opts = opts.merge(
|
133
133
|
bucket: name,
|
134
134
|
key: path,
|
135
135
|
)
|
136
|
-
@client.delete_object(opts)
|
136
|
+
@client.delete_object(**opts)
|
137
137
|
rescue Aws::S3::Errors::NoSuchKey, Aws::S3::Errors::NoSuchBucket, Aws::S3::Errors::NotFound # rubocop:disable Lint/SuppressedException
|
138
138
|
end
|
139
139
|
|
140
140
|
# Copies a file.
|
141
|
-
def cp(src, dst, opts
|
141
|
+
def cp(src, dst, **opts)
|
142
142
|
src = full_path(src)
|
143
143
|
dst = full_path(dst)
|
144
144
|
opts = opts.merge(
|
@@ -146,14 +146,14 @@ module BFS
|
|
146
146
|
copy_source: "/#{name}/#{src}",
|
147
147
|
key: dst,
|
148
148
|
)
|
149
|
-
@client.copy_object(opts)
|
149
|
+
@client.copy_object(**opts)
|
150
150
|
rescue Aws::S3::Errors::NoSuchKey, Aws::S3::Errors::NoSuchBucket, Aws::S3::Errors::NotFound
|
151
151
|
raise BFS::FileNotFound, trim_prefix(src)
|
152
152
|
end
|
153
153
|
|
154
154
|
private
|
155
155
|
|
156
|
-
def init_client(opts)
|
156
|
+
def init_client(**opts)
|
157
157
|
config = {}
|
158
158
|
config[:region] = opts[:region] if opts[:region]
|
159
159
|
config[:credentials] = opts[:credentials] if opts[:credentials]
|
@@ -172,11 +172,11 @@ BFS.register('s3') do |url|
|
|
172
172
|
prefix = nil if prefix.empty?
|
173
173
|
|
174
174
|
BFS::Bucket::S3.new url.host,
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
175
|
+
prefix: prefix,
|
176
|
+
region: params.key?('region') ? params['region'].first : nil,
|
177
|
+
sse: params.key?('sse') ? params['sse'].first : nil,
|
178
|
+
access_key_id: params.key?('access_key_id') ? params['access_key_id'].first : nil,
|
179
|
+
secret_access_key: params.key?('secret_access_key') ? params['secret_access_key'].first : nil,
|
180
|
+
acl: params.key?('acl') ? params['acl'].first : nil,
|
181
|
+
storage_class: params.key?('storage_class') ? params['storage_class'].first : nil
|
182
182
|
end
|
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.6.
|
4
|
+
version: 0.6.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:
|
11
|
+
date: 2020-02-11 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.6.
|
33
|
+
version: 0.6.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.6.
|
40
|
+
version: 0.6.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.5.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.2
|
71
71
|
signing_key:
|
72
72
|
specification_version: 4
|
73
73
|
summary: S3 bucket adapter for bfs
|