bfs-gs 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bfs/bucket/gs.rb +12 -19
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d983acad48732ac1b9aefe1c9e24d38e69555a16d5888ab44628e3961af8248
|
4
|
+
data.tar.gz: 5b2c07919f56f3063fa2dd2f6f7446305dca58fb0686e3c3a035812580a25735
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22f44daf6914f672d9c214e0a2f048cdd413a977ba180ed08010cf5c6bef55f7bba85d792fc16f0389ea0027277ef83cc47573edf9d0482791d598438c36b7ad
|
7
|
+
data.tar.gz: 213fa8a1545fbae970c01d54cb0665967a2b10db6c1f07603836d83a505125fe04870d3304a1688e6ec783eeee37a1f74e702333291a512a5ecfe096a90c1023
|
data/lib/bfs/bucket/gs.rb
CHANGED
@@ -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
|
@@ -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:
|
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
|
-
|
64
|
-
|
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:
|
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:
|
82
|
+
temp = Tempfile.new(File.basename(path), tempdir, encoding: encoding)
|
86
83
|
temp.close
|
87
|
-
file.download
|
84
|
+
file.download(temp.path, **opts)
|
88
85
|
|
89
|
-
File.open(temp.path, encoding:
|
86
|
+
File.open(temp.path, encoding: encoding, &block)
|
90
87
|
end
|
91
88
|
|
92
89
|
# Deletes a file.
|
@@ -108,16 +105,12 @@ module BFS
|
|
108
105
|
end
|
109
106
|
end
|
110
107
|
|
111
|
-
BFS.register('gs') do |url|
|
112
|
-
|
113
|
-
prefix = BFS.norm_path(params.key?('prefix') ? params['prefix'].first : url.path)
|
108
|
+
BFS.register('gs') do |url, opts|
|
109
|
+
prefix = BFS.norm_path(opts.key?(:prefix) ? opts[:prefix] : url.path)
|
114
110
|
prefix = nil if prefix.empty?
|
115
111
|
|
116
|
-
BFS::Bucket::GS.new url.host,
|
112
|
+
BFS::Bucket::GS.new url.host, **opts.slice(:project_id, :credentials, :acl),
|
117
113
|
prefix: prefix,
|
118
|
-
|
119
|
-
|
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
|
114
|
+
timeout: opts.key?(:timeout) ? opts[:timeout].to_i : nil,
|
115
|
+
retries: opts.key?(:retries) ? opts[:retries].to_i : nil
|
123
116
|
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.
|
4
|
+
version: 0.6.3
|
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-
|
11
|
+
date: 2020-02-13 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.
|
19
|
+
version: 0.6.3
|
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.
|
26
|
+
version: 0.6.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: google-cloud-storage
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
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: GS bucket adapter for bfs
|