bfs-s3 0.7.0 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e2a56db1b3250b2054d01e38788642c887f4c747c17570b49e0c5efed3e28e2
4
- data.tar.gz: 43462a7a5cb5b7d1eb86a45422f1f4ed2d2dab5409309a39be859d02027c4a39
3
+ metadata.gz: 5d22f34e604788253bb1ad66fe31eeea816daddd8ae793de9e9a8919e5a8ff7c
4
+ data.tar.gz: f840bb61c273719aa5305a1c27580b42584db47aec88efdc719beac492cc55e5
5
5
  SHA512:
6
- metadata.gz: 72798b2b002302d858556669318977a4b74ea32a7c76fd703e1cb368e0b3f426150d6eb760f7fe77f59e34c36db7d3ce36d45b4a72198c7dd8a1b21b4fa32277
7
- data.tar.gz: f9a7376141e5aaab374ac62887245a7458e04de47d9208222559b6b041a28e965cc18d7dd81ee3128f39b748515511ab40ae4b5e48ed6c1aa1d5a1d5503342bf
6
+ metadata.gz: d96d23659c8c35ca2f140e3d39500c60afd92787cc885ec71730eac6b3f9d6f7d8597feec95c55ad8ca7e032d581d160daa78b2bf81dce9e78a42b8accf3b646
7
+ data.tar.gz: f3da02ff82b2b995090c0e8fd79730174dc29e78a88e8ff930ddc5d520599a62636d386a3746298e3c78672b33a840bd3909a8f6b417384f85196315407bac3e
@@ -33,7 +33,7 @@ module BFS
33
33
 
34
34
  # Lists the contents of a bucket using a glob pattern
35
35
  def ls(pattern = '**/*', **opts)
36
- prefix = pattern[%r{^[^\*\?\{\}\[\]]+/}]
36
+ prefix = pattern[%r{^[^*?\{\}\[\]]+/}]
37
37
  prefix = File.join(*[@prefix, prefix].compact) if @prefix
38
38
 
39
39
  opts = opts.merge(bucket: name, prefix: @prefix)
@@ -82,18 +82,11 @@ module BFS
82
82
  opts[:server_side_encryption] ||= @sse if @sse
83
83
  opts[:storage_class] ||= @storage_class if @storage_class
84
84
 
85
- temp = BFS::TempWriter.new(path, encoding: encoding, perm: perm) do |t|
85
+ BFS::TempWriter.new(path, encoding: encoding, perm: perm) do |t|
86
86
  File.open(t, encoding: encoding) do |file|
87
87
  @client.put_object(opts.merge(body: file))
88
88
  end
89
- end
90
- return temp unless block
91
-
92
- begin
93
- yield temp
94
- ensure
95
- temp.close
96
- end
89
+ end.perform(&block)
97
90
  end
98
91
 
99
92
  # Opens an existing file for reading
@@ -126,7 +119,7 @@ module BFS
126
119
  key: path,
127
120
  )
128
121
  @client.delete_object(**opts)
129
- rescue Aws::S3::Errors::NoSuchKey, Aws::S3::Errors::NoSuchBucket, Aws::S3::Errors::NotFound
122
+ rescue Aws::S3::Errors::NoSuchKey, Aws::S3::Errors::NoSuchBucket, Aws::S3::Errors::NotFound # rubocop:disable Lint/SuppressedException
130
123
  end
131
124
 
132
125
  # Copies a file.
@@ -158,9 +151,10 @@ module BFS
158
151
  end
159
152
  end
160
153
 
161
- BFS.register('s3') do |url, opts|
154
+ BFS.register('s3') do |url, opts, block|
162
155
  prefix = BFS.norm_path(opts[:prefix] || url.path)
163
156
  opts[:prefix] = prefix.empty? ? nil : prefix
157
+ opts = opts.slice(:prefix, :region, :sse, :access_key_id, :secret_access_key, :acl, :storage_class, :encoding)
164
158
 
165
- BFS::Bucket::S3.new url.host, **opts.slice(:prefix, :region, :sse, :access_key_id, :secret_access_key, :acl, :storage_class, :encoding)
159
+ BFS::Bucket::S3.open url.host, **opts, &block
166
160
  end
@@ -1,17 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
- sandbox = { bucket: 'bsm-bfs-unittest' }.freeze
4
- run_spec = \
5
- begin
6
- s = Aws::S3::Client.new
7
- s.head_bucket(bucket: sandbox[:bucket])
8
- true
9
- rescue StandardError => e
10
- warn "WARNING: unable to run #{File.basename __FILE__}: #{e.message}"
11
- false
12
- end
3
+ sandbox = { bucket: 'bsm-bfs-unittest' }.freeze
13
4
 
14
- RSpec.describe BFS::Bucket::S3, if: run_spec do
5
+ RSpec.describe BFS::Bucket::S3, s3: true do
15
6
  let(:prefix) { "x/#{SecureRandom.uuid}/" }
16
7
 
17
8
  subject do
@@ -31,15 +22,18 @@ RSpec.describe BFS::Bucket::S3, if: run_spec do
31
22
  expect(bucket.acl).to eq(:private)
32
23
  expect(bucket.encoding).to eq('binary')
33
24
  expect(bucket.instance_variable_get(:@prefix)).to be_nil
25
+ bucket.close
34
26
 
35
27
  bucket = BFS.resolve("s3://#{sandbox[:bucket]}/a/b/")
36
28
  expect(bucket).to be_instance_of(described_class)
37
29
  expect(bucket.name).to eq(sandbox[:bucket])
38
30
  expect(bucket.instance_variable_get(:@prefix)).to eq('a/b')
31
+ bucket.close
39
32
  end
40
33
 
41
34
  it 'should enumerate over a large number of files' do
42
35
  bucket = described_class.new sandbox[:bucket], prefix: 'm/'
43
36
  expect(bucket.ls('**/*').count).to eq(2121)
37
+ bucket.close
44
38
  end
45
39
  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.7.0
4
+ version: 0.7.5
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-05-28 00:00:00.000000000 Z
11
+ date: 2020-11-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.7.0
33
+ version: 0.7.5
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.7.0
40
+ version: 0.7.5
41
41
  description: https://github.com/bsm/bfs.rb
42
42
  email: dimitrij@blacksquaremedia.com
43
43
  executables: []