bfs-scp 0.5.0 → 0.5.1
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 +12 -3
- data/spec/bfs/bucket/scp_spec.rb +26 -5
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 6262201fae915737a6ed368d730f812a0e179ce6a8b21f722f4aacd93fe47ceb
         | 
| 4 | 
            +
              data.tar.gz: 2c1225b186236d9b112ec3ceb787aa19cb4cf0b28ca2dcb43742b0f2c3ef1e2e
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 1cdc7db7d5bc18d93733ceaf15a114b832c234cfbf1099387072425716d182f1c063c877cae63948667b6c8ee26b776b58653d07153993243cfb54f85121e33d
         | 
| 7 | 
            +
              data.tar.gz: b7a0dad1fa8b08604ab4ec6fb844160ea12e05345aee867884b4d5a85f65f96713979f9d807029d706ba0d6f6f828b03bd635526d11c68542ab190995f34fb5a
         | 
    
        data/lib/bfs/bucket/scp.rb
    CHANGED
    
    | @@ -41,17 +41,17 @@ module BFS | |
| 41 41 |  | 
| 42 42 | 
             
                    if @prefix # rubocop:disable Style/GuardClause
         | 
| 43 43 | 
             
                      @prefix = norm_path(@prefix) + '/'
         | 
| 44 | 
            -
                      mkdir_p(@prefix)
         | 
| 44 | 
            +
                      mkdir_p abs_path(@prefix)
         | 
| 45 45 | 
             
                    end
         | 
| 46 46 | 
             
                  end
         | 
| 47 47 |  | 
| 48 48 | 
             
                  # Lists the contents of a bucket using a glob pattern
         | 
| 49 49 | 
             
                  def ls(pattern='**/*', _opts={})
         | 
| 50 | 
            -
                    prefix = @prefix  | 
| 50 | 
            +
                    prefix = @prefix ? abs_path(@prefix) : '/'
         | 
| 51 51 | 
             
                    Enumerator.new do |y|
         | 
| 52 52 | 
             
                      sh! 'find', prefix, '-type', 'f' do |out|
         | 
| 53 53 | 
             
                        out.each_line do |line|
         | 
| 54 | 
            -
                          path = trim_prefix(line.strip)
         | 
| 54 | 
            +
                          path = trim_prefix(norm_path(line.strip))
         | 
| 55 55 | 
             
                          y << path if File.fnmatch?(pattern, path, File::FNM_PATHNAME)
         | 
| 56 56 | 
             
                        end
         | 
| 57 57 | 
             
                      end
         | 
| @@ -141,6 +141,15 @@ module BFS | |
| 141 141 |  | 
| 142 142 | 
             
                  private
         | 
| 143 143 |  | 
| 144 | 
            +
                  def abs_path(path)
         | 
| 145 | 
            +
                    path = "/#{path}" unless path.start_with?('~/', './')
         | 
| 146 | 
            +
                    path
         | 
| 147 | 
            +
                  end
         | 
| 148 | 
            +
             | 
| 149 | 
            +
                  def full_path(*)
         | 
| 150 | 
            +
                    abs_path(super)
         | 
| 151 | 
            +
                  end
         | 
| 152 | 
            +
             | 
| 144 153 | 
             
                  def mkdir_p(path)
         | 
| 145 154 | 
             
                    sh! 'mkdir', '-p', path
         | 
| 146 155 | 
             
                  end
         | 
    
        data/spec/bfs/bucket/scp_spec.rb
    CHANGED
    
    | @@ -13,15 +13,36 @@ run_spec = \ | |
| 13 13 | 
             
              end
         | 
| 14 14 |  | 
| 15 15 | 
             
            RSpec.describe BFS::Bucket::SCP, if: run_spec do
         | 
| 16 | 
            -
               | 
| 17 | 
            -
             | 
| 16 | 
            +
              context 'absolute' do
         | 
| 17 | 
            +
                subject { described_class.new sandbox[:host], sandbox[:opts].merge(prefix: SecureRandom.uuid) }
         | 
| 18 | 
            +
                after   { subject.close }
         | 
| 18 19 |  | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 20 | 
            +
                it_behaves_like 'a bucket', content_type: false, metadata: false
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              context 'relative' do
         | 
| 24 | 
            +
                subject { described_class.new sandbox[:host], sandbox[:opts].merge(prefix: "~/#{SecureRandom.uuid}") }
         | 
| 25 | 
            +
                after   { subject.close }
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                it_behaves_like 'a bucket', content_type: false, metadata: false
         | 
| 28 | 
            +
              end
         | 
| 22 29 |  | 
| 23 30 | 
             
              it 'should resolve from URL' do
         | 
| 24 31 | 
             
                bucket = BFS.resolve('scp://root:root@127.0.0.1:7022')
         | 
| 25 32 | 
             
                expect(bucket).to be_instance_of(described_class)
         | 
| 26 33 | 
             
              end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              it 'should handle absolute and relative paths' do
         | 
| 36 | 
            +
                abs = BFS::Blob.new("scp://root:root@127.0.0.1:7022/#{SecureRandom.uuid}/file.txt")
         | 
| 37 | 
            +
                abs.create {|w| w.write 'absolute' }
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                rel = BFS::Blob.new("scp://root:root@127.0.0.1:7022/~/#{SecureRandom.uuid}/file.txt")
         | 
| 40 | 
            +
                rel.create {|w| w.write 'relative' }
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                expect(abs.read).to eq('absolute')
         | 
| 43 | 
            +
                expect(rel.read).to eq('relative')
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                abs.close
         | 
| 46 | 
            +
                rel.close
         | 
| 47 | 
            +
              end
         | 
| 27 48 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: bfs-scp
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.5. | 
| 4 | 
            +
              version: 0.5.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Dimitrij Denissenko
         | 
| @@ -16,14 +16,14 @@ dependencies: | |
| 16 16 | 
             
                requirements:
         | 
| 17 17 | 
             
                - - '='
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version: 0.5. | 
| 19 | 
            +
                    version: 0.5.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.5. | 
| 26 | 
            +
                    version: 0.5.1
         | 
| 27 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 28 | 
             
              name: net-scp
         | 
| 29 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         |