bfs-gs 0.3.7 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/bfs-gs.gemspec +2 -2
 - data/lib/bfs/bucket/gs.rb +13 -6
 - data/spec/bfs/bucket/gs_spec.rb +9 -2
 - metadata +10 -10
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: fc0ffe7adec5e56bdc0c6ebf5becb4c61c172a15c4a3174f8c658711ddb88dc8
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: c5d30528ecb0b9e2a9e6246e27f4c3aa99ba7088b5cb6292a608e0e0c719100e
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 7fbe8cb95159dc5a96f9206a797100ab9cee9738b974b6c998ff2468325d74c846bca33bb64c702e7144827c7fbd64699f5a9143f3badd77bab02e23d8bdbb40
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 2bc7bbe37de5a80a92ef782c66c60d938e401da98f5e300da537927faddfef836e09210fc72815a908cd6d8e614786b4ec6ed411ff242c9c15e8c617019d4ab2
         
     | 
    
        data/bfs-gs.gemspec
    CHANGED
    
    | 
         @@ -15,8 +15,8 @@ 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. 
     | 
| 
      
 18 
     | 
    
         
            +
              s.required_ruby_version = '>= 2.4.0'
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
              s.add_dependency 'bfs', s.version
         
     | 
| 
       21 
     | 
    
         
            -
              s.add_dependency 'google-cloud-storage'
         
     | 
| 
      
 21 
     | 
    
         
            +
              s.add_dependency 'google-cloud-storage', '~> 1.18'
         
     | 
| 
       22 
22 
     | 
    
         
             
            end
         
     | 
    
        data/lib/bfs/bucket/gs.rb
    CHANGED
    
    | 
         @@ -12,7 +12,7 @@ module BFS 
     | 
|
| 
       12 
12 
     | 
    
         
             
                  #
         
     | 
| 
       13 
13 
     | 
    
         
             
                  # @param [String] name the bucket name.
         
     | 
| 
       14 
14 
     | 
    
         
             
                  # @param [Hash] opts options.
         
     | 
| 
       15 
     | 
    
         
            -
                  # @option opts [String] :project_id project ID. Defaults to GCP_PROJECT env var. 
     | 
| 
      
 15 
     | 
    
         
            +
                  # @option opts [String] :project_id project ID. Defaults to GCP_PROJECT env var.
         
     | 
| 
       16 
16 
     | 
    
         
             
                  # @option opts [String, Hash, Google::Auth::Credentials] :credentials
         
     | 
| 
       17 
17 
     | 
    
         
             
                  #   the path to the keyfile as a String, the contents of the keyfile as a Hash, or a Google::Auth::Credentials object.
         
     | 
| 
       18 
18 
     | 
    
         
             
                  # @option opts [String] :prefix custom namespace within the bucket
         
     | 
| 
         @@ -20,12 +20,14 @@ module BFS 
     | 
|
| 
       20 
20 
     | 
    
         
             
                  # @option opts [Integer] :timeout request timeout, in seconds.
         
     | 
| 
       21 
21 
     | 
    
         
             
                  # @option opts [String] :acl set the default ACL.
         
     | 
| 
       22 
22 
     | 
    
         
             
                  # @option opts [Google::Cloud::Storage] :client custom client.
         
     | 
| 
      
 23 
     | 
    
         
            +
                  # @option opts [String] :encoding default encoding to use, default: 'binary'
         
     | 
| 
       23 
24 
     | 
    
         
             
                  def initialize(name, opts={})
         
     | 
| 
       24 
25 
     | 
    
         
             
                    opts = opts.dup
         
     | 
| 
       25 
26 
     | 
    
         
             
                    opts.keys.each do |key|
         
     | 
| 
       26 
27 
     | 
    
         
             
                      val = opts.delete(key)
         
     | 
| 
       27 
28 
     | 
    
         
             
                      opts[key.to_sym] = val unless val.nil?
         
     | 
| 
       28 
29 
     | 
    
         
             
                    end
         
     | 
| 
      
 30 
     | 
    
         
            +
                    super(opts)
         
     | 
| 
       29 
31 
     | 
    
         | 
| 
       30 
32 
     | 
    
         
             
                    @prefix = opts.delete(:prefix)
         
     | 
| 
       31 
33 
     | 
    
         
             
                    acl     = opts.delete(:acl)
         
     | 
| 
         @@ -63,8 +65,9 @@ module BFS 
     | 
|
| 
       63 
65 
     | 
    
         
             
                  # Creates a new file and opens it for writing
         
     | 
| 
       64 
66 
     | 
    
         
             
                  def create(path, opts={}, &block)
         
     | 
| 
       65 
67 
     | 
    
         
             
                    path = full_path(path)
         
     | 
| 
       66 
     | 
    
         
            -
                     
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
      
 68 
     | 
    
         
            +
                    enc  = opts.delete(:encoding) || @encoding
         
     | 
| 
      
 69 
     | 
    
         
            +
                    temp = BFS::TempWriter.new(path, encoding: enc) do |t|
         
     | 
| 
      
 70 
     | 
    
         
            +
                      File.open(t, encoding: enc) do |file|
         
     | 
| 
       68 
71 
     | 
    
         
             
                        @bucket.create_file(file, path, opts)
         
     | 
| 
       69 
72 
     | 
    
         
             
                      end
         
     | 
| 
       70 
73 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -80,21 +83,22 @@ module BFS 
     | 
|
| 
       80 
83 
     | 
    
         
             
                  # Opens an existing file for reading
         
     | 
| 
       81 
84 
     | 
    
         
             
                  def open(path, opts={}, &block)
         
     | 
| 
       82 
85 
     | 
    
         
             
                    path = full_path(path)
         
     | 
| 
      
 86 
     | 
    
         
            +
                    enc  = opts.delete(:encoding) || @encoding
         
     | 
| 
       83 
87 
     | 
    
         
             
                    file = @bucket.file(path)
         
     | 
| 
       84 
88 
     | 
    
         
             
                    raise BFS::FileNotFound, trim_prefix(path) unless file
         
     | 
| 
       85 
89 
     | 
    
         | 
| 
       86 
     | 
    
         
            -
                    temp = Tempfile.new(File.basename(path),  
     | 
| 
      
 90 
     | 
    
         
            +
                    temp = Tempfile.new(File.basename(path), encoding: enc)
         
     | 
| 
       87 
91 
     | 
    
         
             
                    temp.close
         
     | 
| 
       88 
92 
     | 
    
         
             
                    file.download temp.path, opts
         
     | 
| 
       89 
93 
     | 
    
         | 
| 
       90 
     | 
    
         
            -
                    File.open(temp.path,  
     | 
| 
      
 94 
     | 
    
         
            +
                    File.open(temp.path, encoding: enc, &block)
         
     | 
| 
       91 
95 
     | 
    
         
             
                  end
         
     | 
| 
       92 
96 
     | 
    
         | 
| 
       93 
97 
     | 
    
         
             
                  # Deletes a file.
         
     | 
| 
       94 
98 
     | 
    
         
             
                  def rm(path, opts={})
         
     | 
| 
       95 
99 
     | 
    
         
             
                    path = full_path(path)
         
     | 
| 
       96 
100 
     | 
    
         
             
                    file = @bucket.file(path)
         
     | 
| 
       97 
     | 
    
         
            -
                    file 
     | 
| 
      
 101 
     | 
    
         
            +
                    file&.delete(opts)
         
     | 
| 
       98 
102 
     | 
    
         
             
                  end
         
     | 
| 
       99 
103 
     | 
    
         | 
| 
       100 
104 
     | 
    
         
             
                  # Copies a file.
         
     | 
| 
         @@ -111,8 +115,11 @@ end 
     | 
|
| 
       111 
115 
     | 
    
         | 
| 
       112 
116 
     | 
    
         
             
            BFS.register('gs') do |url|
         
     | 
| 
       113 
117 
     | 
    
         
             
              params = CGI.parse(url.query.to_s)
         
     | 
| 
      
 118 
     | 
    
         
            +
              prefix = BFS.norm_path(params.key?('prefix') ? params['prefix'].first : url.path)
         
     | 
| 
      
 119 
     | 
    
         
            +
              prefix = nil if prefix.empty?
         
     | 
| 
       114 
120 
     | 
    
         | 
| 
       115 
121 
     | 
    
         
             
              BFS::Bucket::GS.new url.host,
         
     | 
| 
      
 122 
     | 
    
         
            +
                prefix: prefix,
         
     | 
| 
       116 
123 
     | 
    
         
             
                project_id: params.key?('project_id') ? params['project_id'].first : nil,
         
     | 
| 
       117 
124 
     | 
    
         
             
                credentials: params.key?('credentials') ? params['credentials'].first : nil,
         
     | 
| 
       118 
125 
     | 
    
         
             
                acl: params.key?('acl') ? params['acl'].first : nil,
         
     | 
    
        data/spec/bfs/bucket/gs_spec.rb
    CHANGED
    
    | 
         @@ -11,7 +11,8 @@ run_spec = \ 
     | 
|
| 
       11 
11 
     | 
    
         
             
              begin
         
     | 
| 
       12 
12 
     | 
    
         
             
                s = Google::Cloud::Storage.new(project_id: sandbox[:project])
         
     | 
| 
       13 
13 
     | 
    
         
             
                !s.bucket(sandbox[:bucket]).nil?
         
     | 
| 
       14 
     | 
    
         
            -
              rescue Signet::AuthorizationError
         
     | 
| 
      
 14 
     | 
    
         
            +
              rescue Signet::AuthorizationError => e
         
     | 
| 
      
 15 
     | 
    
         
            +
                warn "WARNING: unable to run #{File.basename __FILE__}: #{e.message}"
         
     | 
| 
       15 
16 
     | 
    
         
             
                false
         
     | 
| 
       16 
17 
     | 
    
         
             
              end
         
     | 
| 
       17 
18 
     | 
    
         | 
| 
         @@ -29,9 +30,15 @@ RSpec.describe BFS::Bucket::GS, if: run_spec do 
     | 
|
| 
       29 
30 
     | 
    
         
             
              it_behaves_like 'a bucket'
         
     | 
| 
       30 
31 
     | 
    
         | 
| 
       31 
32 
     | 
    
         
             
              it 'should resolve from URL' do
         
     | 
| 
       32 
     | 
    
         
            -
                bucket = BFS.resolve("gs://#{sandbox[:bucket]} 
     | 
| 
      
 33 
     | 
    
         
            +
                bucket = BFS.resolve("gs://#{sandbox[:bucket]}/?acl=private&project_id=#{sandbox[:project]}")
         
     | 
| 
       33 
34 
     | 
    
         
             
                expect(bucket).to be_instance_of(described_class)
         
     | 
| 
       34 
35 
     | 
    
         
             
                expect(bucket.name).to eq(sandbox[:bucket])
         
     | 
| 
      
 36 
     | 
    
         
            +
                expect(bucket.instance_variable_get(:@prefix)).to be_nil
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                bucket = BFS.resolve("gs://#{sandbox[:bucket]}/a/b/")
         
     | 
| 
      
 39 
     | 
    
         
            +
                expect(bucket).to be_instance_of(described_class)
         
     | 
| 
      
 40 
     | 
    
         
            +
                expect(bucket.name).to eq(sandbox[:bucket])
         
     | 
| 
      
 41 
     | 
    
         
            +
                expect(bucket.instance_variable_get(:@prefix)).to eq('a/b')
         
     | 
| 
       35 
42 
     | 
    
         
             
              end
         
     | 
| 
       36 
43 
     | 
    
         | 
| 
       37 
44 
     | 
    
         
             
              it 'should enumerate over a large number of files' do
         
     | 
    
        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. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.4.4
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Dimitrij Denissenko
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2019- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2019-09-27 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bfs
         
     | 
| 
         @@ -16,28 +16,28 @@ dependencies: 
     | 
|
| 
       16 
16 
     | 
    
         
             
                requirements:
         
     | 
| 
       17 
17 
     | 
    
         
             
                - - '='
         
     | 
| 
       18 
18 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       19 
     | 
    
         
            -
                    version: 0. 
     | 
| 
      
 19 
     | 
    
         
            +
                    version: 0.4.4
         
     | 
| 
       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. 
     | 
| 
      
 26 
     | 
    
         
            +
                    version: 0.4.4
         
     | 
| 
       27 
27 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       28 
28 
     | 
    
         
             
              name: google-cloud-storage
         
     | 
| 
       29 
29 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       30 
30 
     | 
    
         
             
                requirements:
         
     | 
| 
       31 
     | 
    
         
            -
                - - " 
     | 
| 
      
 31 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       32 
32 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       33 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '1.18'
         
     | 
| 
       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: ' 
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '1.18'
         
     | 
| 
       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. 
     | 
| 
      
 63 
     | 
    
         
            +
                  version: 2.4.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. 
     | 
| 
      
 70 
     | 
    
         
            +
            rubygems_version: 3.0.3
         
     | 
| 
       71 
71 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       72 
72 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       73 
73 
     | 
    
         
             
            summary: GS bucket adapter for bfs
         
     |