bfs-scp 0.4.1 → 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: 31c7f82a6aae8c2bd13d174bb267ba3a27d2635e03813fa99f2aa531be59f9be
4
- data.tar.gz: 3b89574dc5e9b02693de9a6bae66fefea69605b5d75e83a17de062dd532a35a6
3
+ metadata.gz: 6262201fae915737a6ed368d730f812a0e179ce6a8b21f722f4aacd93fe47ceb
4
+ data.tar.gz: 2c1225b186236d9b112ec3ceb787aa19cb4cf0b28ca2dcb43742b0f2c3ef1e2e
5
5
  SHA512:
6
- metadata.gz: 84c82c16c24daa41792c9a2509092f06a79bd080ae4b83dad44ab97b41730cc03b1af9921f25d6c5dcf9f137ec2260b47d814afbd52699a259eb6b0f07280498
7
- data.tar.gz: 58d1ef53e369746d33b4c783c1bcaa67a72963e6b289f7f2b080362525197503eea5c4599e2b5d469b76fb3fe8b614585743806d48a8e9b62459591912a28b29
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
@@ -7,21 +7,42 @@ run_spec = \
7
7
  scp.session.exec!('hostname')
8
8
  end
9
9
  true
10
- rescue Net::SSH::Exception => e
10
+ rescue Net::SSH::Exception, Errno::ECONNREFUSED => e
11
11
  warn "WARNING: unable to run #{File.basename __FILE__}: #{e.message}"
12
12
  false
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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bfs-scp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.1
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-09-04 00:00:00.000000000 Z
11
+ date: 2019-10-09 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.4.1
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.4.1
26
+ version: 0.5.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: net-scp
29
29
  requirement: !ruby/object:Gem::Requirement