bfs-gs 0.6.2 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bfs-gs.gemspec +1 -1
  3. data/lib/bfs/bucket/gs.rb +18 -22
  4. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce3945c75293459554de992abd3feb7f5e67dc37f4c85277aed1a00e25fc6f12
4
- data.tar.gz: f8f4de972d679ec3bd44bfff8c4cfaef30b7fb3f864b28eaa366df3d1ff28007
3
+ metadata.gz: 0205b7e3e0a0657a5573c76e214761e8cb094370a9ec9f2e438a917cac121ea7
4
+ data.tar.gz: 73482e997b5d16fdbc0e18fbf3c40aa70316d41a0540aafd1e04f7be7cdf4742
5
5
  SHA512:
6
- metadata.gz: 06bc1b3093aad6a6be0dcdbfd7c17ed10d3121c5785b1aaa8ce12460ef40df05d26cdd3ba47d149d9e91ca9445cc38456b70abe17af87db023490959cd98959f
7
- data.tar.gz: 4c6e3a77f3c0c63fa1e7eafb58c5ddb585984fbdc76b5960ab96e2ceff2a147df3f48bd9f8dbcfe66a45718a6411b0d21c1bd7dea1f005f81e338b7d4b7acf82
6
+ metadata.gz: 62bfd2c665b53f6ba4cd9e80a57d8014337a771cae1b1bc129e720959163f9c99de6b881e3bbe8e4aa4e9075d4db40bd29fc414387519f66255271b89a16d12e
7
+ data.tar.gz: 5f1c3741bf46866c0917b908f7cc778087a9e97a04003dbade21f9e5e8e5d51f740cbc30b570a6f3112b91b606741b353f75dad1da40af289bc8de979b0668e8
@@ -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 'bfs', s.version
21
21
  s.add_dependency 'google-cloud-storage', '~> 1.18'
@@ -1,6 +1,5 @@
1
1
  require 'bfs'
2
2
  require 'google/cloud/storage'
3
- require 'cgi'
4
3
 
5
4
  module BFS
6
5
  module Bucket
@@ -34,7 +33,7 @@ module BFS
34
33
 
35
34
  # Lists the contents of a bucket using a glob pattern
36
35
  def ls(pattern = '**/*', **opts)
37
- prefix = pattern[%r{^[^\*\?\{\}\[\]]+/}]
36
+ prefix = pattern[%r{^[^*?\{\}\[\]]+/}]
38
37
  prefix = File.join(*[@prefix, prefix].compact) if @prefix
39
38
  opts = opts.merge(prefix: prefix) if prefix
40
39
 
@@ -57,12 +56,11 @@ module BFS
57
56
  end
58
57
 
59
58
  # Creates a new file and opens it for writing
60
- def create(path, encoding: nil, perm: nil, **opts, &block)
59
+ def create(path, encoding: self.encoding, perm: self.perm, **opts, &block)
61
60
  opts[:metadata] = norm_meta(opts[:metadata])
62
61
  path = full_path(path)
63
- enc = encoding || @encoding
64
- temp = BFS::TempWriter.new(path, encoding: enc, perm: perm) do |t|
65
- File.open(t, encoding: enc) do |file|
62
+ temp = BFS::TempWriter.new(path, encoding: encoding, perm: perm) do |t|
63
+ File.open(t, encoding: encoding) do |file|
66
64
  @bucket.create_file(file, path, **opts)
67
65
  end
68
66
  end
@@ -76,17 +74,16 @@ module BFS
76
74
  end
77
75
 
78
76
  # Opens an existing file for reading
79
- def open(path, encoding: nil, tempdir: nil, **opts, &block)
77
+ def open(path, encoding: self.encoding, tempdir: nil, **opts, &block)
80
78
  path = full_path(path)
81
- enc = encoding || @encoding
82
79
  file = @bucket.file(path)
83
80
  raise BFS::FileNotFound, trim_prefix(path) unless file
84
81
 
85
- temp = Tempfile.new(File.basename(path), tempdir, encoding: enc)
82
+ temp = Tempfile.new(File.basename(path), tempdir, encoding: encoding)
86
83
  temp.close
87
- file.download temp.path, opts
84
+ file.download(temp.path, **opts)
88
85
 
89
- File.open(temp.path, encoding: enc, &block)
86
+ File.open(temp.path, encoding: encoding, &block)
90
87
  end
91
88
 
92
89
  # Deletes a file.
@@ -108,16 +105,15 @@ module BFS
108
105
  end
109
106
  end
110
107
 
111
- BFS.register('gs') do |url|
112
- params = CGI.parse(url.query.to_s)
113
- prefix = BFS.norm_path(params.key?('prefix') ? params['prefix'].first : url.path)
108
+ BFS.register('gs') do |url, opts, block|
109
+ prefix = BFS.norm_path(opts.key?(:prefix) ? opts[:prefix] : url.path)
114
110
  prefix = nil if prefix.empty?
115
-
116
- BFS::Bucket::GS.new url.host,
117
- prefix: prefix,
118
- project_id: params.key?('project_id') ? params['project_id'].first : nil,
119
- credentials: params.key?('credentials') ? params['credentials'].first : nil,
120
- acl: params.key?('acl') ? params['acl'].first : nil,
121
- timeout: params.key?('timeout') ? params['timeout'].first.to_i : nil,
122
- retries: params.key?('retries') ? params['retries'].first.to_i : nil
111
+ opts = opts.slice(:project_id, :credentials, :acl)
112
+ extra = {
113
+ prefix: prefix,
114
+ timeout: opts.key?(:timeout) ? opts[:timeout].to_i : nil,
115
+ retries: opts.key?(:retries) ? opts[:retries].to_i : nil,
116
+ }
117
+
118
+ BFS::Bucket::GS.open url.host, **opts, **extra, &block
123
119
  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.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: bfs
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.6.2
19
+ version: 0.7.1
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.6.2
26
+ version: 0.7.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: google-cloud-storage
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -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: GS bucket adapter for bfs