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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 37e10fdc93aa067bed7a72b5bcbccbc8b05bebad755e1bdd5091f6ed03b78206
4
- data.tar.gz: 6db5a4abb0b6b6825785eff4a18ca74e5bf6083c2a6ce3f0344e3ea28b7e0446
3
+ metadata.gz: e49f967d04b05a36711b1c2b858347af451e6c6aa9690739c524b21249137aee
4
+ data.tar.gz: dfe6415867f0e4af1a8b2106123972aa12f3531729b65bf0806081076cd1b903
5
5
  SHA512:
6
- metadata.gz: 37ddc5cd5672316032a45fe30e99ee1a29b8e17b83c770542fd7998c2bf4c3f6046acb374e3440ae4ea646c88437dc7cf065b8d6f40b6456d81d56fa2d8786f4
7
- data.tar.gz: c3744960bc91b119af9fe51c52429662b6d7e13aee85c4d373efc579e11492df599ddd0fbd35e1a5dd107cd870c2937add208db43ce9d6a96a8068b82e27f1f8
6
+ metadata.gz: f29025c22ba7bb6bb72c0a7c517da339de233964ced69e6aae02dba86f2a69a54d80a6eb7d3915808b303159c6a864fe498703583932de1368314458ef414b4e
7
+ data.tar.gz: 4fd3e4ebac13f4f7f21698f8e193e977319c906902d1510e6879fdae74eecc51c41cfe3f7b1d24994511d1a8beaa2484fadde2d145a5e332c80508d3749412f2
@@ -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.5.0'
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
@@ -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: nil, perm: nil, **opts, &block)
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: enc, perm: perm) do |t|
89
- File.open(t, encoding: enc) do |file|
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: nil, tempdir: nil, **opts, &block)
104
+ def open(path, encoding: self.encoding, tempdir: nil, **opts, &block)
108
105
  path = full_path(path)
109
- enc = encoding || @encoding
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: enc, &block)
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
- params = CGI.parse(url.query.to_s)
167
- prefix = BFS.norm_path(params.key?('prefix') ? params['prefix'].first : url.path)
168
- prefix = nil if prefix.empty?
169
-
170
- BFS::Bucket::S3.new url.host,
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
@@ -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.6.2
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-12 00:00:00.000000000 Z
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.6.2
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.6.2
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.5.0
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.0.6
70
+ rubygems_version: 3.1.4
71
71
  signing_key:
72
72
  specification_version: 4
73
73
  summary: S3 bucket adapter for bfs