bfs-gs 0.7.2 → 0.8.0

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: afb6b88566a06b714276613bb998fb3d4d02dd8534ba2210a57b2a215d567c14
4
- data.tar.gz: 26b4631d61959bd3d02c45fcd7a02e9c5d64e4aadfdce9f9beee6051185097f4
3
+ metadata.gz: 345994febf6083e1839a95b796da1b86075c831aa320eee9f9fff7ea13974099
4
+ data.tar.gz: '096620f7ada887459c5bbd94b46c94c8175523f03f2d47b33880068af3e7b2e2'
5
5
  SHA512:
6
- metadata.gz: 37352e78eec850efe6aa791e25597bf17fec5efec0088826736865320ba99d1a6ae24e8c818df45ffe0fd10abe8111258603cb272c5116e9bec3d0b0792671fe
7
- data.tar.gz: 1e3e729c4c231821a09e045d94f9e38f10b530de567e8bad1eacccb2ecc6abe79c4736dd6031a8e306adfe26d5565bb1b967c4dcfffb04f826aff3c3335ee890
6
+ metadata.gz: 7e65dd0c03fbedff21bf049bcd32db8e3e3a55456577cf1e28647ab109dab3e8b2123199b210c97e96e458263672ef1fe55c5c21008cfe5494330e9e2fb4e912
7
+ data.tar.gz: cbaf26fa087974a16d84bead6fdb88a99b66c17fc4876fbe7df70cd67ace72ed430345c175419c68fb6321896beddefe9ed15ff3a2d6abcaac2002cf8aad4e1f
@@ -59,18 +59,11 @@ module BFS
59
59
  def create(path, encoding: self.encoding, perm: self.perm, **opts, &block)
60
60
  opts[:metadata] = norm_meta(opts[:metadata])
61
61
  path = full_path(path)
62
- temp = BFS::TempWriter.new(path, encoding: encoding, perm: perm) do |t|
62
+ BFS::Writer.new(path, encoding: encoding, perm: perm) do |t|
63
63
  File.open(t, encoding: encoding) do |file|
64
64
  @bucket.create_file(file, path, **opts)
65
65
  end
66
- end
67
- return temp unless block
68
-
69
- begin
70
- yield temp
71
- ensure
72
- temp.close
73
- end
66
+ end.perform(&block)
74
67
  end
75
68
 
76
69
  # Opens an existing file for reading
@@ -6,43 +6,39 @@ module Google::Auth::CredentialsLoader
6
6
  module_function :warn_if_cloud_sdk_credentials # rubocop:disable Style/AccessModifierDeclarations
7
7
  end
8
8
 
9
- sandbox = { project: 'bogus', bucket: 'bsm-bfs-unittest' }.freeze
10
- run_spec = \
11
- begin
12
- s = Google::Cloud::Storage.new(project_id: sandbox[:project])
13
- !s.bucket(sandbox[:bucket]).nil?
14
- rescue Signet::AuthorizationError => e
15
- warn "WARNING: unable to run #{File.basename __FILE__}: #{e.message}"
16
- false
17
- end
9
+ bucket_name = 'bsm-bfs-unittest'
18
10
 
19
- RSpec.describe BFS::Bucket::GS, if: run_spec do
11
+ RSpec.describe BFS::Bucket::GS, gs: true do
20
12
  let(:prefix) { "x/#{SecureRandom.uuid}/" }
21
13
 
22
14
  subject do
23
- described_class.new sandbox[:bucket], project_id: sandbox[:project], prefix: prefix
15
+ described_class.new bucket_name, prefix: prefix
24
16
  end
17
+
25
18
  after :all do
26
- bucket = described_class.new sandbox[:bucket], project_id: sandbox[:project], prefix: 'x/'
19
+ bucket = described_class.new bucket_name, prefix: 'x/'
27
20
  bucket.ls.each {|name| bucket.rm(name) }
28
21
  end
29
22
 
30
23
  it_behaves_like 'a bucket'
31
24
 
32
25
  it 'should resolve from URL' do
33
- bucket = BFS.resolve("gs://#{sandbox[:bucket]}/?project_id=#{sandbox[:project]}")
26
+ bucket = BFS.resolve("gs://#{bucket_name}")
34
27
  expect(bucket).to be_instance_of(described_class)
35
- expect(bucket.name).to eq(sandbox[:bucket])
28
+ expect(bucket.name).to eq(bucket_name)
36
29
  expect(bucket.instance_variable_get(:@prefix)).to be_nil
30
+ bucket.close
37
31
 
38
- bucket = BFS.resolve("gs://#{sandbox[:bucket]}/a/b/")
32
+ bucket = BFS.resolve("gs://#{bucket_name}/a/b/")
39
33
  expect(bucket).to be_instance_of(described_class)
40
- expect(bucket.name).to eq(sandbox[:bucket])
34
+ expect(bucket.name).to eq(bucket_name)
41
35
  expect(bucket.instance_variable_get(:@prefix)).to eq('a/b')
36
+ bucket.close
42
37
  end
43
38
 
44
39
  it 'should enumerate over a large number of files' do
45
- bucket = described_class.new sandbox[:bucket], project_id: sandbox[:project], prefix: 'm/'
40
+ bucket = described_class.new bucket_name, prefix: 'm/'
46
41
  expect(bucket.ls('**/*').count).to eq(2121)
42
+ bucket.close
47
43
  end
48
44
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bfs-gs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.8.0
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-07-02 00:00:00.000000000 Z
11
+ date: 2020-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bfs
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.7.2
19
+ version: 0.8.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.7.2
26
+ version: 0.8.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: google-cloud-storage
29
29
  requirement: !ruby/object:Gem::Requirement