prep_kit 0.1.8 → 0.1.9

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
  SHA1:
3
- metadata.gz: 8cd5f08170c8218f60129bdb66d94ad714ee2a16
4
- data.tar.gz: ea53500e04585df087780ed5373829405c239be7
3
+ metadata.gz: 9191872a8674750052b1e662cdc945dd5d5625d5
4
+ data.tar.gz: 94ed4d91c37f711ea4c731e0c33fe00ff18321ed
5
5
  SHA512:
6
- metadata.gz: b25f05441760238e487da7f3b3699ddf473a91441ac6df841dbcec6a6445daf58c8b80de8ee9f63d22b399f3de3ad851aae89b61ee73606a3daad1fe91a01fbc
7
- data.tar.gz: 427de6267edb65f24ca6302ce27158a57add8edcb8caeb704599ee55ec740df7ffb5718457e3621c436797e22965145d006129ecc65007dd5f765915396d2cb6
6
+ metadata.gz: cc777bde408a35d80513a321d68c379331e05461a8d35443a7069f42b7543f121b82f0cf92ad67fc5bf5e003bbd2518e6daaee27de64263fe3337a93c577df3e
7
+ data.tar.gz: 6ece4b3b0a6e23dc5eeadffc10b1602c699f729e93d9706e7fc36618174f1da310714164683be26bac5e32ecb39a1f44d0b26dfcb0ec3a8a60f2f468f2287252
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- prep_kit (0.1.8)
4
+ prep_kit (0.1.9)
5
5
  colorize
6
6
  net-scp
7
7
  net-ssh
@@ -1,16 +1,16 @@
1
1
  module PrepKit
2
2
  class Remote
3
3
  def initialize(host, user, options, &callback)
4
- @ssh = create_ssh(host, user, options, &callback)
4
+ @ssh, @scp = create_connection(host, user, options, &callback)
5
5
  end
6
6
 
7
7
  def exec!(command)
8
- @ssh.call(command)
8
+ @ssh.(command)
9
9
  end
10
10
 
11
11
  %i(upload! download!).each do |name|
12
12
  define_method(name) do |src, dst|
13
- @ssh.call { |ssh| ssh.scp.public_send(name, src, dst) }
13
+ @scp.() { |scp| scp.public_send(name, src, dst) }
14
14
  end
15
15
  end
16
16
 
@@ -20,11 +20,23 @@ module PrepKit
20
20
 
21
21
  private
22
22
 
23
- def create_ssh(host, user, options, &callback)
23
+ def create_connection(host, user, options, &callback)
24
+ connection = lambda do |&block|
25
+ Net::SSH.start(host, user, options) do |ssh|
26
+ block.(ssh)
27
+
28
+ ssh.loop
29
+ end
30
+ end
31
+
32
+ [create_ssh(connection, &callback), create_scp(connection)]
33
+ end
34
+
35
+ def create_ssh(connection, &callback)
24
36
  lambda do |command|
25
37
  status = nil
26
38
 
27
- Net::SSH.start(host, user, options) do |ssh|
39
+ connection.() do |ssh|
28
40
  channel = ssh.open_channel do |chan|
29
41
  chan.exec command do |ch, success|
30
42
  raise RuntimeError command unless success
@@ -41,14 +53,17 @@ module PrepKit
41
53
  status = data.read_long
42
54
  end
43
55
  end
44
- end
45
56
 
46
- channel.wait
47
- ssh.loop
57
+ channel.wait
58
+ end
48
59
  end
49
60
 
50
61
  status
51
62
  end
52
63
  end
64
+
65
+ def create_scp(connection)
66
+ -> (&callback) { connection.() { |ssh| callback.(ssh.scp) } }
67
+ end
53
68
  end
54
69
  end
@@ -1,3 +1,3 @@
1
1
  module PrepKit
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prep_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - daisuko