bfs-scp 0.7.1 → 0.7.6
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/lib/bfs/bucket/scp.rb +5 -10
- data/spec/bfs/bucket/scp_spec.rb +15 -17
- 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: b6de04002b6c77e4844986f058b84ed6ec066ea0449a8046f14f5bb5d30c9451
         | 
| 4 | 
            +
              data.tar.gz: 8da046cce602ade820a2d3143918919db5f5d7d5f5af4f083e98a3bd81082fa1
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 18039611b8beffc15715cc13de3e1d9f36af8f71bd5a79ff2847289572d16d6793bd3a3d9ee90cce28623a6b40f1fad5894b4c64d1a131ea9cc8230d06bcf34b
         | 
| 7 | 
            +
              data.tar.gz: a6be1bb4418cc1e31c45a6e247879a0269d3f5832bb62dabf9b083658050eb05a20b429a030d8b36d4403f13cadfd239a9705037123dd08e536847ef22b61cb1
         | 
    
        data/lib/bfs/bucket/scp.rb
    CHANGED
    
    | @@ -35,7 +35,7 @@ module BFS | |
| 35 35 | 
             
                    @client = Net::SCP.start(host, nil, **opts.slice(*Net::SSH::VALID_OPTIONS))
         | 
| 36 36 |  | 
| 37 37 | 
             
                    if @prefix # rubocop:disable Style/GuardClause
         | 
| 38 | 
            -
                      @prefix = norm_path(@prefix) | 
| 38 | 
            +
                      @prefix = "#{norm_path(@prefix)}/"
         | 
| 39 39 | 
             
                      mkdir_p abs_path(@prefix)
         | 
| 40 40 | 
             
                    end
         | 
| 41 41 | 
             
                  end
         | 
| @@ -72,17 +72,10 @@ module BFS | |
| 72 72 | 
             
                    full = full_path(path)
         | 
| 73 73 |  | 
| 74 74 | 
             
                    opts[:preserve] = true if perm && !opts.key?(:preserve)
         | 
| 75 | 
            -
                     | 
| 75 | 
            +
                    BFS::TempWriter.new(path, encoding: encoding, perm: perm) do |temp_path|
         | 
| 76 76 | 
             
                      mkdir_p File.dirname(full)
         | 
| 77 77 | 
             
                      @client.upload!(temp_path, full, **opts)
         | 
| 78 | 
            -
                    end
         | 
| 79 | 
            -
                    return temp unless block
         | 
| 80 | 
            -
             | 
| 81 | 
            -
                    begin
         | 
| 82 | 
            -
                      yield temp
         | 
| 83 | 
            -
                    ensure
         | 
| 84 | 
            -
                      temp.close
         | 
| 85 | 
            -
                    end
         | 
| 78 | 
            +
                    end.perform(&block)
         | 
| 86 79 | 
             
                  end
         | 
| 87 80 |  | 
| 88 81 | 
             
                  # Opens an existing file for reading
         | 
| @@ -184,6 +177,8 @@ module BFS | |
| 184 177 | 
             
            end
         | 
| 185 178 |  | 
| 186 179 | 
             
            BFS.register('scp', 'ssh') do |url, opts, block|
         | 
| 180 | 
            +
              prefix = BFS.norm_path(opts[:prefix] || url.path)
         | 
| 181 | 
            +
              opts[:prefix] = prefix unless prefix.empty?
         | 
| 187 182 | 
             
              opts[:user] ||= CGI.unescape(url.user) if url.user
         | 
| 188 183 | 
             
              opts[:password] ||= CGI.unescape(url.password) if url.password
         | 
| 189 184 | 
             
              opts[:port] ||= url.port if url.port
         | 
    
        data/spec/bfs/bucket/scp_spec.rb
    CHANGED
    
    | @@ -1,28 +1,19 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
               | 
| 6 | 
            -
             | 
| 7 | 
            -
                  scp.session.exec!('hostname')
         | 
| 8 | 
            -
                end
         | 
| 9 | 
            -
                true
         | 
| 10 | 
            -
              rescue Net::SSH::Exception, Errno::ECONNREFUSED => e
         | 
| 11 | 
            -
                warn "WARNING: unable to run #{File.basename __FILE__}: #{e.message}"
         | 
| 12 | 
            -
                false
         | 
| 13 | 
            -
              end
         | 
| 3 | 
            +
            RSpec.describe BFS::Bucket::SCP, scp: true do
         | 
| 4 | 
            +
              let(:hostname) { '127.0.0.1' }
         | 
| 5 | 
            +
              let(:conn_opts) { { port: 7022, user: 'root', password: 'root', prefix: prefix } }
         | 
| 6 | 
            +
              let(:prefix) { SecureRandom.uuid }
         | 
| 14 7 |  | 
| 15 | 
            -
             | 
| 16 | 
            -
               | 
| 17 | 
            -
                subject { described_class.new sandbox[:host], **sandbox[:opts].merge(prefix: SecureRandom.uuid) }
         | 
| 18 | 
            -
                after   { subject.close }
         | 
| 8 | 
            +
              subject { described_class.new hostname, **conn_opts }
         | 
| 9 | 
            +
              after { subject.close }
         | 
| 19 10 |  | 
| 11 | 
            +
              context 'absolute' do
         | 
| 20 12 | 
             
                it_behaves_like 'a bucket', content_type: false, metadata: false
         | 
| 21 13 | 
             
              end
         | 
| 22 14 |  | 
| 23 15 | 
             
              context 'relative' do
         | 
| 24 | 
            -
                 | 
| 25 | 
            -
                after   { subject.close }
         | 
| 16 | 
            +
                let(:prefix) { "~/#{SecureRandom.uuid}" }
         | 
| 26 17 |  | 
| 27 18 | 
             
                it_behaves_like 'a bucket', content_type: false, metadata: false
         | 
| 28 19 | 
             
              end
         | 
| @@ -30,6 +21,13 @@ RSpec.describe BFS::Bucket::SCP, if: run_spec do | |
| 30 21 | 
             
              it 'should resolve from URL' do
         | 
| 31 22 | 
             
                bucket = BFS.resolve('scp://root:root@127.0.0.1:7022')
         | 
| 32 23 | 
             
                expect(bucket).to be_instance_of(described_class)
         | 
| 24 | 
            +
                expect(bucket.instance_variable_get(:@prefix)).to be_nil
         | 
| 25 | 
            +
                bucket.close
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                bucket = BFS.resolve('scp://root:root@127.0.0.1:7022/a/b/')
         | 
| 28 | 
            +
                expect(bucket).to be_instance_of(described_class)
         | 
| 29 | 
            +
                expect(bucket.instance_variable_get(:@prefix)).to eq('a/b/')
         | 
| 30 | 
            +
                bucket.close
         | 
| 33 31 | 
             
              end
         | 
| 34 32 |  | 
| 35 33 | 
             
              it 'should handle absolute and relative paths' do
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: bfs-scp
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.7. | 
| 4 | 
            +
              version: 0.7.6
         | 
| 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- | 
| 11 | 
            +
            date: 2020-11-10 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. | 
| 19 | 
            +
                    version: 0.7.6
         | 
| 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. | 
| 26 | 
            +
                    version: 0.7.6
         | 
| 27 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 28 | 
             
              name: net-scp
         | 
| 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.1. | 
| 70 | 
            +
            rubygems_version: 3.1.2
         | 
| 71 71 | 
             
            signing_key: 
         | 
| 72 72 | 
             
            specification_version: 4
         | 
| 73 73 | 
             
            summary: SCP/SSH adapter for bfs
         |