bfs-scp 0.4.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bfs/bucket/scp.rb +12 -3
- data/spec/bfs/bucket/scp_spec.rb +27 -6
- 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: 9fc1b42d4747715149cbe00ed2712c973680221579ab7a420ac46f6bd1bb2333
|
4
|
+
data.tar.gz: abf74a6979b1959547f91ed3ab238dab1a3120ffcd0191dc552c17916c4a0627
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8aef59c1210055d2852a39a1c8100e8f63e19094e6b8708614c66339386321ff15434538e6add8e7112bfd1c6caf360e5cff62ae4c34a9d8a35d642ccf1349ad
|
7
|
+
data.tar.gz: f1f5755b3f4d2751582d7dd4fc592dad5bfbf98c6e07527372bd04e6dbd52c793c390675a9d7ade419aa854d5e9e9347530828d0c8bd5c1c636d4dd87abc30d3
|
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
@@ -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
|
-
|
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,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
|
+
version: 0.6.0
|
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-12-19 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.
|
19
|
+
version: 0.6.0
|
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.6.0
|
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.0.
|
70
|
+
rubygems_version: 3.0.6
|
71
71
|
signing_key:
|
72
72
|
specification_version: 4
|
73
73
|
summary: SCP/SSH adapter for bfs
|