blower 4.2 → 4.3

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: b55806c505a65e5ffaee6b32452ce71a5e0b624e
4
- data.tar.gz: fca7868031a386caf0f1d3d6163c0a02a0af4c02
3
+ metadata.gz: a923b0167ae5ee7acc8461d3929b7001134f93a2
4
+ data.tar.gz: 2647d91696288ef1ea8cba942c6dc9b467e36f23
5
5
  SHA512:
6
- metadata.gz: 092f012a5b3f1732a89be2488415da2f1a8d544ec65c91d21084b2d6cfb34edb3b4f8b100ead6d121a94d00c2c2a376296fda57094a5fff2b2e1c36d12b8b42e
7
- data.tar.gz: ded113687dbc5a0fc3a5a82e8a5dc351a7e2c3c649fc72d3800bd70660175a358e9f3a9ddc98ca5d0e4ec78d03c07e20d2fb5da02eef322b2d4b5493a273e683
6
+ metadata.gz: de25c87aadad63fa9b007224836be6bc2c83b0a5c62bea88f3a00c972e8ed3cdb00f7c5de1668802915a33bb63294ed57ed5b7d1190a6b937b572df03ecd7b34
7
+ data.tar.gz: bfeab889da3cdde2b2f5e9b26a1ddfecb948699b2095918cfd1103d7b17607fd0ae615abd0d96580f2bee0c5f4771cd1a829997dc02e8638767c7f75416c981d
data/bin/blow CHANGED
@@ -6,6 +6,7 @@ require 'optparse'
6
6
  path = []
7
7
 
8
8
  OptionParser.new do |opts|
9
+ Version = Blower::VERSION
9
10
  opts.banner = "Usage: blow [options] task..."
10
11
  opts.on "-d DIR", "Set working directory" do |v|
11
12
  Dir.chdir v
@@ -16,10 +17,6 @@ OptionParser.new do |opts|
16
17
  opts.on "-I DIR", "Add directory to search path" do |v|
17
18
  path << v
18
19
  end
19
- opts.on "-v", "Show version and exit" do |v|
20
- puts "blow (blower) #{Blower::VERSION}"
21
- exit
22
- end
23
20
  end.order!
24
21
 
25
22
  $: << File.join(Dir.pwd, "lib")
@@ -275,14 +275,17 @@ module Blower
275
275
 
276
276
  def each (hosts = self.hosts)
277
277
  fail "No hosts" if hosts.empty?
278
- [hosts].flatten.each do |host|
279
- begin
280
- yield host
281
- rescue => e
282
- host.log.error e.message
283
- hosts.delete host
278
+ threads = [hosts].flatten.map do |host|
279
+ Thread.new do
280
+ begin
281
+ yield host
282
+ rescue => e
283
+ host.log.error e.message
284
+ hosts.delete host
285
+ end
284
286
  end
285
287
  end
288
+ threads.each(&:join)
286
289
  fail "No hosts remaining" if hosts.empty?
287
290
  end
288
291
 
data/lib/blower/host.rb CHANGED
@@ -62,7 +62,7 @@ module Blower
62
62
  [froms].flatten.each do |from|
63
63
  if from.is_a?(String)
64
64
  to += "/" if to[-1] != "/" && from.is_a?(Array)
65
- command = ["rsync", "-e", "ssh -oStrictHostKeyChecking=no", "-r"]
65
+ command = ["rsync", "-e", ssh_command, "-r"]
66
66
  command += [*from, "#{as}@#{@address}:#{to}"]
67
67
  log.trace command.shelljoin, quiet: quiet
68
68
  IO.popen(command, in: :close, err: %i(child out)) do |io|
@@ -147,13 +147,21 @@ module Blower
147
147
  # Connect to the host as a Gateway
148
148
  # @api private
149
149
  def gateway ()
150
- Net::SSH::Gateway(address, user)
150
+ Net::SSH::Gateway.new(address, user)
151
151
  end
152
152
 
153
153
  private
154
154
 
155
155
  attr_accessor :data
156
156
 
157
+ def ssh_command
158
+ if via
159
+ "ssh -t -A -oStrictHostKeyChecking=no #{via} ssh -oStrictHostKeyChecking=no"
160
+ else
161
+ "ssh -oStrictHostKeyChecking=no"
162
+ end
163
+ end
164
+
157
165
  def ssh (user)
158
166
  @sessions ||= {}
159
167
  if @sessions[user] && @sessions[user].closed?
@@ -0,0 +1,22 @@
1
+ module Blower
2
+
3
+ class Plugin
4
+ extend Forwardable
5
+
6
+ def_delegators :@context, *%i(get unset set with on as run sh cp read write render ping once)
7
+
8
+ def initialize (context)
9
+ @context = context
10
+ end
11
+
12
+ end
13
+
14
+ def self.plugin (name, &body)
15
+ Class.new(Plugin, &body).tap do |klass|
16
+ Context.send :define_method, name do
17
+ klass.new(self)
18
+ end
19
+ end
20
+ end
21
+
22
+ end
@@ -1,3 +1,3 @@
1
1
  module Blower
2
- VERSION = "4.2"
2
+ VERSION = "4.3"
3
3
  end
data/lib/blower.rb CHANGED
@@ -8,4 +8,5 @@ require 'blower/logger'
8
8
  require 'blower/errors'
9
9
  require 'blower/context'
10
10
  require 'blower/host'
11
+ require 'blower/plugin'
11
12
  require 'blower/version'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blower
3
3
  version: !ruby/object:Gem::Version
4
- version: '4.2'
4
+ version: '4.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Baum
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-24 00:00:00.000000000 Z
11
+ date: 2016-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh
@@ -93,6 +93,7 @@ files:
93
93
  - lib/blower/errors.rb
94
94
  - lib/blower/host.rb
95
95
  - lib/blower/logger.rb
96
+ - lib/blower/plugin.rb
96
97
  - lib/blower/util.rb
97
98
  - lib/blower/version.rb
98
99
  homepage: http://www.github.org/nbaum/blower