bfs-scp 0.7.4 → 0.8.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef0ef96a3e86298cb7dd7fa6ff941b737a7a8e81d77739628eb1bd94ddca8369
4
- data.tar.gz: 2bdf06c5c853c2af45b7ab2ffb93877179134eafe4a9ee28d44fbbddf71e5370
3
+ metadata.gz: d4627ddec1e22cfa27903d4c4ac60cdfe70be0dd04ccb6ab7fed1c6151baac4a
4
+ data.tar.gz: ee63b464044b610d84fae116446167093c6e3d643245bf5194bf965138d100fc
5
5
  SHA512:
6
- metadata.gz: 2438d29d8106ef151596a2a7556349796e0a2a491f0f8f35386182d65669b6db4fb1a7f8bc5ae8195fc46f983e52545f5c7d8782df64f5cc272f13bad954c6a9
7
- data.tar.gz: 57e203c4d7b5a2d4d561f4a51a301312f3abe109eef6ab127335e62d70d56943c4abf95e3f03d7d80a534d4ddad8544ca923ab65e074fa18d735b291eeb730e6
6
+ metadata.gz: 8bd631d3af1b50eea69afcad98eeacf626462326145460572f17473666880c6c5312a53e1bf5637878ab4270d6582b4592a3214f267ae423c9b00619e11d7a74
7
+ data.tar.gz: e0a7aeab8accb3266422b2a34b93946831da31852fd3d0684f84cb587a5df8af72d87e3b9fb98c3eb2445ba4cc11fe9e1bc1f6e1e74598e8759e6d8f900fa951
@@ -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
- temp = BFS::TempWriter.new(path, encoding: encoding, perm: perm) do |temp_path|
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
- yield data
165
- else
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
 
@@ -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
- context 'absolute' do
7
- subject { described_class.new sandbox[:host], **sandbox[:opts].merge(prefix: SecureRandom.uuid) }
8
- after { subject.close }
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
- subject { described_class.new sandbox[:host], **sandbox[:opts].merge(prefix: "~/#{SecureRandom.uuid}") }
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 'should resolve from URL' do
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 'should handle absolute and relative paths' do
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 'should support custom perms' do
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.7.4
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitrij Denissenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-26 00:00:00.000000000 Z
11
+ date: 2021-05-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.7.4
19
+ version: 0.8.2
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.7.4
26
+ version: 0.8.2
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.1.2
70
+ rubygems_version: 3.1.4
71
71
  signing_key:
72
72
  specification_version: 4
73
73
  summary: SCP/SSH adapter for bfs