bfs-scp 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b576e021897096431c5d8b7a5b25d854057a4c2410f3ef149c098678a3db3598
4
- data.tar.gz: 8129ba1132e4282c346491ea0a8a3eec40cc7a38fa3ec3e27b354f0fce44f8de
3
+ metadata.gz: 6262201fae915737a6ed368d730f812a0e179ce6a8b21f722f4aacd93fe47ceb
4
+ data.tar.gz: 2c1225b186236d9b112ec3ceb787aa19cb4cf0b28ca2dcb43742b0f2c3ef1e2e
5
5
  SHA512:
6
- metadata.gz: 5c679c83e17e8f06a8ccf06269755f007b7e72fc2ea12d2a9c4e99e36b252f688336bbf9a3495ae181594452b3d00abb15e66217accd8e4c320505191b6395c9
7
- data.tar.gz: d84fe1852fd409e2fbf60b1eac8b48237bf0b3fae3db98eac1529e7922278fbf7b9674bd2ffbbfe716b26230dfe3ab4d8c40654fae17fcb8d0b84247d144a563
6
+ metadata.gz: 1cdc7db7d5bc18d93733ceaf15a114b832c234cfbf1099387072425716d182f1c063c877cae63948667b6c8ee26b776b58653d07153993243cfb54f85121e33d
7
+ data.tar.gz: b7a0dad1fa8b08604ab4ec6fb844160ea12e05345aee867884b4d5a85f65f96713979f9d807029d706ba0d6f6f828b03bd635526d11c68542ab190995f34fb5a
@@ -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
@@ -13,15 +13,36 @@ run_spec = \
13
13
  end
14
14
 
15
15
  RSpec.describe BFS::Bucket::SCP, if: run_spec do
16
- subject { described_class.new sandbox[:host], sandbox[:opts].merge(prefix: SecureRandom.uuid) }
17
- after { subject.close }
16
+ context 'absolute' do
17
+ subject { described_class.new sandbox[:host], sandbox[:opts].merge(prefix: SecureRandom.uuid) }
18
+ after { subject.close }
18
19
 
19
- it_behaves_like 'a bucket',
20
- content_type: false,
21
- metadata: false
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.0
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.0
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.0
26
+ version: 0.5.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: net-scp
29
29
  requirement: !ruby/object:Gem::Requirement