bfs-scp 0.7.3 → 0.8.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 +13 -13
- data/spec/bfs/bucket/scp_spec.rb +13 -11
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44a0713c9f175213b7c659269892ea70cb8ed870cf60d8346e04d884d59c26c0
|
4
|
+
data.tar.gz: f47f64d9a6c0e981c45ebecb993d70ee6f8a3813e327a23f1ac817824bf67321
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f81f0d970feacce7728442dc01b645b797202473ac5798eaa9c13593362a80fcdcee4324d3193ea269e8203db0354211f7ffad0a60914dbb6ed53a1b013b25b6
|
7
|
+
data.tar.gz: 75112da87d9464b66ae823a03d28c9ae7074d47bb1ca237ccc53d61f93af4760317ad8067a9ae12e9248b07704d800050d20d1be8713c329302b4657ede9e660
|
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::Writer.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
|
@@ -160,10 +153,11 @@ module BFS
|
|
160
153
|
@client.session.open_channel do |ch|
|
161
154
|
ch.exec(cmdstr) do |_, _success|
|
162
155
|
ch.on_data do |_, data|
|
156
|
+
stdout << data
|
157
|
+
|
163
158
|
if block_given?
|
164
|
-
|
165
|
-
|
166
|
-
stdout += data
|
159
|
+
pos = stdout.rindex("\n")
|
160
|
+
yield stdout.slice!(0..pos) if pos
|
167
161
|
end
|
168
162
|
end
|
169
163
|
ch.on_extended_data do |_, _, data|
|
@@ -174,6 +168,12 @@ module BFS
|
|
174
168
|
end
|
175
169
|
end
|
176
170
|
end
|
171
|
+
|
172
|
+
if block_given? && stdout.length.positive?
|
173
|
+
yield stdout
|
174
|
+
stdout.clear
|
175
|
+
end
|
176
|
+
|
177
177
|
@client.session.loop
|
178
178
|
raise CommandError.new(cmdstr, status, stderr) unless status.zero?
|
179
179
|
|
data/spec/bfs/bucket/scp_spec.rb
CHANGED
@@ -1,23 +1,25 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
sandbox = { host: '127.0.0.1', opts: { port: 7022, user: 'root', password: 'root' } }.freeze
|
4
|
-
|
5
3
|
RSpec.describe BFS::Bucket::SCP, scp: true do
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
subject { described_class.new hostname, **conn_opts }
|
5
|
+
|
6
|
+
let(:hostname) { '127.0.0.1' }
|
7
|
+
let(:conn_opts) { { port: 7022, user: 'root', password: 'root', prefix: prefix } }
|
8
|
+
let(:prefix) { SecureRandom.uuid }
|
9
|
+
|
10
|
+
after { subject.close }
|
9
11
|
|
12
|
+
context 'with absolute path' do
|
10
13
|
it_behaves_like 'a bucket', content_type: false, metadata: false
|
11
14
|
end
|
12
15
|
|
13
|
-
context 'relative' do
|
14
|
-
|
15
|
-
after { subject.close }
|
16
|
+
context 'with relative path' do
|
17
|
+
let(:prefix) { "~/#{SecureRandom.uuid}" }
|
16
18
|
|
17
19
|
it_behaves_like 'a bucket', content_type: false, metadata: false
|
18
20
|
end
|
19
21
|
|
20
|
-
it '
|
22
|
+
it 'resolves from URL' do
|
21
23
|
bucket = BFS.resolve('scp://root:root@127.0.0.1:7022')
|
22
24
|
expect(bucket).to be_instance_of(described_class)
|
23
25
|
expect(bucket.instance_variable_get(:@prefix)).to be_nil
|
@@ -29,7 +31,7 @@ RSpec.describe BFS::Bucket::SCP, scp: true do
|
|
29
31
|
bucket.close
|
30
32
|
end
|
31
33
|
|
32
|
-
it '
|
34
|
+
it 'handles absolute and relative paths' do
|
33
35
|
abs = BFS::Blob.new("scp://root:root@127.0.0.1:7022/#{SecureRandom.uuid}/file.txt")
|
34
36
|
abs.create {|w| w.write 'absolute' }
|
35
37
|
|
@@ -43,7 +45,7 @@ RSpec.describe BFS::Bucket::SCP, scp: true do
|
|
43
45
|
rel.close
|
44
46
|
end
|
45
47
|
|
46
|
-
it '
|
48
|
+
it 'supports custom perms' do
|
47
49
|
blob = BFS::Blob.new("scp://root:root@127.0.0.1:7022/#{SecureRandom.uuid}/file.txt")
|
48
50
|
blob.create(perm: 0o666) {|w| w.write 'foo' }
|
49
51
|
expect(blob.info.mode).to eq(0o666)
|
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.8.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:
|
11
|
+
date: 2021-02-04 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.8.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.
|
26
|
+
version: 0.8.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: net-scp
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|